summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaj Yengisetty <rajesh@cyngn.com>2015-04-06 18:09:12 -0700
committerRajesh Yengisetty <rajesh@cyngn.com>2015-04-07 22:40:18 +0000
commitd9ebf239ba12450ba151909765c2849e197dad6c (patch)
tree6a67ef62d77bf4982536ae241aed3b640a9c376f
parent16ccce7eb0711c2c7f4cdbed236dc15c21234337 (diff)
downloadandroid_frameworks_opt_chips-d9ebf239ba12450ba151909765c2849e197dad6c.tar.gz
android_frameworks_opt_chips-d9ebf239ba12450ba151909765c2849e197dad6c.tar.bz2
android_frameworks_opt_chips-d9ebf239ba12450ba151909765c2849e197dad6c.zip
Chips: Add a view attribute for maximum number of chips parsedstable/cm-12.1-YOG3C
Additionally add a dynamic way to set maxChipsParsed Change-Id: I8e88d4268b8e2ecc6de26d8cf69a985821c8e9f0 (cherry picked from commit c274746186af89f4c11499771678696d18158476) (cherry picked from commit 9f53ad13ad78945689c6e16aad127bdfca4c4779)
-rw-r--r--res/values/attrs.xml3
-rw-r--r--src/com/android/ex/chips/RecipientEditTextView.java29
2 files changed, 30 insertions, 2 deletions
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index d3500aa..7803de0 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -31,5 +31,6 @@
<enum name="bottom" value = "0"/>
<enum name="baseline" value = "1"/>
</attr>
+ <attr name="maxChips" format="integer" />
</declare-styleable>
-</resources> \ No newline at end of file
+</resources>
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index e1dedf6..0bc65a9 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -158,6 +158,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
private boolean mDisableDelete;
private int mMaxLines;
private int mActionBarHeight;
+ private int mMaxChipsParsed;
/**
* Enumerator for avatar position. See attr.xml for more details.
@@ -954,6 +955,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources()
.getDisplayMetrics());
}
+ mMaxChipsParsed = a.getInt(R.styleable.RecipientEditTextView_maxChips, MAX_CHIPS_PARSED);
a.recycle();
}
@@ -1048,7 +1050,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
synchronized (mPendingChips) {
Editable editable = getText();
// Tokenize!
- if (mPendingChipsCount <= MAX_CHIPS_PARSED) {
+ if (mPendingChipsCount <= mMaxChipsParsed) {
for (int i = 0; i < mPendingChips.size(); i++) {
String current = mPendingChips.get(i);
int tokenStart = editable.toString().indexOf(current);
@@ -3129,4 +3131,29 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
float right;
float bottom;
}
+
+ /**
+ * Get the current max chips limits.
+ * @return The value used to cap the number of contacts that this field will tokenize.
+ */
+ protected int getMaxChipsParsed() {
+ return mMaxChipsParsed;
+ }
+
+ /**
+ * Set the current max chips limit.
+ * @param maxChipsParsed - This value will cap the number of contacts that this field will
+ * tokenize.
+ */
+ protected void setMaxChipsParsed(int maxChipsParsed) {
+ mMaxChipsParsed = maxChipsParsed;
+ }
+
+ /**
+ * Get whether we are still tokenizing input
+ * @return true if still tokenizing contacts, false otherwise
+ */
+ protected boolean isChipping() {
+ return !mNoChips;
+ }
}