Make TextInputLayout's error handling spec compliant

BUG: 23494861
Change-Id: I6b867d375e41c25e44923f2db5057842715e3f8e
diff --git a/design/src/android/support/design/widget/TextInputLayout.java b/design/src/android/support/design/widget/TextInputLayout.java
index 00ad669..2926606 100644
--- a/design/src/android/support/design/widget/TextInputLayout.java
+++ b/design/src/android/support/design/widget/TextInputLayout.java
@@ -216,6 +216,8 @@
     private void updateLabelVisibility(boolean animate) {
         boolean hasText = mEditText != null && !TextUtils.isEmpty(mEditText.getText());
         boolean isFocused = arrayContains(getDrawableState(), android.R.attr.state_focused);
+        boolean isErrorShowing = !TextUtils.isEmpty(getError());
+
 
         if (mDefaultTextColor != null && mFocusedTextColor != null) {
             mCollapsingTextHelper.setExpandedTextColor(mDefaultTextColor.getDefaultColor());
@@ -224,7 +226,7 @@
                     : mDefaultTextColor.getDefaultColor());
         }
 
-        if (hasText || isFocused) {
+        if (hasText || isFocused || isErrorShowing) {
             // We should be showing the label so do so if it isn't already
             collapseHint(animate);
         } else {
@@ -364,6 +366,9 @@
             // Set the EditText's background tint to the error color
             ViewCompat.setBackgroundTintList(mEditText,
                     ColorStateList.valueOf(mErrorView.getCurrentTextColor()));
+
+            updateLabelVisibility(true);
+
         } else {
             if (mErrorView.getVisibility() == VISIBLE) {
                 ViewCompat.animate(mErrorView)
@@ -374,6 +379,8 @@
                             @Override
                             public void onAnimationEnd(View view) {
                                 view.setVisibility(INVISIBLE);
+
+                                updateLabelVisibility(true);
                             }
                         }).start();