1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.email.activity; 18 19 import android.content.Context; 20 import android.util.AttributeSet; 21 22 import com.android.ex.chips.RecipientEditTextView; 23 24 /** 25 * This is a MultiAutoCompleteTextView which has a custom validator. 26 */ 27 class ChipsAddressTextView extends RecipientEditTextView { 28 /** A noop validator that does not munge invalid texts. */ 29 private class ForwardValidator implements Validator { 30 private Validator mValidator = null; 31 32 public CharSequence fixText(CharSequence invalidText) { 33 return invalidText; 34 } 35 36 public boolean isValid(CharSequence text) { 37 return mValidator != null ? mValidator.isValid(text) : true; 38 } 39 40 public void setValidator(Validator validator) { 41 mValidator = validator; 42 } 43 } 44 45 private final ForwardValidator mInternalValidator = new ForwardValidator(); 46 47 public ChipsAddressTextView(Context context, AttributeSet attrs) { 48 super(context, attrs); 49 super.setValidator(mInternalValidator); 50 } 51 52 @Override 53 public void setValidator(Validator validator) { 54 mInternalValidator.setValidator(validator); 55 } 56 } 57