Draw focus outline in search app result

Before:
https://screenshot.googleplex.com/9qoPoBNZkDY94gy
https://screenshot.googleplex.com/7XVFxwj8d6UqLUs
https://screenshot.googleplex.com/4KtQcma26eSdBnb

After:
https://screenshot.googleplex.com/BxfNAJGqXhyGBbJ
https://screenshot.googleplex.com/8EMKUQW4ubXHdDd
https://screenshot.googleplex.com/32KBfdj4preL8H6

Bug: 319454774
Test: Manual, open all apps, type some word and press enter to search. Navigate to the search result below and outline should appear
Test: will add screenshot test in b/318360469
Flag: ACONFIG com.android.launcher3.enable_focus_outline Development
Change-Id: I8caef8dd9e590d43e05baa78cebee73d21b84acf
This commit is contained in:
helencheuk
2024-01-24 11:42:46 +00:00
parent c5be03f062
commit bbd54b3e32
3 changed files with 23 additions and 5 deletions

View File

@@ -80,6 +80,7 @@ import com.android.launcher3.allapps.search.AllAppsSearchUiDelegate;
import com.android.launcher3.allapps.search.SearchAdapterProvider;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.pm.UserCache;
@@ -1535,7 +1536,11 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
// No animations will occur when changes occur to the items in this RecyclerView.
mRecyclerView.setItemAnimator(null);
onInitializeRecyclerView(mRecyclerView);
FocusedItemDecorator focusedItemDecorator = new FocusedItemDecorator(mRecyclerView);
// Use ViewGroupFocusHelper for SearchRecyclerView to draw focus outline for the
// buttons in the view (e.g. query builder button and setting button)
FocusedItemDecorator focusedItemDecorator = isSearch() ? new FocusedItemDecorator(
new ViewGroupFocusHelper(mRecyclerView)) : new FocusedItemDecorator(
mRecyclerView);
mRecyclerView.addItemDecoration(focusedItemDecorator);
mOnFocusChangeListener = focusedItemDecorator.getFocusListener();
mAdapter.setIconFocusListener(mOnFocusChangeListener);