[AA+] Add QueryLength to DeviceSearchResultContainer. am: 43b1d40918

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/13486574

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ifc935c178457f9e614134f2f36ae6892b5476c70
This commit is contained in:
thiruram authored and Automerger Merge Worker committed 2021-02-08 22:11:18 +00:00
commit d45bcde260
3 files changed
+17 -8

No files matched your search

@@ -31,4 +31,5 @@ message ExtendedContainers {
// Represents on-device search result container.
message DeviceSearchResultContainer{
optional int32 query_length = 1;
}
@@ -81,7 +81,7 @@ public class SearchResultIcon extends BubbleTextView implements
private static final int BITMAP_CROP_MASK_COLOR = 0xff424242;
private final Launcher mLauncher;
private final SearchSessionTracker mSearchSessionTracker;
private String mTargetId;
private Consumer<ItemInfoWithIcon> mOnItemInfoChanged;
@@ -97,6 +97,7 @@ public class SearchResultIcon extends BubbleTextView implements
public SearchResultIcon(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mLauncher = Launcher.getLauncher(getContext());
mSearchSessionTracker = SearchSessionTracker.getInstance(getContext());
}
private boolean mLongPressSupported;
@@ -113,8 +114,8 @@ public class SearchResultIcon extends BubbleTextView implements
}
/**
* Applies {@link SearchTarget} to view. registers a consumer after a corresponding
* {@link ItemInfoWithIcon} is created
* Applies {@link SearchTarget} to view. registers a consumer after a corresponding {@link
* ItemInfoWithIcon} is created
*/
public void apply(SearchTarget searchTarget, List<SearchTarget> inlineItems,
Consumer<ItemInfoWithIcon> cb) {
@@ -317,13 +318,15 @@ public class SearchResultIcon extends BubbleTextView implements
}
}
private static ContainerInfo buildDeviceSearchResultContainer() {
private ContainerInfo buildDeviceSearchResultContainer() {
return ContainerInfo.newBuilder().setExtendedContainers(
ExtendedContainers
.newBuilder()
.setDeviceSearchResultContainer(
DeviceSearchResultContainer
.newBuilder()))
mSearchSessionTracker.getQueryLength()
.map(queryLength -> DeviceSearchResultContainer.newBuilder()
.setQueryLength(queryLength))
.orElse(DeviceSearchResultContainer.newBuilder())))
.build();
}
}
@@ -15,9 +15,10 @@
*/
package com.android.launcher3.search;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import android.app.search.Query;
import android.app.search.SearchSession;
import android.app.search.SearchTarget;
import android.app.search.SearchTargetEvent;
import android.content.Context;
import android.util.Log;
@@ -27,7 +28,7 @@ import androidx.annotation.WorkerThread;
import com.android.launcher3.util.MainThreadInitializedObject;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import java.util.Optional;
/**
* A singleton class to track and report search events back to SearchSession
@@ -63,6 +64,10 @@ public class SearchSessionTracker {
mQuery = query;
}
public Optional<Integer> getQueryLength() {
return Optional.ofNullable(mQuery).map(Query::getInput).map(String::length);
}
/**
* Send the user event handling back to the {@link SearchSession} object.
*/