summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMindy Pereira <mindyp@google.com>2011-05-31 16:28:54 -0700
committerMindy Pereira <mindyp@google.com>2011-05-31 16:55:26 -0700
commit9ff623bbf3b5bc790e40dd51ebbb13fc99fbf875 (patch)
tree4350cf7552e8d466efc852441429dfcf427b109d
parentc510471c4f7ccbb75ee00fe3d2723c600c7369d9 (diff)
downloadandroid_frameworks_opt_chips-9ff623bbf3b5bc790e40dd51ebbb13fc99fbf875.tar.gz
android_frameworks_opt_chips-9ff623bbf3b5bc790e40dd51ebbb13fc99fbf875.tar.bz2
android_frameworks_opt_chips-9ff623bbf3b5bc790e40dd51ebbb13fc99fbf875.zip
Add getRecipients
Method gives the calling application a plain editable containing all of the recipient addresses Also added larger assets for the delete icon as the others were untappable! Change-Id: Ib02dfcffc3d9e739586f5b502cf92f726cd5c0ef
-rw-r--r--res/drawable-hdpi/delete.pngbin557 -> 1159 bytes
-rw-r--r--res/drawable-mdpi/delete.pngbin557 -> 1159 bytes
-rw-r--r--src/com/android/ex/chips/RecipientEditTextView.java21
3 files changed, 21 insertions, 0 deletions
diff --git a/res/drawable-hdpi/delete.png b/res/drawable-hdpi/delete.png
index 200eae4..ca277ba 100644
--- a/res/drawable-hdpi/delete.png
+++ b/res/drawable-hdpi/delete.png
Binary files differ
diff --git a/res/drawable-mdpi/delete.png b/res/drawable-mdpi/delete.png
index 200eae4..ca277ba 100644
--- a/res/drawable-mdpi/delete.png
+++ b/res/drawable-mdpi/delete.png
Binary files differ
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index 8fc953c..e12518e 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -45,6 +45,8 @@ import android.widget.PopupWindow.OnDismissListener;
import android.widget.ListPopupWindow;
import android.widget.MultiAutoCompleteTextView;
+import java.util.ArrayList;
+
/**
* RecipientEditTextView is an auto complete text view for use with applications
* that use the new Chips UI for addressing a message to recipients.
@@ -77,10 +79,13 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView
private int mChipDeleteWidth;
+ private ArrayList<RecipientChip> mRecipients;
+
public RecipientEditTextView(Context context, AttributeSet attrs) {
super(context, attrs);
mHandler = new Handler();
setOnItemClickListener(this);
+ mRecipients = new ArrayList<RecipientChip>();
}
public RecipientChip constructChipSpan(RecipientEntry contact, int offset, boolean pressed)
@@ -284,6 +289,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView
int action = event.getAction();
boolean handled = super.onTouchEvent(event);
boolean chipWasSelected = false;
+
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) {
Spannable span = getSpannable();
int offset = getOffsetForPosition(event.getX(), event.getY());
@@ -351,6 +357,18 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView
QwertyKeyListener.markAsReplaced(editable, start, end, "");
}
+ public Editable getRecipients() {
+ StringBuilder plainText = new StringBuilder();
+ int size = mRecipients.size();
+ for (int i = 0; i < size; i++) {
+ plainText.append(mRecipients.get(i).getValue());
+ if (i != size-1) {
+ plainText.append(',');
+ }
+ }
+ return Editable.Factory.getInstance().newEditable(plainText);
+ }
+
/**
* RecipientChip defines an ImageSpan that contains information relevant to
* a particular recipient.
@@ -391,6 +409,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView
mAnchorView.setTop(bounds.bottom);
mAnchorView.setBottom(bounds.bottom);
mAnchorView.setVisibility(View.GONE);
+ mRecipients.add(this);
}
public void unselectChip() {
@@ -432,6 +451,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView
int spanEnd = getChipEnd();
QwertyKeyListener.markAsReplaced(getText(), spanStart, spanEnd, "");
spannable.removeSpan(this);
+ mRecipients.remove(this);
spannable.setSpan(newChip, spanStart, spanEnd, 0);
}
@@ -442,6 +462,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView
QwertyKeyListener.markAsReplaced(getText(), spanStart, spanEnd, "");
spannable.removeSpan(this);
+ mRecipients.remove(this);
spannable.setSpan(null, spanStart, spanEnd, 0);
getText().delete(spanStart, spanEnd);
}