Merge "Compose UI fixes"

This commit is contained in:
Ben Komalo 2011-08-08 11:30:04 -07:00 committed by Android (Google) Code Review
commit 86ed3c07a8
2 changed files with 10 additions and 24 deletions

View File

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

View File

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