Track search results with position and search Identifier

Bug: 169087008
Test: Manual
Change-Id: I54c74093b90e5aea03a7810f55fcc32f0ddf8dda
This commit is contained in:
Samuel Fufa 2020-09-22 20:52:45 -07:00
parent 2508239d1e
commit f01064953b
12 changed files with 141 additions and 36 deletions

View File

@ -200,6 +200,7 @@ public class AllAppsGridAdapter extends
*/ */
public static class AdapterItemWithPayload<T> extends AdapterItem { public static class AdapterItemWithPayload<T> extends AdapterItem {
private T mPayload; private T mPayload;
private String mSearchSessionId;
private AllAppsSearchPlugin mPlugin; private AllAppsSearchPlugin mPlugin;
private IntConsumer mSelectionHandler; private IntConsumer mSelectionHandler;
@ -221,6 +222,14 @@ public class AllAppsGridAdapter extends
mSelectionHandler = runnable; mSelectionHandler = runnable;
} }
public void setSearchSessionId(String searchSessionId) {
mSearchSessionId = searchSessionId;
}
public String getSearchSessionId() {
return mSearchSessionId;
}
public IntConsumer getSelectionHandler() { public IntConsumer getSelectionHandler() {
return mSelectionHandler; return mSelectionHandler;
} }
@ -228,6 +237,8 @@ public class AllAppsGridAdapter extends
public T getPayload() { public T getPayload() {
return mPayload; return mPayload;
} }
} }
/** /**
@ -476,24 +487,23 @@ public class AllAppsGridAdapter extends
//TODO: replace with custom TopHitBubbleTextView with support for both shortcut //TODO: replace with custom TopHitBubbleTextView with support for both shortcut
// and apps // and apps
if (adapterItem instanceof AdapterItemWithPayload) { if (adapterItem instanceof AdapterItemWithPayload) {
AdapterItemWithPayload withPayload = (AdapterItemWithPayload) adapterItem; AdapterItemWithPayload item = (AdapterItemWithPayload) adapterItem;
IntConsumer selectionHandler = type -> { item.setSelectionHandler(type -> {
SearchTargetEvent e = new SearchTargetEvent(SearchTarget.ItemType.APP, SearchTargetEvent e = new SearchTargetEvent(SearchTarget.ItemType.APP,
type); type, item.position, item.getSearchSessionId());
e.bundle = HeroSearchResultView.getAppBundle(info); e.bundle = HeroSearchResultView.getAppBundle(info);
if (withPayload.getPlugin() != null) { if (item.getPlugin() != null) {
withPayload.getPlugin().notifySearchTargetEvent(e); item.getPlugin().notifySearchTargetEvent(e);
} }
}; });
icon.setOnClickListener(view -> { icon.setOnClickListener(view -> {
selectionHandler.accept(SearchTargetEvent.SELECT); item.getSelectionHandler().accept(SearchTargetEvent.SELECT);
mOnIconClickListener.onClick(view); mOnIconClickListener.onClick(view);
}); });
icon.setOnLongClickListener(view -> { icon.setOnLongClickListener(view -> {
selectionHandler.accept(SearchTargetEvent.LONG_PRESS); item.getSelectionHandler().accept(SearchTargetEvent.SELECT);
return mOnIconLongClickListener.onLongClick(view); return mOnIconLongClickListener.onLongClick(view);
}); });
withPayload.setSelectionHandler(selectionHandler);
} }
else { else {
icon.setOnClickListener(mOnIconClickListener); icon.setOnClickListener(mOnIconClickListener);
@ -516,20 +526,22 @@ public class AllAppsGridAdapter extends
break; break;
case VIEW_TYPE_SEARCH_SLICE: case VIEW_TYPE_SEARCH_SLICE:
SliceView sliceView = (SliceView) holder.itemView; SliceView sliceView = (SliceView) holder.itemView;
AdapterItemWithPayload<Uri> item = AdapterItemWithPayload<Uri> slicePayload =
(AdapterItemWithPayload<Uri>) mApps.getAdapterItems().get(position); (AdapterItemWithPayload<Uri>) mApps.getAdapterItems().get(position);
sliceView.setOnSliceActionListener((info1, s) -> { sliceView.setOnSliceActionListener((info1, s) -> {
if (item.getPlugin() != null) { if (slicePayload.getPlugin() != null) {
SearchTargetEvent searchTargetEvent = new SearchTargetEvent( SearchTargetEvent searchTargetEvent = new SearchTargetEvent(
SearchTarget.ItemType.SETTINGS_SLICE, SearchTarget.ItemType.SETTINGS_SLICE,
SearchTargetEvent.CHILD_SELECT); SearchTargetEvent.CHILD_SELECT, slicePayload.position,
slicePayload.getSearchSessionId());
searchTargetEvent.bundle = new Bundle(); searchTargetEvent.bundle = new Bundle();
searchTargetEvent.bundle.putParcelable("uri", item.getPayload()); searchTargetEvent.bundle.putParcelable("uri", slicePayload.getPayload());
item.getPlugin().notifySearchTargetEvent(searchTargetEvent); slicePayload.getPlugin().notifySearchTargetEvent(searchTargetEvent);
} }
}); });
try { try {
LiveData<Slice> liveData = SliceLiveData.fromUri(mLauncher, item.getPayload()); LiveData<Slice> liveData = SliceLiveData.fromUri(mLauncher,
slicePayload.getPayload());
liveData.observe((Launcher) mLauncher, sliceView); liveData.observe((Launcher) mLauncher, sliceView);
sliceView.setTag(liveData); sliceView.setTag(liveData);
} catch (Exception ignored) { } catch (Exception ignored) {
@ -542,9 +554,10 @@ public class AllAppsGridAdapter extends
case VIEW_TYPE_SEARCH_SHORTCUT: case VIEW_TYPE_SEARCH_SHORTCUT:
case VIEW_TYPE_SEARCH_PEOPLE: case VIEW_TYPE_SEARCH_PEOPLE:
case VIEW_TYPE_SEARCH_THUMBNAIL: case VIEW_TYPE_SEARCH_THUMBNAIL:
AdapterItemWithPayload item =
(AdapterItemWithPayload) mApps.getAdapterItems().get(position);
PayloadResultHandler payloadResultView = (PayloadResultHandler) holder.itemView; PayloadResultHandler payloadResultView = (PayloadResultHandler) holder.itemView;
payloadResultView.applyAdapterInfo( payloadResultView.setup(item);
(AdapterItemWithPayload) mApps.getAdapterItems().get(position));
break; break;
case VIEW_TYPE_ALL_APPS_DIVIDER: case VIEW_TYPE_ALL_APPS_DIVIDER:
// nothing to do // nothing to do

View File

@ -35,6 +35,8 @@ import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItemWithPayload;
import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.util.PackageManagerHelper;
import com.android.systemui.plugins.AllAppsSearchPlugin; import com.android.systemui.plugins.AllAppsSearchPlugin;
import com.android.systemui.plugins.shared.SearchTarget;
import com.android.systemui.plugins.shared.SearchTargetEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -213,6 +215,44 @@ public class AllAppsSearchBarController
/** /**
* Updates View using Adapter's payload * Updates View using Adapter's payload
*/ */
default void setup(AdapterItemWithPayload<T> adapterItemWithPayload) {
Object[] targetInfo = getTargetInfo();
if (targetInfo != null) {
targetInfo[0] = adapterItemWithPayload.getSearchSessionId();
targetInfo[1] = adapterItemWithPayload.position;
}
applyAdapterInfo(adapterItemWithPayload);
}
void applyAdapterInfo(AdapterItemWithPayload<T> adapterItemWithPayload); void applyAdapterInfo(AdapterItemWithPayload<T> adapterItemWithPayload);
/**
* Gets object created by {@link PayloadResultHandler#createTargetInfo()}
*/
Object[] getTargetInfo();
/**
* Creates a wrapper object to hold searchSessionId and item position
*/
default Object[] createTargetInfo() {
return new Object[2];
}
/**
* Generates a SearchTargetEvent object for a PayloadHandlerView
*/
default SearchTargetEvent getSearchTargetEvent(SearchTarget.ItemType itemType,
int eventType) {
Object[] targetInfo = getTargetInfo();
if (targetInfo == null) return null;
String searchSessionId = (String) targetInfo[0];
int position = (int) targetInfo[1];
return new SearchTargetEvent(itemType, eventType,
position, searchSessionId);
}
} }
} }

