From b86da6b913364cfd076e25c10af53e1b55d2429b Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Fri, 5 Aug 2011 13:15:41 -0700 Subject: [PATCH] Compose UI fixes - don't show error message if there are chips Bug: 5126958 Change-Id: I65a22555260b00ded1df49668cde09b03d7f7d90 --- .../email/activity/ChipsAddressTextView.java | 27 +++---------------- .../email/activity/MessageCompose.java | 7 ++++- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/src/com/android/email/activity/ChipsAddressTextView.java b/src/com/android/email/activity/ChipsAddressTextView.java index 43c036433..dac6b06c1 100644 --- a/src/com/android/email/activity/ChipsAddressTextView.java +++ b/src/com/android/email/activity/ChipsAddressTextView.java @@ -16,23 +16,20 @@ package com.android.email.activity; -import com.android.email.R; -import com.android.ex.chips.RecipientEditTextView; - import android.content.Context; import android.util.AttributeSet; -import android.widget.MultiAutoCompleteTextView; + +import com.android.ex.chips.RecipientEditTextView; /** - * This is a MultiAutoCompleteTextView which sets the error state - * (@see TextView.setError) when email address validation fails. + * This is a MultiAutoCompleteTextView which has a custom validator. */ class ChipsAddressTextView extends RecipientEditTextView { + /** A noop validator that does not munge invalid texts. */ private class ForwardValidator implements Validator { private Validator mValidator = null; public CharSequence fixText(CharSequence invalidText) { - mIsValid = false; return invalidText; } @@ -45,7 +42,6 @@ class ChipsAddressTextView extends RecipientEditTextView { } } - private boolean mIsValid = true; private final ForwardValidator mInternalValidator = new ForwardValidator(); public ChipsAddressTextView(Context context, AttributeSet attrs) { @@ -57,19 +53,4 @@ class ChipsAddressTextView extends RecipientEditTextView { public void setValidator(Validator validator) { mInternalValidator.setValidator(validator); } - - @Override - public void performValidation() { - mIsValid = true; - super.performValidation(); - markError(!mIsValid); - } - - private void markError(boolean enable) { - if (enable) { - setError(getContext().getString(R.string.message_compose_error_invalid_email)); - } else { - setError(null); - } - } } diff --git a/src/com/android/email/activity/MessageCompose.java b/src/com/android/email/activity/MessageCompose.java index 5b255294f..c746896c9 100644 --- a/src/com/android/email/activity/MessageCompose.java +++ b/src/com/android/email/activity/MessageCompose.java @@ -1407,10 +1407,15 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus */ @VisibleForTesting boolean isAddressAllValid() { + boolean supportsChips = ChipsUtil.supportsChipsUi(); for (TextView view : new TextView[]{mToView, mCcView, mBccView}) { String addresses = view.getText().toString().trim(); if (!Address.isAllValid(addresses)) { - view.setError(getString(R.string.message_compose_error_invalid_email)); + // Don't show an error message if we're using chips as the chips have + // their own error state. + if (!supportsChips || !(view instanceof RecipientEditTextView)) { + view.setError(getString(R.string.message_compose_error_invalid_email)); + } return false; } }