diff --git a/Android.mk b/Android.mk
index 752b530ab0..25f5412d21 100644
--- a/Android.mk
+++ b/Android.mk
@@ -28,6 +28,7 @@ LOCAL_STATIC_ANDROID_LIBRARIES := \
androidx.recyclerview_recyclerview \
androidx.dynamicanimation_dynamicanimation \
androidx.preference_preference \
+ androidx.slice_slice-view \
iconloader_base
LOCAL_STATIC_JAVA_LIBRARIES := \
diff --git a/res/layout/search_result_settings_row.xml b/res/layout/search_result_settings_row.xml
new file mode 100644
index 0000000000..19daf346e2
--- /dev/null
+++ b/res/layout/search_result_settings_row.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/search_result_slice.xml b/res/layout/search_result_slice.xml
new file mode 100644
index 0000000000..ea1d49a56d
--- /dev/null
+++ b/res/layout/search_result_slice.xml
@@ -0,0 +1,19 @@
+
+
+
\ No newline at end of file
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index c61f01f206..da161ac1cc 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -20,6 +20,7 @@ import static com.android.launcher3.touch.ItemLongClickListener.INSTANCE_ALL_APP
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
+import android.net.Uri;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -30,18 +31,27 @@ import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.widget.TextView;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.accessibility.AccessibilityEventCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.view.accessibility.AccessibilityRecordCompat;
+import androidx.lifecycle.Lifecycle;
+import androidx.lifecycle.LifecycleOwner;
+import androidx.lifecycle.LifecycleRegistry;
+import androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
+import androidx.slice.Slice;
+import androidx.slice.widget.SliceLiveData;
+import androidx.slice.widget.SliceView;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.R;
import com.android.launcher3.allapps.search.AllAppsSearchBarController.PayloadResultHandler;
import com.android.launcher3.allapps.search.SearchSectionInfo;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.util.PackageManagerHelper;
@@ -50,7 +60,9 @@ import java.util.List;
/**
* The grid view adapter of all the apps.
*/
-public class AllAppsGridAdapter extends RecyclerView.Adapter {
+public class AllAppsGridAdapter extends
+ RecyclerView.Adapter implements
+ LifecycleOwner {
public static final String TAG = "AppsGridAdapter";
@@ -71,12 +83,18 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter Play load Type
*/
public static class AdapterItemWithPayload extends AdapterItem {
@@ -310,6 +331,12 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter) mApps.getAdapterItems().get(position))
+ .getPayload();
+ try {
+ LiveData liveData = SliceLiveData.fromUri(mLauncher, uri);
+ liveData.observe(this::getLifecycle, sliceView);
+ } catch (Exception ignored) {
+ }
+ break;
case VIEW_TYPE_SEARCH_CORPUS_TITLE:
- case DETAIL_ROW_WITH_BUTTON:
+ case VIEW_TYPE_SEARCH_ROW_WITH_BUTTON:
case VIEW_TYPE_SEARCH_HERO_APP:
+ case VIEW_TYPE_SEARCH_ROW:
PayloadResultHandler payloadResultView = (PayloadResultHandler) holder.itemView;
payloadResultView.applyAdapterInfo(
(AdapterItemWithPayload) mApps.getAdapterItems().get(position));
@@ -451,4 +495,9 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter {
+
+ private TextView mTitleView;
+ private TextView mDescriptionView;
+ private TextView mBreadcrumbsView;
+ private Intent mIntent;
+
+ public SearchSettingsRowView(@NonNull Context context) {
+ super(context);
+ }
+
+ public SearchSettingsRowView(@NonNull Context context,
+ @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public SearchSettingsRowView(@NonNull Context context, @Nullable AttributeSet attrs,
+ int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mTitleView = findViewById(R.id.title);
+ mDescriptionView = findViewById(R.id.description);
+ mBreadcrumbsView = findViewById(R.id.breadcrumbs);
+ setOnClickListener(this);
+ }
+
+ @Override
+ public void applyAdapterInfo(
+ AllAppsGridAdapter.AdapterItemWithPayload adapterItemWithPayload) {
+ Bundle bundle = adapterItemWithPayload.getPayload();
+ mIntent = bundle.getParcelable("intent");
+ showIfAvailable(mTitleView, bundle.getString("title"));
+ showIfAvailable(mDescriptionView, bundle.getString("description"));
+ ArrayList breadcrumbs = bundle.getStringArrayList("breadcrumbs");
+ //TODO: implement RTL friendly breadcrumbs view
+ showIfAvailable(mBreadcrumbsView, breadcrumbs != null
+ ? String.join(" > ", breadcrumbs) : null);
+ adapterItemWithPayload.setSelectionHandler(() -> onClick(this));
+ }
+
+ private void showIfAvailable(TextView view, @Nullable String string) {
+ if (TextUtils.isEmpty(string)) {
+ view.setVisibility(GONE);
+ } else {
+ view.setVisibility(VISIBLE);
+ view.setText(string);
+ }
+ }
+
+ @Override
+ public void onClick(View view) {
+ if (mIntent == null) return;
+ // TODO: create ItemInfo object and then use it to call startActivityForResult for proper
+ // WW logging
+ Launcher launcher = Launcher.getLauncher(view.getContext());
+ launcher.startActivityForResult(mIntent, 0);
+ }
+}