Merge "Support shorter height row layout / Disable ICON_SLICE" into sc-dev
This commit is contained in:
commit
aa793ff226
|
@ -20,10 +20,10 @@
|
||||||
android:padding="@dimen/dynamic_grid_edge_margin">
|
android:padding="@dimen/dynamic_grid_edge_margin">
|
||||||
|
|
||||||
<com.android.launcher3.search.SearchResultIcon
|
<com.android.launcher3.search.SearchResultIcon
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:id="@+id/icon"
|
android:id="@+id/icon"
|
||||||
launcher:iconDisplay="hero_app"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
launcher:iconDisplay="hero_app" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -34,8 +34,8 @@
|
||||||
android:layout_gravity="center_vertical">
|
android:layout_gravity="center_vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:id="@id/title"
|
android:id="@id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2021 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<com.android.launcher3.search.SearchResultSmallIconRow
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:launcher="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="@dimen/dynamic_grid_edge_margin">
|
||||||
|
|
||||||
|
<com.android.launcher3.search.SearchResultIcon
|
||||||
|
android:id="@+id/icon"
|
||||||
|
style="@style/BaseIcon"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:drawablePadding="@dimen/dynamic_grid_icon_drawable_padding"
|
||||||
|
android:drawableTint="?android:attr/textColorPrimary"
|
||||||
|
android:padding="@dimen/dynamic_grid_edge_margin"
|
||||||
|
launcher:iconDisplay="hero_app"
|
||||||
|
launcher:iconSizeOverride="48dp"
|
||||||
|
launcher:matchTextInsetWithQuery="true"
|
||||||
|
launcher:layoutHorizontal="true" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:padding="@dimen/dynamic_grid_edge_margin" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingEnd="4dp"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/search_hero_title_size" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/delimeter"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="\u2022"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/search_hero_subtitle_size" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/subtitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingStart="4dp"
|
||||||
|
android:textColor="?android:attr/textColorTertiary"
|
||||||
|
android:textSize="@dimen/search_hero_subtitle_size" />
|
||||||
|
</LinearLayout>
|
||||||
|
</com.android.launcher3.search.SearchResultSmallIconRow>
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.android.launcher3.search;
|
package com.android.launcher3.search;
|
||||||
|
|
||||||
|
import static com.android.launcher3.allapps.AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER;
|
||||||
import static com.android.launcher3.allapps.AllAppsGridAdapter.VIEW_TYPE_ICON;
|
import static com.android.launcher3.allapps.AllAppsGridAdapter.VIEW_TYPE_ICON;
|
||||||
|
|
||||||
import android.app.search.SearchTarget;
|
import android.app.search.SearchTarget;
|
||||||
|
@ -31,6 +32,7 @@ import com.android.launcher3.R;
|
||||||
import com.android.launcher3.allapps.AllAppsContainerView;
|
import com.android.launcher3.allapps.AllAppsContainerView;
|
||||||
import com.android.launcher3.allapps.AllAppsGridAdapter;
|
import com.android.launcher3.allapps.AllAppsGridAdapter;
|
||||||
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
||||||
|
import com.android.launcher3.config.FeatureFlags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides views for on-device search results
|
* Provides views for on-device search results
|
||||||
|
@ -41,11 +43,12 @@ public class DeviceSearchAdapterProvider extends SearchAdapterProvider {
|
||||||
public static final int VIEW_TYPE_SEARCH_SLICE = 1 << 7;
|
public static final int VIEW_TYPE_SEARCH_SLICE = 1 << 7;
|
||||||
public static final int VIEW_TYPE_SEARCH_ICON = (1 << 8) | VIEW_TYPE_ICON;
|
public static final int VIEW_TYPE_SEARCH_ICON = (1 << 8) | VIEW_TYPE_ICON;
|
||||||
public static final int VIEW_TYPE_SEARCH_ICON_ROW = (1 << 9);
|
public static final int VIEW_TYPE_SEARCH_ICON_ROW = (1 << 9);
|
||||||
|
public static final int VIEW_TYPE_SEARCH_SMALL_ICON_ROW = (1 << 10);
|
||||||
public static final int VIEW_TYPE_SEARCH_THUMBNAIL = 1 << 12;
|
public static final int VIEW_TYPE_SEARCH_THUMBNAIL = 1 << 12;
|
||||||
public static final int VIEW_TYPE_SEARCH_WIDGET_LIVE = 1 << 15;
|
public static final int VIEW_TYPE_SEARCH_WIDGET_LIVE = 1 << 15;
|
||||||
public static final int VIEW_TYPE_SEARCH_WIDGET_PREVIEW = 1 << 16;
|
public static final int VIEW_TYPE_SEARCH_WIDGET_PREVIEW = 1 << 16;
|
||||||
|
|
||||||
private static final String TAG = "SearchServiceAdapterProvider";
|
private static final String TAG = "SearchServiceAdapter";
|
||||||
|
|
||||||
private final AllAppsContainerView mAppsView;
|
private final AllAppsContainerView mAppsView;
|
||||||
private final SparseIntArray mViewTypeToLayoutMap = new SparseIntArray();
|
private final SparseIntArray mViewTypeToLayoutMap = new SparseIntArray();
|
||||||
|
@ -57,11 +60,13 @@ public class DeviceSearchAdapterProvider extends SearchAdapterProvider {
|
||||||
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_CORPUS_TITLE, R.layout.search_section_title);
|
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_CORPUS_TITLE, R.layout.search_section_title);
|
||||||
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_ICON, R.layout.search_result_icon);
|
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_ICON, R.layout.search_result_icon);
|
||||||
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_ICON_ROW, R.layout.search_result_icon_row);
|
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_ICON_ROW, R.layout.search_result_icon_row);
|
||||||
|
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_SMALL_ICON_ROW, R.layout.search_result_small_icon_row);
|
||||||
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_SLICE, R.layout.search_result_slice);
|
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_SLICE, R.layout.search_result_slice);
|
||||||
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_THUMBNAIL, R.layout.search_result_thumbnail);
|
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_THUMBNAIL, R.layout.search_result_thumbnail);
|
||||||
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_WIDGET_LIVE, R.layout.search_result_widget_live);
|
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_WIDGET_LIVE, R.layout.search_result_widget_live);
|
||||||
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_WIDGET_PREVIEW,
|
mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_WIDGET_PREVIEW,
|
||||||
R.layout.search_result_widget_preview);
|
R.layout.search_result_widget_preview);
|
||||||
|
mViewTypeToLayoutMap.put(VIEW_TYPE_ALL_APPS_DIVIDER, R.layout.all_apps_divider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -116,25 +121,33 @@ public class DeviceSearchAdapterProvider extends SearchAdapterProvider {
|
||||||
case LayoutType.ICON_SINGLE_VERTICAL_TEXT:
|
case LayoutType.ICON_SINGLE_VERTICAL_TEXT:
|
||||||
return VIEW_TYPE_SEARCH_ICON;
|
return VIEW_TYPE_SEARCH_ICON;
|
||||||
case LayoutType.ICON_SLICE:
|
case LayoutType.ICON_SLICE:
|
||||||
|
if (FeatureFlags.DISABLE_SLICE_IN_ALLAPPS.get()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (t.getSliceUri() != null) {
|
if (t.getSliceUri() != null) {
|
||||||
return VIEW_TYPE_SEARCH_SLICE;
|
return VIEW_TYPE_SEARCH_SLICE;
|
||||||
}
|
}
|
||||||
Log.w(TAG, "Dropping as LayoutType.ICON_SLICE target doesn't contain sliceUri.");
|
Log.w(TAG, "LayoutType.ICON_SLICE target doesn't contain sliceUri.");
|
||||||
break;
|
break;
|
||||||
case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT:
|
case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT:
|
||||||
case LayoutType.ICON_SINGLE_HORIZONTAL_TEXT:
|
case LayoutType.ICON_SINGLE_HORIZONTAL_TEXT:
|
||||||
case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT_BUTTON:
|
case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT_BUTTON:
|
||||||
|
case LayoutType.ICON_HORIZONTAL_TEXT:
|
||||||
return VIEW_TYPE_SEARCH_ICON_ROW;
|
return VIEW_TYPE_SEARCH_ICON_ROW;
|
||||||
|
case LayoutType.SMALL_ICON_HORIZONTAL_TEXT:
|
||||||
|
return VIEW_TYPE_SEARCH_SMALL_ICON_ROW;
|
||||||
case LayoutType.THUMBNAIL:
|
case LayoutType.THUMBNAIL:
|
||||||
if (t.getSearchAction() != null) {
|
if (t.getSearchAction() != null) {
|
||||||
return VIEW_TYPE_SEARCH_THUMBNAIL;
|
return VIEW_TYPE_SEARCH_THUMBNAIL;
|
||||||
}
|
}
|
||||||
Log.w(TAG, "Dropping as LayoutType.THUMBNAIL target doesn't contain searchAction.");
|
Log.w(TAG, "LayoutType.THUMBNAIL target doesn't contain searchAction.");
|
||||||
break;
|
break;
|
||||||
case LayoutType.WIDGET_PREVIEW:
|
case LayoutType.WIDGET_PREVIEW:
|
||||||
return VIEW_TYPE_SEARCH_WIDGET_PREVIEW;
|
return VIEW_TYPE_SEARCH_WIDGET_PREVIEW;
|
||||||
case LayoutType.WIDGET_LIVE:
|
case LayoutType.WIDGET_LIVE:
|
||||||
return VIEW_TYPE_SEARCH_WIDGET_LIVE;
|
return VIEW_TYPE_SEARCH_WIDGET_LIVE;
|
||||||
|
case LayoutType.DIVIDER:
|
||||||
|
return VIEW_TYPE_ALL_APPS_DIVIDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -18,6 +18,7 @@ package com.android.launcher3.search;
|
||||||
|
|
||||||
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_ICON;
|
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_ICON;
|
||||||
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_ICON_ROW;
|
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_ICON_ROW;
|
||||||
|
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_SMALL_ICON_ROW;
|
||||||
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_SLICE;
|
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_SLICE;
|
||||||
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_THUMBNAIL;
|
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_THUMBNAIL;
|
||||||
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_WIDGET_LIVE;
|
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_WIDGET_LIVE;
|
||||||
|
@ -26,7 +27,6 @@ import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE
|
||||||
import android.app.search.SearchTarget;
|
import android.app.search.SearchTarget;
|
||||||
|
|
||||||
import com.android.launcher3.allapps.AllAppsGridAdapter;
|
import com.android.launcher3.allapps.AllAppsGridAdapter;
|
||||||
import com.android.systemui.plugins.shared.SearchTargetLegacy;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -35,31 +35,23 @@ import java.util.List;
|
||||||
* Extension of AdapterItem that contains an extra payload specific to item
|
* Extension of AdapterItem that contains an extra payload specific to item
|
||||||
*/
|
*/
|
||||||
public class SearchAdapterItem extends AllAppsGridAdapter.AdapterItem {
|
public class SearchAdapterItem extends AllAppsGridAdapter.AdapterItem {
|
||||||
private SearchTargetLegacy mSearchTargetLegacy;
|
|
||||||
private SearchTarget mSearchTarget;
|
private SearchTarget mSearchTarget;
|
||||||
private List<SearchTarget> mInlineItems = new ArrayList<>();
|
private List<SearchTarget> mInlineItems = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
private static final int AVAILABLE_FOR_ACCESSIBILITY =
|
private static final int AVAILABLE_FOR_ACCESSIBILITY = VIEW_TYPE_SEARCH_SLICE
|
||||||
VIEW_TYPE_SEARCH_SLICE | VIEW_TYPE_SEARCH_THUMBNAIL | VIEW_TYPE_SEARCH_ICON_ROW
|
| VIEW_TYPE_SEARCH_THUMBNAIL
|
||||||
| VIEW_TYPE_SEARCH_ICON | VIEW_TYPE_SEARCH_WIDGET_PREVIEW
|
| VIEW_TYPE_SEARCH_ICON_ROW
|
||||||
| VIEW_TYPE_SEARCH_WIDGET_LIVE;
|
| VIEW_TYPE_SEARCH_ICON
|
||||||
|
| VIEW_TYPE_SEARCH_SMALL_ICON_ROW
|
||||||
|
| VIEW_TYPE_SEARCH_WIDGET_PREVIEW
|
||||||
public SearchAdapterItem(SearchTargetLegacy searchTargetLegacy, int type) {
|
| VIEW_TYPE_SEARCH_WIDGET_LIVE;
|
||||||
mSearchTargetLegacy = searchTargetLegacy;
|
|
||||||
viewType = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SearchAdapterItem(SearchTarget searchTarget, int type) {
|
public SearchAdapterItem(SearchTarget searchTarget, int type) {
|
||||||
mSearchTarget = searchTarget;
|
mSearchTarget = searchTarget;
|
||||||
viewType = type;
|
viewType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchTargetLegacy getSearchTargetLegacy() {
|
|
||||||
return mSearchTargetLegacy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SearchTarget getSearchTarget() {
|
public SearchTarget getSearchTarget() {
|
||||||
return mSearchTarget;
|
return mSearchTarget;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,12 @@ public class SearchResultIconRow extends LinearLayout implements SearchTargetHan
|
||||||
public static final int MAX_INLINE_ITEMS = 3;
|
public static final int MAX_INLINE_ITEMS = 3;
|
||||||
|
|
||||||
protected final Launcher mLauncher;
|
protected final Launcher mLauncher;
|
||||||
private final LauncherAppState mLauncherAppState;
|
protected final SearchResultIcon[] mInlineIcons = new SearchResultIcon[MAX_INLINE_ITEMS];
|
||||||
protected SearchResultIcon mResultIcon;
|
private SearchResultIcon mResultIcon;
|
||||||
|
|
||||||
|
private final LauncherAppState mLauncherAppState;
|
||||||
private TextView mTitleView;
|
private TextView mTitleView;
|
||||||
private TextView mSubTitleView;
|
private TextView mSubTitleView;
|
||||||
protected final SearchResultIcon[] mInlineIcons = new SearchResultIcon[MAX_INLINE_ITEMS];
|
|
||||||
|
|
||||||
private PackageItemInfo mProviderInfo;
|
private PackageItemInfo mProviderInfo;
|
||||||
|
|
||||||
|
@ -77,13 +77,14 @@ public class SearchResultIconRow extends LinearLayout implements SearchTargetHan
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
|
|
||||||
int iconSize = getIconSize();
|
int iconSize = getIconSize();
|
||||||
|
|
||||||
mResultIcon = findViewById(R.id.icon);
|
mResultIcon = findViewById(R.id.icon);
|
||||||
|
|
||||||
mTitleView = findViewById(R.id.title);
|
mTitleView = findViewById(R.id.title);
|
||||||
mSubTitleView = findViewById(R.id.subtitle);
|
mSubTitleView = findViewById(R.id.subtitle);
|
||||||
mSubTitleView.setVisibility(GONE);
|
mSubTitleView.setVisibility(GONE);
|
||||||
|
|
||||||
mResultIcon.getLayoutParams().height = iconSize;
|
mResultIcon.getLayoutParams().height = iconSize;
|
||||||
mResultIcon.getLayoutParams().width = iconSize;
|
mResultIcon.getLayoutParams().width = iconSize;
|
||||||
mResultIcon.setTextVisibility(false);
|
mResultIcon.setTextVisibility(false);
|
||||||
|
@ -94,15 +95,16 @@ public class SearchResultIconRow extends LinearLayout implements SearchTargetHan
|
||||||
for (SearchResultIcon inlineIcon : mInlineIcons) {
|
for (SearchResultIcon inlineIcon : mInlineIcons) {
|
||||||
inlineIcon.getLayoutParams().width = getIconSize();
|
inlineIcon.getLayoutParams().width = getIconSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
setOnClickListener(mResultIcon);
|
setOnClickListener(mResultIcon);
|
||||||
setOnLongClickListener(mResultIcon);
|
setOnLongClickListener(mResultIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
|
public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
|
||||||
showSubtitleIfNeeded(null);
|
|
||||||
mResultIcon.apply(parentTarget, children, this::onItemInfoCreated);
|
mResultIcon.apply(parentTarget, children, this::onItemInfoCreated);
|
||||||
|
|
||||||
|
showSubtitleIfNeeded(null);
|
||||||
|
|
||||||
if (parentTarget.getShortcutInfo() != null) {
|
if (parentTarget.getShortcutInfo() != null) {
|
||||||
updateWithShortcutInfo(parentTarget.getShortcutInfo());
|
updateWithShortcutInfo(parentTarget.getShortcutInfo());
|
||||||
} else if (parentTarget.getSearchAction() != null) {
|
} else if (parentTarget.getSearchAction() != null) {
|
||||||
|
|
|
@ -0,0 +1,142 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2020 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.android.launcher3.search;
|
||||||
|
|
||||||
|
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||||
|
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
|
||||||
|
|
||||||
|
import android.app.search.SearchTarget;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.ShortcutInfo;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.android.launcher3.Launcher;
|
||||||
|
import com.android.launcher3.LauncherAppState;
|
||||||
|
import com.android.launcher3.R;
|
||||||
|
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||||
|
import com.android.launcher3.model.data.PackageItemInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A full width representation of {@link SearchResultIcon} with a secondary label and inline
|
||||||
|
* SearchTargets
|
||||||
|
*/
|
||||||
|
public class SearchResultSmallIconRow extends LinearLayout implements SearchTargetHandler {
|
||||||
|
|
||||||
|
protected final Launcher mLauncher;
|
||||||
|
private final LauncherAppState mLauncherAppState;
|
||||||
|
protected SearchResultIcon mResultIcon;
|
||||||
|
|
||||||
|
private TextView mTitleView;
|
||||||
|
private TextView mDelimeterView;
|
||||||
|
private TextView mSubTitleView;
|
||||||
|
|
||||||
|
private PackageItemInfo mProviderInfo;
|
||||||
|
|
||||||
|
public SearchResultSmallIconRow(Context context) {
|
||||||
|
this(context, null, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SearchResultSmallIconRow(Context context,
|
||||||
|
@Nullable AttributeSet attrs) {
|
||||||
|
this(context, attrs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SearchResultSmallIconRow(Context context,
|
||||||
|
@Nullable AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
mLauncher = Launcher.getLauncher(getContext());
|
||||||
|
mLauncherAppState = LauncherAppState.getInstance(getContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getIconSize() {
|
||||||
|
return mLauncher.getDeviceProfile().allAppsIconSizePx;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onFinishInflate() {
|
||||||
|
super.onFinishInflate();
|
||||||
|
int iconSize = getIconSize();
|
||||||
|
|
||||||
|
mResultIcon = findViewById(R.id.icon);
|
||||||
|
|
||||||
|
mTitleView = findViewById(R.id.title);
|
||||||
|
mDelimeterView = findViewById(R.id.delimeter);
|
||||||
|
mDelimeterView.setVisibility(GONE);
|
||||||
|
mSubTitleView = findViewById(R.id.subtitle);
|
||||||
|
mSubTitleView.setVisibility(GONE);
|
||||||
|
|
||||||
|
mResultIcon.getLayoutParams().height = iconSize;
|
||||||
|
mResultIcon.getLayoutParams().width = iconSize;
|
||||||
|
mResultIcon.setTextVisibility(false);
|
||||||
|
|
||||||
|
setOnClickListener(mResultIcon);
|
||||||
|
setOnLongClickListener(mResultIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
|
||||||
|
mResultIcon.apply(parentTarget, children, this::onItemInfoCreated);
|
||||||
|
|
||||||
|
showSubtitleIfNeeded(null);
|
||||||
|
|
||||||
|
if (parentTarget.getShortcutInfo() != null) {
|
||||||
|
updateWithShortcutInfo(parentTarget.getShortcutInfo());
|
||||||
|
} else if (parentTarget.getSearchAction() != null) {
|
||||||
|
showSubtitleIfNeeded(parentTarget.getSearchAction().getSubtitle());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean quickSelect() {
|
||||||
|
this.performClick();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateWithShortcutInfo(ShortcutInfo shortcutInfo) {
|
||||||
|
PackageItemInfo packageItemInfo = new PackageItemInfo(shortcutInfo.getPackage());
|
||||||
|
if (packageItemInfo.equals(mProviderInfo)) return;
|
||||||
|
MODEL_EXECUTOR.post(() -> {
|
||||||
|
mLauncherAppState.getIconCache().getTitleAndIconForApp(packageItemInfo, true);
|
||||||
|
MAIN_EXECUTOR.post(() -> {
|
||||||
|
showSubtitleIfNeeded(packageItemInfo.title);
|
||||||
|
mProviderInfo = packageItemInfo;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void showSubtitleIfNeeded(CharSequence subTitle) {
|
||||||
|
if (!TextUtils.isEmpty(subTitle)) {
|
||||||
|
mSubTitleView.setText(subTitle);
|
||||||
|
mSubTitleView.setVisibility(VISIBLE);
|
||||||
|
mDelimeterView.setVisibility(VISIBLE);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mSubTitleView.setVisibility(GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onItemInfoCreated(ItemInfoWithIcon info) {
|
||||||
|
setTag(info);
|
||||||
|
mTitleView.setText(info.title);
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,10 +13,12 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.launcher3.search;
|
package com.android.launcher3.search;
|
||||||
|
|
||||||
import static com.android.app.search.LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT;
|
import static com.android.app.search.LayoutType.DIVIDER;
|
||||||
import static com.android.app.search.LayoutType.ICON_SINGLE_HORIZONTAL_TEXT;
|
import static com.android.app.search.LayoutType.ICON_HORIZONTAL_TEXT;
|
||||||
|
import static com.android.app.search.LayoutType.SMALL_ICON_HORIZONTAL_TEXT;
|
||||||
import static com.android.app.search.LayoutType.THUMBNAIL;
|
import static com.android.app.search.LayoutType.THUMBNAIL;
|
||||||
import static com.android.app.search.ResultType.ACTION;
|
import static com.android.app.search.ResultType.ACTION;
|
||||||
import static com.android.app.search.ResultType.SCREENSHOT;
|
import static com.android.app.search.ResultType.SCREENSHOT;
|
||||||
|
@ -54,17 +56,17 @@ public class SearchTargetUtil {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate SearchTargetUtil for ICON_DOUBLE_HORIZONTAL_TEXT layout type.
|
* Generate SearchTargetUtil for ICON_HORIZONTAL_TEXT layout type.
|
||||||
*
|
*
|
||||||
* targets.add(SearchTargetUtil.generateIconDoubleHorizontalText_SearchAction(
|
* targets.add(SearchTargetUtil.generateIconDoubleHorizontalText_SearchAction(
|
||||||
* mContext, "red", Color.RED));
|
* mContext, "red", Color.RED));
|
||||||
* targets.add(SearchTargetUtil.generateIconDoubleHorizontalText_SearchAction(
|
* targets.add(SearchTargetUtil.generateIconDoubleHorizontalText_SearchAction(
|
||||||
* mContext, "yellow", Color.YELLOW));
|
* mContext, "yellow", Color.YELLOW));
|
||||||
*/
|
*/
|
||||||
public static SearchTarget generateIconDoubleHorizontalText_SearchAction(
|
public static SearchTarget generateIcoHorizontalText_usingSearchAction(
|
||||||
Context context, String id, int color) {
|
Context context, String id, int color) {
|
||||||
SearchTarget.Builder builder =
|
SearchTarget.Builder builder =
|
||||||
new SearchTarget.Builder(ACTION, ICON_DOUBLE_HORIZONTAL_TEXT, id)
|
new SearchTarget.Builder(ACTION, ICON_HORIZONTAL_TEXT, id)
|
||||||
.setPackageName(PACKAGE2) /* required */
|
.setPackageName(PACKAGE2) /* required */
|
||||||
.setUserHandle(USERHANDLE); /* required */
|
.setUserHandle(USERHANDLE); /* required */
|
||||||
|
|
||||||
|
@ -102,7 +104,7 @@ public class SearchTargetUtil {
|
||||||
* targets.add(SearchTargetUtil.generateThumbnail_SearchAction("red", Color.RED));
|
* targets.add(SearchTargetUtil.generateThumbnail_SearchAction("red", Color.RED));
|
||||||
* targets.add(SearchTargetUtil.generateThumbnail_SearchAction("green", Color.GREEN));
|
* targets.add(SearchTargetUtil.generateThumbnail_SearchAction("green", Color.GREEN));
|
||||||
*/
|
*/
|
||||||
public static SearchTarget generateThumbnail_SearchAction(String id, int color) {
|
public static SearchTarget generateThumbnail_usingSearchAction(String id, int color) {
|
||||||
SearchTarget.Builder builder =
|
SearchTarget.Builder builder =
|
||||||
new SearchTarget.Builder(SCREENSHOT, THUMBNAIL, id)
|
new SearchTarget.Builder(SCREENSHOT, THUMBNAIL, id)
|
||||||
.setPackageName(PACKAGE2) /* required */
|
.setPackageName(PACKAGE2) /* required */
|
||||||
|
@ -130,16 +132,19 @@ public class SearchTargetUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Generate SearchTargetUtil for SMALL_ICON_HORIZONTAL_TEXT layout type.
|
||||||
|
*
|
||||||
* targets.add(SearchTargetUtil.generateIconHorizontalText_SearchAction(
|
* targets.add(SearchTargetUtil.generateIconHorizontalText_SearchAction(
|
||||||
* mContext, "red", Color.RED));
|
* mContext, "red", Color.RED));
|
||||||
* targets.add(SearchTargetUtil.generateIconHorizontalText_SearchAction(
|
* targets.add(SearchTargetUtil.generateIconHorizontalText_SearchAction(
|
||||||
* mContext, "yellow", Color.YELLOW));
|
* mContext, "yellow", Color.YELLOW));
|
||||||
*/
|
*/
|
||||||
public static SearchTarget generateIconHorizontalText_SearchAction(
|
public static SearchTarget generateSmallIconHorizontalText_usingSearchAction(
|
||||||
Context context, String id, int color) {
|
Context context, String id, int color) {
|
||||||
String fallbackQuery = "How to make cookie";
|
String title = "Ask the assistant";
|
||||||
|
String fallbackQuery = "sourdough bread";
|
||||||
SearchTarget.Builder builder =
|
SearchTarget.Builder builder =
|
||||||
new SearchTarget.Builder(SUGGEST, ICON_SINGLE_HORIZONTAL_TEXT, id)
|
new SearchTarget.Builder(SUGGEST, SMALL_ICON_HORIZONTAL_TEXT, id)
|
||||||
.setPackageName(PACKAGE2) /* required */
|
.setPackageName(PACKAGE2) /* required */
|
||||||
.setUserHandle(USERHANDLE); /* required */
|
.setUserHandle(USERHANDLE); /* required */
|
||||||
|
|
||||||
|
@ -159,7 +164,8 @@ public class SearchTargetUtil {
|
||||||
Bundle extra = new Bundle();
|
Bundle extra = new Bundle();
|
||||||
extra.putBoolean(BUNDLE_EXTRA_SHOULD_START_FOR_RESULT, true);
|
extra.putBoolean(BUNDLE_EXTRA_SHOULD_START_FOR_RESULT, true);
|
||||||
|
|
||||||
SearchAction searchAction = new SearchAction.Builder(id, fallbackQuery)
|
SearchAction searchAction = new SearchAction.Builder(id, title)
|
||||||
|
.setSubtitle(fallbackQuery)
|
||||||
.setPendingIntent(pendingIntent3)
|
.setPendingIntent(pendingIntent3)
|
||||||
.setIcon(icon)
|
.setIcon(icon)
|
||||||
.setExtras(extra)
|
.setExtras(extra)
|
||||||
|
@ -167,6 +173,14 @@ public class SearchTargetUtil {
|
||||||
return builder.setSearchAction(searchAction).build();
|
return builder.setSearchAction(searchAction).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SearchTarget generateDivider() {
|
||||||
|
SearchTarget.Builder builder =
|
||||||
|
new SearchTarget.Builder(SUGGEST, DIVIDER, "divider")
|
||||||
|
.setPackageName("") /* required but not used*/
|
||||||
|
.setUserHandle(USERHANDLE); /* required */
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate SearchTargetUtil for ICON_DOUBLE_HORIZONTAL_TEXT layout type.
|
* Generate SearchTargetUtil for ICON_DOUBLE_HORIZONTAL_TEXT layout type.
|
||||||
|
@ -174,7 +188,7 @@ public class SearchTargetUtil {
|
||||||
public static SearchTarget generateIconDoubleHorizontalText_ShortcutInfo(Context context) {
|
public static SearchTarget generateIconDoubleHorizontalText_ShortcutInfo(Context context) {
|
||||||
String id = "23456";
|
String id = "23456";
|
||||||
SearchTarget.Builder builder =
|
SearchTarget.Builder builder =
|
||||||
new SearchTarget.Builder(ResultType.SHORTCUT, ICON_DOUBLE_HORIZONTAL_TEXT, id)
|
new SearchTarget.Builder(ResultType.SHORTCUT, SMALL_ICON_HORIZONTAL_TEXT, id)
|
||||||
.setPackageName("com.google.android.gm") /* required */
|
.setPackageName("com.google.android.gm") /* required */
|
||||||
.setUserHandle(UserHandle.CURRENT); /* required */
|
.setUserHandle(UserHandle.CURRENT); /* required */
|
||||||
|
|
||||||
|
|
|
@ -98,12 +98,12 @@ public final class FeatureFlags {
|
||||||
public static final BooleanFlag ENABLE_DEVICE_SEARCH = new DeviceFlag(
|
public static final BooleanFlag ENABLE_DEVICE_SEARCH = new DeviceFlag(
|
||||||
"ENABLE_DEVICE_SEARCH", false, "Allows on device search in all apps");
|
"ENABLE_DEVICE_SEARCH", false, "Allows on device search in all apps");
|
||||||
|
|
||||||
public static final BooleanFlag USE_SEARCH_API = getDebugFlag(
|
|
||||||
"USE_SEARCH_API", true, "Use SearchUIManager api for device search");
|
|
||||||
|
|
||||||
public static final BooleanFlag DISABLE_INITIAL_IME_IN_ALLAPPS = getDebugFlag(
|
public static final BooleanFlag DISABLE_INITIAL_IME_IN_ALLAPPS = getDebugFlag(
|
||||||
"DISABLE_INITIAL_IME_IN_ALLAPPS", false, "Disable default IME state in all apps");
|
"DISABLE_INITIAL_IME_IN_ALLAPPS", false, "Disable default IME state in all apps");
|
||||||
|
|
||||||
|
public static final BooleanFlag DISABLE_SLICE_IN_ALLAPPS = getDebugFlag(
|
||||||
|
"DISABLE_SLICE_IN_ALLAPPS", true, "Disable slice in all apps");
|
||||||
|
|
||||||
public static final BooleanFlag FOLDER_NAME_SUGGEST = new DeviceFlag(
|
public static final BooleanFlag FOLDER_NAME_SUGGEST = new DeviceFlag(
|
||||||
"FOLDER_NAME_SUGGEST", true,
|
"FOLDER_NAME_SUGGEST", true,
|
||||||
"Suggests folder names instead of blank text.");
|
"Suggests folder names instead of blank text.");
|
||||||
|
|
|
@ -1,105 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2020 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.systemui.plugins;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.CancellationSignal;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
|
||||||
import com.android.systemui.plugins.shared.SearchTargetEventLegacy;
|
|
||||||
import com.android.systemui.plugins.shared.SearchTargetLegacy;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implement this plugin interface to fetch search result data from the plugin side.
|
|
||||||
*/
|
|
||||||
@ProvidesInterface(action = AllAppsSearchPlugin.ACTION, version = AllAppsSearchPlugin.VERSION)
|
|
||||||
public interface AllAppsSearchPlugin extends Plugin {
|
|
||||||
String ACTION = "com.android.systemui.action.PLUGIN_ALL_APPS_SEARCH_ACTIONS";
|
|
||||||
int VERSION = 9;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* init plugin
|
|
||||||
*/
|
|
||||||
void setup(Activity activity, View view, boolean useLegacy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send launcher state related signals.
|
|
||||||
*/
|
|
||||||
void onStateTransitionStart(int fromState, int toState);
|
|
||||||
|
|
||||||
void onStateTransitionComplete(int state);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send launcher window focus and visibility changed signals.
|
|
||||||
*/
|
|
||||||
void onWindowFocusChanged(boolean hasFocus);
|
|
||||||
|
|
||||||
void onWindowVisibilityChanged(int visibility);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send signal when user starts typing, perform search, notify search target
|
|
||||||
* event when search ends.
|
|
||||||
*/
|
|
||||||
void startedSearchSession();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main function that triggers search.
|
|
||||||
*
|
|
||||||
* @param input string that has been typed by a user
|
|
||||||
* @param inputArgs extra info that may be relevant for the input query
|
|
||||||
* @param results contains the result that will be rendered in all apps search
|
|
||||||
* surface
|
|
||||||
* @param cancellationSignal {@link CancellationSignal} can be used to share status of current
|
|
||||||
*/
|
|
||||||
void queryLegacy(String input, Bundle inputArgs, Consumer<List<SearchTargetLegacy>> results,
|
|
||||||
CancellationSignal cancellationSignal);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main function that triggers search.
|
|
||||||
*
|
|
||||||
* @param input string that has been typed by a user
|
|
||||||
* @param inputArgs extra info that may be relevant for the input query
|
|
||||||
* @param results contains the result that will be rendered in all apps search
|
|
||||||
* surface
|
|
||||||
* @param cancellationSignal {@link CancellationSignal} can be used to share status of current
|
|
||||||
*/
|
|
||||||
void query(String input, Bundle inputArgs, Consumer<List<Parcelable>> results,
|
|
||||||
CancellationSignal cancellationSignal);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send over search target interaction events to Plugin
|
|
||||||
*/
|
|
||||||
void notifySearchTargetEventLegacy(SearchTargetEventLegacy event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send over search target interaction events to Plugin
|
|
||||||
*/
|
|
||||||
void notifySearchTargetEvent(Parcelable event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launcher activity lifecycle callbacks
|
|
||||||
*/
|
|
||||||
void onResume(int state);
|
|
||||||
|
|
||||||
void onStop(int state);
|
|
||||||
}
|
|
|
@ -1,95 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2020 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.android.systemui.plugins.shared;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Event used for the feedback loop to the plugin. (and future aiai)
|
|
||||||
*
|
|
||||||
* @deprecated Use {@link android.app.search.SearchTargetEvent}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class SearchTargetEventLegacy {
|
|
||||||
public static final int POSITION_NONE = -1;
|
|
||||||
|
|
||||||
public static final int SELECT = 0;
|
|
||||||
public static final int QUICK_SELECT = 1;
|
|
||||||
public static final int LONG_PRESS = 2;
|
|
||||||
public static final int CHILD_SELECT = 3;
|
|
||||||
|
|
||||||
private final SearchTargetLegacy mSearchTarget;
|
|
||||||
private final int mEventType;
|
|
||||||
private final int mShortcutPosition;
|
|
||||||
private final Bundle mExtras;
|
|
||||||
|
|
||||||
public SearchTargetEventLegacy(SearchTargetLegacy searchTarget, int eventType,
|
|
||||||
int shortcutPosition,
|
|
||||||
Bundle extras) {
|
|
||||||
mSearchTarget = searchTarget;
|
|
||||||
mEventType = eventType;
|
|
||||||
mShortcutPosition = shortcutPosition;
|
|
||||||
mExtras = extras;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public SearchTargetLegacy getSearchTarget() {
|
|
||||||
return mSearchTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getShortcutPosition() {
|
|
||||||
return mShortcutPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getEventType() {
|
|
||||||
return mEventType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bundle getExtras() {
|
|
||||||
return mExtras;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A builder for {@link SearchTargetLegacy}
|
|
||||||
*/
|
|
||||||
public static final class Builder {
|
|
||||||
private final SearchTargetLegacy mSearchTarget;
|
|
||||||
private final int mEventType;
|
|
||||||
private int mShortcutPosition = POSITION_NONE;
|
|
||||||
private Bundle mExtras;
|
|
||||||
|
|
||||||
public Builder(SearchTargetLegacy searchTarget, int eventType) {
|
|
||||||
mSearchTarget = searchTarget;
|
|
||||||
mEventType = eventType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setShortcutPosition(int shortcutPosition) {
|
|
||||||
mShortcutPosition = shortcutPosition;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setExtras(Bundle extras) {
|
|
||||||
mExtras = extras;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SearchTargetEventLegacy build() {
|
|
||||||
return new SearchTargetEventLegacy(mSearchTarget, mEventType, mShortcutPosition,
|
|
||||||
mExtras);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,175 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2020 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.android.systemui.plugins.shared;
|
|
||||||
|
|
||||||
import android.app.RemoteAction;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.pm.ShortcutInfo;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.UserHandle;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to return all apps search targets.
|
|
||||||
*
|
|
||||||
* @deprecated Use SearchTarget
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class SearchTargetLegacy implements Comparable<SearchTargetLegacy> {
|
|
||||||
|
|
||||||
private final String mItemId;
|
|
||||||
private final String mItemType;
|
|
||||||
private final float mScore;
|
|
||||||
|
|
||||||
private final ComponentName mComponentName;
|
|
||||||
private final UserHandle mUserHandle;
|
|
||||||
private final List<ShortcutInfo> mShortcutInfos;
|
|
||||||
//TODO: (sfufa) replace with a list of a custom type
|
|
||||||
private final RemoteAction mRemoteAction;
|
|
||||||
private final Bundle mExtras;
|
|
||||||
|
|
||||||
private SearchTargetLegacy(String itemId, String itemType, float score,
|
|
||||||
ComponentName componentName, UserHandle userHandle, List<ShortcutInfo> shortcutInfos,
|
|
||||||
RemoteAction remoteAction, Bundle extras) {
|
|
||||||
mItemId = itemId;
|
|
||||||
mItemType = itemType;
|
|
||||||
mScore = score;
|
|
||||||
mComponentName = componentName;
|
|
||||||
mUserHandle = userHandle;
|
|
||||||
mShortcutInfos = shortcutInfos;
|
|
||||||
mExtras = extras;
|
|
||||||
mRemoteAction = remoteAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getItemId() {
|
|
||||||
return mItemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getItemType() {
|
|
||||||
return mItemType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentName getComponentName() {
|
|
||||||
return mComponentName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserHandle getUserHandle() {
|
|
||||||
return mUserHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getScore() {
|
|
||||||
return mScore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ShortcutInfo> getShortcutInfos() {
|
|
||||||
return mShortcutInfos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bundle getExtras() {
|
|
||||||
return mExtras;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RemoteAction getRemoteAction() {
|
|
||||||
return mRemoteAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(SearchTargetLegacy o) {
|
|
||||||
return Float.compare(o.mScore, mScore);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A builder for {@link SearchTargetLegacy}
|
|
||||||
*/
|
|
||||||
public static final class Builder {
|
|
||||||
|
|
||||||
|
|
||||||
private String mItemId;
|
|
||||||
|
|
||||||
private final String mItemType;
|
|
||||||
private final float mScore;
|
|
||||||
|
|
||||||
|
|
||||||
private ComponentName mComponentName;
|
|
||||||
private UserHandle mUserHandle;
|
|
||||||
private List<ShortcutInfo> mShortcutInfos;
|
|
||||||
private Bundle mExtras;
|
|
||||||
private RemoteAction mRemoteAction;
|
|
||||||
|
|
||||||
public Builder(String itemType, float score) {
|
|
||||||
this(itemType, score, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder(String itemType, float score, ComponentName cn,
|
|
||||||
UserHandle user) {
|
|
||||||
mItemType = itemType;
|
|
||||||
mScore = score;
|
|
||||||
mComponentName = cn;
|
|
||||||
mUserHandle = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getItemId() {
|
|
||||||
return mItemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getScore() {
|
|
||||||
return mScore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setItemId(String itemId) {
|
|
||||||
mItemId = itemId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setComponentName(ComponentName componentName) {
|
|
||||||
mComponentName = componentName;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setUserHandle(UserHandle userHandle) {
|
|
||||||
mUserHandle = userHandle;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setShortcutInfos(List<ShortcutInfo> shortcutInfos) {
|
|
||||||
mShortcutInfos = shortcutInfos;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setExtras(Bundle extras) {
|
|
||||||
mExtras = extras;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setRemoteAction(RemoteAction remoteAction) {
|
|
||||||
mRemoteAction = remoteAction;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a {@link SearchTargetLegacy}
|
|
||||||
*/
|
|
||||||
public SearchTargetLegacy build() {
|
|
||||||
if (mItemId == null) {
|
|
||||||
throw new IllegalStateException("Item ID is required for building SearchTarget");
|
|
||||||
}
|
|
||||||
return new SearchTargetLegacy(mItemId, mItemType, mScore, mComponentName, mUserHandle,
|
|
||||||
mShortcutInfos,
|
|
||||||
mRemoteAction, mExtras);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue