From d208e709267f8af77690cb38dba2ae8e30ab5241 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Fri, 8 Oct 2010 16:22:43 -0400 Subject: [PATCH] Get rid of the global actions menu on tablets. We have the system tray for that stuff. Make long press on power go directly to the shut down confirmation dialog. Make that dialog auto dismiss when the screen goes off. Reword it when we're skipping the global actions menu, because it feels too abrupt to say "The phone will shut down" when they haven't clearly pressed a button that says shut down. Change-Id: I8c92a1362bd4ed242e6cd94c2dae6d9ff9c4c34d --- .../android/internal/app/ShutdownThread.java | 38 +++- core/res/res/values-xlarge/config.xml | 3 + core/res/res/values/config.xml | 7 + core/res/res/values/strings.xml | 9 +- .../policy/impl/PhoneWindowManager.java | 31 ++- .../internal/policy/impl/PowerDialog.java | 182 ------------------ 6 files changed, 80 insertions(+), 190 deletions(-) delete mode 100644 policy/src/com/android/internal/policy/impl/PowerDialog.java diff --git a/core/java/com/android/internal/app/ShutdownThread.java b/core/java/com/android/internal/app/ShutdownThread.java index e07c54f59c34a..8104ece7b7906 100644 --- a/core/java/com/android/internal/app/ShutdownThread.java +++ b/core/java/com/android/internal/app/ShutdownThread.java @@ -18,15 +18,17 @@ package com.android.internal.app; import android.app.ActivityManagerNative; +import android.app.AlertDialog; +import android.app.Dialog; import android.app.IActivityManager; import android.app.ProgressDialog; -import android.app.AlertDialog; import android.bluetooth.BluetoothAdapter; import android.bluetooth.IBluetooth; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.IntentFilter; import android.os.Handler; import android.os.Power; import android.os.PowerManager; @@ -91,13 +93,20 @@ public final class ShutdownThread extends Thread { } } - Log.d(TAG, "Notifying thread to start radio shutdown"); + final int longPressBehavior = context.getResources().getInteger( + com.android.internal.R.integer.config_longPressOnPowerBehavior); + final int resourceId = longPressBehavior == 2 + ? com.android.internal.R.string.shutdown_confirm_question + : com.android.internal.R.string.shutdown_confirm; + + Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior); if (confirm) { + final CloseDialogReceiver closer = new CloseDialogReceiver(context); final AlertDialog dialog = new AlertDialog.Builder(context) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(com.android.internal.R.string.power_off) - .setMessage(com.android.internal.R.string.shutdown_confirm) + .setMessage(resourceId) .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { beginShutdownSequence(context); @@ -105,6 +114,8 @@ public final class ShutdownThread extends Thread { }) .setNegativeButton(com.android.internal.R.string.no, null) .create(); + closer.dialog = dialog; + dialog.setOnDismissListener(closer); dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); if (!context.getResources().getBoolean( com.android.internal.R.bool.config_sf_slowBlur)) { @@ -116,6 +127,27 @@ public final class ShutdownThread extends Thread { } } + private static class CloseDialogReceiver extends BroadcastReceiver + implements DialogInterface.OnDismissListener { + private Context mContext; + public Dialog dialog; + + CloseDialogReceiver(Context context) { + mContext = context; + IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); + context.registerReceiver(this, filter); + } + + @Override + public void onReceive(Context context, Intent intent) { + dialog.cancel(); + } + + public void onDismiss(DialogInterface unused) { + mContext.unregisterReceiver(this); + } + } + /** * Request a clean shutdown, waiting for subsystems to clean up their * state etc. Must be called from a Looper thread in which its UI diff --git a/core/res/res/values-xlarge/config.xml b/core/res/res/values-xlarge/config.xml index 7e5a27b348d89..813651e9e7018 100644 --- a/core/res/res/values-xlarge/config.xml +++ b/core/res/res/values-xlarge/config.xml @@ -25,6 +25,9 @@ com.android.systemui/com.android.systemui.statusbar.tablet.TabletStatusBarService false + + 2 + false diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 71967d4a59ce2..d353db6768d44 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -221,6 +221,13 @@ closed. The default is 0. --> 0 + + 1 + false diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 521a739f88c3c..0172827c5891e 100755 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -280,9 +280,16 @@ Shutting down\u2026 - + Your phone will shut down. + + Would you like to shut down? +