Loading src/com/android/launcher3/allapps/AllAppsContainerView.java +3 −33 Original line number Diff line number Diff line Loading @@ -15,7 +15,6 @@ */ package com.android.launcher3.allapps; import static com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB; import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_HAS_SHORTCUT_PERMISSION; Loading Loading @@ -63,7 +62,6 @@ import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.keyboard.FocusedItemDecorator; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.MultiValueAlpha; Loading Loading @@ -564,37 +562,9 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo /** * Handles selection on focused view and returns success */ public boolean selectFocusedView(View v) { ItemInfo headerItem = getHighlightedItemFromHeader(); if (headerItem != null) { return mLauncher.startActivitySafely(v, headerItem.getIntent(), headerItem); } AdapterItem focusedItem = getActiveRecyclerView().getApps().getFocusedChild(); if (focusedItem != null) { View focusedView = getActiveRecyclerView().getLayoutManager() .findViewByPosition(focusedItem.position); if (focusedView != null && mSearchAdapterProvider.onAdapterItemSelected(focusedItem, focusedView)) { return true; } } if (focusedItem != null && focusedItem.appInfo != null) { ItemInfo itemInfo = focusedItem.appInfo; return mLauncher.startActivitySafely(v, itemInfo.getIntent(), itemInfo); } return false; } /** * Returns the ItemInfo of a focused view inside {@link FloatingHeaderView} */ public ItemInfo getHighlightedItemFromHeader() { View view = getFloatingHeaderView().getFocusedChild(); if (view != null && view.getTag() instanceof ItemInfo) { return ((ItemInfo) view.getTag()); } return null; public boolean launchHighlightedItem() { if (mSearchAdapterProvider == null) return false; return mSearchAdapterProvider.launchHighlightedItem(); } public SearchAdapterProvider getSearchAdapterProvider() { Loading src/com/android/launcher3/allapps/AllAppsSectionDecorator.java +4 −2 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.android.launcher3.R; import com.android.launcher3.allapps.AllAppsGridAdapter.AppsGridLayoutManager; import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.allapps.search.SectionDecorationInfo; import com.android.launcher3.util.Themes; Loading @@ -48,6 +49,7 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration { @Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { List<AllAppsGridAdapter.AdapterItem> adapterItems = mAppsView.getApps().getAdapterItems(); SearchAdapterProvider adapterProvider = mAppsView.getSearchAdapterProvider(); for (int i = 0; i < parent.getChildCount(); i++) { View view = parent.getChildAt(i); int position = parent.getChildAdapterPosition(view); Loading @@ -56,7 +58,7 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration { SectionDecorationInfo sectionInfo = adapterItem.sectionDecorationInfo; SectionDecorationHandler decorationHandler = sectionInfo.getDecorationHandler(); if (decorationHandler != null) { if (sectionInfo.isFocusedView()) { if (view.equals(adapterProvider.getHighlightedItem())) { decorationHandler.onFocusDraw(c, view); } else { decorationHandler.onGroupDraw(c, view); Loading src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +6 −23 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.search.SearchAlgorithm; import com.android.launcher3.search.SearchCallback; import com.android.launcher3.util.PackageManagerHelper; /** * An interface to a search box that AllApps can command. Loading Loading @@ -105,31 +104,15 @@ public class AllAppsSearchBarController @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_GO) { mLauncher.getStatsLogManager().logger() .log(LAUNCHER_ALLAPPS_FOCUSED_ITEM_SELECTED_WITH_IME); // selectFocusedView should return SearchTargetEvent that is passed onto onClick if (Launcher.getLauncher(mLauncher).getAppsView().selectFocusedView(v)) { return true; } } } // Skip if it's not the right action if (actionId != EditorInfo.IME_ACTION_SEARCH) { return false; return Launcher.getLauncher(mLauncher).getAppsView().launchHighlightedItem(); } // Skip if the query is empty String query = v.getText().toString(); if (query.isEmpty()) { return false; } return mLauncher.startActivitySafely(v, PackageManagerHelper.getMarketSearchIntent(mLauncher, query), null ); } @Override public boolean onBackKey() { Loading src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java +18 −8 Original line number Diff line number Diff line Loading @@ -15,31 +15,31 @@ */ package com.android.launcher3.allapps.search; import android.net.Uri; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.BubbleTextView; import com.android.launcher3.allapps.AllAppsGridAdapter; import com.android.launcher3.model.data.ItemInfo; /** * Provides views for local search results */ public class DefaultSearchAdapterProvider extends SearchAdapterProvider { private View mHighlightedView; public DefaultSearchAdapterProvider(BaseDraggingActivity launcher) { super(launcher); } @Override public void onBindView(AllAppsGridAdapter.ViewHolder holder, int position) { if (position == 0) { mHighlightedView = holder.itemView; } @Override public void onSliceStatusUpdate(Uri sliceUri) { } @Override Loading @@ -54,7 +54,17 @@ public class DefaultSearchAdapterProvider extends SearchAdapterProvider { } @Override public boolean onAdapterItemSelected(AllAppsGridAdapter.AdapterItem adapterItem, View view) { public boolean launchHighlightedItem() { if (mHighlightedView instanceof BubbleTextView && mHighlightedView.getTag() instanceof ItemInfo) { ItemInfo itemInfo = (ItemInfo) mHighlightedView.getTag(); return mLauncher.startActivitySafely(mHighlightedView, itemInfo.getIntent(), itemInfo); } return false; } @Override public View getHighlightedItem() { return mHighlightedView; } } src/com/android/launcher3/allapps/search/SearchAdapterProvider.java +10 −3 Original line number Diff line number Diff line Loading @@ -43,7 +43,8 @@ public abstract class SearchAdapterProvider { /** * Called from LiveSearchManager to notify slice status updates. */ public abstract void onSliceStatusUpdate(Uri sliceUri); public void onSliceStatusUpdate(Uri sliceUri) { } /** * Returns whether or not viewType can be handled by searchProvider Loading Loading @@ -74,6 +75,12 @@ public abstract class SearchAdapterProvider { * handles selection event on search adapter item. Returns false if provider can not handle * event */ public abstract boolean onAdapterItemSelected(AllAppsGridAdapter.AdapterItem adapterItem, View view); public abstract boolean launchHighlightedItem(); /** * Returns the current highlighted view */ public abstract View getHighlightedItem(); } Loading
src/com/android/launcher3/allapps/AllAppsContainerView.java +3 −33 Original line number Diff line number Diff line Loading @@ -15,7 +15,6 @@ */ package com.android.launcher3.allapps; import static com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB; import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_HAS_SHORTCUT_PERMISSION; Loading Loading @@ -63,7 +62,6 @@ import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.keyboard.FocusedItemDecorator; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.MultiValueAlpha; Loading Loading @@ -564,37 +562,9 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo /** * Handles selection on focused view and returns success */ public boolean selectFocusedView(View v) { ItemInfo headerItem = getHighlightedItemFromHeader(); if (headerItem != null) { return mLauncher.startActivitySafely(v, headerItem.getIntent(), headerItem); } AdapterItem focusedItem = getActiveRecyclerView().getApps().getFocusedChild(); if (focusedItem != null) { View focusedView = getActiveRecyclerView().getLayoutManager() .findViewByPosition(focusedItem.position); if (focusedView != null && mSearchAdapterProvider.onAdapterItemSelected(focusedItem, focusedView)) { return true; } } if (focusedItem != null && focusedItem.appInfo != null) { ItemInfo itemInfo = focusedItem.appInfo; return mLauncher.startActivitySafely(v, itemInfo.getIntent(), itemInfo); } return false; } /** * Returns the ItemInfo of a focused view inside {@link FloatingHeaderView} */ public ItemInfo getHighlightedItemFromHeader() { View view = getFloatingHeaderView().getFocusedChild(); if (view != null && view.getTag() instanceof ItemInfo) { return ((ItemInfo) view.getTag()); } return null; public boolean launchHighlightedItem() { if (mSearchAdapterProvider == null) return false; return mSearchAdapterProvider.launchHighlightedItem(); } public SearchAdapterProvider getSearchAdapterProvider() { Loading
src/com/android/launcher3/allapps/AllAppsSectionDecorator.java +4 −2 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.android.launcher3.R; import com.android.launcher3.allapps.AllAppsGridAdapter.AppsGridLayoutManager; import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.allapps.search.SectionDecorationInfo; import com.android.launcher3.util.Themes; Loading @@ -48,6 +49,7 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration { @Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { List<AllAppsGridAdapter.AdapterItem> adapterItems = mAppsView.getApps().getAdapterItems(); SearchAdapterProvider adapterProvider = mAppsView.getSearchAdapterProvider(); for (int i = 0; i < parent.getChildCount(); i++) { View view = parent.getChildAt(i); int position = parent.getChildAdapterPosition(view); Loading @@ -56,7 +58,7 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration { SectionDecorationInfo sectionInfo = adapterItem.sectionDecorationInfo; SectionDecorationHandler decorationHandler = sectionInfo.getDecorationHandler(); if (decorationHandler != null) { if (sectionInfo.isFocusedView()) { if (view.equals(adapterProvider.getHighlightedItem())) { decorationHandler.onFocusDraw(c, view); } else { decorationHandler.onGroupDraw(c, view); Loading
src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +6 −23 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.search.SearchAlgorithm; import com.android.launcher3.search.SearchCallback; import com.android.launcher3.util.PackageManagerHelper; /** * An interface to a search box that AllApps can command. Loading Loading @@ -105,31 +104,15 @@ public class AllAppsSearchBarController @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_GO) { mLauncher.getStatsLogManager().logger() .log(LAUNCHER_ALLAPPS_FOCUSED_ITEM_SELECTED_WITH_IME); // selectFocusedView should return SearchTargetEvent that is passed onto onClick if (Launcher.getLauncher(mLauncher).getAppsView().selectFocusedView(v)) { return true; } } } // Skip if it's not the right action if (actionId != EditorInfo.IME_ACTION_SEARCH) { return false; return Launcher.getLauncher(mLauncher).getAppsView().launchHighlightedItem(); } // Skip if the query is empty String query = v.getText().toString(); if (query.isEmpty()) { return false; } return mLauncher.startActivitySafely(v, PackageManagerHelper.getMarketSearchIntent(mLauncher, query), null ); } @Override public boolean onBackKey() { Loading
src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java +18 −8 Original line number Diff line number Diff line Loading @@ -15,31 +15,31 @@ */ package com.android.launcher3.allapps.search; import android.net.Uri; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.BubbleTextView; import com.android.launcher3.allapps.AllAppsGridAdapter; import com.android.launcher3.model.data.ItemInfo; /** * Provides views for local search results */ public class DefaultSearchAdapterProvider extends SearchAdapterProvider { private View mHighlightedView; public DefaultSearchAdapterProvider(BaseDraggingActivity launcher) { super(launcher); } @Override public void onBindView(AllAppsGridAdapter.ViewHolder holder, int position) { if (position == 0) { mHighlightedView = holder.itemView; } @Override public void onSliceStatusUpdate(Uri sliceUri) { } @Override Loading @@ -54,7 +54,17 @@ public class DefaultSearchAdapterProvider extends SearchAdapterProvider { } @Override public boolean onAdapterItemSelected(AllAppsGridAdapter.AdapterItem adapterItem, View view) { public boolean launchHighlightedItem() { if (mHighlightedView instanceof BubbleTextView && mHighlightedView.getTag() instanceof ItemInfo) { ItemInfo itemInfo = (ItemInfo) mHighlightedView.getTag(); return mLauncher.startActivitySafely(mHighlightedView, itemInfo.getIntent(), itemInfo); } return false; } @Override public View getHighlightedItem() { return mHighlightedView; } }
src/com/android/launcher3/allapps/search/SearchAdapterProvider.java +10 −3 Original line number Diff line number Diff line Loading @@ -43,7 +43,8 @@ public abstract class SearchAdapterProvider { /** * Called from LiveSearchManager to notify slice status updates. */ public abstract void onSliceStatusUpdate(Uri sliceUri); public void onSliceStatusUpdate(Uri sliceUri) { } /** * Returns whether or not viewType can be handled by searchProvider Loading Loading @@ -74,6 +75,12 @@ public abstract class SearchAdapterProvider { * handles selection event on search adapter item. Returns false if provider can not handle * event */ public abstract boolean onAdapterItemSelected(AllAppsGridAdapter.AdapterItem adapterItem, View view); public abstract boolean launchHighlightedItem(); /** * Returns the current highlighted view */ public abstract View getHighlightedItem(); }