am 023e003d: am 2425b0f3: am 18636118: am 1648dba0: am ea7a7052: am 70b1f88b: Merge "[USSD] Consolidate USSD messages in a single dialog box" into klp-dev
* commit '023e003d99a37c9ef715b5eea8296e13c628b06b':
[USSD] Consolidate USSD messages in a single dialog box
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4b9ac2f..16c52e1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -379,6 +379,10 @@
<string name="roaming_reenable_message">You\'ve lost data connectivity because you left your home network with data roaming turned off.</string>
<!-- Mobile network settings screen, dialog message when user selects the Data roaming check box -->
<string name="roaming_warning">Allow data roaming? You may incur significant roaming charges!</string>
+
+ <!-- USSD aggregation dialog box: separator strings between messages (new-lines will be added before and after) -->
+ <string name="ussd_dialog_sep" translatable="false">----------</string>
+
<string name="gsm_umts_options">GSM/UMTS Options</string>
<string name="cdma_options">CDMA Options</string>
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 4ceefe1..19bd71b 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -139,6 +139,10 @@
}
}
+ /** USSD information used to aggregate all USSD messages */
+ private static AlertDialog sUssdDialog = null;
+ private static StringBuilder sUssdMsg = new StringBuilder();
+
/**
* Handler that tracks the connections and updates the value of the
* Mute settings for each connection as needed.
@@ -1104,18 +1108,33 @@
// 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 newDialog = new AlertDialog.Builder(context)
- .setMessage(text)
- .setPositiveButton(R.string.ok, null)
- .setCancelable(true)
- .create();
- newDialog.getWindow().setType(
- WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
- newDialog.getWindow().addFlags(
- WindowManager.LayoutParams.FLAG_DIM_BEHIND);
+ if (sUssdDialog == null) {
+ sUssdDialog = new AlertDialog.Builder(context)
+ .setPositiveButton(R.string.ok, null)
+ .setCancelable(true)
+ .setOnDismissListener(new DialogInterface.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ sUssdMsg.setLength(0);
+ }
+ })
+ .create();
- newDialog.show();
+ sUssdDialog.getWindow().setType(
+ WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
+ sUssdDialog.getWindow().addFlags(
+ WindowManager.LayoutParams.FLAG_DIM_BEHIND);
+ }
+ if (sUssdMsg.length() != 0) {
+ sUssdMsg
+ .insert(0, "\n")
+ .insert(0, app.getResources().getString(R.string.ussd_dialog_sep))
+ .insert(0, "\n");
+ }
+ sUssdMsg.insert(0, text);
+ sUssdDialog.setMessage(sUssdMsg.toString());
+ sUssdDialog.show();
} else {
if (DBG) log("USSD code has requested user input. Constructing input dialog.");