Merge "Add recent tasks to Taskbar" into sc-dev
diff --git a/Android.bp b/Android.bp
index b20b307..a720658 100644
--- a/Android.bp
+++ b/Android.bp
@@ -36,17 +36,37 @@
name: "launcher_log_protos_lite",
srcs: [
"protos/*.proto",
+ "protos_overrides/*.proto",
],
sdk_version: "current",
proto: {
type: "lite",
local_include_dirs:[
"protos",
+ "protos_overrides",
],
},
static_libs: ["libprotobuf-java-lite"],
}
+java_library_static {
+ name: "launcher_quickstep_log_protos_lite",
+ srcs: [
+ "quickstep/protos_overrides/*.proto",
+ ],
+ sdk_version: "current",
+ proto: {
+ type: "lite",
+ local_include_dirs:[
+ "quickstep/protos_overrides",
+ ],
+ },
+ static_libs: [
+ "libprotobuf-java-lite",
+ "launcher_log_protos_lite"
+ ],
+}
+
java_library {
name: "LauncherPluginLib",
diff --git a/Android.mk b/Android.mk
index ed42039..19ad328 100644
--- a/Android.mk
+++ b/Android.mk
@@ -33,7 +33,7 @@
LOCAL_STATIC_JAVA_LIBRARIES := \
LauncherPluginLib \
- launcher_log_protos_lite \
+ launcher_quickstep_log_protos_lite \
search_ui
LOCAL_SRC_FILES := \
@@ -65,7 +65,7 @@
$(call all-java-files-under, src_shortcuts_overrides) \
$(call all-java-files-under, src_ui_overrides) \
$(call all-java-files-under, ext_tests/src)
-
+
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/ext_tests/res
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
@@ -129,8 +129,7 @@
LOCAL_STATIC_JAVA_LIBRARIES := \
SystemUI-statsd \
- SystemUISharedLib \
- launcher_log_protos_lite
+ SystemUISharedLib
ifneq (,$(wildcard frameworks/base))
LOCAL_PRIVATE_PLATFORM_APIS := true
else
@@ -196,8 +195,7 @@
LOCAL_STATIC_JAVA_LIBRARIES := \
SystemUI-statsd \
- SystemUISharedLib \
- launcher_log_protos_lite
+ SystemUISharedLib
ifneq (,$(wildcard frameworks/base))
LOCAL_PRIVATE_PLATFORM_APIS := true
else
diff --git a/build.gradle b/build.gradle
index 28a05d5..a7eef13 100644
--- a/build.gradle
+++ b/build.gradle
@@ -81,7 +81,7 @@
java.srcDirs = ['src', 'src_plugins']
manifest.srcFile 'AndroidManifest-common.xml'
proto {
- srcDir 'protos/'
+ srcDirs = ['protos/', 'protos_overrides/']
}
}
@@ -181,4 +181,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/protos/launcher_atom.proto b/protos/launcher_atom.proto
index cd229ae..b4c6138 100644
--- a/protos/launcher_atom.proto
+++ b/protos/launcher_atom.proto
@@ -18,6 +18,8 @@
option java_package = "com.android.launcher3.logger";
option java_outer_classname = "LauncherAtom";
+import "launcher_atom_extension.proto";
+
//
// ItemInfos
message ItemInfo {
@@ -55,6 +57,7 @@
SettingsContainer settings_container = 9;
PredictedHotseatContainer predicted_hotseat_container = 10;
TaskSwitcherContainer task_switcher_container = 11;
+ ExtendedContainers extended_containers = 20;
}
}
diff --git a/protos_overrides/launcher_atom_extension.proto b/protos_overrides/launcher_atom_extension.proto
new file mode 100644
index 0000000..a07daf8
--- /dev/null
+++ b/protos_overrides/launcher_atom_extension.proto
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+syntax = "proto2";
+
+option java_package = "com.android.launcher3.logger";
+option java_outer_classname = "LauncherAtomExtensions";
+
+
+// This proto file contains placeholder messages that can be overridden by
+// other Launcher variants.
+// Variants could have its own launcher_atom_extension.proto file(should have
+// same messages declared here but with different implementation); when building
+// variant's apk launcher_atom.proto will reference variant's extension file,
+// essentially overriding this file.
+
+
+// Wrapper message for additional containers used in variants.
+message ExtendedContainers {}
diff --git a/quickstep/protos_overrides/launcher_atom_extension.proto b/quickstep/protos_overrides/launcher_atom_extension.proto
new file mode 100644
index 0000000..2766acf
--- /dev/null
+++ b/quickstep/protos_overrides/launcher_atom_extension.proto
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+syntax = "proto2";
+
+option java_package = "com.android.launcher3.logger";
+option java_outer_classname = "LauncherAtomExtensions";
+
+
+// Wrapper message for containers used at the quickstep level.
+// Message name should match with launcher_atom_extension.proto message at
+// the AOSP level.
+message ExtendedContainers {
+
+ oneof Container{
+ DeviceSearchResultContainer device_search_result_container = 1;
+ }
+}
+
+// Represents on-device search result container.
+message DeviceSearchResultContainer{
+}
diff --git a/quickstep/res/layout/search_result_icon_row.xml b/quickstep/res/layout/search_result_icon_row.xml
index 81190cf..084920a 100644
--- a/quickstep/res/layout/search_result_icon_row.xml
+++ b/quickstep/res/layout/search_result_icon_row.xml
@@ -20,10 +20,10 @@
android:padding="@dimen/dynamic_grid_edge_margin">
<com.android.launcher3.search.SearchResultIcon
- android:layout_width="wrap_content"
android:id="@+id/icon"
- launcher:iconDisplay="hero_app"
- android:layout_height="wrap_content" />
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ launcher:iconDisplay="hero_app" />
<LinearLayout
android:layout_width="0dp"
@@ -34,8 +34,8 @@
android:layout_gravity="center_vertical">
<TextView
- android:layout_width="wrap_content"
android:id="@id/title"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start|center_vertical"
android:maxLines="1"
diff --git a/quickstep/res/layout/search_result_small_icon_row.xml b/quickstep/res/layout/search_result_small_icon_row.xml
new file mode 100644
index 0000000..41856fe
--- /dev/null
+++ b/quickstep/res/layout/search_result_small_icon_row.xml
@@ -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>
\ No newline at end of file
diff --git a/quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java b/quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java
index acf6c15..4a656c1 100644
--- a/quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java
+++ b/quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java
@@ -16,6 +16,7 @@
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 android.app.search.SearchTarget;
@@ -31,6 +32,7 @@
import com.android.launcher3.allapps.AllAppsContainerView;
import com.android.launcher3.allapps.AllAppsGridAdapter;
import com.android.launcher3.allapps.search.SearchAdapterProvider;
+import com.android.launcher3.config.FeatureFlags;
/**
* Provides views for on-device search results
@@ -41,11 +43,12 @@
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_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_WIDGET_LIVE = 1 << 15;
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 SparseIntArray mViewTypeToLayoutMap = new SparseIntArray();
@@ -57,11 +60,13 @@
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_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_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_PREVIEW,
R.layout.search_result_widget_preview);
+ mViewTypeToLayoutMap.put(VIEW_TYPE_ALL_APPS_DIVIDER, R.layout.all_apps_divider);
}
@Override
@@ -116,25 +121,33 @@
case LayoutType.ICON_SINGLE_VERTICAL_TEXT:
return VIEW_TYPE_SEARCH_ICON;
case LayoutType.ICON_SLICE:
+ if (FeatureFlags.DISABLE_SLICE_IN_ALLAPPS.get()) {
+ return -1;
+ }
if (t.getSliceUri() != null) {
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;
case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT:
case LayoutType.ICON_SINGLE_HORIZONTAL_TEXT:
case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT_BUTTON:
+ case LayoutType.ICON_HORIZONTAL_TEXT:
return VIEW_TYPE_SEARCH_ICON_ROW;
+ case LayoutType.SMALL_ICON_HORIZONTAL_TEXT:
+ return VIEW_TYPE_SEARCH_SMALL_ICON_ROW;
case LayoutType.THUMBNAIL:
if (t.getSearchAction() != null) {
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;
case LayoutType.WIDGET_PREVIEW:
return VIEW_TYPE_SEARCH_WIDGET_PREVIEW;
case LayoutType.WIDGET_LIVE:
return VIEW_TYPE_SEARCH_WIDGET_LIVE;
+ case LayoutType.DIVIDER:
+ return VIEW_TYPE_ALL_APPS_DIVIDER;
}
return -1;
diff --git a/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java b/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java
index b402f61..8983c4f 100644
--- a/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java
+++ b/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java
@@ -18,6 +18,7 @@
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_SMALL_ICON_ROW;
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_WIDGET_LIVE;
@@ -26,7 +27,6 @@
import android.app.search.SearchTarget;
import com.android.launcher3.allapps.AllAppsGridAdapter;
-import com.android.systemui.plugins.shared.SearchTargetLegacy;
import java.util.ArrayList;
import java.util.List;
@@ -35,31 +35,23 @@
* Extension of AdapterItem that contains an extra payload specific to item
*/
public class SearchAdapterItem extends AllAppsGridAdapter.AdapterItem {
- private SearchTargetLegacy mSearchTargetLegacy;
private SearchTarget mSearchTarget;
private List<SearchTarget> mInlineItems = new ArrayList<>();
- private static final int AVAILABLE_FOR_ACCESSIBILITY =
- VIEW_TYPE_SEARCH_SLICE | VIEW_TYPE_SEARCH_THUMBNAIL | VIEW_TYPE_SEARCH_ICON_ROW
- | VIEW_TYPE_SEARCH_ICON | VIEW_TYPE_SEARCH_WIDGET_PREVIEW
- | VIEW_TYPE_SEARCH_WIDGET_LIVE;
-
-
- public SearchAdapterItem(SearchTargetLegacy searchTargetLegacy, int type) {
- mSearchTargetLegacy = searchTargetLegacy;
- viewType = type;
- }
+ private static final int AVAILABLE_FOR_ACCESSIBILITY = VIEW_TYPE_SEARCH_SLICE
+ | VIEW_TYPE_SEARCH_THUMBNAIL
+ | VIEW_TYPE_SEARCH_ICON_ROW
+ | VIEW_TYPE_SEARCH_ICON
+ | VIEW_TYPE_SEARCH_SMALL_ICON_ROW
+ | VIEW_TYPE_SEARCH_WIDGET_PREVIEW
+ | VIEW_TYPE_SEARCH_WIDGET_LIVE;
public SearchAdapterItem(SearchTarget searchTarget, int type) {
mSearchTarget = searchTarget;
viewType = type;
}
- public SearchTargetLegacy getSearchTargetLegacy() {
- return mSearchTargetLegacy;
- }
-
public SearchTarget getSearchTarget() {
return mSearchTarget;
}
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultIcon.java b/quickstep/src/com/android/launcher3/search/SearchResultIcon.java
index c353d7a..f7d5f45 100644
--- a/quickstep/src/com/android/launcher3/search/SearchResultIcon.java
+++ b/quickstep/src/com/android/launcher3/search/SearchResultIcon.java
@@ -49,6 +49,9 @@
import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.BitmapRenderer;
import com.android.launcher3.icons.LauncherIcons;
+import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
+import com.android.launcher3.logger.LauncherAtomExtensions.DeviceSearchResultContainer;
+import com.android.launcher3.logger.LauncherAtomExtensions.ExtendedContainers;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.PackageItemInfo;
@@ -142,8 +145,14 @@
SearchActionItemInfo itemInfo = new SearchActionItemInfo(searchAction.getIcon(),
searchTarget.getPackageName(), searchTarget.getUserHandle(),
- searchAction.getTitle()
- );
+ searchAction.getTitle()) {
+ // Workaround to log ItemInfo with DeviceSearchResultContainer without
+ // updating ItemInfo.container field.
+ @Override
+ public ContainerInfo getContainerInfo() {
+ return buildDeviceSearchResultContainer();
+ }
+ };
itemInfo.setIntent(searchAction.getIntent());
itemInfo.setPendingIntent(searchAction.getPendingIntent());
@@ -243,7 +252,15 @@
private void prepareUsingApp(ComponentName componentName, UserHandle userHandle) {
AllAppsStore appsStore = mLauncher.getAppsView().getAppsStore();
- AppInfo appInfo = appsStore.getApp(new ComponentKey(componentName, userHandle));
+ AppInfo appInfo = new AppInfo(
+ appsStore.getApp(new ComponentKey(componentName, userHandle))) {
+ // Workaround to log ItemInfo with DeviceSearchResultContainer without
+ // updating ItemInfo.container field.
+ @Override
+ public ContainerInfo getContainerInfo() {
+ return buildDeviceSearchResultContainer();
+ }
+ };
if (appInfo == null) {
setVisibility(GONE);
@@ -253,9 +270,15 @@
notifyItemInfoChanged(appInfo);
}
-
private void prepareUsingShortcutInfo(ShortcutInfo shortcutInfo) {
- WorkspaceItemInfo workspaceItemInfo = new WorkspaceItemInfo(shortcutInfo, getContext());
+ WorkspaceItemInfo workspaceItemInfo = new WorkspaceItemInfo(shortcutInfo, getContext()) {
+ // Workaround to log ItemInfo with DeviceSearchResultContainer without
+ // updating ItemInfo.container field.
+ @Override
+ public ContainerInfo getContainerInfo() {
+ return buildDeviceSearchResultContainer();
+ }
+ };
notifyItemInfoChanged(workspaceItemInfo);
LauncherAppState launcherAppState = LauncherAppState.getInstance(getContext());
MODEL_EXECUTOR.execute(() -> {
@@ -293,4 +316,14 @@
mOnItemInfoChanged = null;
}
}
+
+ private static ContainerInfo buildDeviceSearchResultContainer() {
+ return ContainerInfo.newBuilder().setExtendedContainers(
+ ExtendedContainers
+ .newBuilder()
+ .setDeviceSearchResultContainer(
+ DeviceSearchResultContainer
+ .newBuilder()))
+ .build();
+ }
}
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java b/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java
index 7c3ed69..12a1a1c 100644
--- a/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java
+++ b/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java
@@ -46,12 +46,12 @@
public static final int MAX_INLINE_ITEMS = 3;
protected final Launcher mLauncher;
- private final LauncherAppState mLauncherAppState;
- protected SearchResultIcon mResultIcon;
+ protected final SearchResultIcon[] mInlineIcons = new SearchResultIcon[MAX_INLINE_ITEMS];
+ private SearchResultIcon mResultIcon;
+ private final LauncherAppState mLauncherAppState;
private TextView mTitleView;
private TextView mSubTitleView;
- protected final SearchResultIcon[] mInlineIcons = new SearchResultIcon[MAX_INLINE_ITEMS];
private PackageItemInfo mProviderInfo;
@@ -77,13 +77,14 @@
@Override
protected void onFinishInflate() {
super.onFinishInflate();
-
int iconSize = getIconSize();
mResultIcon = findViewById(R.id.icon);
+
mTitleView = findViewById(R.id.title);
mSubTitleView = findViewById(R.id.subtitle);
mSubTitleView.setVisibility(GONE);
+
mResultIcon.getLayoutParams().height = iconSize;
mResultIcon.getLayoutParams().width = iconSize;
mResultIcon.setTextVisibility(false);
@@ -94,15 +95,16 @@
for (SearchResultIcon inlineIcon : mInlineIcons) {
inlineIcon.getLayoutParams().width = getIconSize();
}
-
setOnClickListener(mResultIcon);
setOnLongClickListener(mResultIcon);
}
@Override
public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
- showSubtitleIfNeeded(null);
mResultIcon.apply(parentTarget, children, this::onItemInfoCreated);
+
+ showSubtitleIfNeeded(null);
+
if (parentTarget.getShortcutInfo() != null) {
updateWithShortcutInfo(parentTarget.getShortcutInfo());
} else if (parentTarget.getSearchAction() != null) {
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultSmallIconRow.java b/quickstep/src/com/android/launcher3/search/SearchResultSmallIconRow.java
new file mode 100644
index 0000000..ca8aa81
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/search/SearchResultSmallIconRow.java
@@ -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);
+ }
+}
diff --git a/quickstep/src/com/android/launcher3/search/SearchTargetUtil.java b/quickstep/src/com/android/launcher3/search/SearchTargetUtil.java
index 0abed03..ede3b9d 100644
--- a/quickstep/src/com/android/launcher3/search/SearchTargetUtil.java
+++ b/quickstep/src/com/android/launcher3/search/SearchTargetUtil.java
@@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.android.launcher3.search;
-import static com.android.app.search.LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT;
-import static com.android.app.search.LayoutType.ICON_SINGLE_HORIZONTAL_TEXT;
+import static com.android.app.search.LayoutType.DIVIDER;
+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.ResultType.ACTION;
import static com.android.app.search.ResultType.SCREENSHOT;
@@ -54,17 +56,17 @@
/**
- * Generate SearchTargetUtil for ICON_DOUBLE_HORIZONTAL_TEXT layout type.
+ * Generate SearchTargetUtil for ICON_HORIZONTAL_TEXT layout type.
*
* targets.add(SearchTargetUtil.generateIconDoubleHorizontalText_SearchAction(
* mContext, "red", Color.RED));
* targets.add(SearchTargetUtil.generateIconDoubleHorizontalText_SearchAction(
* mContext, "yellow", Color.YELLOW));
*/
- public static SearchTarget generateIconDoubleHorizontalText_SearchAction(
+ public static SearchTarget generateIcoHorizontalText_usingSearchAction(
Context context, String id, int color) {
SearchTarget.Builder builder =
- new SearchTarget.Builder(ACTION, ICON_DOUBLE_HORIZONTAL_TEXT, id)
+ new SearchTarget.Builder(ACTION, ICON_HORIZONTAL_TEXT, id)
.setPackageName(PACKAGE2) /* required */
.setUserHandle(USERHANDLE); /* required */
@@ -102,7 +104,7 @@
* targets.add(SearchTargetUtil.generateThumbnail_SearchAction("red", Color.RED));
* 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 =
new SearchTarget.Builder(SCREENSHOT, THUMBNAIL, id)
.setPackageName(PACKAGE2) /* required */
@@ -130,16 +132,19 @@
}
/**
+ * Generate SearchTargetUtil for SMALL_ICON_HORIZONTAL_TEXT layout type.
+ *
* targets.add(SearchTargetUtil.generateIconHorizontalText_SearchAction(
* mContext, "red", Color.RED));
* targets.add(SearchTargetUtil.generateIconHorizontalText_SearchAction(
* mContext, "yellow", Color.YELLOW));
*/
- public static SearchTarget generateIconHorizontalText_SearchAction(
+ public static SearchTarget generateSmallIconHorizontalText_usingSearchAction(
Context context, String id, int color) {
- String fallbackQuery = "How to make cookie";
+ String title = "Ask the assistant";
+ String fallbackQuery = "sourdough bread";
SearchTarget.Builder builder =
- new SearchTarget.Builder(SUGGEST, ICON_SINGLE_HORIZONTAL_TEXT, id)
+ new SearchTarget.Builder(SUGGEST, SMALL_ICON_HORIZONTAL_TEXT, id)
.setPackageName(PACKAGE2) /* required */
.setUserHandle(USERHANDLE); /* required */
@@ -159,7 +164,8 @@
Bundle extra = new Bundle();
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)
.setIcon(icon)
.setExtras(extra)
@@ -167,6 +173,14 @@
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.
@@ -174,7 +188,7 @@
public static SearchTarget generateIconDoubleHorizontalText_ShortcutInfo(Context context) {
String id = "23456";
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 */
.setUserHandle(UserHandle.CURRENT); /* required */
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index a00ce56..ee00ed2 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -24,6 +24,8 @@
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW_MODAL_TASK;
import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent;
+import static com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.EXTENDED_CONTAINERS;
+import static com.android.launcher3.logger.LauncherAtomExtensions.ExtendedContainers.ContainerCase.DEVICE_SEARCH_RESULT_CONTAINER;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP;
import static com.android.launcher3.testing.TestProtocol.HINT_STATE_ORDINAL;
import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL;
@@ -81,6 +83,7 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Objects;
+import java.util.Optional;
import java.util.stream.Stream;
public class QuickstepLauncher extends BaseQuickstepLauncher {
@@ -105,6 +108,15 @@
@Override
protected void logAppLaunch(ItemInfo info, InstanceId instanceId) {
+ // If the app launch is from DeviceSearchResultContainer then add the InstanceId from
+ // LiveSearchManager to recreate the AllApps search session on the server side.
+ Optional<InstanceId> logInstanceId = this.getLiveSearchManager().getLogInstanceId();
+ if (info.getContainerInfo().getContainerCase() == EXTENDED_CONTAINERS
+ && info.getContainerInfo().getExtendedContainers().getContainerCase()
+ == DEVICE_SEARCH_RESULT_CONTAINER && logInstanceId.isPresent()) {
+ instanceId = logInstanceId.get();
+ }
+
StatsLogger logger = getStatsLogManager()
.logger().withItemInfo(info).withInstanceId(instanceId);
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 6bcc4bf..36b51cd 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -731,7 +731,6 @@
setIsLikelyToStartNewTask(isLikelyToStartNewTask, false /* animate */);
mStateCallback.setStateOnUiThread(STATE_GESTURE_STARTED);
mGestureStarted = true;
- mTaskViewSimulator.setDrawsBelowRecents(true);
}
/**
@@ -958,7 +957,6 @@
if (endTarget == HOME) {
duration = Math.max(MIN_OVERSHOOT_DURATION, duration);
} else if (endTarget == RECENTS) {
- LiveTileOverlay.INSTANCE.startIconAnimation();
if (mRecentsView != null) {
int nearestPage = mRecentsView.getPageNearestToCenterOfScreen();
if (mRecentsView.getNextPage() != nearestPage) {
@@ -971,9 +969,6 @@
}
duration = Math.max(duration, mRecentsView.getScroller().getDuration());
}
- if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
- mRecentsView.getRunningTaskView().setIsClickableAsLiveTile(false);
- }
}
// Let RecentsView handle the scrolling to the task, which we launch in startNewTask()
@@ -1067,7 +1062,6 @@
}
if (mGestureState.getEndTarget() == HOME) {
- mTaskViewSimulator.setDrawsBelowRecents(false);
getOrientationHandler().adjustFloatingIconStartVelocity(velocityPxPerMs);
final RemoteAnimationTargetCompat runningTaskTarget = mRecentsAnimationTargets != null
? mRecentsAnimationTargets.findTask(mGestureState.getRunningTaskId())
@@ -1453,10 +1447,6 @@
private void finishCurrentTransitionToRecents() {
if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED);
- final TaskView runningTaskView = mRecentsView.getRunningTaskView();
- if (runningTaskView != null) {
- runningTaskView.setIsClickableAsLiveTile(true);
- }
} else if (!hasTargets() || mRecentsAnimationController == null) {
// If there are no targets or the animation not started, then there is nothing to finish
mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED);
diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
index d949126..d22496d 100644
--- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
+++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
@@ -16,6 +16,7 @@
package com.android.quickstep.logging;
+import static com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.EXTENDED_CONTAINERS;
import static com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.FOLDER;
import static com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.SEARCH_RESULT_CONTAINER;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORKSPACE_SNAPSHOT;
@@ -72,6 +73,7 @@
private static final int DEFAULT_PAGE_INDEX = -2;
private static final int FOLDER_HIERARCHY_OFFSET = 100;
private static final int SEARCH_RESULT_HIERARCHY_OFFSET = 200;
+ private static final int EXTENDED_CONTAINERS_HIERARCHY_OFFSET = 300;
public static final CopyOnWriteArrayList<StatsLogConsumer> LOGS_CONSUMER =
new CopyOnWriteArrayList<>();
@@ -397,6 +399,9 @@
} else if (info.getContainerInfo().getContainerCase() == SEARCH_RESULT_CONTAINER) {
return info.getContainerInfo().getSearchResultContainer().getParentContainerCase()
.getNumber() + SEARCH_RESULT_HIERARCHY_OFFSET;
+ } else if (info.getContainerInfo().getContainerCase() == EXTENDED_CONTAINERS) {
+ return info.getContainerInfo().getExtendedContainers().getContainerCase().getNumber()
+ + EXTENDED_CONTAINERS_HIERARCHY_OFFSET;
} else {
return info.getContainerInfo().getContainerCase().getNumber();
}
diff --git a/quickstep/src/com/android/quickstep/views/LiveTileOverlay.java b/quickstep/src/com/android/quickstep/views/LiveTileOverlay.java
index 747c3f2..8210ab0 100644
--- a/quickstep/src/com/android/quickstep/views/LiveTileOverlay.java
+++ b/quickstep/src/com/android/quickstep/views/LiveTileOverlay.java
@@ -85,6 +85,11 @@
mIcon = icon;
}
+ // TODO: consider cleaning this up and drawing icon in another way. Previously we place app
+ // below launcher during the initial swipe up and render the icon in this live tile overlay.
+ // However, this resulted in a bunch of touch input issues caused by Launcher getting the input
+ // events during transition (to overview / to another app (quick switch). So now our new
+ // solution places app on top in live tile until it fully settles in Overview.
public void startIconAnimation() {
if (mIconAnimator != null) {
mIconAnimator.cancel();
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 2f2b566..d9d0a93 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -2277,7 +2277,9 @@
}
public void redrawLiveTile() {
- mLiveTileTaskViewSimulator.apply(mLiveTileParams);
+ if (mLiveTileParams.getTargetSet() != null) {
+ mLiveTileTaskViewSimulator.apply(mLiveTileParams);
+ }
}
public TaskViewSimulator getLiveTileTaskViewSimulator() {
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index e8f590f..59cf3b2 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -356,10 +356,6 @@
return false;
}
- public void setIsClickableAsLiveTile(boolean isClickableAsLiveTile) {
- mIsClickableAsLiveTile = isClickableAsLiveTile;
- }
-
private void computeAndSetIconTouchDelegate() {
float iconHalfSize = mIconView.getWidth() / 2f;
mIconCenterCoords[0] = mIconCenterCoords[1] = iconHalfSize;
diff --git a/src/com/android/launcher3/allapps/AllAppsInsetTransitionController.java b/src/com/android/launcher3/allapps/AllAppsInsetTransitionController.java
index 1cf98e1..f6e54aa 100644
--- a/src/com/android/launcher3/allapps/AllAppsInsetTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsInsetTransitionController.java
@@ -164,8 +164,11 @@
@Override
public void onCancelled(@Nullable WindowInsetsAnimationController controller) {
if (DEBUG) {
- Log.d(TAG, "Listener.onCancelled ctrl=" + controller
- + " mAnimationController=" + mAnimationController);
+ // Keep the verbose logging to chase down IME not showing up issue.
+ // b/178904132
+ Log.e(TAG, "Listener.onCancelled ctrl=" + controller
+ + " mAnimationController=" + mAnimationController,
+ new Exception());
}
if (mState == State.DRAG_START_BOTTOM) {
mState = State.DRAG_START_BOTTOM_IME_CANCELLED;
diff --git a/src/com/android/launcher3/allapps/search/LiveSearchManager.java b/src/com/android/launcher3/allapps/search/LiveSearchManager.java
index ec33908..c2f0b96 100644
--- a/src/com/android/launcher3/allapps/search/LiveSearchManager.java
+++ b/src/com/android/launcher3/allapps/search/LiveSearchManager.java
@@ -33,10 +33,13 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
+import com.android.launcher3.logging.InstanceId;
+import com.android.launcher3.logging.InstanceIdSequence;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.widget.PendingAddWidgetInfo;
import java.util.HashMap;
+import java.util.Optional;
/**
* Manages Lifecycle for Live search results
@@ -51,6 +54,7 @@
new HashMap<>();
private final HashMap<Uri, LiveData<Slice>> mUriSliceMap = new HashMap<>();
private SearchWidgetHost mSearchWidgetHost;
+ private InstanceId mLogInstanceId;
public LiveSearchManager(Launcher launcher) {
mLauncher = launcher;
@@ -113,6 +117,7 @@
*/
public void start() {
stop();
+ mLogInstanceId = new InstanceIdSequence().newInstanceId();
mSearchWidgetHost = new SearchWidgetHost(mLauncher);
mSearchWidgetHost.startListening();
}
@@ -136,6 +141,14 @@
mUriSliceMap.clear();
}
+ /**
+ * Returns {@link InstanceId} that should be used for logging events within search session, if
+ * available.
+ */
+ public Optional<InstanceId> getLogInstanceId() {
+ return Optional.ofNullable(mLogInstanceId);
+ }
+
static class SearchWidgetHost extends AppWidgetHost {
SearchWidgetHost(Context context) {
super(context, SEARCH_APPWIDGET_HOST_ID);
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 086d665..b61799f 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -98,12 +98,12 @@
public static final BooleanFlag ENABLE_DEVICE_SEARCH = new DeviceFlag(
"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(
"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(
"FOLDER_NAME_SUGGEST", true,
"Suggests folder names instead of blank text.");
diff --git a/src/com/android/launcher3/graphics/PreloadIconDrawable.java b/src/com/android/launcher3/graphics/PreloadIconDrawable.java
index 304d496..ce824df 100644
--- a/src/com/android/launcher3/graphics/PreloadIconDrawable.java
+++ b/src/com/android/launcher3/graphics/PreloadIconDrawable.java
@@ -24,6 +24,7 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
+import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
@@ -34,10 +35,12 @@
import android.util.Pair;
import android.util.Property;
import android.util.SparseArray;
+import android.view.ContextThemeWrapper;
import com.android.launcher3.FastBitmapDrawable;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.model.data.ItemInfoWithIcon;
+import com.android.launcher3.util.Themes;
import java.lang.ref.WeakReference;
@@ -77,6 +80,9 @@
private static final SparseArray<WeakReference<Pair<Path, Bitmap>>> sShadowCache =
new SparseArray<>();
+ private static final int PRELOAD_ACCENT_COLOR_INDEX = 0;
+ private static final int PRELOAD_BACKGROUND_COLOR_INDEX = 1;
+
private final Matrix mTmpMatrix = new Matrix();
private final PathMeasure mPathMeasure = new PathMeasure();
@@ -91,6 +97,9 @@
private Bitmap mShadowBitmap;
private final int mIndicatorColor;
+ private final int mSystemAccentColor;
+ private final int mSystemBackgroundColor;
+ private final boolean mIsDarkMode;
private int mTrackAlpha;
private float mTrackLength;
@@ -104,11 +113,23 @@
private ObjectAnimator mCurrentAnim;
+ private boolean mIsStartable;
+
public PreloadIconDrawable(ItemInfoWithIcon info, Context context) {
- this(info, IconPalette.getPreloadProgressColor(context, info.bitmap.color));
+ this(
+ info,
+ IconPalette.getPreloadProgressColor(context, info.bitmap.color),
+ getPreloadColors(context),
+ (context.getResources().getConfiguration().uiMode
+ & Configuration.UI_MODE_NIGHT_MASK
+ & Configuration.UI_MODE_NIGHT_YES) != 0) /* isDarkMode */;
}
- public PreloadIconDrawable(ItemInfoWithIcon info, int indicatorColor) {
+ public PreloadIconDrawable(
+ ItemInfoWithIcon info,
+ int indicatorColor,
+ int[] preloadColors,
+ boolean isDarkMode) {
super(info.bitmap);
mItem = info;
mShapePath = getShapePath();
@@ -120,9 +141,12 @@
mProgressPaint.setStrokeCap(Paint.Cap.ROUND);
mIndicatorColor = indicatorColor;
- setInternalProgress(0);
+ mSystemAccentColor = preloadColors[PRELOAD_ACCENT_COLOR_INDEX];
+ mSystemBackgroundColor = preloadColors[PRELOAD_BACKGROUND_COLOR_INDEX];
+ mIsDarkMode = isDarkMode;
- setIsDisabled(!info.isAppStartable());
+ setInternalProgress(info.getProgressLevel());
+ setIsStartable(info.isAppStartable());
}
@Override
@@ -148,7 +172,7 @@
}
private Bitmap getShadowBitmap(int width, int height, float shadowRadius) {
- int key = (width << 16) | height;
+ int key = ((width << 16) | height) * (mIsDarkMode ? -1 : 1);
WeakReference<Pair<Path, Bitmap>> shadowRef = sShadowCache.get(key);
Pair<Path, Bitmap> cache = shadowRef != null ? shadowRef.get() : null;
Bitmap shadow = cache != null && cache.first.equals(mShapePath) ? cache.second : null;
@@ -157,8 +181,9 @@
}
shadow = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(shadow);
- mProgressPaint.setShadowLayer(shadowRadius, 0, 0, COLOR_SHADOW);
- mProgressPaint.setColor(COLOR_TRACK);
+ mProgressPaint.setShadowLayer(shadowRadius, 0, 0, mIsStartable
+ ? COLOR_SHADOW : mSystemAccentColor);
+ mProgressPaint.setColor(mIsStartable ? COLOR_TRACK : mSystemBackgroundColor);
mProgressPaint.setAlpha(MAX_PAINT_ALPHA);
c.drawPath(mScaledTrackPath, mProgressPaint);
mProgressPaint.clearShadowLayer();
@@ -176,7 +201,7 @@
}
// Draw track.
- mProgressPaint.setColor(mIndicatorColor);
+ mProgressPaint.setColor(mIsStartable ? mIndicatorColor : mSystemAccentColor);
mProgressPaint.setAlpha(mTrackAlpha);
if (mShadowBitmap != null) {
canvas.drawBitmap(mShadowBitmap, bounds.left, bounds.top, mProgressPaint);
@@ -215,6 +240,14 @@
return !mRanFinishAnimation;
}
+ /** Sets whether this icon should display the startable app UI. */
+ public void setIsStartable(boolean isStartable) {
+ if (mIsStartable != isStartable) {
+ mIsStartable = isStartable;
+ setIsDisabled(!isStartable);
+ }
+ }
+
private void updateInternalState(float finalProgress, boolean shouldAnimate, boolean isFinish) {
if (mCurrentAnim != null) {
mCurrentAnim.cancel();
@@ -295,6 +328,18 @@
invalidateSelf();
}
+ private static int[] getPreloadColors(Context context) {
+ Context dayNightThemeContext = new ContextThemeWrapper(
+ context, android.R.style.Theme_DeviceDefault_DayNight);
+ int[] preloadColors = new int[2];
+
+ preloadColors[PRELOAD_ACCENT_COLOR_INDEX] = Themes.getColorAccent(dayNightThemeContext);
+ preloadColors[PRELOAD_BACKGROUND_COLOR_INDEX] = Themes.getColorBackgroundFloating(
+ dayNightThemeContext);
+
+ return preloadColors;
+ }
+
/**
* Returns a FastBitmapDrawable with the icon.
*/
@@ -305,13 +350,21 @@
@Override
public ConstantState getConstantState() {
return new PreloadIconConstantState(
- mBitmap, mIconColor, !mItem.isAppStartable(), mItem, mIndicatorColor);
+ mBitmap,
+ mIconColor,
+ !mItem.isAppStartable(),
+ mItem,
+ mIndicatorColor,
+ new int[] {mSystemAccentColor, mSystemBackgroundColor},
+ mIsDarkMode);
}
protected static class PreloadIconConstantState extends FastBitmapConstantState {
protected final ItemInfoWithIcon mInfo;
protected final int mIndicatorColor;
+ protected final int[] mPreloadColors;
+ protected final boolean mIsDarkMode;
protected final int mLevel;
public PreloadIconConstantState(
@@ -319,19 +372,24 @@
int iconColor,
boolean isDisabled,
ItemInfoWithIcon info,
- int indicatorcolor) {
+ int indicatorColor,
+ int[] preloadColors,
+ boolean isDarkMode) {
super(bitmap, iconColor, isDisabled);
mInfo = info;
- mIndicatorColor = indicatorcolor;
+ mIndicatorColor = indicatorColor;
+ mPreloadColors = preloadColors;
+ mIsDarkMode = isDarkMode;
mLevel = info.getProgressLevel();
}
@Override
public PreloadIconDrawable newDrawable() {
- PreloadIconDrawable drawable = new PreloadIconDrawable(mInfo, mIndicatorColor);
- drawable.setLevel(mLevel);
- drawable.setIsDisabled(mIsDisabled);
- return drawable;
+ return new PreloadIconDrawable(
+ mInfo,
+ mIndicatorColor,
+ mPreloadColors,
+ mIsDarkMode);
}
@Override
diff --git a/src/com/android/launcher3/model/data/ItemInfo.java b/src/com/android/launcher3/model/data/ItemInfo.java
index b11b419..3851ab0 100644
--- a/src/com/android/launcher3/model/data/ItemInfo.java
+++ b/src/com/android/launcher3/model/data/ItemInfo.java
@@ -225,7 +225,7 @@
protected String dumpProperties() {
return "id=" + id
+ " type=" + LauncherSettings.Favorites.itemTypeToString(itemType)
- + " container=" + LauncherSettings.Favorites.containerToString(container)
+ + " container=" + getContainerInfo()
+ " targetComponent=" + getTargetComponent()
+ " screen=" + screenId
+ " cell(" + cellX + "," + cellY + ")"
@@ -352,7 +352,10 @@
return itemBuilder;
}
- protected ContainerInfo getContainerInfo() {
+ /**
+ * Returns {@link ContainerInfo} used when logging this item.
+ */
+ public ContainerInfo getContainerInfo() {
switch (container) {
case CONTAINER_HOTSEAT:
return ContainerInfo.newBuilder()
diff --git a/src/com/android/launcher3/util/Themes.java b/src/com/android/launcher3/util/Themes.java
index b74686f..55d17fc 100644
--- a/src/com/android/launcher3/util/Themes.java
+++ b/src/com/android/launcher3/util/Themes.java
@@ -81,6 +81,11 @@
return getAttrColor(context, android.R.attr.colorAccent);
}
+ /** Returns the floating background color attribute. */
+ public static int getColorBackgroundFloating(Context context) {
+ return getAttrColor(context, android.R.attr.colorBackgroundFloating);
+ }
+
public static int getAttrColor(Context context, int attr) {
TypedArray ta = context.obtainStyledAttributes(new int[]{attr});
int colorAccent = ta.getColor(0, 0);
diff --git a/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java b/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java
deleted file mode 100644
index 0b48c07..0000000
--- a/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java
+++ /dev/null
@@ -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);
-}
\ No newline at end of file
diff --git a/src_plugins/com/android/systemui/plugins/shared/SearchTargetEventLegacy.java b/src_plugins/com/android/systemui/plugins/shared/SearchTargetEventLegacy.java
deleted file mode 100644
index 0fc61f0..0000000
--- a/src_plugins/com/android/systemui/plugins/shared/SearchTargetEventLegacy.java
+++ /dev/null
@@ -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);
- }
- }
-
-}
diff --git a/src_plugins/com/android/systemui/plugins/shared/SearchTargetLegacy.java b/src_plugins/com/android/systemui/plugins/shared/SearchTargetLegacy.java
deleted file mode 100644
index 2a6ba88..0000000
--- a/src_plugins/com/android/systemui/plugins/shared/SearchTargetLegacy.java
+++ /dev/null
@@ -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);
- }
- }
-}