From f477ec203272b79699d3173bf3bc4dec16c8bad1 Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Tue, 15 Mar 2022 13:46:37 -0700 Subject: [PATCH] Refactor allapps.search package to depend on ActivityContext. Test: Manual Bug: 216683257 Change-Id: I6230498b24380b37531f8a83db1dc768270e708a --- .../launcher3/allapps/ActivityAllAppsContainerView.java | 5 ----- .../allapps/search/AllAppsSearchBarController.java | 9 ++++----- .../allapps/search/AppsSearchContainerLayout.java | 8 ++++---- .../allapps/search/DefaultSearchAdapterProvider.java | 8 ++++---- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index b94a61251b..f530b0089c 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -103,11 +103,6 @@ public class ActivityAllAppsContainerView extend } } - /** Handles selection on focused view and returns {@code true} on success. */ - public boolean launchHighlightedItem() { - return getMainAdapterProvider().launchHighlightedItem(); - } - @Override protected SearchAdapterProvider createMainAdapterProvider() { return mActivityContext.createSearchAdapterProvider(this); diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java index fd8945a0f6..a6a47a71db 100644 --- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java @@ -29,14 +29,13 @@ import android.view.inputmethod.EditorInfo; import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; -import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.ExtendedEditText; -import com.android.launcher3.Launcher; import com.android.launcher3.Utilities; import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.search.SearchAlgorithm; import com.android.launcher3.search.SearchCallback; +import com.android.launcher3.views.ActivityContext; /** * An interface to a search box that AllApps can command. @@ -45,7 +44,7 @@ public class AllAppsSearchBarController implements TextWatcher, OnEditorActionListener, ExtendedEditText.OnBackKeyListener, OnFocusChangeListener { - protected BaseDraggingActivity mLauncher; + protected ActivityContext mLauncher; protected SearchCallback mCallback; protected ExtendedEditText mInput; protected String mQuery; @@ -62,7 +61,7 @@ public class AllAppsSearchBarController */ public final void initialize( SearchAlgorithm searchAlgorithm, ExtendedEditText input, - BaseDraggingActivity launcher, SearchCallback callback) { + ActivityContext launcher, SearchCallback callback) { mCallback = callback; mLauncher = launcher; @@ -125,7 +124,7 @@ public class AllAppsSearchBarController mLauncher.getStatsLogManager().logger() .log(LAUNCHER_ALLAPPS_FOCUSED_ITEM_SELECTED_WITH_IME); // selectFocusedView should return SearchTargetEvent that is passed onto onClick - return Launcher.getLauncher(mLauncher).getAppsView().launchHighlightedItem(); + return mLauncher.getAppsView().getMainAdapterProvider().launchHighlightedItem(); } return false; } diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java index cb459eacb3..893e547340 100644 --- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java +++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java @@ -32,7 +32,6 @@ import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup.MarginLayoutParams; -import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.ExtendedEditText; import com.android.launcher3.Insettable; @@ -43,6 +42,7 @@ import com.android.launcher3.allapps.AlphabeticalAppsList; import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem; import com.android.launcher3.allapps.SearchUiManager; import com.android.launcher3.search.SearchCallback; +import com.android.launcher3.views.ActivityContext; import java.util.ArrayList; @@ -53,7 +53,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText implements SearchUiManager, SearchCallback, AllAppsStore.OnUpdateListener, Insettable { - private final BaseDraggingActivity mLauncher; + private final ActivityContext mLauncher; private final AllAppsSearchBarController mSearchBarController; private final SpannableStringBuilder mSearchQueryBuilder; @@ -74,7 +74,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText public AppsSearchContainerLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - mLauncher = BaseDraggingActivity.fromContext(context); + mLauncher = ActivityContext.lookupContext(context); mSearchBarController = new AllAppsSearchBarController(); mSearchQueryBuilder = new SpannableStringBuilder(); @@ -134,7 +134,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText mApps = appsView.getApps(); mAppsView = appsView; mSearchBarController.initialize( - new DefaultAppSearchAlgorithm(mLauncher), + new DefaultAppSearchAlgorithm(getContext()), this, mLauncher, this); } diff --git a/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java b/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java index 2fe4915e2f..a95bd514da 100644 --- a/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java +++ b/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java @@ -23,20 +23,20 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.BubbleTextView; import com.android.launcher3.allapps.AllAppsGridAdapter; import com.android.launcher3.model.data.ItemInfo; +import com.android.launcher3.views.AppLauncher; /** - * Provides views for local search results + * Provides views for local search results. */ -public class DefaultSearchAdapterProvider extends SearchAdapterProvider { +public class DefaultSearchAdapterProvider extends SearchAdapterProvider { private final RecyclerView.ItemDecoration mDecoration; private View mHighlightedView; - public DefaultSearchAdapterProvider(BaseDraggingActivity launcher) { + public DefaultSearchAdapterProvider(AppLauncher launcher) { super(launcher); mDecoration = new RecyclerView.ItemDecoration() { @Override