Compose UI fixes
- don't show error message if there are chips Bug: 5126958 Change-Id: I65a22555260b00ded1df49668cde09b03d7f7d90
This commit is contained in:
parent
5b4a214240
commit
b86da6b913
@ -16,23 +16,20 @@
|
|||||||
|
|
||||||
package com.android.email.activity;
|
package com.android.email.activity;
|
||||||
|
|
||||||
import com.android.email.R;
|
|
||||||
import com.android.ex.chips.RecipientEditTextView;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.MultiAutoCompleteTextView;
|
|
||||||
|
import com.android.ex.chips.RecipientEditTextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a MultiAutoCompleteTextView which sets the error state
|
* This is a MultiAutoCompleteTextView which has a custom validator.
|
||||||
* (@see TextView.setError) when email address validation fails.
|
|
||||||
*/
|
*/
|
||||||
class ChipsAddressTextView extends RecipientEditTextView {
|
class ChipsAddressTextView extends RecipientEditTextView {
|
||||||
|
/** A noop validator that does not munge invalid texts. */
|
||||||
private class ForwardValidator implements Validator {
|
private class ForwardValidator implements Validator {
|
||||||
private Validator mValidator = null;
|
private Validator mValidator = null;
|
||||||
|
|
||||||
public CharSequence fixText(CharSequence invalidText) {
|
public CharSequence fixText(CharSequence invalidText) {
|
||||||
mIsValid = false;
|
|
||||||
return invalidText;
|
return invalidText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +42,6 @@ class ChipsAddressTextView extends RecipientEditTextView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean mIsValid = true;
|
|
||||||
private final ForwardValidator mInternalValidator = new ForwardValidator();
|
private final ForwardValidator mInternalValidator = new ForwardValidator();
|
||||||
|
|
||||||
public ChipsAddressTextView(Context context, AttributeSet attrs) {
|
public ChipsAddressTextView(Context context, AttributeSet attrs) {
|
||||||
@ -57,19 +53,4 @@ class ChipsAddressTextView extends RecipientEditTextView {
|
|||||||
public void setValidator(Validator validator) {
|
public void setValidator(Validator validator) {
|
||||||
mInternalValidator.setValidator(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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1407,10 +1407,15 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
|||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean isAddressAllValid() {
|
boolean isAddressAllValid() {
|
||||||
|
boolean supportsChips = ChipsUtil.supportsChipsUi();
|
||||||
for (TextView view : new TextView[]{mToView, mCcView, mBccView}) {
|
for (TextView view : new TextView[]{mToView, mCcView, mBccView}) {
|
||||||
String addresses = view.getText().toString().trim();
|
String addresses = view.getText().toString().trim();
|
||||||
if (!Address.isAllValid(addresses)) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user