View File

@ -61,6 +61,7 @@ public class HeroSearchResultView extends LinearLayout implements DragSource,
PayloadResultHandler<List<Pair<ShortcutInfo, ItemInfoWithIcon>>> { PayloadResultHandler<List<Pair<ShortcutInfo, ItemInfoWithIcon>>> {
public static final int MAX_SHORTCUTS_COUNT = 2; public static final int MAX_SHORTCUTS_COUNT = 2;
private final Object[] mTargetInfo = createTargetInfo();
BubbleTextView mBubbleTextView; BubbleTextView mBubbleTextView;
View mIconView; View mIconView;
BubbleTextView[] mDeepShortcutTextViews = new BubbleTextView[2]; BubbleTextView[] mDeepShortcutTextViews = new BubbleTextView[2];
@ -107,7 +108,7 @@ public class HeroSearchResultView extends LinearLayout implements DragSource,
grid.allAppsIconSizePx)); grid.allAppsIconSizePx));
bubbleTextView.setOnClickListener(view -> { bubbleTextView.setOnClickListener(view -> {
WorkspaceItemInfo itemInfo = (WorkspaceItemInfo) bubbleTextView.getTag(); WorkspaceItemInfo itemInfo = (WorkspaceItemInfo) bubbleTextView.getTag();
SearchTargetEvent event = new SearchTargetEvent( SearchTargetEvent event = getSearchTargetEvent(
SearchTarget.ItemType.APP_HERO, SearchTarget.ItemType.APP_HERO,
SearchTargetEvent.CHILD_SELECT); SearchTargetEvent.CHILD_SELECT);
event.bundle = getAppBundle(itemInfo); event.bundle = getAppBundle(itemInfo);
@ -149,6 +150,11 @@ public class HeroSearchResultView extends LinearLayout implements DragSource,
adapterItem.setSelectionHandler(this::handleSelection); adapterItem.setSelectionHandler(this::handleSelection);
} }
@Override
public Object[] getTargetInfo() {
return mTargetInfo;
}
@Override @Override
public void onDropCompleted(View target, DropTarget.DragObject d, boolean success) { public void onDropCompleted(View target, DropTarget.DragObject d, boolean success) {
mBubbleTextView.setVisibility(VISIBLE); mBubbleTextView.setVisibility(VISIBLE);
@ -184,7 +190,7 @@ public class HeroSearchResultView extends LinearLayout implements DragSource,
mLauncher.getWorkspace().beginDragShared(mContainer.mBubbleTextView, mLauncher.getWorkspace().beginDragShared(mContainer.mBubbleTextView,
draggableView, mContainer, itemInfo, previewProvider, new DragOptions()); draggableView, mContainer, itemInfo, previewProvider, new DragOptions());
SearchTargetEvent event = new SearchTargetEvent( SearchTargetEvent event = mContainer.getSearchTargetEvent(
SearchTarget.ItemType.APP_HERO, SearchTargetEvent.LONG_PRESS); SearchTarget.ItemType.APP_HERO, SearchTargetEvent.LONG_PRESS);
event.bundle = getAppBundle(itemInfo); event.bundle = getAppBundle(itemInfo);
if (mContainer.mPlugin != null) { if (mContainer.mPlugin != null) {
@ -201,7 +207,7 @@ public class HeroSearchResultView extends LinearLayout implements DragSource,
Launcher launcher = Launcher.getLauncher(getContext()); Launcher launcher = Launcher.getLauncher(getContext());
launcher.startActivitySafely(this, itemInfo.getIntent(), itemInfo); launcher.startActivitySafely(this, itemInfo.getIntent(), itemInfo);
SearchTargetEvent event = new SearchTargetEvent( SearchTargetEvent event = getSearchTargetEvent(
SearchTarget.ItemType.APP_HERO, eventType); SearchTarget.ItemType.APP_HERO, eventType);
event.bundle = getAppBundle(itemInfo); event.bundle = getAppBundle(itemInfo);
if (mPlugin != null) { if (mPlugin != null) {

View File

@ -67,7 +67,7 @@ public class SearchResultPeopleView extends LinearLayout implements
private ImageButton[] mProviderButtons = new ImageButton[3]; private ImageButton[] mProviderButtons = new ImageButton[3];
private AllAppsSearchPlugin mPlugin; private AllAppsSearchPlugin mPlugin;
private Uri mContactUri; private Uri mContactUri;
private final Object[] mTargetInfo = createTargetInfo();
public SearchResultPeopleView(Context context) { public SearchResultPeopleView(Context context) {
this(context, null, 0); this(context, null, 0);
@ -129,14 +129,14 @@ public class SearchResultPeopleView extends LinearLayout implements
Bundle provider = providers.get(i); Bundle provider = providers.get(i);
Intent intent = Intent.parseUri(provider.getString("intent_uri_str"), Intent intent = Intent.parseUri(provider.getString("intent_uri_str"),
URI_ANDROID_APP_SCHEME | URI_ALLOW_UNSAFE); URI_ANDROID_APP_SCHEME | URI_ALLOW_UNSAFE);
setupProviderButton(button, provider, intent); setupProviderButton(button, provider, intent, adapterItemWithPayload);
String pkg = provider.getString("package_name"); String pkg = provider.getString("package_name");
UI_HELPER_EXECUTOR.post(() -> { UI_HELPER_EXECUTOR.post(() -> {
try { try {
ApplicationInfo applicationInfo = mPackageManager.getApplicationInfo( ApplicationInfo applicationInfo = mPackageManager.getApplicationInfo(
pkg, 0); pkg, 0);
Drawable appIcon = applicationInfo.loadIcon(mPackageManager); Drawable appIcon = applicationInfo.loadIcon(mPackageManager);
MAIN_EXECUTOR.post(()-> button.setImageDrawable(appIcon)); MAIN_EXECUTOR.post(() -> button.setImageDrawable(appIcon));
} catch (PackageManager.NameNotFoundException ignored) { } catch (PackageManager.NameNotFoundException ignored) {
} }
@ -151,11 +151,17 @@ public class SearchResultPeopleView extends LinearLayout implements
adapterItemWithPayload.setSelectionHandler(this::handleSelection); adapterItemWithPayload.setSelectionHandler(this::handleSelection);
} }
private void setupProviderButton(ImageButton button, Bundle provider, Intent intent) { @Override
public Object[] getTargetInfo() {
return mTargetInfo;
}
private void setupProviderButton(ImageButton button, Bundle provider, Intent intent,
AllAppsGridAdapter.AdapterItem adapterItem) {
Launcher launcher = Launcher.getLauncher(getContext()); Launcher launcher = Launcher.getLauncher(getContext());
button.setOnClickListener(b -> { button.setOnClickListener(b -> {
launcher.startActivitySafely(b, intent, null); launcher.startActivitySafely(b, intent, null);
SearchTargetEvent searchTargetEvent = new SearchTargetEvent( SearchTargetEvent searchTargetEvent = getSearchTargetEvent(
SearchTarget.ItemType.PEOPLE, SearchTarget.ItemType.PEOPLE,
SearchTargetEvent.CHILD_SELECT); SearchTargetEvent.CHILD_SELECT);
searchTargetEvent.bundle = new Bundle(); searchTargetEvent.bundle = new Bundle();
@ -173,8 +179,8 @@ public class SearchResultPeopleView extends LinearLayout implements
Launcher launcher = Launcher.getLauncher(getContext()); Launcher launcher = Launcher.getLauncher(getContext());
launcher.startActivitySafely(this, new Intent(Intent.ACTION_VIEW, mContactUri).setFlags( launcher.startActivitySafely(this, new Intent(Intent.ACTION_VIEW, mContactUri).setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK), null); Intent.FLAG_ACTIVITY_NEW_TASK), null);
SearchTargetEvent searchTargetEvent = new SearchTargetEvent( SearchTargetEvent searchTargetEvent = getSearchTargetEvent(SearchTarget.ItemType.PEOPLE,
SearchTarget.ItemType.PEOPLE, eventType); eventType);
searchTargetEvent.bundle = new Bundle(); searchTargetEvent.bundle = new Bundle();
searchTargetEvent.bundle.putParcelable("contact_uri", mContactUri); searchTargetEvent.bundle.putParcelable("contact_uri", mContactUri);
if (mPlugin != null) { if (mPlugin != null) {

View File

@ -58,6 +58,8 @@ public class SearchResultPlayItem extends LinearLayout implements
private String mPackageName; private String mPackageName;
private boolean mIsInstantGame; private boolean mIsInstantGame;
private AllAppsSearchPlugin mPlugin; private AllAppsSearchPlugin mPlugin;
private final Object[] mTargetInfo = createTargetInfo();
public SearchResultPlayItem(Context context) { public SearchResultPlayItem(Context context) {
this(context, null, 0); this(context, null, 0);
@ -125,6 +127,11 @@ public class SearchResultPlayItem extends LinearLayout implements
}); });
} }
@Override
public Object[] getTargetInfo() {
return mTargetInfo;
}
private void showIfNecessary(TextView textView, @Nullable String string) { private void showIfNecessary(TextView textView, @Nullable String string) {
if (string == null || string.isEmpty()) { if (string == null || string.isEmpty()) {
textView.setVisibility(GONE); textView.setVisibility(GONE);
@ -160,7 +167,7 @@ public class SearchResultPlayItem extends LinearLayout implements
} }
private void logSearchEvent(int eventType) { private void logSearchEvent(int eventType) {
SearchTargetEvent searchTargetEvent = new SearchTargetEvent( SearchTargetEvent searchTargetEvent = getSearchTargetEvent(
SearchTarget.ItemType.PLAY_RESULTS, eventType); SearchTarget.ItemType.PLAY_RESULTS, eventType);
searchTargetEvent.bundle = new Bundle(); searchTargetEvent.bundle = new Bundle();
searchTargetEvent.bundle.putString("package_name", mPackageName); searchTargetEvent.bundle.putString("package_name", mPackageName);

View File

@ -50,6 +50,8 @@ public class SearchResultShortcut extends FrameLayout implements
private View mIconView; private View mIconView;
private ShortcutInfo mShortcutInfo; private ShortcutInfo mShortcutInfo;
private AllAppsSearchPlugin mPlugin; private AllAppsSearchPlugin mPlugin;
private final Object[] mTargetInfo = createTargetInfo();
public SearchResultShortcut(@NonNull Context context) { public SearchResultShortcut(@NonNull Context context) {
super(context); super(context);
@ -96,12 +98,17 @@ public class SearchResultShortcut extends FrameLayout implements
adapterItemWithPayload.setSelectionHandler(this::handleSelection); adapterItemWithPayload.setSelectionHandler(this::handleSelection);
} }
@Override
public Object[] getTargetInfo() {
return mTargetInfo;
}
private void handleSelection(int eventType) { private void handleSelection(int eventType) {
WorkspaceItemInfo itemInfo = (WorkspaceItemInfo) mBubbleTextView.getTag(); WorkspaceItemInfo itemInfo = (WorkspaceItemInfo) mBubbleTextView.getTag();
ItemClickHandler.onClickAppShortcut(this, itemInfo, Launcher.getLauncher(getContext())); ItemClickHandler.onClickAppShortcut(this, itemInfo, Launcher.getLauncher(getContext()));
SearchTargetEvent searchTargetEvent = new SearchTargetEvent( SearchTargetEvent searchTargetEvent = getSearchTargetEvent(SearchTarget.ItemType.SHORTCUT,
SearchTarget.ItemType.SHORTCUT, eventType); eventType);
searchTargetEvent.shortcut = mShortcutInfo; searchTargetEvent.shortcut = mShortcutInfo;
if (mPlugin != null) { if (mPlugin != null) {
mPlugin.notifySearchTargetEvent(searchTargetEvent); mPlugin.notifySearchTargetEvent(searchTargetEvent);

View File

@ -52,4 +52,9 @@ public class SearchSectionHeaderView extends TextView implements
setVisibility(INVISIBLE); setVisibility(INVISIBLE);
} }
} }
@Override
public Object[] getTargetInfo() {
return null;
}
} }

View File

@ -48,6 +48,8 @@ public class SearchSettingsRowView extends LinearLayout implements
private TextView mBreadcrumbsView; private TextView mBreadcrumbsView;
private Intent mIntent; private Intent mIntent;
private AllAppsSearchPlugin mPlugin; private AllAppsSearchPlugin mPlugin;
private final Object[] mTargetInfo = createTargetInfo();
public SearchSettingsRowView(@NonNull Context context) { public SearchSettingsRowView(@NonNull Context context) {
super(context); super(context);
@ -87,6 +89,11 @@ public class SearchSettingsRowView extends LinearLayout implements
adapterItemWithPayload.setSelectionHandler(this::handleSelection); adapterItemWithPayload.setSelectionHandler(this::handleSelection);
} }
@Override
public Object[] getTargetInfo() {
return mTargetInfo;
}
private void showIfAvailable(TextView view, @Nullable String string) { private void showIfAvailable(TextView view, @Nullable String string) {
if (TextUtils.isEmpty(string)) { if (TextUtils.isEmpty(string)) {
view.setVisibility(GONE); view.setVisibility(GONE);
@ -108,7 +115,7 @@ public class SearchSettingsRowView extends LinearLayout implements
Launcher launcher = Launcher.getLauncher(getContext()); Launcher launcher = Launcher.getLauncher(getContext());
launcher.startActivityForResult(mIntent, 0); launcher.startActivityForResult(mIntent, 0);
SearchTargetEvent searchTargetEvent = new SearchTargetEvent( SearchTargetEvent searchTargetEvent = getSearchTargetEvent(
SearchTarget.ItemType.SETTINGS_ROW, eventType); SearchTarget.ItemType.SETTINGS_ROW, eventType);
searchTargetEvent.bundle = new Bundle(); searchTargetEvent.bundle = new Bundle();
searchTargetEvent.bundle.putParcelable("intent", mIntent); searchTargetEvent.bundle.putParcelable("intent", mIntent);

View File

@ -39,8 +39,10 @@ import com.android.systemui.plugins.shared.SearchTargetEvent;
public class ThumbnailSearchResultView extends androidx.appcompat.widget.AppCompatImageView public class ThumbnailSearchResultView extends androidx.appcompat.widget.AppCompatImageView
implements AllAppsSearchBarController.PayloadResultHandler<Bundle> { implements AllAppsSearchBarController.PayloadResultHandler<Bundle> {
private final Object[] mTargetInfo = createTargetInfo();
Intent mIntent; Intent mIntent;
AllAppsSearchPlugin mPlugin; AllAppsSearchPlugin mPlugin;
int mPosition;
public ThumbnailSearchResultView(Context context) { public ThumbnailSearchResultView(Context context) {
super(context); super(context);
@ -58,7 +60,7 @@ public class ThumbnailSearchResultView extends androidx.appcompat.widget.AppComp
Launcher launcher = Launcher.getLauncher(getContext()); Launcher launcher = Launcher.getLauncher(getContext());
launcher.startActivitySafely(this, mIntent, null); launcher.startActivitySafely(this, mIntent, null);
SearchTargetEvent event = new SearchTargetEvent( SearchTargetEvent event = getSearchTargetEvent(
SearchTarget.ItemType.SCREENSHOT, eventType); SearchTarget.ItemType.SCREENSHOT, eventType);
if (mPlugin != null) { if (mPlugin != null) {
mPlugin.notifySearchTargetEvent(event); mPlugin.notifySearchTargetEvent(event);
@ -67,6 +69,7 @@ public class ThumbnailSearchResultView extends androidx.appcompat.widget.AppComp
@Override @Override
public void applyAdapterInfo(AdapterItemWithPayload<Bundle> adapterItem) { public void applyAdapterInfo(AdapterItemWithPayload<Bundle> adapterItem) {
mPosition = adapterItem.position;
RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(null, RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(null,
(Bitmap) adapterItem.getPayload().getParcelable("bitmap")); (Bitmap) adapterItem.getPayload().getParcelable("bitmap"));
drawable.setCornerRadius(Themes.getDialogCornerRadius(getContext())); drawable.setCornerRadius(Themes.getDialogCornerRadius(getContext()));
@ -78,4 +81,9 @@ public class ThumbnailSearchResultView extends androidx.appcompat.widget.AppComp
mPlugin = adapterItem.getPlugin(); mPlugin = adapterItem.getPlugin();
adapterItem.setSelectionHandler(this::handleSelection); adapterItem.setSelectionHandler(this::handleSelection);
} }
@Override
public Object[] getTargetInfo() {
return mTargetInfo;
}
} }

View File

@ -32,7 +32,7 @@ import java.util.function.Consumer;
@ProvidesInterface(action = AllAppsSearchPlugin.ACTION, version = AllAppsSearchPlugin.VERSION) @ProvidesInterface(action = AllAppsSearchPlugin.ACTION, version = AllAppsSearchPlugin.VERSION)
public interface AllAppsSearchPlugin extends Plugin { public interface AllAppsSearchPlugin extends Plugin {
String ACTION = "com.android.systemui.action.PLUGIN_ALL_APPS_SEARCH_ACTIONS"; String ACTION = "com.android.systemui.action.PLUGIN_ALL_APPS_SEARCH_ACTIONS";
int VERSION = 6; int VERSION = 7;
void setup(Activity activity, View view); void setup(Activity activity, View view);

View File

@ -122,6 +122,7 @@ public class SearchTarget implements Comparable<SearchTarget> {
public List<ShortcutInfo> shortcuts; public List<ShortcutInfo> shortcuts;
public Bundle bundle; public Bundle bundle;
public float score; public float score;
public String mSessionId;
/** /**
* Constructor to create the search target. Bundle is currently temporary to hold * Constructor to create the search target. Bundle is currently temporary to hold
@ -130,11 +131,12 @@ public class SearchTarget implements Comparable<SearchTarget> {
* *
*/ */
public SearchTarget(ItemType itemType, List<ShortcutInfo> shortcuts, public SearchTarget(ItemType itemType, List<ShortcutInfo> shortcuts,
Bundle bundle, float score) { Bundle bundle, float score, String sessionId) {
this.type = itemType; this.type = itemType;
this.shortcuts = shortcuts; this.shortcuts = shortcuts;
this.bundle = bundle; this.bundle = bundle;
this.score = score; this.score = score;
this.mSessionId = sessionId;
} }
@Override @Override

View File

@ -31,10 +31,14 @@ public class SearchTargetEvent {
public ShortcutInfo shortcut; public ShortcutInfo shortcut;
public int eventType; public int eventType;
public Bundle bundle; public Bundle bundle;
public float score; public int index;
public String sessionIdentifier;
public SearchTargetEvent(SearchTarget.ItemType itemType, int eventType) { public SearchTargetEvent(SearchTarget.ItemType itemType, int eventType, int index,
String sessionId) {
this.type = itemType; this.type = itemType;
this.eventType = eventType; this.eventType = eventType;
this.index = index;
this.sessionIdentifier = sessionId;
} }
} }