[Search] Tie quick-launch and focus highlight
Highlight and quick-launch item should be determined by Search service pipeline based on quick_launch flag on SearchTarget
Bug: 183083807
Bug: 183083682
Test: Manual
Change-Id: I0191474653deca7e1ecd01fa92c90efcdbb9a8dc
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 78c404f..591de04 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -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;
@@ -63,7 +62,6 @@
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;
@@ -564,37 +562,9 @@
/**
* 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() {
diff --git a/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java b/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java
index 269e390..7fcd6ec 100644
--- a/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java
+++ b/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java
@@ -29,6 +29,7 @@
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;
@@ -48,6 +49,7 @@
@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);
@@ -56,7 +58,7 @@
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);
@@ -102,7 +104,7 @@
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final boolean mIsTopRound;
private final boolean mIsBottomRound;
- private float [] mCorners;
+ private float[] mCorners;
private float mFillSpacing;
public SectionDecorationHandler(Context context, boolean isFullWidth, int fillAlpha,
diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
index d3c9993..79718fb 100644
--- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
+++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
@@ -35,7 +35,6 @@
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.
@@ -105,30 +104,14 @@
@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;
+ 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
+ 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
- );
+ return false;
}
@Override
diff --git a/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java b/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java
index e268f56..ba895ed 100644
--- a/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java
+++ b/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java
@@ -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) {
-
- }
-
- @Override
- public void onSliceStatusUpdate(Uri sliceUri) {
-
+ if (position == 0) {
+ mHighlightedView = holder.itemView;
+ }
}
@Override
@@ -54,7 +54,17 @@
}
@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;
+ }
}
diff --git a/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java b/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java
index 0864090..a650a7d 100644
--- a/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java
+++ b/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java
@@ -43,7 +43,8 @@
/**
* 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
@@ -74,6 +75,12 @@
* 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();
+
+
}
diff --git a/src/com/android/launcher3/allapps/search/SectionDecorationInfo.java b/src/com/android/launcher3/allapps/search/SectionDecorationInfo.java
index 0b64fca..56dd63c 100644
--- a/src/com/android/launcher3/allapps/search/SectionDecorationInfo.java
+++ b/src/com/android/launcher3/allapps/search/SectionDecorationInfo.java
@@ -21,22 +21,11 @@
* Info class for a search section that is primarily used for decoration.
*/
public class SectionDecorationInfo {
-
- public static final int QUICK_LAUNCH = 1 << 0;
public static final int GROUPING = 1 << 1;
private String mSectionId;
- private boolean mFocused;
private SectionDecorationHandler mDecorationHandler;
- public boolean isFocusedView() {
- return mFocused;
- }
-
- public void setFocusedView(boolean focused) {
- mFocused = focused;
- }
-
public SectionDecorationInfo() {
this(null);
}