summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2015-04-08 22:30:31 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2015-04-08 22:30:31 -0700
commit23a004320ce0a2d285c08f7aba1fe690b7486d0f (patch)
tree68c98b6b4e6b91aa7d24aa76680479f624cb783e
parentb8f1bea3d47508a5a333dbd1f43c82fcfa916fd8 (diff)
parent2c0ca1809ebc46afccf2e0e67b98a815aafd19a6 (diff)
downloadandroid_frameworks_opt_chips-23a004320ce0a2d285c08f7aba1fe690b7486d0f.tar.gz
android_frameworks_opt_chips-23a004320ce0a2d285c08f7aba1fe690b7486d0f.tar.bz2
android_frameworks_opt_chips-23a004320ce0a2d285c08f7aba1fe690b7486d0f.zip
Merge "Chips: Add a view attribute for maximum number of chips parsed"
-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 fe814da..8a979a9 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -156,6 +156,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.
@@ -963,6 +964,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();
}
@@ -1057,7 +1059,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);
@@ -3133,4 +3135,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;
+ }
}