Fixed that OK button is not localized
Because the dialog is stored as a static variable, so
the ok button string resource was not refreshed after
language changed.
And in fact there is no need to cache the dialog. We
should always create it when needed, and let it GC'd
when closed.
Test: Manual
Fix: 145309447
Merged-In: Iaccf51e669dbf76ae4c9fcf149cec665f9090c97
Change-Id: Iaccf51e669dbf76ae4c9fcf149cec665f9090c97
(cherry picked from commit 07666003e20dc99b50f11ddb540d9b2fdf3092ec)
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 20a818e..c567806 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -87,7 +87,6 @@
private static final int THEME = com.android.internal.R.style.Theme_DeviceDefault_Dialog_Alert;
/** USSD information used to aggregate all USSD messages */
- private static AlertDialog sUssdDialog = null;
private static StringBuilder sUssdMsg = new StringBuilder();
private static final ComponentName PSTN_CONNECTION_SERVICE_COMPONENT =
@@ -524,39 +523,36 @@
// displaying system alert dialog on the screen instead of
// using another activity to display the message. This
// places the message at the forefront of the UI.
+ AlertDialog ussdDialog = new AlertDialog.Builder(context, THEME)
+ .setPositiveButton(R.string.ok, null)
+ .setCancelable(true)
+ .setOnDismissListener(new DialogInterface.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ sUssdMsg.setLength(0);
+ }
+ })
+ .create();
- if (sUssdDialog == null) {
- sUssdDialog = new AlertDialog.Builder(context, THEME)
- .setPositiveButton(R.string.ok, null)
- .setCancelable(true)
- .setOnDismissListener(new DialogInterface.OnDismissListener() {
- @Override
- public void onDismiss(DialogInterface dialog) {
- sUssdMsg.setLength(0);
- }
- })
- .create();
+ ussdDialog.getWindow().setType(windowType);
+ ussdDialog.getWindow().addFlags(
+ WindowManager.LayoutParams.FLAG_DIM_BEHIND);
- sUssdDialog.getWindow().setType(windowType);
- sUssdDialog.getWindow().addFlags(
- WindowManager.LayoutParams.FLAG_DIM_BEHIND);
- }
if (sUssdMsg.length() != 0) {
- sUssdMsg
- .insert(0, "\n")
+ sUssdMsg.insert(0, "\n")
.insert(0, app.getResources().getString(R.string.ussd_dialog_sep))
.insert(0, "\n");
}
if (phone != null && phone.getCarrierName() != null) {
- sUssdDialog.setTitle(app.getResources().getString(R.string.carrier_mmi_msg_title,
+ ussdDialog.setTitle(app.getResources().getString(R.string.carrier_mmi_msg_title,
phone.getCarrierName()));
} else {
- sUssdDialog
+ ussdDialog
.setTitle(app.getResources().getString(R.string.default_carrier_mmi_msg_title));
}
sUssdMsg.insert(0, text);
- sUssdDialog.setMessage(sUssdMsg.toString());
- sUssdDialog.show();
+ ussdDialog.setMessage(sUssdMsg.toString());
+ ussdDialog.show();
}
/**