From 4616347537efec8b039477e8a1660575a0923c90 Mon Sep 17 00:00:00 2001 From: Winson Date: Tue, 22 Sep 2015 17:31:56 -0700 Subject: [PATCH] Fixing workspace state issue with option menu. - Hitting a ctrl key combo will actually call onPrepareOptionsMenu(), which will change the state of the workspace incorrectly. Instead, listen for the menu button, and only allow the user to enter overview mode if they are currently not dragging or in an overlay state (like all apps or widgets). - Also making the overview buttons focusable so that they are focused when you go into overview mode. Bug: 22483367 Change-Id: Ie6e9febd8a5a4e7ad25d745639d42d1c7b9801b4 --- res/layout/overview_panel.xml | 9 ++++--- src/com/android/launcher3/Launcher.java | 36 ++++++++++++++++--------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/res/layout/overview_panel.xml b/res/layout/overview_panel.xml index 1f02dce3c7..4f54f1dfcd 100644 --- a/res/layout/overview_panel.xml +++ b/res/layout/overview_panel.xml @@ -33,7 +33,8 @@ android:text="@string/wallpaper_button_text" android:textAllCaps="true" android:textColor="@android:color/white" - android:textSize="12sp" /> + android:textSize="12sp" + android:focusable="true" /> + android:textSize="12sp" + android:focusable="true" /> + android:textSize="12sp" + android:focusable="true" /> \ No newline at end of file diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 812445e856..35de223076 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1282,6 +1282,29 @@ public class Launcher extends Activity return handled; } + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_MENU) { + // Ignore the menu key if we are currently dragging or are on the custom content screen + if (!isOnCustomContent() && !mDragController.isDragging()) { + // Close any open folders + closeFolder(); + + // Stop resizing any widgets + mWorkspace.exitWidgetResizeMode(); + + // Show the overview mode if we are on the workspace + if (mState == State.WORKSPACE && !mWorkspace.isInOverviewMode() && + !mWorkspace.isSwitchingState()) { + mOverviewPanel.requestFocus(); + showOverviewMode(true); + } + } + return true; + } + return super.onKeyUp(keyCode, event); + } + private String getTypedText() { return mDefaultKeySsb.toString(); } @@ -2181,22 +2204,9 @@ public class Launcher extends Activity @Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); - if (!isOnCustomContent()) { - // Close any open folders - closeFolder(); - // Stop resizing any widgets - mWorkspace.exitWidgetResizeMode(); - if (!mWorkspace.isInOverviewMode()) { - // Show the overview mode - showOverviewMode(true); - } else { - showWorkspace(true); - } - } if (mLauncherCallbacks != null) { return mLauncherCallbacks.onPrepareOptionsMenu(menu); } - return false; }