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
This commit is contained in:
Chris Banes 2016-11-30 03:50:07 +00:00 committed by Travis Collins
parent 04f8c8ed36
commit d344f52414
5 changed files with 47 additions and 5 deletions

View File

@ -365,6 +365,9 @@
<attr name="bottomSheetDialogTheme" format="reference" />
<!-- Style to use for modal bottom sheets in this theme. -->
<attr name="bottomSheetStyle" format="reference" />
<!-- Text color used to indicate an error has occurred. -->
<attr name="textColorError" format="color" />
</declare-styleable>
</resources>

View File

@ -33,7 +33,8 @@
<!-- Shadow color for the furthest pixels of a shadow -->
<color name="design_fab_shadow_end_color">@android:color/transparent</color>
<color name="design_textinput_error_color">#FFDD2C00</color>
<color name="design_textinput_error_color_light">#FFD50000</color>
<color name="design_textinput_error_color_dark">#FFFF6E6E</color>
<color name="design_snackbar_background_color">#323232</color>

View File

@ -71,13 +71,13 @@
</style>
<style name="TextAppearance.Design.Error" parent="TextAppearance.AppCompat.Caption">
<item name="android:textColor">@color/design_textinput_error_color</item>
<item name="android:textColor">?attr/textColorError</item>
</style>
<style name="TextAppearance.Design.Counter" parent="TextAppearance.AppCompat.Caption"/>
<style name="TextAppearance.Design.Counter.Overflow" parent="TextAppearance.AppCompat.Caption">
<item name="android:textColor">@color/design_textinput_error_color</item>
<item name="android:textColor">?attr/textColorError</item>
</style>
<style name="TextAppearance.Design.Snackbar.Message" parent="android:TextAppearance">

View File

@ -28,4 +28,22 @@
<item name="bottomSheetStyle">@style/Widget.Design.BottomSheet.Modal</item>
</style>
<style name="Theme.Design" parent="Theme.AppCompat">
<item name="textColorError">@color/design_textinput_error_color_dark</item>
</style>
<style name="Theme.Design.Light" parent="Theme.AppCompat.Light">
<item name="textColorError">@color/design_textinput_error_color_light</item>
</style>
<style name="Theme.Design.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.Design.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>

View File

@ -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);