RecipientEditTextView.java revision 699c1e37a1bf26daab34f2117a14c6e883636077
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 17package com.android.ex.chips; 18 19import android.content.Context; 20import android.graphics.drawable.Drawable; 21import android.text.Editable; 22import android.util.AttributeSet; 23import android.widget.Filterable; 24import android.widget.FrameLayout; 25import android.widget.ListAdapter; 26import android.widget.MultiAutoCompleteTextView; 27 28import java.util.Collection; 29 30/** 31 * RecipientEditTextView is an auto complete text view for use with applications 32 * that use the new Chips UI for addressing a message to recipients. 33 */ 34public class RecipientEditTextView extends FrameLayout { 35 private RecipientEditTextViewInner mEditTextViewInner; 36 37 public RecipientEditTextView(Context context, AttributeSet attrs) { 38 super(context, attrs); 39 mEditTextViewInner = new RecipientEditTextViewInner(context, attrs); 40 addView(mEditTextViewInner); 41 } 42 43 Collection<Long> getContactIds() { 44 return mEditTextViewInner.getContactIds(); 45 } 46 47 Collection<Long> getDataIds() { 48 return mEditTextViewInner.getDataIds(); 49 } 50 51 public Editable getText() { 52 return mEditTextViewInner.getRecipients(); 53 } 54 55 public <T extends ListAdapter & Filterable> void setAdapter(T adapter) { 56 mEditTextViewInner.setAdapter(adapter); 57 } 58 59 public void setChipDimensions(Drawable chipBackground, Drawable chipBackgroundPressed, 60 Drawable chipDelete, int alternatesLayout, int alternatesSelected, float padding) { 61 mEditTextViewInner.setChipDimensions(chipBackground, chipBackgroundPressed, chipDelete, 62 alternatesLayout, alternatesSelected, padding); 63 } 64 65 public void setTokenizer(MultiAutoCompleteTextView.Tokenizer tokenizer) { 66 mEditTextViewInner.setTokenizer(tokenizer); 67 } 68} 69