Commit 50296b02 authored by Sinan Sahin's avatar Sinan Sahin Committed by Commit Bot

Update editor dropdown text and error icon colors

Bug: 953103, 953105
Change-Id: I576f1098f25f03c1e60017a1da25815032b79f57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1574247Reviewed-by: default avatarBecky Zhou <huayinz@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Sinan Sahin <sinansahin@google.com>
Cr-Commit-Position: refs/heads/master@{#652557}
parent ac4622a3
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2019 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:targetApi="21"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-2h2v2zM13,13h-2L11,7h2v6z"
android:fillColor="@color/default_red"/>
</vector>
......@@ -6,7 +6,9 @@ package org.chromium.chrome.browser.widget.prefeditor;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MotionEvent;
......@@ -30,6 +32,7 @@ import java.util.List;
* Helper class for creating a dropdown view with a label.
*/
class EditorDropdownField implements EditorFieldView {
private final Context mContext;
private final EditorFieldModel mFieldModel;
private final View mLayout;
private final TextView mLabel;
......@@ -51,6 +54,7 @@ class EditorDropdownField implements EditorFieldView {
public EditorDropdownField(Context context, ViewGroup root, final EditorFieldModel fieldModel,
final Runnable changedCallback, @Nullable EditorObserverForTest observer) {
assert fieldModel.getInputTypeHint() == EditorFieldModel.INPUT_TYPE_HINT_DROPDOWN;
mContext = context;
mFieldModel = fieldModel;
mObserverForTest = observer;
......@@ -166,7 +170,15 @@ class EditorDropdownField implements EditorFieldView {
public void updateDisplayedError(boolean showError) {
View view = mDropdown.getSelectedView();
if (view != null && view instanceof TextView) {
((TextView) view).setError(showError ? mFieldModel.getErrorMessage() : null);
if (showError) {
Drawable drawable = VectorDrawableCompat.create(
mContext.getResources(), R.drawable.ic_error, mContext.getTheme());
drawable.setBounds(
0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
((TextView) view).setError(mFieldModel.getErrorMessage(), drawable);
} else {
((TextView) view).setError(null);
}
}
}
......
......@@ -65,8 +65,7 @@ public class HintedDropDownAdapter<T> extends DropdownFieldAdapter<T> {
ViewCompat.setPaddingRelative(convertView, ViewCompat.getPaddingStart(convertView), 0,
ViewCompat.getPaddingEnd(convertView), 0);
mTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
ApiCompatibilityUtils.setTextAppearance(
mTextView, android.R.style.TextAppearance_Widget_DropDownItem);
ApiCompatibilityUtils.setTextAppearance(mTextView, R.style.TextAppearance_BlackTitle1);
}
convertView = super.getDropDownView(position, convertView, parent);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment