summaryrefslogtreecommitdiffstats
path: root/chips/src/com/android/ex/chips
diff options
context:
space:
mode:
authorMindy Pereira <mindyp@google.com>2011-12-15 13:35:37 -0800
committerMindy Pereira <mindyp@google.com>2011-12-15 14:49:03 -0800
commita11c2b0e1ea043aa4d8745285f2dcbe20448b417 (patch)
tree40bce7e838e164c31ba947b2f873994b040c172e /chips/src/com/android/ex/chips
parent0c980c3f851ee251e8914ae439403acf3c446268 (diff)
downloadandroid_frameworks_ex-a11c2b0e1ea043aa4d8745285f2dcbe20448b417.tar.gz
android_frameworks_ex-a11c2b0e1ea043aa4d8745285f2dcbe20448b417.tar.bz2
android_frameworks_ex-a11c2b0e1ea043aa4d8745285f2dcbe20448b417.zip
Update build file to allow us to have resources in static libs.
Depends on: Change Ifb4d2300: Support to build static Java library with Android resource Change-Id: Ie1ac8c93cb3f12a7d4e9afd873a13607ed72b932
Diffstat (limited to 'chips/src/com/android/ex/chips')
-rw-r--r--chips/src/com/android/ex/chips/BaseRecipientAdapter.java12
-rw-r--r--chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java5
-rw-r--r--chips/src/com/android/ex/chips/RecipientEditTextView.java20
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,