diff options
author | Winson Chung <winsonc@google.com> | 2014-05-19 16:25:39 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-19 16:25:40 +0000 |
commit | 958e559b98bd7c3ab6dd20bf530bf58f56f20b63 (patch) | |
tree | 8a752bc6057bdf9cb137805136e8e74ebfaa2456 /policy | |
parent | b82bbf6113a5b72631f1ee727d98d35a2b215121 (diff) | |
parent | 1e8d71b605b4872e93200706a80a88a3ff25498c (diff) | |
download | frameworks_base-958e559b98bd7c3ab6dd20bf530bf58f56f20b63.zip frameworks_base-958e559b98bd7c3ab6dd20bf530bf58f56f20b63.tar.gz frameworks_base-958e559b98bd7c3ab6dd20bf530bf58f56f20b63.tar.bz2 |
Merge "Initial changes to enable keyboard support with alternate Recents. (Bug 14067913)"
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 100 | ||||
-rw-r--r-- | policy/src/com/android/internal/policy/impl/RecentApplicationsDialog.java | 2 |
2 files changed, 38 insertions, 64 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 8eed414..466c8ed 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -261,13 +261,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { WindowState mLastInputMethodWindow = null; WindowState mLastInputMethodTargetWindow = null; - static final int RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS = 0; - static final int RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW = 1; - static final int RECENT_APPS_BEHAVIOR_DISMISS = 2; - static final int RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH = 3; - - RecentApplicationsDialog mRecentAppsDialog; - int mRecentAppsDialogHeldModifiers; + int mRecentAppsHeldModifiers; boolean mLanguageSwitchKeyPressed; int mLidState = LID_ABSENT; @@ -807,52 +801,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { } }; - /** - * Create (if necessary) and show or dismiss the recent apps dialog according - * according to the requested behavior. - */ - void showOrHideRecentAppsDialog(final int behavior) { - mHandler.post(new Runnable() { - @Override - public void run() { - if (mRecentAppsDialog == null) { - mRecentAppsDialog = new RecentApplicationsDialog(mContext); - } - if (mRecentAppsDialog.isShowing()) { - switch (behavior) { - case RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS: - case RECENT_APPS_BEHAVIOR_DISMISS: - mRecentAppsDialog.dismiss(); - break; - case RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH: - mRecentAppsDialog.dismissAndSwitch(); - break; - case RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW: - default: - break; - } - } else { - switch (behavior) { - case RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS: - mRecentAppsDialog.show(); - break; - case RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW: - try { - mWindowManager.setInTouchMode(false); - } catch (RemoteException e) { - } - mRecentAppsDialog.show(); - break; - case RECENT_APPS_BEHAVIOR_DISMISS: - case RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH: - default: - break; - } - } - } - }); - } - /** {@inheritDoc} */ @Override public void init(Context context, IWindowManager windowManager, @@ -2261,21 +2209,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Display task switcher for ALT-TAB or Meta-TAB. if (down && repeatCount == 0 && keyCode == KeyEvent.KEYCODE_TAB) { - if (mRecentAppsDialogHeldModifiers == 0 && !keyguardOn) { + if (mRecentAppsHeldModifiers == 0 && !keyguardOn) { final int shiftlessModifiers = event.getModifiers() & ~KeyEvent.META_SHIFT_MASK; if (KeyEvent.metaStateHasModifiers(shiftlessModifiers, KeyEvent.META_ALT_ON) || KeyEvent.metaStateHasModifiers( shiftlessModifiers, KeyEvent.META_META_ON)) { - mRecentAppsDialogHeldModifiers = shiftlessModifiers; - showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW); + mRecentAppsHeldModifiers = shiftlessModifiers; + showRecentApps(true); return -1; } } - } else if (!down && mRecentAppsDialogHeldModifiers != 0 - && (metaState & mRecentAppsDialogHeldModifiers) == 0) { - mRecentAppsDialogHeldModifiers = 0; - showOrHideRecentAppsDialog(keyguardOn ? RECENT_APPS_BEHAVIOR_DISMISS : - RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH); + } else if (!down && mRecentAppsHeldModifiers != 0 + && (metaState & mRecentAppsHeldModifiers) == 0) { + mRecentAppsHeldModifiers = 0; + hideRecentApps(); } // Handle keyboard language switching. @@ -2448,7 +2395,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { statusbar.cancelPreloadRecentApps(); } } catch (RemoteException e) { - Slog.e(TAG, "RemoteException when showing recent apps", e); + Slog.e(TAG, "RemoteException when cancelling recent apps preload", e); // re-acquire status bar service next time it is needed. mStatusBarService = null; } @@ -2457,19 +2404,46 @@ public class PhoneWindowManager implements WindowManagerPolicy { private void toggleRecentApps() { mPreloadedRecentApps = false; // preloading no longer needs to be canceled - sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS); try { IStatusBarService statusbar = getStatusBarService(); if (statusbar != null) { statusbar.toggleRecentApps(); } } catch (RemoteException e) { + Slog.e(TAG, "RemoteException when toggling recent apps", e); + // re-acquire status bar service next time it is needed. + mStatusBarService = null; + } + } + + private void showRecentApps(boolean triggeredFromAltTab) { + mPreloadedRecentApps = false; // preloading no longer needs to be canceled + try { + IStatusBarService statusbar = getStatusBarService(); + if (statusbar != null) { + statusbar.showRecentApps(triggeredFromAltTab); + } + } catch (RemoteException e) { Slog.e(TAG, "RemoteException when showing recent apps", e); // re-acquire status bar service next time it is needed. mStatusBarService = null; } } + private void hideRecentApps() { + mPreloadedRecentApps = false; // preloading no longer needs to be canceled + try { + IStatusBarService statusbar = getStatusBarService(); + if (statusbar != null) { + statusbar.hideRecentApps(); + } + } catch (RemoteException e) { + Slog.e(TAG, "RemoteException when closing recent apps", e); + // re-acquire status bar service next time it is needed. + mStatusBarService = null; + } + } + /** * A home key -> launch home action was detected. Take the appropriate action * given the situation with the keyguard. diff --git a/policy/src/com/android/internal/policy/impl/RecentApplicationsDialog.java b/policy/src/com/android/internal/policy/impl/RecentApplicationsDialog.java index 2f0d7d6..bc55ed1 100644 --- a/policy/src/com/android/internal/policy/impl/RecentApplicationsDialog.java +++ b/policy/src/com/android/internal/policy/impl/RecentApplicationsDialog.java @@ -123,7 +123,7 @@ public class RecentApplicationsDialog extends Dialog implements OnClickListener } @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { + public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_TAB) { // Ignore all meta keys other than SHIFT. The app switch key could be a // fallback action chorded with ALT, META or even CTRL depending on the key map. |