/** * Joins a list of {@link CharSequence} into a single {@link CharSequence} seperated by a * localized delimiter such as ", ". * * @param resources Resources used to get list delimiter. * @param list List of char sequences to join. * @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); 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()); }
getContext().getResources().getString(R.string.phone_type_and_phone_number), mContact.getPhoneType(), BidiFormatter.getInstance().unicodeWrap(mContact.getPhoneNumber(), TextDirectionHeuristics.LTR)); setSummary(summary);
} else { menu.setHeaderTitle(PhoneNumberUtilsCompat.createTtsSpannable( BidiFormatter.getInstance().unicodeWrap(number, TextDirectionHeuristics.LTR)));