diff options
author | John Spurlock <jspurlock@google.com> | 2014-05-30 23:51:13 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-30 23:51:13 +0000 |
commit | b8a0feed0406e91eaa6f5bee223bc9316171c2b6 (patch) | |
tree | 7c458d6171572c8c6820a58bb0a0d2a7f4d931b5 /policy | |
parent | 05dc18d69ad64254f2bcdd9c1e208ab54ee664fe (diff) | |
parent | 822e5cc4823a09727833eb984e3982dcd98e4d99 (diff) | |
download | frameworks_base-b8a0feed0406e91eaa6f5bee223bc9316171c2b6.zip frameworks_base-b8a0feed0406e91eaa6f5bee223bc9316171c2b6.tar.gz frameworks_base-b8a0feed0406e91eaa6f5bee223bc9316171c2b6.tar.bz2 |
Merge "Resurrect global actions, remove confirmation for Power off." into lmp-preview-dev
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/GlobalActions.java | 83 |
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; } |