From cfffaeecb614d67b17dbfd7630493788bf5e0821 Mon Sep 17 00:00:00 2001 From: Chris Banes Date: Wed, 30 Nov 2016 01:31:23 +0000 Subject: [PATCH] am 83e60f1b: am bca00ffa: Merge "Make sure that we reset the EditText backgroud tint" into mnc-ub-dev * commit '83e60f1bbb345b753d49613687ef4bb3976dcd84': Make sure that we reset the EditText backgroud tint GitOrigin-RevId=b3140f0b62e15e7d4f548e9efe1538907d0a1194 PiperOrigin-RevId: 140550025 --- .../design/widget/TextInputLayout.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/android/support/design/widget/TextInputLayout.java b/src/android/support/design/widget/TextInputLayout.java index 29266062e..3fb8b6583 100644 --- a/src/android/support/design/widget/TextInputLayout.java +++ b/src/android/support/design/widget/TextInputLayout.java @@ -309,6 +309,7 @@ public class TextInputLayout extends LinearLayout { 0, ViewCompat.getPaddingEnd(mEditText), mEditText.getPaddingBottom()); } } else { + updateEditTextBackground(false); removeView(mErrorView); mErrorView = null; } @@ -364,11 +365,8 @@ public class TextInputLayout extends LinearLayout { .start(); // Set the EditText's background tint to the error color - ViewCompat.setBackgroundTintList(mEditText, - ColorStateList.valueOf(mErrorView.getCurrentTextColor())); - + updateEditTextBackground(true); updateLabelVisibility(true); - } else { if (mErrorView.getVisibility() == VISIBLE) { ViewCompat.animate(mErrorView) @@ -385,15 +383,25 @@ public class TextInputLayout extends LinearLayout { }).start(); // Restore the 'original' tint, using colorControlNormal and colorControlActivated - final TintManager tintManager = TintManager.get(getContext()); - ViewCompat.setBackgroundTintList(mEditText, - tintManager.getTintList(R.drawable.abc_edit_text_material)); + updateEditTextBackground(false); } } sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); } + private void updateEditTextBackground(boolean errorShown) { + if (errorShown && mErrorView != null) { + // Set the EditText's background tint to the error color + ViewCompat.setBackgroundTintList(mEditText, + ColorStateList.valueOf(mErrorView.getCurrentTextColor())); + } else { + final TintManager tintManager = TintManager.get(getContext()); + ViewCompat.setBackgroundTintList(mEditText, + tintManager.getTintList(R.drawable.abc_edit_text_material)); + } + } + /** * Returns the error message that was set to be displayed with * {@link #setError(CharSequence)}, or null if no error was set