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
diff --git a/chips/Android.mk b/chips/Android.mk
index bba269d..4a7977a 100644
--- a/chips/Android.mk
+++ b/chips/Android.mk
@@ -20,4 +20,5 @@
LOCAL_SRC_FILES := \
$(call all-java-files-under, src) \
$(call all-logtags-files-under, src)
-include $(BUILD_STATIC_JAVA_LIBRARY)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+include $(BUILD_STATIC_JAVA_LIBRARY)
\ No newline at end of file
diff --git a/chips/AndroidManifest.xml b/chips/AndroidManifest.xml
new file mode 100644
index 0000000..e159fd2
--- /dev/null
+++ b/chips/AndroidManifest.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.ex.chips"
+ android:versionCode="1">
+</manifest>
\ No newline at end of file
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 @@
* (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 @@
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 @@
String.valueOf(contactId)
}, null), 0);
mLayoutInflater = LayoutInflater.from(context);
- mLayoutId = viewId;
mCurrentId = currentId;
mCheckedItemChangedListener = listener;
}
@@ -192,7 +189,7 @@
}
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.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.ScrollView;
import android.widget.TextView;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -218,6 +220,7 @@
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 @@
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 @@
* @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,