Loading src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +8 −1 Original line number Diff line number Diff line Loading @@ -1046,6 +1046,11 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> return getActiveAppsRecyclerView(); } /** The current focus change listener in the search container. */ public OnFocusChangeListener getSearchFocusChangeListener() { return mAH.get(AdapterHolder.SEARCH).mOnFocusChangeListener; } /** The current apps recycler view in the container. */ private AllAppsRecyclerView getActiveAppsRecyclerView() { if (!mUsingTabs || isPersonalTab()) { Loading Loading @@ -1442,6 +1447,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> final AlphabeticalAppsList<T> mAppsList; final Rect mPadding = new Rect(); AllAppsRecyclerView mRecyclerView; private OnFocusChangeListener mOnFocusChangeListener; AdapterHolder(int type, AlphabeticalAppsList<T> appsList) { mType = type; Loading @@ -1465,7 +1471,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> onInitializeRecyclerView(mRecyclerView); FocusedItemDecorator focusedItemDecorator = new FocusedItemDecorator(mRecyclerView); mRecyclerView.addItemDecoration(focusedItemDecorator); mAdapter.setIconFocusListener(focusedItemDecorator.getFocusListener()); mOnFocusChangeListener = focusedItemDecorator.getFocusListener(); mAdapter.setIconFocusListener(mOnFocusChangeListener); applyPadding(); } Loading tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java +37 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import android.view.KeyEvent; import android.view.View; import android.view.WindowInsets; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; Loading Loading @@ -76,4 +78,39 @@ public class TaplKeyboardFocusTest extends AbstractLauncherUiTest { allApps.unfreeze(); } } @Test public void testAllAppsExitSearchAndFocusSearchResults() { final HomeAllApps allApps = mLauncher.goHome().switchToAllApps(); assertTrue("Launcher internal state is not All Apps", isInState(() -> LauncherState.ALL_APPS)); allApps.freeze(); try { executeOnLauncher(launcher -> launcher.getAppsView().getSearchView().requestFocus()); waitForLauncherCondition("Search view does not have focus.", launcher -> launcher.getAppsView().getSearchView().hasFocus()); mLauncher.pressAndHoldKeyCode(KeyEvent.KEYCODE_C, 0); waitForLauncherCondition("Search view not active.", launcher -> launcher.getAppsView().getActiveRecyclerView() instanceof SearchRecyclerView); mLauncher.unpressKeyCode(KeyEvent.KEYCODE_C, 0); executeOnLauncher(launcher -> launcher.getAppsView().getSearchUiManager().getEditText() .hideKeyboard(/* clearFocus= */ false)); waitForLauncherCondition("Keyboard still visible.", launcher -> { View root = launcher.getDragLayer(); WindowInsets insets = root.getRootWindowInsets(); return insets != null && !insets.isVisible(WindowInsets.Type.ime()); }); mLauncher.pressAndHoldKeyCode(KeyEvent.KEYCODE_DPAD_DOWN, 0); mLauncher.unpressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN, 0); waitForLauncherCondition("No focused child", launcher -> launcher.getAppsView().getActiveRecyclerView().getApps().getFocusedChild() != null); } finally { allApps.unfreeze(); } } } Loading
src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +8 −1 Original line number Diff line number Diff line Loading @@ -1046,6 +1046,11 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> return getActiveAppsRecyclerView(); } /** The current focus change listener in the search container. */ public OnFocusChangeListener getSearchFocusChangeListener() { return mAH.get(AdapterHolder.SEARCH).mOnFocusChangeListener; } /** The current apps recycler view in the container. */ private AllAppsRecyclerView getActiveAppsRecyclerView() { if (!mUsingTabs || isPersonalTab()) { Loading Loading @@ -1442,6 +1447,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> final AlphabeticalAppsList<T> mAppsList; final Rect mPadding = new Rect(); AllAppsRecyclerView mRecyclerView; private OnFocusChangeListener mOnFocusChangeListener; AdapterHolder(int type, AlphabeticalAppsList<T> appsList) { mType = type; Loading @@ -1465,7 +1471,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> onInitializeRecyclerView(mRecyclerView); FocusedItemDecorator focusedItemDecorator = new FocusedItemDecorator(mRecyclerView); mRecyclerView.addItemDecoration(focusedItemDecorator); mAdapter.setIconFocusListener(focusedItemDecorator.getFocusListener()); mOnFocusChangeListener = focusedItemDecorator.getFocusListener(); mAdapter.setIconFocusListener(mOnFocusChangeListener); applyPadding(); } Loading
tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java +37 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import android.view.KeyEvent; import android.view.View; import android.view.WindowInsets; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; Loading Loading @@ -76,4 +78,39 @@ public class TaplKeyboardFocusTest extends AbstractLauncherUiTest { allApps.unfreeze(); } } @Test public void testAllAppsExitSearchAndFocusSearchResults() { final HomeAllApps allApps = mLauncher.goHome().switchToAllApps(); assertTrue("Launcher internal state is not All Apps", isInState(() -> LauncherState.ALL_APPS)); allApps.freeze(); try { executeOnLauncher(launcher -> launcher.getAppsView().getSearchView().requestFocus()); waitForLauncherCondition("Search view does not have focus.", launcher -> launcher.getAppsView().getSearchView().hasFocus()); mLauncher.pressAndHoldKeyCode(KeyEvent.KEYCODE_C, 0); waitForLauncherCondition("Search view not active.", launcher -> launcher.getAppsView().getActiveRecyclerView() instanceof SearchRecyclerView); mLauncher.unpressKeyCode(KeyEvent.KEYCODE_C, 0); executeOnLauncher(launcher -> launcher.getAppsView().getSearchUiManager().getEditText() .hideKeyboard(/* clearFocus= */ false)); waitForLauncherCondition("Keyboard still visible.", launcher -> { View root = launcher.getDragLayer(); WindowInsets insets = root.getRootWindowInsets(); return insets != null && !insets.isVisible(WindowInsets.Type.ime()); }); mLauncher.pressAndHoldKeyCode(KeyEvent.KEYCODE_DPAD_DOWN, 0); mLauncher.unpressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN, 0); waitForLauncherCondition("No focused child", launcher -> launcher.getAppsView().getActiveRecyclerView().getApps().getFocusedChild() != null); } finally { allApps.unfreeze(); } } }