Reformat phone number to show for quick respond message result toast.
For messages in RTL languages such as Arabic, phone numbers can be
displayed in wrong order. Reformat the phone number so that the toast
won't mistankenly show it in wrong order.
Bug: 228933665
Test: Manually make sure the phone number can be displayed properly in
Arabic.
Change-Id: I7ca1f9d6e62edd9e40067ba25c4e99d6a9e18ba3
diff --git a/src/com/android/server/telecom/RespondViaSmsManager.java b/src/com/android/server/telecom/RespondViaSmsManager.java
index 23ccc1c..6ee4a4e 100644
--- a/src/com/android/server/telecom/RespondViaSmsManager.java
+++ b/src/com/android/server/telecom/RespondViaSmsManager.java
@@ -31,11 +31,13 @@
import android.telephony.PhoneNumberUtils;
import android.telephony.SmsManager;
import android.telephony.SubscriptionManager;
+import android.text.BidiFormatter;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.widget.Toast;
+import java.text.Bidi;
import java.util.ArrayList;
import java.util.List;
@@ -158,7 +160,9 @@
final String formatString = res.getString(success
? R.string.respond_via_sms_confirmation_format
: R.string.respond_via_sms_failure_format);
- final String confirmationMsg = String.format(formatString, phoneNumber);
+ final BidiFormatter phoneNumberFormatter = BidiFormatter.getInstance();
+ final String confirmationMsg = String.format(formatString,
+ phoneNumberFormatter.unicodeWrap(phoneNumber));
int startingPosition = confirmationMsg.indexOf(phoneNumber);
int endingPosition = startingPosition + phoneNumber.length();
@@ -207,6 +211,7 @@
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
sentIntents.add(pendingIntent);
}
+
MessageSentReceiver receiver = new MessageSentReceiver(
!TextUtils.isEmpty(contactName) ? contactName : phoneNumber,
messageParts.size());