Refactor allapps.search package to depend on ActivityContext.
Test: Manual Bug: 216683257 Change-Id: I6230498b24380b37531f8a83db1dc768270e708a
This commit is contained in:
@@ -103,11 +103,6 @@ public class ActivityAllAppsContainerView<T extends BaseDraggingActivity> 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);
|
||||
|
||||
@@ -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<AdapterItem> mCallback;
|
||||
protected ExtendedEditText mInput;
|
||||
protected String mQuery;
|
||||
@@ -62,7 +61,7 @@ public class AllAppsSearchBarController
|
||||
*/
|
||||
public final void initialize(
|
||||
SearchAlgorithm<AdapterItem> searchAlgorithm, ExtendedEditText input,
|
||||
BaseDraggingActivity launcher, SearchCallback<AdapterItem> callback) {
|
||||
ActivityContext launcher, SearchCallback<AdapterItem> 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;
|
||||
}
|
||||
|
||||
@@ -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<AdapterItem>,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<BaseDraggingActivity> {
|
||||
public class DefaultSearchAdapterProvider extends SearchAdapterProvider<AppLauncher> {
|
||||
|
||||
private final RecyclerView.ItemDecoration mDecoration;
|
||||
private View mHighlightedView;
|
||||
|
||||
public DefaultSearchAdapterProvider(BaseDraggingActivity launcher) {
|
||||
public DefaultSearchAdapterProvider(AppLauncher launcher) {
|
||||
super(launcher);
|
||||
mDecoration = new RecyclerView.ItemDecoration() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user