summaryrefslogtreecommitdiff
path: root/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java')
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java74
1 files changed, 6 insertions, 68 deletions
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java
index 3a62abcac..1b3bf33d3 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java
@@ -22,9 +22,9 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.app.KeyguardManager;
import android.app.NotificationManager;
-import android.app.StatusBarManager;
import android.app.PendingIntent;
import android.app.RemoteAction;
+import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ClipboardManager;
@@ -44,7 +44,6 @@ import android.preference.PreferenceManager;
import android.provider.Telephony;
import android.telephony.SmsCbCmasInfo;
import android.telephony.SmsCbMessage;
-import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.Spannable;
import android.text.SpannableString;
@@ -76,8 +75,7 @@ import com.android.internal.annotations.VisibleForTesting;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -356,8 +354,7 @@ public class CellBroadcastAlertDialog extends Activity {
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
// Disable home button when alert dialog is showing if mute_by_physical_button is false.
- if (!CellBroadcastSettings.getResources(getApplicationContext(),
- SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)
+ if (!CellBroadcastSettings.getResourcesForDefaultSubId(getApplicationContext())
.getBoolean(R.bool.mute_by_physical_button)) {
final View decorView = win.getDecorView();
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
@@ -454,10 +451,6 @@ public class CellBroadcastAlertDialog extends Activity {
mAnimationHandler.startIconAnimation(subId);
}
}
- // Some LATAM carriers mandate to disable navigation bars, quick settings etc when alert
- // dialog is showing. This is to make sure users to ack the alert before switching to
- // other activities.
- setStatusBarDisabledIfNeeded(true);
}
/**
@@ -468,7 +461,6 @@ public class CellBroadcastAlertDialog extends Activity {
public void onPause() {
Log.d(TAG, "onPause called");
mAnimationHandler.stopIconAnimation();
- setStatusBarDisabledIfNeeded(false);
super.onPause();
}
@@ -708,20 +700,11 @@ public class CellBroadcastAlertDialog extends Activity {
TextView titleTextView = findViewById(R.id.alertTitle);
if (titleTextView != null) {
- if (res.getBoolean(R.bool.show_date_time_title)) {
+ String timeFormat = res.getString(R.string.date_time_format);
+ if (!TextUtils.isEmpty(timeFormat)) {
titleTextView.setSingleLine(false);
- int flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_SHOW_TIME
- | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_DATE
- | DateUtils.FORMAT_CAP_AMPM;
- if (res.getBoolean(R.bool.show_date_time_with_year_title)) {
- flags |= DateUtils.FORMAT_SHOW_YEAR;
- }
- if (res.getBoolean(R.bool.show_date_in_numeric_format)) {
- flags |= DateUtils.FORMAT_NUMERIC_DATE;
- }
- title += "\n" + DateUtils.formatDateTime(context, message.getReceivedTime(), flags);
+ title += "\n" + new SimpleDateFormat(timeFormat).format(message.getReceivedTime());
}
-
setTitle(title);
titleTextView.setText(title);
}
@@ -1175,49 +1158,4 @@ public class CellBroadcastAlertDialog extends Activity {
setFinishOnTouchOutside(mMessageList.size() > 0 && mMessageList.size() == dismissCount);
}
}
-
- /**
- * To disable navigation bars, quick settings etc. Force users to engage with the alert dialog
- * before switching to other activities.
- *
- * @param disable if set to {@code true} to disable the status bar. {@code false} otherwise.
- */
- private void setStatusBarDisabledIfNeeded(boolean disable) {
- if (!CellBroadcastSettings.getResourcesForDefaultSubId(getApplicationContext())
- .getBoolean(R.bool.disable_status_bar)) {
- return;
- }
- try {
- // TODO change to system API in S.
- StatusBarManager statusBarManager = getSystemService(StatusBarManager.class);
- Method disableMethod = StatusBarManager.class.getDeclaredMethod(
- "disable", int.class);
- Method disableMethod2 = StatusBarManager.class.getDeclaredMethod(
- "disable2", int.class);
- if (disable) {
- // flags to be disabled
- int disableHome = StatusBarManager.class.getDeclaredField("DISABLE_HOME")
- .getInt(null);
- int disableRecent = StatusBarManager.class
- .getDeclaredField("DISABLE_RECENT").getInt(null);
- int disableBack = StatusBarManager.class.getDeclaredField("DISABLE_BACK")
- .getInt(null);
- int disableQuickSettings = StatusBarManager.class.getDeclaredField(
- "DISABLE2_QUICK_SETTINGS").getInt(null);
- int disableNotificationShaded = StatusBarManager.class.getDeclaredField(
- "DISABLE2_NOTIFICATION_SHADE").getInt(null);
- disableMethod.invoke(statusBarManager, disableHome | disableBack | disableRecent);
- disableMethod2.invoke(statusBarManager, disableQuickSettings
- | disableNotificationShaded);
- } else {
- int disableNone = StatusBarManager.class.getDeclaredField("DISABLE_NONE")
- .getInt(null);
- disableMethod.invoke(statusBarManager, disableNone);
- disableMethod2.invoke(statusBarManager, disableNone);
- }
- } catch (NoSuchFieldException | IllegalAccessException
- | NoSuchMethodException | InvocationTargetException e) {
- Log.e(TAG, "Failed to disable navigation when showing alert: " + e);
- }
- }
}