summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2014-05-30 17:48:54 -0400
committerJohn Spurlock <jspurlock@google.com>2014-05-30 17:51:43 -0400
commit822e5cc4823a09727833eb984e3982dcd98e4d99 (patch)
tree3515f07ce47146091a94f22b5b95989bf0e2ecdd /policy
parenta24114e7b1418ec911b6328656f36f9598482d87 (diff)
downloadframeworks_base-822e5cc4823a09727833eb984e3982dcd98e4d99.zip
frameworks_base-822e5cc4823a09727833eb984e3982dcd98e4d99.tar.gz
frameworks_base-822e5cc4823a09727833eb984e3982dcd98e4d99.tar.bz2
Resurrect global actions, remove confirmation for Power off.
Instead of fast forwarding to the power off confirmation dialog, display the global actions dialog with a single item by default, with no confirmation. Re-configure the bugreport option, it will appear if specified in developer settings. Bug:15109463 Change-Id: I5a19df8684d661345e42ad305f64f01c271aae19
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/GlobalActions.java83
1 files changed, 38 insertions, 45 deletions
diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java
index 673ce0b..762d3df 100644
--- a/policy/src/com/android/internal/policy/impl/GlobalActions.java
+++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java
@@ -185,7 +185,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
// If we only have 1 item and it's a simple press action, just do this action.
if (mAdapter.getCount() == 1
- && mAdapter.getItem(0) instanceof SinglePressAction) {
+ && mAdapter.getItem(0) instanceof SinglePressAction
+ && !(mAdapter.getItem(0) instanceof LongPressAction)) {
((SinglePressAction) mAdapter.getItem(0)).onPress();
} else {
WindowManager.LayoutParams attrs = mDialog.getWindow().getAttributes();
@@ -262,7 +263,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
continue;
}
if (GLOBAL_ACTION_KEY_POWER.equals(actionKey)) {
- mItems.add(getPowerAction());
+ mItems.add(new PowerAction());
} else if (GLOBAL_ACTION_KEY_AIRPLANE.equals(actionKey)) {
mItems.add(mAirplaneModeOn);
} else if (GLOBAL_ACTION_KEY_BUGREPORT.equals(actionKey)
@@ -300,7 +301,11 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position,
long id) {
- return mAdapter.getItem(position).onLongPress();
+ final Action action = mAdapter.getItem(position);
+ if (action instanceof LongPressAction) {
+ return ((LongPressAction) action).onLongPress();
+ }
+ return false;
}
});
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
@@ -310,29 +315,33 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
return dialog;
}
- private Action getPowerAction() {
- return new SinglePressAction(
- com.android.internal.R.drawable.ic_lock_power_off,
- R.string.global_action_power_off) {
+ private final class PowerAction extends SinglePressAction implements LongPressAction {
+ private PowerAction() {
+ super(com.android.internal.R.drawable.ic_lock_power_off,
+ R.string.global_action_power_off);
+ }
- public void onPress() {
- // shutdown by making sure radio and power are handled accordingly.
- mWindowManagerFuncs.shutdown(true);
- }
+ @Override
+ public boolean onLongPress() {
+ mWindowManagerFuncs.rebootSafeMode(true);
+ return true;
+ }
- public boolean onLongPress() {
- mWindowManagerFuncs.rebootSafeMode(true);
- return true;
- }
+ @Override
+ public boolean showDuringKeyguard() {
+ return true;
+ }
- public boolean showDuringKeyguard() {
- return true;
- }
+ @Override
+ public boolean showBeforeProvisioning() {
+ return true;
+ }
- public boolean showBeforeProvisioning() {
- return true;
- }
- };
+ @Override
+ public void onPress() {
+ // shutdown by making sure radio and power are handled accordingly.
+ mWindowManagerFuncs.shutdown(false /* confirm */);
+ }
}
private Action getBugReportAction() {
@@ -367,10 +376,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
dialog.show();
}
- public boolean onLongPress() {
- return false;
- }
-
public boolean showDuringKeyguard() {
return true;
}
@@ -393,11 +398,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
}
@Override
- public boolean onLongPress() {
- return false;
- }
-
- @Override
public boolean showDuringKeyguard() {
return true;
}
@@ -583,8 +583,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
void onPress();
- public boolean onLongPress();
-
/**
* @return whether this action should appear in the dialog when the keygaurd
* is showing.
@@ -601,6 +599,13 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
}
/**
+ * An action that also supports long press.
+ */
+ private interface LongPressAction extends Action {
+ boolean onLongPress();
+ }
+
+ /**
* A single press action maintains no state, just responds to a press
* and takes an action.
*/
@@ -637,10 +642,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
abstract public void onPress();
- public boolean onLongPress() {
- return false;
- }
-
public View create(
Context context, View convertView, ViewGroup parent, LayoutInflater inflater) {
View v = inflater.inflate(R.layout.global_actions_item, parent, false);
@@ -769,10 +770,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
changeStateFromPress(nowOn);
}
- public boolean onLongPress() {
- return false;
- }
-
public boolean isEnabled() {
return !mState.inTransition();
}
@@ -862,10 +859,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
public void onPress() {
}
- public boolean onLongPress() {
- return false;
- }
-
public boolean showDuringKeyguard() {
return true;
}