diff options
| author | Raj Yengisetty <rajesh@cyngn.com> | 2015-04-06 18:09:12 -0700 |
|---|---|---|
| committer | Rajesh Yengisetty <rajesh@cyngn.com> | 2015-04-07 22:40:05 +0000 |
| commit | 9f53ad13ad78945689c6e16aad127bdfca4c4779 (patch) | |
| tree | 2aa294eb3d3e7dbe931fc2cdd0826b72e2be46d4 | |
| parent | 6201bd38aeda13bcd79bc6a044084efdd9c07d3c (diff) | |
| download | android_frameworks_opt_chips-9f53ad13ad78945689c6e16aad127bdfca4c4779.tar.gz android_frameworks_opt_chips-9f53ad13ad78945689c6e16aad127bdfca4c4779.tar.bz2 android_frameworks_opt_chips-9f53ad13ad78945689c6e16aad127bdfca4c4779.zip | |
Chips: Add a view attribute for maximum number of chips parsed
Additionally add a dynamic way to set maxChipsParsed
Change-Id: I8e88d4268b8e2ecc6de26d8cf69a985821c8e9f0
(cherry picked from commit c274746186af89f4c11499771678696d18158476)
| -rw-r--r-- | res/values/attrs.xml | 3 | ||||
| -rw-r--r-- | src/com/android/ex/chips/RecipientEditTextView.java | 29 |
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 90fadd0..b9f67d1 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. @@ -965,6 +966,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(); } @@ -1059,7 +1061,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); @@ -3140,4 +3142,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; + } } |
