diff options
Diffstat (limited to 'chips/src/com/android/ex/chips')
3 files changed, 30 insertions, 7 deletions
diff --git a/chips/src/com/android/ex/chips/BaseRecipientAdapter.java b/chips/src/com/android/ex/chips/BaseRecipientAdapter.java index 8c251bb..e788fc1 100644 --- a/chips/src/com/android/ex/chips/BaseRecipientAdapter.java +++ b/chips/src/com/android/ex/chips/BaseRecipientAdapter.java @@ -901,18 +901,24 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter * (for photo). Ids for those should be available via {@link #getDisplayNameId()}, * {@link #getDestinationId()}, and {@link #getPhotoId()}. */ - protected abstract int getItemLayout(); + protected int getItemLayout() { + return R.layout.chips_recipient_dropdown_item; + } /** * Returns a layout id for a view showing "waiting for more contacts". */ - protected abstract int getWaitingForDirectorySearchLayout(); + protected int getWaitingForDirectorySearchLayout() { + return R.layout.chips_recipient_dropdown_item; + } /** * Returns a resource ID representing an image which should be shown when ther's no relevant * photo is available. */ - protected abstract int getDefaultPhotoResource(); + protected int getDefaultPhotoResource() { + return R.drawable.ic_contact_picture; + } /** * Returns an id for TextView in an item View for showing a display name. By default diff --git a/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java b/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java index fa7ca0c..1108854 100644 --- a/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java +++ b/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java @@ -37,8 +37,6 @@ public class RecipientAlternatesAdapter extends CursorAdapter { static final int MAX_LOOKUPS = 50; private final LayoutInflater mLayoutInflater; - private final int mLayoutId; - private final long mCurrentId; private int mCheckedItemPosition = -1; @@ -114,7 +112,6 @@ public class RecipientAlternatesAdapter extends CursorAdapter { String.valueOf(contactId) }, null), 0); mLayoutInflater = LayoutInflater.from(context); - mLayoutId = viewId; mCurrentId = currentId; mCheckedItemChangedListener = listener; } @@ -192,7 +189,7 @@ public class RecipientAlternatesAdapter extends CursorAdapter { } private View newView() { - return mLayoutInflater.inflate(mLayoutId, null); + return mLayoutInflater.inflate(R.layout.chips_recipient_dropdown_item, null); } /*package*/ static interface OnCheckedItemChangedListener { diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java index 9579510..e508fd9 100644 --- a/chips/src/com/android/ex/chips/RecipientEditTextView.java +++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java @@ -23,6 +23,7 @@ import android.content.ClipboardManager; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnDismissListener; +import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -74,6 +75,7 @@ import android.widget.PopupWindow; import android.widget.ScrollView; import android.widget.TextView; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -218,6 +220,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements public RecipientEditTextView(Context context, AttributeSet attrs) { super(context, attrs); + setChipDimensions(); if (sSelectedTextColor == -1) { sSelectedTextColor = context.getResources().getColor(android.R.color.white); } @@ -591,6 +594,22 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements return getWidth() - getPaddingLeft() - getPaddingRight() - (mChipPadding * 2); } + + private void setChipDimensions() { + Resources r = getContext().getResources(); + mChipBackground = r.getDrawable(R.drawable.chip_background); + mChipBackgroundPressed = r.getDrawable(R.drawable.chip_background_selected); + mChipDelete = r.getDrawable(R.drawable.chip_delete); + mChipPadding = (int) r.getDimension(R.dimen.chip_padding); + mAlternatesLayout = R.layout.chips_alternate_item; + mDefaultContactPhoto = BitmapFactory.decodeResource(r, R.drawable.ic_contact_picture); + mMoreItem = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.more_item, null); + mChipHeight = r.getDimension(R.dimen.chip_height); + mChipFontSize = r.getDimension(R.dimen.chip_text_size); + mInvalidChipBackground = r.getDrawable(R.drawable.chip_background_invalid); + mCopyViewRes = R.layout.copy_chip_dialog_layout; + } + /** * Set all chip dimensions and resources. This has to be done from the * application as this is a static library. @@ -605,6 +624,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements * @param padding Padding around the text in a chip * @param chipFontSize * @param copyViewRes + * @deprecated */ public void setChipDimensions(Drawable chipBackground, Drawable chipBackgroundPressed, Drawable invalidChip, Drawable chipDelete, Bitmap defaultContact, int moreResource, |