From d344f524145a8317be6cb2b27aace1d9342ef517 Mon Sep 17 00:00:00 2001 From: Chris Banes Date: Wed, 30 Nov 2016 03:50:07 +0000 Subject: [PATCH] Merge "Fix error colours in design lib" into mnc-ub-dev am: c37d0d5de3 am: ef445d0c1b * commit 'ef445d0c1bed0992dcabfada1f96fea1b131b5bf': Fix error colours in design lib GitOrigin-RevId=325ee6357c68ff444db3a9f8f0cbc3cf6ecdee82 PiperOrigin-RevId: 140559810 --- res/values/attrs.xml | 3 +++ res/values/colors.xml | 3 ++- res/values/styles.xml | 4 ++-- res/values/themes.xml | 18 ++++++++++++++ .../design/widget/TextInputLayout.java | 24 +++++++++++++++++-- 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 7a9e3c120..c472fdf97 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -365,6 +365,9 @@ + + + diff --git a/res/values/colors.xml b/res/values/colors.xml index a958156e5..ebf641235 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -33,7 +33,8 @@ @android:color/transparent - #FFDD2C00 + #FFD50000 + #FFFF6E6E #323232 diff --git a/res/values/styles.xml b/res/values/styles.xml index 7111ad9d6..8753c6339 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -71,13 +71,13 @@ + + + + + + + + diff --git a/src/android/support/design/widget/TextInputLayout.java b/src/android/support/design/widget/TextInputLayout.java index 45c7452bc..3bf0204b0 100644 --- a/src/android/support/design/widget/TextInputLayout.java +++ b/src/android/support/design/widget/TextInputLayout.java @@ -18,6 +18,7 @@ package android.support.design.widget; import android.content.Context; import android.content.res.ColorStateList; +import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Paint; @@ -31,6 +32,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.StyleRes; import android.support.design.R; +import android.support.v4.content.ContextCompat; import android.support.v4.view.AccessibilityDelegateCompat; import android.support.v4.view.GravityCompat; import android.support.v4.view.ViewCompat; @@ -481,7 +483,16 @@ public class TextInputLayout extends LinearLayout { if (enabled) { mErrorView = new TextView(getContext()); - mErrorView.setTextAppearance(getContext(), mErrorTextAppearance); + try { + mErrorView.setTextAppearance(getContext(), mErrorTextAppearance); + } catch (Resources.NotFoundException nfe) { + // Probably caused by our theme not extending from Theme.Design*. Instead + // we manually set something appropriate + mErrorView.setTextAppearance(getContext(), + R.style.TextAppearance_AppCompat_Caption); + mErrorView.setTextColor(ContextCompat.getColor( + getContext(), R.color.design_textinput_error_color_light)); + } mErrorView.setVisibility(INVISIBLE); ViewCompat.setAccessibilityLiveRegion(mErrorView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE); @@ -593,7 +604,16 @@ public class TextInputLayout extends LinearLayout { if (enabled) { mCounterView = new TextView(getContext()); mCounterView.setMaxLines(1); - mCounterView.setTextAppearance(getContext(), mCounterTextAppearance); + try { + mCounterView.setTextAppearance(getContext(), mCounterTextAppearance); + } catch (Resources.NotFoundException nfe) { + // Probably caused by our theme not extending from Theme.Design*. Instead + // we manually set something appropriate + mCounterView.setTextAppearance(getContext(), + R.style.TextAppearance_AppCompat_Caption); + mCounterView.setTextColor(ContextCompat.getColor( + getContext(), R.color.design_textinput_error_color_light)); + } ViewCompat.setAccessibilityLiveRegion(mCounterView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE); addIndicator(mCounterView, -1);