Loading quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayDragLayer.java +9 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,15 @@ public class TaskbarOverlayDragLayer extends topView.onBackInvoked(); return true; } } else if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ESCAPE && event.hasNoModifiers()) { // Ignore escape if pressed in conjunction with any modifier keys. Close each // floating view one at a time for each key press. AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mActivity); if (topView != null) { topView.close(/* animate= */ true); return true; } } return super.dispatchKeyEvent(event); } Loading src/com/android/launcher3/util/KeyboardShortcutsDelegate.java +17 −4 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.view.KeyboardShortcutGroup; import android.view.KeyboardShortcutInfo; import android.view.Menu; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.Utilities; Loading Loading @@ -108,14 +109,26 @@ public class KeyboardShortcutsDelegate { * @see android.view.KeyEvent */ public Boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ESCAPE) { // Close any open floating views. mLauncher.closeOpenViews(); // Ignore escape if pressed in conjunction with any modifier keys. if (keyCode == KeyEvent.KEYCODE_ESCAPE && event.hasNoModifiers()) { AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mLauncher); if (topView != null) { // Close each floating view one at a time for each key press. topView.close(/* animate= */ true); return true; } else if (mLauncher.getAppsView().isInAllApps()) { // Close all apps if there are no open floating views. closeAllApps(); return true; } } return null; } private void closeAllApps() { mLauncher.getStateManager().goToState(NORMAL, true); } /** * Handle key up event. * @param keyCode code of the key being pressed. Loading tests/src/com/android/launcher3/allapps/TaplOpenCloseAllApps.java +6 −0 Original line number Diff line number Diff line Loading @@ -217,4 +217,10 @@ public class TaplOpenCloseAllApps extends AbstractLauncherUiTest { mLauncher.getWorkspace(); waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); } @Test public void testDismissAllAppsWithEscKey() { mLauncher.goHome().switchToAllApps().dismissByEscKey(); waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); } } tests/tapl/com/android/launcher3/tapl/AllApps.java +20 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.launcher3.tapl; import static android.view.KeyEvent.KEYCODE_ESCAPE; import static android.view.KeyEvent.KEYCODE_META_RIGHT; import static com.android.launcher3.tapl.LauncherInstrumentation.DEFAULT_POLL_INTERVAL; Loading @@ -39,6 +40,7 @@ import com.android.launcher3.testing.shared.TestProtocol; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.regex.Pattern; import java.util.stream.Collectors; /** Loading @@ -53,6 +55,11 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background"; private static final Pattern EVENT_ALT_ESC_DOWN = Pattern.compile( "Key event: KeyEvent.*?action=ACTION_DOWN.*?keyCode=KEYCODE_ESCAPE.*?metaState=0"); private static final Pattern EVENT_ALT_ESC_UP = Pattern.compile( "Key event: KeyEvent.*?action=ACTION_UP.*?keyCode=KEYCODE_ESCAPE.*?metaState=0"); private final int mHeight; private final int mIconHeight; Loading Loading @@ -383,6 +390,19 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer } } /** Presses the esc key to dismiss AllApps. */ public void dismissByEscKey() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_ESC_DOWN); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_ESC_UP); mLauncher.getDevice().pressKeyCode(KEYCODE_ESCAPE); try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "pressed esc key")) { verifyVisibleContainerOnDismiss(); } } } protected abstract void verifyVisibleContainerOnDismiss(); /** Loading Loading
quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayDragLayer.java +9 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,15 @@ public class TaskbarOverlayDragLayer extends topView.onBackInvoked(); return true; } } else if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ESCAPE && event.hasNoModifiers()) { // Ignore escape if pressed in conjunction with any modifier keys. Close each // floating view one at a time for each key press. AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mActivity); if (topView != null) { topView.close(/* animate= */ true); return true; } } return super.dispatchKeyEvent(event); } Loading
src/com/android/launcher3/util/KeyboardShortcutsDelegate.java +17 −4 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.view.KeyboardShortcutGroup; import android.view.KeyboardShortcutInfo; import android.view.Menu; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.Utilities; Loading Loading @@ -108,14 +109,26 @@ public class KeyboardShortcutsDelegate { * @see android.view.KeyEvent */ public Boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ESCAPE) { // Close any open floating views. mLauncher.closeOpenViews(); // Ignore escape if pressed in conjunction with any modifier keys. if (keyCode == KeyEvent.KEYCODE_ESCAPE && event.hasNoModifiers()) { AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mLauncher); if (topView != null) { // Close each floating view one at a time for each key press. topView.close(/* animate= */ true); return true; } else if (mLauncher.getAppsView().isInAllApps()) { // Close all apps if there are no open floating views. closeAllApps(); return true; } } return null; } private void closeAllApps() { mLauncher.getStateManager().goToState(NORMAL, true); } /** * Handle key up event. * @param keyCode code of the key being pressed. Loading
tests/src/com/android/launcher3/allapps/TaplOpenCloseAllApps.java +6 −0 Original line number Diff line number Diff line Loading @@ -217,4 +217,10 @@ public class TaplOpenCloseAllApps extends AbstractLauncherUiTest { mLauncher.getWorkspace(); waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); } @Test public void testDismissAllAppsWithEscKey() { mLauncher.goHome().switchToAllApps().dismissByEscKey(); waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); } }
tests/tapl/com/android/launcher3/tapl/AllApps.java +20 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.launcher3.tapl; import static android.view.KeyEvent.KEYCODE_ESCAPE; import static android.view.KeyEvent.KEYCODE_META_RIGHT; import static com.android.launcher3.tapl.LauncherInstrumentation.DEFAULT_POLL_INTERVAL; Loading @@ -39,6 +40,7 @@ import com.android.launcher3.testing.shared.TestProtocol; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.regex.Pattern; import java.util.stream.Collectors; /** Loading @@ -53,6 +55,11 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background"; private static final Pattern EVENT_ALT_ESC_DOWN = Pattern.compile( "Key event: KeyEvent.*?action=ACTION_DOWN.*?keyCode=KEYCODE_ESCAPE.*?metaState=0"); private static final Pattern EVENT_ALT_ESC_UP = Pattern.compile( "Key event: KeyEvent.*?action=ACTION_UP.*?keyCode=KEYCODE_ESCAPE.*?metaState=0"); private final int mHeight; private final int mIconHeight; Loading Loading @@ -383,6 +390,19 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer } } /** Presses the esc key to dismiss AllApps. */ public void dismissByEscKey() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_ESC_DOWN); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_ESC_UP); mLauncher.getDevice().pressKeyCode(KEYCODE_ESCAPE); try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "pressed esc key")) { verifyVisibleContainerOnDismiss(); } } } protected abstract void verifyVisibleContainerOnDismiss(); /** Loading