diff options
author | Andrew Lee <anwlee@google.com> | 2015-06-04 21:28:35 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-04 21:28:44 +0000 |
commit | ee163fa1ac6477da543568053f8b81f3d5006374 (patch) | |
tree | abe57f64a8d9cf01b6ee78d5e99c5ce2b36f838d /src | |
parent | 16249d19754ae21bc31b1187dc42e51d86bdbff6 (diff) | |
parent | f4cb047c49e061cd0590a53d0a176233019eb906 (diff) |
Merge "Bidi-format joined strings." into mnc-dev
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/util/DialerUtils.java | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/com/android/dialer/util/DialerUtils.java b/src/com/android/dialer/util/DialerUtils.java index a04719a41..a44c2eec6 100644 --- a/src/com/android/dialer/util/DialerUtils.java +++ b/src/com/android/dialer/util/DialerUtils.java @@ -28,6 +28,8 @@ import android.net.Uri; import android.os.Bundle; import android.provider.Telephony; import android.telecom.TelecomManager; +import android.text.BidiFormatter; +import android.text.TextDirectionHeuristics; import android.text.TextUtils; import android.view.View; import android.view.inputmethod.InputMethodManager; @@ -41,6 +43,8 @@ import com.android.dialer.R; import com.android.incallui.CallCardFragment; import com.android.incallui.Log; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -158,8 +162,25 @@ public class DialerUtils { * @return Joined char sequences. */ public static CharSequence join(Resources resources, Iterable<CharSequence> list) { + StringBuilder sb = new StringBuilder(); + final BidiFormatter formatter = BidiFormatter.getInstance(); final CharSequence separator = resources.getString(R.string.list_delimeter); - return TextUtils.join(separator, list); + + Iterator<CharSequence> itr = list.iterator(); + boolean firstTime = true; + while (itr.hasNext()) { + if (firstTime) { + firstTime = false; + } else { + sb.append(separator); + } + // Unicode wrap the elements of the list to respect RTL for individual strings. + sb.append(formatter.unicodeWrap( + itr.next().toString(), TextDirectionHeuristics.FIRSTSTRONG_LTR)); + } + + // Unicode wrap the joined value, to respect locale's RTL ordering for the whole list. + return formatter.unicodeWrap(sb.toString()); } /** |