diff options
author | Martin Brabham <optedoblivion@cyngn.com> | 2015-11-19 18:55:28 -0800 |
---|---|---|
committer | Martin Brabham <optedoblivion@cyngn.com> | 2015-11-20 11:48:52 -0800 |
commit | 778bda87ed2722e4d40517ecfadd2d1b1022a8fb (patch) | |
tree | 5284a313b936695011410cf0650fd25d616e2242 | |
parent | afc21fbcc1d2ae570ff168ff0591c20c1e54923c (diff) | |
download | android_frameworks_opt_chips-cm-12.1.tar.gz android_frameworks_opt_chips-cm-12.1.tar.bz2 android_frameworks_opt_chips-cm-12.1.zip |
Fix plus sign on number dropdowncm-12.1
if there are spaces
each group is treated as a word
e.g.
1 234 567 8900
will show as 8900 567 234 1
and if you do
1+234+567+8900 it'll show as 8900+567+234+1
so +1 will show as 1+
2+1 will show as 1+2
Change-Id: I6df5876d8eeb317cb425ab0d36f972423dd803f7
Ticket-Id: HAM-1146
-rw-r--r-- | src/com/android/ex/chips/DropdownChipLayouter.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/com/android/ex/chips/DropdownChipLayouter.java b/src/com/android/ex/chips/DropdownChipLayouter.java index 882cd9f..622dc25 100644 --- a/src/com/android/ex/chips/DropdownChipLayouter.java +++ b/src/com/android/ex/chips/DropdownChipLayouter.java @@ -28,6 +28,7 @@ import com.android.ex.chips.ResultAnimationDrawable.STATE; import java.util.ArrayList; import java.util.List; +import java.util.Locale; /** * A class that inflates and binds the views in the dropdown list from @@ -222,6 +223,16 @@ public class DropdownChipLayouter { return bindView(convertView, parent, entry, position, type, constraint, null); } + public static boolean isRTL() { + return isRTL(Locale.getDefault()); + } + + public static boolean isRTL(Locale locale) { + final int directionality = Character.getDirectionality(locale.getDisplayName().charAt(0)); + return directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT || + directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC; + } + /** * See {@link #bindView(View, ViewGroup, RecipientEntry, int, AdapterType, String)} * @param deleteDrawable @@ -277,6 +288,16 @@ public class DropdownChipLayouter { destinationType = null; } + if (!TextUtils.isEmpty(destination)) { + if (isRTL()) { + if (destination.contains("+")) { + // Move the plus sign to the rear so it displays at the beginning + destination = destination.replace("+", ""); + destination = destination + "+"; + } + } + } + // Bind the information to the view bindTextToView(displayName, viewHolder.displayNameView); bindTextToView(destination, viewHolder.destinationView); |