[AA+] Add QueryLength to DeviceSearchResultContainer.
Bug: 178562918 Change-Id: I4891433bcd8848edd92f103448f5c00c5f9619e4
This commit is contained in:
parent
fd03d04ae0
commit
43b1d40918
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue