Merge "Map shell transition to recents animation" into sc-dev
diff --git a/quickstep/res/layout/search_result_icon_row.xml b/quickstep/res/layout/search_result_icon_row.xml
index 2119fc3..81190cf 100644
--- a/quickstep/res/layout/search_result_icon_row.xml
+++ b/quickstep/res/layout/search_result_icon_row.xml
@@ -57,9 +57,10 @@
style="@style/BaseIcon"
android:layout_width="@dimen/deep_shortcut_icon_size"
android:layout_height="match_parent"
- android:gravity="start|center_vertical"
+ android:layout_marginStart="4dp"
+ android:gravity="center"
launcher:iconDisplay="shortcut_popup"
- android:textSize="@dimen/search_hero_subtitle_size"
+ android:textSize="@dimen/search_hero_inline_button_size"
launcher:iconSizeOverride="@dimen/deep_shortcut_icon_size"
launcher:layoutHorizontal="false" />
@@ -68,6 +69,20 @@
style="@style/BaseIcon"
android:layout_width="@dimen/deep_shortcut_icon_size"
android:layout_height="match_parent"
+ android:layout_marginStart="4dp"
+ android:gravity="center"
+ launcher:iconDisplay="shortcut_popup"
+ android:textSize="@dimen/search_hero_inline_button_size"
+ launcher:iconSizeOverride="@dimen/deep_shortcut_icon_size"
+ launcher:layoutHorizontal="false" />
+
+ <com.android.launcher3.search.SearchResultIcon
+ android:id="@+id/shortcut_2"
+ style="@style/BaseIcon"
+ android:layout_width="@dimen/deep_shortcut_icon_size"
+ android:layout_height="match_parent"
+ android:layout_marginStart="4dp"
+ android:gravity="center"
launcher:iconDisplay="shortcut_popup"
android:textSize="@dimen/search_hero_inline_button_size"
launcher:iconSizeOverride="@dimen/deep_shortcut_icon_size"
diff --git a/quickstep/res/layout/search_result_people_item.xml b/quickstep/res/layout/search_result_people_item.xml
deleted file mode 100644
index 964300d..0000000
--- a/quickstep/res/layout/search_result_people_item.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!-- 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.
--->
-<com.android.launcher3.search.SearchResultPeopleView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:gravity="center_vertical"
- android:layout_height="wrap_content"
- android:padding="8dp"
- android:orientation="horizontal">
-
- <View
- android:id="@+id/icon"
- android:layout_marginRight="8dp"
- android:layout_width="@dimen/deep_shortcut_icon_size"
- android:layout_height="@dimen/deep_shortcut_icon_size" />
-
- <TextView
- android:layout_width="0dp"
- android:textColor="?android:attr/textColorPrimary"
- android:id="@+id/title"
- android:textSize="@dimen/search_hero_title_size"
- android:layout_height="wrap_content"
- android:layout_weight="1" />
-
- <ImageButton
- android:id="@+id/provider_0"
- android:scaleType="fitCenter"
- android:adjustViewBounds="true"
- android:layout_margin="5dp"
- android:background="?android:attr/selectableItemBackground"
- android:layout_width="@dimen/deep_shortcut_icon_size"
- android:layout_height="@dimen/deep_shortcut_icon_size" />
-
- <ImageButton
- android:id="@+id/provider_1"
- android:layout_margin="5dp"
- android:scaleType="fitCenter"
- android:adjustViewBounds="true"
- android:background="?android:attr/selectableItemBackground"
- android:layout_width="@dimen/deep_shortcut_icon_size"
- android:layout_height="@dimen/deep_shortcut_icon_size" />
-
- <ImageButton
- android:id="@+id/provider_2"
- android:layout_margin="5dp"
- android:scaleType="fitCenter"
- android:adjustViewBounds="true"
- android:background="?android:attr/selectableItemBackground"
- android:layout_width="@dimen/deep_shortcut_icon_size"
- android:layout_height="@dimen/deep_shortcut_icon_size" />
-
-</com.android.launcher3.search.SearchResultPeopleView>
\ 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 02be0b9..acf6c15 100644
--- a/quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java
+++ b/quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java
@@ -41,7 +41,6 @@
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_PEOPLE = 1 << 11;
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;
@@ -59,7 +58,6 @@
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_SLICE, R.layout.search_result_slice);
- mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_PEOPLE, R.layout.search_result_people_item);
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,
@@ -125,6 +123,7 @@
break;
case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT:
case LayoutType.ICON_SINGLE_HORIZONTAL_TEXT:
+ case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT_BUTTON:
return VIEW_TYPE_SEARCH_ICON_ROW;
case LayoutType.THUMBNAIL:
if (t.getSearchAction() != null) {
diff --git a/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java b/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java
index 0eb3edb..b402f61 100644
--- a/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java
+++ b/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java
@@ -18,7 +18,6 @@
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_PEOPLE;
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;
@@ -42,9 +41,10 @@
private static final int AVAILABLE_FOR_ACCESSIBILITY =
- VIEW_TYPE_SEARCH_SLICE | VIEW_TYPE_SEARCH_PEOPLE | VIEW_TYPE_SEARCH_THUMBNAIL
- | VIEW_TYPE_SEARCH_ICON_ROW | VIEW_TYPE_SEARCH_ICON
- | VIEW_TYPE_SEARCH_WIDGET_PREVIEW | VIEW_TYPE_SEARCH_WIDGET_LIVE;
+ 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;
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultIcon.java b/quickstep/src/com/android/launcher3/search/SearchResultIcon.java
index 3d89ac5..c353d7a 100644
--- a/quickstep/src/com/android/launcher3/search/SearchResultIcon.java
+++ b/quickstep/src/com/android/launcher3/search/SearchResultIcon.java
@@ -15,12 +15,9 @@
*/
package com.android.launcher3.search;
-import static com.android.launcher3.model.data.SearchActionItemInfo.FLAG_BADGE_FROM_ICON;
+import static com.android.launcher3.model.data.SearchActionItemInfo.FLAG_BADGE_WITH_PACKAGE;
import static com.android.launcher3.model.data.SearchActionItemInfo.FLAG_PRIMARY_ICON_FROM_TITLE;
-import static com.android.launcher3.search.SearchTargetUtil.BUNDLE_EXTRA_BADGE_FROM_ICON;
import static com.android.launcher3.search.SearchTargetUtil.BUNDLE_EXTRA_PRIMARY_ICON_FROM_TITLE;
-import static com.android.launcher3.search.SearchTargetUtil.BUNDLE_EXTRA_SHOULD_START;
-import static com.android.launcher3.search.SearchTargetUtil.BUNDLE_EXTRA_SHOULD_START_FOR_RESULT;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
@@ -30,9 +27,14 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ShortcutInfo;
-import android.graphics.drawable.Drawable;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Paint;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffXfermode;
+import android.graphics.Rect;
+import android.graphics.RectF;
import android.graphics.drawable.Icon;
-import android.os.Build;
import android.os.Bundle;
import android.os.UserHandle;
import android.util.AttributeSet;
@@ -45,6 +47,7 @@
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.allapps.AllAppsStore;
import com.android.launcher3.icons.BitmapInfo;
+import com.android.launcher3.icons.BitmapRenderer;
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
@@ -54,14 +57,25 @@
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.util.ComponentKey;
+import com.android.launcher3.util.Themes;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
import java.util.List;
import java.util.function.Consumer;
/**
* A {@link BubbleTextView} representing a single cell result in AllApps
*/
-public class SearchResultIcon extends BubbleTextView implements SearchTargetHandler {
+public class SearchResultIcon extends BubbleTextView implements
+ SearchTargetHandler, View.OnClickListener,
+ View.OnLongClickListener {
+
+ //Play store thumbnail process workaround
+ private final Rect mTempRect = new Rect();
+ private final Paint mIconPaint = new Paint();
+ private static final int BITMAP_CROP_MASK_COLOR = 0xff424242;
private final Launcher mLauncher;
@@ -99,7 +113,7 @@
* Applies {@link SearchTarget} to view. registers a consumer after a corresponding
* {@link ItemInfoWithIcon} is created
*/
- public void applySearchTarget(SearchTarget searchTarget, List<SearchTarget> inlineItems,
+ public void apply(SearchTarget searchTarget, List<SearchTarget> inlineItems,
Consumer<ItemInfoWithIcon> cb) {
mOnItemInfoChanged = cb;
apply(searchTarget, inlineItems);
@@ -115,8 +129,8 @@
prepareUsingSearchAction(parentTarget);
mLongPressSupported = false;
} else {
- prepareUsingApp(new ComponentName(parentTarget.getPackageName(),
- parentTarget.getExtras().getString(SearchTargetUtil.EXTRA_CLASS)),
+ String className = parentTarget.getExtras().getString(SearchTargetUtil.EXTRA_CLASS);
+ prepareUsingApp(new ComponentName(parentTarget.getPackageName(), className),
parentTarget.getUserHandle());
mLongPressSupported = true;
}
@@ -136,14 +150,17 @@
//TODO: remove this after flags are introduced in SearchAction. Settings results require
// startActivityForResult
boolean isSettingsResult = searchTarget.getResultType() == ResultType.SETTING;
- if ((extras != null && extras.getBoolean(BUNDLE_EXTRA_SHOULD_START_FOR_RESULT))
+ if ((extras != null && extras.getBoolean(
+ SearchTargetUtil.BUNDLE_EXTRA_SHOULD_START_FOR_RESULT))
|| isSettingsResult) {
itemInfo.setFlags(SearchActionItemInfo.FLAG_SHOULD_START_FOR_RESULT);
- } else if (extras != null && extras.getBoolean(BUNDLE_EXTRA_SHOULD_START)) {
+ } else if (extras != null && extras.getBoolean(
+ SearchTargetUtil.BUNDLE_EXTRA_SHOULD_START)) {
itemInfo.setFlags(SearchActionItemInfo.FLAG_SHOULD_START);
}
- if (extras != null && extras.getBoolean(BUNDLE_EXTRA_BADGE_FROM_ICON)) {
- itemInfo.setFlags(FLAG_BADGE_FROM_ICON);
+ if (extras != null && extras.getBoolean(
+ SearchTargetUtil.BUNDLE_EXTRA_BADGE_WITH_PACKAGE)) {
+ itemInfo.setFlags(FLAG_BADGE_WITH_PACKAGE);
}
if (extras != null && extras.getBoolean(BUNDLE_EXTRA_PRIMARY_ICON_FROM_TITLE)) {
itemInfo.setFlags(FLAG_PRIMARY_ICON_FROM_TITLE);
@@ -154,39 +171,76 @@
MODEL_EXECUTOR.post(() -> {
try (LauncherIcons li = LauncherIcons.obtain(getContext())) {
Icon icon = searchTarget.getSearchAction().getIcon();
- Drawable d;
- // This bitmapInfo can be used as main icon or as a badge
- BitmapInfo bitmapInfo;
- if (icon == null) {
- PackageItemInfo pkgInfo = new PackageItemInfo(searchTarget.getPackageName());
- pkgInfo.user = searchTarget.getUserHandle();
- appState.getIconCache().getTitleAndIconForApp(pkgInfo, false);
- bitmapInfo = pkgInfo.bitmap;
- } else {
- d = itemInfo.getIcon().loadDrawable(getContext());
- bitmapInfo = li.createBadgedIconBitmap(d, itemInfo.user,
- Build.VERSION.SDK_INT);
- }
-
- BitmapInfo bitmapMainIcon;
+ BitmapInfo pkgBitmap = getPackageBitmap(appState, searchTarget);
if (itemInfo.hasFlags(FLAG_PRIMARY_ICON_FROM_TITLE)) {
- bitmapMainIcon = li.createIconBitmap(
- String.valueOf(itemInfo.title.charAt(0)),
- bitmapInfo.color);
+ // create a bitmap with first char if FLAG_PRIMARY_ICON_FROM_TITLE is set
+ itemInfo.bitmap = li.createIconBitmap(String.valueOf(itemInfo.title.charAt(0)),
+ pkgBitmap.color);
+ } else if (icon == null) {
+ // Use default icon from package name
+ itemInfo.bitmap = pkgBitmap;
} else {
- bitmapMainIcon = bitmapInfo;
- }
- if (itemInfo.hasFlags(FLAG_BADGE_FROM_ICON)) {
- itemInfo.bitmap = li.badgeBitmap(bitmapMainIcon.icon, bitmapInfo);
- } else {
- itemInfo.bitmap = bitmapInfo;
+ boolean isPlayResult = searchTarget.getResultType() == ResultType.PLAY;
+ if (isPlayResult) {
+ Bitmap b = getPlayResultBitmap(searchAction.getIcon());
+ itemInfo.bitmap = b == null
+ ? BitmapInfo.LOW_RES_INFO : BitmapInfo.fromBitmap(b);
+ } else {
+ itemInfo.bitmap = li.createBadgedIconBitmap(icon.loadDrawable(getContext()),
+ itemInfo.user, false);
+ }
}
+ // badge with package name
+ if (itemInfo.hasFlags(FLAG_BADGE_WITH_PACKAGE) && itemInfo.bitmap != pkgBitmap) {
+ itemInfo.bitmap = li.badgeBitmap(itemInfo.bitmap.icon, pkgBitmap);
+ }
}
MAIN_EXECUTOR.post(() -> applyFromSearchActionItemInfo(itemInfo));
});
}
+ private static BitmapInfo getPackageBitmap(LauncherAppState appState, SearchTarget target) {
+ PackageItemInfo pkgInfo = new PackageItemInfo(target.getPackageName());
+ pkgInfo.user = target.getUserHandle();
+ appState.getIconCache().getTitleAndIconForApp(pkgInfo, false);
+ return pkgInfo.bitmap;
+ }
+
+ private Bitmap getPlayResultBitmap(Icon icon) {
+ try {
+ int iconSize = getIconSize();
+ URL url = new URL(icon.getUri().toString());
+ URLConnection con = url.openConnection();
+ con.addRequestProperty("Cache-Control", "max-age: 0");
+ con.setUseCaches(true);
+ Bitmap bitmap = BitmapFactory.decodeStream(con.getInputStream());
+ return getRoundedBitmap(Bitmap.createScaledBitmap(bitmap, iconSize, iconSize, false));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private Bitmap getRoundedBitmap(Bitmap bitmap) {
+ final int iconSize = bitmap.getWidth();
+ final float radius = Themes.getDialogCornerRadius(getContext());
+
+ return BitmapRenderer.createHardwareBitmap(iconSize, iconSize, (canvas) -> {
+ mTempRect.set(0, 0, iconSize, iconSize);
+ final RectF rectF = new RectF(mTempRect);
+
+ mIconPaint.setAntiAlias(true);
+ mIconPaint.reset();
+ canvas.drawARGB(0, 0, 0, 0);
+ mIconPaint.setColor(BITMAP_CROP_MASK_COLOR);
+ canvas.drawRoundRect(rectF, radius, radius, mIconPaint);
+
+ mIconPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
+ canvas.drawBitmap(bitmap, mTempRect, mTempRect, mIconPaint);
+ });
+ }
+
private void prepareUsingApp(ComponentName componentName, UserHandle userHandle) {
AllAppsStore appsStore = mLauncher.getAppsView().getAppsStore();
AppInfo appInfo = appsStore.getApp(new ComponentKey(componentName, userHandle));
@@ -233,7 +287,6 @@
}
-
private void notifyItemInfoChanged(ItemInfoWithIcon itemInfoWithIcon) {
if (mOnItemInfoChanged != null) {
mOnItemInfoChanged.accept(itemInfoWithIcon);
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java b/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java
index eafbc73..7c3ed69 100644
--- a/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java
+++ b/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java
@@ -23,7 +23,6 @@
import android.content.pm.ShortcutInfo;
import android.text.TextUtils;
import android.util.AttributeSet;
-import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -44,15 +43,15 @@
*/
public class SearchResultIconRow extends LinearLayout implements SearchTargetHandler {
- public static final int MAX_INLINE_ITEMS = 2;
+ public static final int MAX_INLINE_ITEMS = 3;
protected final Launcher mLauncher;
private final LauncherAppState mLauncherAppState;
- private SearchResultIcon mResultIcon;
+ protected SearchResultIcon mResultIcon;
private TextView mTitleView;
private TextView mSubTitleView;
- private final SearchResultIcon[] mInlineIcons = new SearchResultIcon[MAX_INLINE_ITEMS];
+ protected final SearchResultIcon[] mInlineIcons = new SearchResultIcon[MAX_INLINE_ITEMS];
private PackageItemInfo mProviderInfo;
@@ -91,9 +90,9 @@
mInlineIcons[0] = findViewById(R.id.shortcut_0);
mInlineIcons[1] = findViewById(R.id.shortcut_1);
+ mInlineIcons[2] = findViewById(R.id.shortcut_2);
for (SearchResultIcon inlineIcon : mInlineIcons) {
inlineIcon.getLayoutParams().width = getIconSize();
- // TODO: inlineIcon.setOnClickListener();
}
setOnClickListener(mResultIcon);
@@ -103,7 +102,7 @@
@Override
public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
showSubtitleIfNeeded(null);
- mResultIcon.applySearchTarget(parentTarget, children, this::onItemInfoCreated);
+ mResultIcon.apply(parentTarget, children, this::onItemInfoCreated);
if (parentTarget.getShortcutInfo() != null) {
updateWithShortcutInfo(parentTarget.getShortcutInfo());
} else if (parentTarget.getSearchAction() != null) {
@@ -142,7 +141,7 @@
protected void showInlineItems(List<SearchTarget> children) {
for (int i = 0; i < MAX_INLINE_ITEMS; i++) {
if (i < children.size()) {
- mInlineIcons[i].apply(children.get(0), new ArrayList<>());
+ mInlineIcons[i].apply(children.get(i), new ArrayList<>());
mInlineIcons[i].setVisibility(VISIBLE);
} else {
mInlineIcons[i].setVisibility(GONE);
@@ -154,15 +153,4 @@
setTag(info);
mTitleView.setText(info.title);
}
-
- @Override
- public void onClick(View view) {
- // do nothing.
- }
-
- @Override
- public boolean onLongClick(View view) {
- // do nothing.
- return false;
- }
}
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultIconSlice.java b/quickstep/src/com/android/launcher3/search/SearchResultIconSlice.java
index f6e5eba..0ea2f8b 100644
--- a/quickstep/src/com/android/launcher3/search/SearchResultIconSlice.java
+++ b/quickstep/src/com/android/launcher3/search/SearchResultIconSlice.java
@@ -22,7 +22,6 @@
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
-import android.view.View;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
@@ -133,15 +132,4 @@
public void onSliceAction(@NonNull EventInfo eventInfo, @NonNull SliceItem sliceItem) {
notifyEvent(mLauncher, mTargetId, SearchTargetEvent.ACTION_TAP);
}
-
- @Override
- public void onClick(View view) {
- notifyEvent(mLauncher, mTargetId, SearchTargetEvent.ACTION_LONGPRESS);
- }
-
- @Override
- public boolean onLongClick(View view) {
- // do nothing
- return false;
- }
}
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultPeopleView.java b/quickstep/src/com/android/launcher3/search/SearchResultPeopleView.java
deleted file mode 100644
index 99e6aa5..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchResultPeopleView.java
+++ /dev/null
@@ -1,199 +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.launcher3.search;
-
-import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
-import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
-
-import android.app.search.SearchTargetEvent;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Process;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.ImageButton;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import androidx.annotation.Nullable;
-import androidx.core.graphics.drawable.RoundedBitmapDrawable;
-import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
-
-import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.Launcher;
-import com.android.launcher3.R;
-import com.android.launcher3.icons.BitmapInfo;
-import com.android.launcher3.icons.LauncherIcons;
-import com.android.systemui.plugins.shared.SearchTargetLegacy;
-
-import java.util.ArrayList;
-
-/**
- * A view representing a single people search result in all apps
- */
-public class SearchResultPeopleView extends LinearLayout implements SearchTargetHandler {
-
- public static final String TARGET_TYPE_PEOPLE = "people";
-
- private final int mIconSize;
- private final int mButtonSize;
- private final PackageManager mPackageManager;
- private View mIconView;
- private TextView mTitleView;
- private ImageButton[] mProviderButtons = new ImageButton[3];
- private Intent mIntent;
-
- private SearchTargetLegacy mSearchTarget;
-
- public SearchResultPeopleView(Context context) {
- this(context, null, 0);
- }
-
- public SearchResultPeopleView(Context context,
- @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SearchResultPeopleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- DeviceProfile deviceProfile = Launcher.getLauncher(getContext()).getDeviceProfile();
- mPackageManager = getContext().getPackageManager();
- mIconSize = deviceProfile.iconSizePx;
- mButtonSize = (int) (deviceProfile.iconSizePx / 1.5f);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- mIconView = findViewById(R.id.icon);
- mIconView.getLayoutParams().height = mIconSize;
- mIconView.getLayoutParams().width = mIconSize;
- mTitleView = findViewById(R.id.title);
- mProviderButtons[0] = findViewById(R.id.provider_0);
- mProviderButtons[1] = findViewById(R.id.provider_1);
- mProviderButtons[2] = findViewById(R.id.provider_2);
- for (ImageButton button : mProviderButtons) {
- button.getLayoutParams().width = mButtonSize;
- button.getLayoutParams().height = mButtonSize;
- }
- }
-
- /*
- @Override
- public void applySearchTarget(SearchTargetLegacy searchTarget) {
- mSearchTarget = searchTarget;
- Bundle payload = searchTarget.getExtras();
- mTitleView.setText(payload.getString("title"));
- mIntent = payload.getParcelable("intent");
- Bitmap contactIcon = payload.getParcelable("icon");
- try (LauncherIcons li = LauncherIcons.obtain(getContext())) {
- BitmapInfo badgeInfo = li.createBadgedIconBitmap(
- getAppIcon(mIntent.getPackage()), Process.myUserHandle(),
- Build.VERSION.SDK_INT);
- setIcon(li.badgeBitmap(roundBitmap(contactIcon), badgeInfo).icon, false);
- } catch (Exception e) {
- setIcon(contactIcon, true);
- }
-
- ArrayList<Bundle> providers = payload.getParcelableArrayList("providers");
- for (int i = 0; i < mProviderButtons.length; i++) {
- ImageButton button = mProviderButtons[i];
- if (providers != null && i < providers.size()) {
- Bundle provider = providers.get(i);
- Intent intent = provider.getParcelable("intent");
- setupProviderButton(button, provider, intent);
- UI_HELPER_EXECUTOR.post(() -> {
- String pkg = provider.getString("package_name");
- Drawable appIcon = getAppIcon(pkg);
- if (appIcon != null) {
- MAIN_EXECUTOR.post(() -> button.setImageDrawable(appIcon));
- }
- });
- button.setVisibility(VISIBLE);
- } else {
- button.setVisibility(GONE);
- }
- }
- }
- */
-
- /**
- * Normalizes the bitmap to look like rounded App Icon
- * TODO(b/170234747) to support styling, generate adaptive icon drawable and generate
- * bitmap from it.
- */
- private Bitmap roundBitmap(Bitmap icon) {
- final RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(getResources(), icon);
- d.setCornerRadius(R.attr.folderIconRadius);
- d.setBounds(0, 0, mIconSize, mIconSize);
- final Bitmap bitmap = Bitmap.createBitmap(d.getBounds().width(), d.getBounds().height(),
- Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(bitmap);
- d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
- d.draw(canvas);
- return bitmap;
- }
-
- private void setIcon(Bitmap icon, Boolean round) {
- if (round) {
- RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(getResources(), icon);
- d.setCornerRadius(R.attr.folderIconRadius);
- d.setBounds(0, 0, mIconSize, mIconSize);
- mIconView.setBackground(d);
- } else {
- mIconView.setBackground(new BitmapDrawable(getResources(), icon));
- }
- }
-
-
- private Drawable getAppIcon(String pkg) {
- try {
- ApplicationInfo applicationInfo = mPackageManager.getApplicationInfo(
- pkg, 0);
- return applicationInfo.loadIcon(mPackageManager);
- } catch (PackageManager.NameNotFoundException ignored) {
- return null;
- }
- }
-
- private void setupProviderButton(ImageButton button, Bundle provider, Intent intent) {
- Launcher launcher = Launcher.getLauncher(getContext());
- button.setOnClickListener(b -> {
- launcher.startActivitySafely(b, intent, null);
- Bundle bundle = new Bundle();
- bundle.putBundle("provider", provider);
- });
- }
-
- @Override
- public void onClick(View view) {
- // do nothing.
- }
-
- @Override
- public boolean onLongClick(View view) {
- // do nothing.
- return false;
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultThumbnailView.java b/quickstep/src/com/android/launcher3/search/SearchResultThumbnailView.java
index b1cbe7d..225f68c 100644
--- a/quickstep/src/com/android/launcher3/search/SearchResultThumbnailView.java
+++ b/quickstep/src/com/android/launcher3/search/SearchResultThumbnailView.java
@@ -23,6 +23,7 @@
import android.graphics.drawable.BitmapDrawable;
import android.util.AttributeSet;
import android.view.View;
+import android.view.ViewGroup;
import androidx.core.graphics.drawable.RoundedBitmapDrawable;
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
@@ -38,10 +39,9 @@
* A view representing a high confidence app search result that includes shortcuts
*/
public class SearchResultThumbnailView extends androidx.appcompat.widget.AppCompatImageView
- implements SearchTargetHandler {
+ implements SearchTargetHandler, View.OnClickListener {
private SearchTarget mSearchTarget;
- private SearchResultIcon mResultIcon;
public SearchResultThumbnailView(Context context) {
super(context);
@@ -56,6 +56,14 @@
}
@Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ setOnFocusChangeListener(Launcher.getLauncher(getContext()).getFocusHandler());
+ setOnClickListener(this);
+ setOnLongClickListener(this);
+ }
+
+ @Override
public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
mSearchTarget = parentTarget;
Bitmap bitmap;
@@ -65,6 +73,9 @@
parentTarget.getPackageName(),
parentTarget.getUserHandle(),
parentTarget.getSearchAction().getTitle());
+ itemInfo.setIntent(parentTarget.getSearchAction().getIntent());
+ itemInfo.setPendingIntent(parentTarget.getSearchAction().getPendingIntent());
+
bitmap = ((BitmapDrawable) itemInfo.getIcon()
.loadDrawable(getContext())).getBitmap();
// crop
@@ -90,10 +101,4 @@
(SearchActionItemInfo) view.getTag());
notifyEvent(getContext(), mSearchTarget.getId(), SearchTargetEvent.ACTION_LAUNCH_TOUCH);
}
-
- @Override
- public boolean onLongClick(View view) {
- // do nothing.
- return false;
- }
}
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultWidget.java b/quickstep/src/com/android/launcher3/search/SearchResultWidget.java
index da14959..4c64265 100644
--- a/quickstep/src/com/android/launcher3/search/SearchResultWidget.java
+++ b/quickstep/src/com/android/launcher3/search/SearchResultWidget.java
@@ -186,10 +186,6 @@
return false;
}
- @Override
- public void onClick(View view) {
- // do nothing.
- }
static class ClickListener extends GestureDetector.SimpleOnGestureListener {
private final Runnable mCb;
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java b/quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java
index 1786baf..5bf1908 100644
--- a/quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java
+++ b/quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java
@@ -47,7 +47,8 @@
/**
* displays preview of a widget upon receiving {@link AppWidgetProviderInfo} from Search provider
*/
-public class SearchResultWidgetPreview extends LinearLayout implements SearchTargetHandler {
+public class SearchResultWidgetPreview extends LinearLayout implements SearchTargetHandler,
+ View.OnClickListener, View.OnLongClickListener {
private final Launcher mLauncher;
private final LauncherAppState mAppState;
diff --git a/quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java b/quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java
index d7c5c5d..9276841 100644
--- a/quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java
+++ b/quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java
@@ -18,7 +18,6 @@
import android.app.search.SearchTarget;
import android.content.Context;
import android.util.AttributeSet;
-import android.view.View;
import android.widget.TextView;
import androidx.annotation.Nullable;
@@ -48,15 +47,4 @@
setText(parentTarget.getSearchAction().getTitle());
setVisibility(VISIBLE);
}
-
- @Override
- public void onClick(View view) {
- // do nothing.
- }
-
- @Override
- public boolean onLongClick(View view) {
- // do nothing.
- return false;
- }
}
diff --git a/quickstep/src/com/android/launcher3/search/SearchServicePipeline.java b/quickstep/src/com/android/launcher3/search/SearchServicePipeline.java
index 197aecb..fac6ba7 100644
--- a/quickstep/src/com/android/launcher3/search/SearchServicePipeline.java
+++ b/quickstep/src/com/android/launcher3/search/SearchServicePipeline.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.search;
+import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
+
import android.app.search.Query;
import android.app.search.SearchContext;
import android.app.search.SearchSession;
@@ -39,8 +41,6 @@
import java.util.List;
import java.util.function.Consumer;
-import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
-
/**
* Search pipeline utilizing {@link android.app.search.SearchUiManager}
*/
diff --git a/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java b/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java
index 0e7b8f2..acf6f8a 100644
--- a/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java
+++ b/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java
@@ -19,15 +19,13 @@
import android.app.search.SearchTarget;
import android.app.search.SearchTargetEvent;
import android.content.Context;
-import android.view.View;
import java.util.List;
-import java.util.function.Consumer;
/**
* An interface for supporting dynamic search results
*/
-public interface SearchTargetHandler extends View.OnClickListener, View.OnLongClickListener {
+public interface SearchTargetHandler {
/**
* Update view using values from {@link SearchTarget}
diff --git a/quickstep/src/com/android/launcher3/search/SearchTargetUtil.java b/quickstep/src/com/android/launcher3/search/SearchTargetUtil.java
index ceef429..0abed03 100644
--- a/quickstep/src/com/android/launcher3/search/SearchTargetUtil.java
+++ b/quickstep/src/com/android/launcher3/search/SearchTargetUtil.java
@@ -15,6 +15,13 @@
*/
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.THUMBNAIL;
+import static com.android.app.search.ResultType.ACTION;
+import static com.android.app.search.ResultType.SCREENSHOT;
+import static com.android.app.search.ResultType.SUGGEST;
+
import android.app.PendingIntent;
import android.app.search.SearchAction;
import android.app.search.SearchTarget;
@@ -31,18 +38,11 @@
import com.android.app.search.ResultType;
-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.THUMBNAIL;
-import static com.android.app.search.ResultType.ACTION;
-import static com.android.app.search.ResultType.SCREENSHOT;
-import static com.android.app.search.ResultType.SUGGEST;
-
public class SearchTargetUtil {
public static final String BUNDLE_EXTRA_SHOULD_START = "should_start";
public static final String BUNDLE_EXTRA_SHOULD_START_FOR_RESULT = "should_start_for_result";
- public static final String BUNDLE_EXTRA_BADGE_FROM_ICON = "badge_from_icon";
+ public static final String BUNDLE_EXTRA_BADGE_WITH_PACKAGE = "badge_with_package";
public static final String BUNDLE_EXTRA_PRIMARY_ICON_FROM_TITLE = "primary_icon_from_title";
public static final String EXTRA_CLASS = "class";
@@ -56,10 +56,10 @@
/**
* Generate SearchTargetUtil for ICON_DOUBLE_HORIZONTAL_TEXT layout type.
*
- targets.add(SearchTargetUtil.generateIconDoubleHorizontalText_SearchAction(
- mContext, "red", Color.RED));
- targets.add(SearchTargetUtil.generateIconDoubleHorizontalText_SearchAction(
- mContext, "yellow", Color.YELLOW));
+ * targets.add(SearchTargetUtil.generateIconDoubleHorizontalText_SearchAction(
+ * mContext, "red", Color.RED));
+ * targets.add(SearchTargetUtil.generateIconDoubleHorizontalText_SearchAction(
+ * mContext, "yellow", Color.YELLOW));
*/
public static SearchTarget generateIconDoubleHorizontalText_SearchAction(
Context context, String id, int color) {
@@ -83,7 +83,7 @@
Bundle b = new Bundle();
b.putBoolean(BUNDLE_EXTRA_SHOULD_START_FOR_RESULT, true);
- b.putBoolean(BUNDLE_EXTRA_BADGE_FROM_ICON, true);
+ b.putBoolean(BUNDLE_EXTRA_BADGE_WITH_PACKAGE, true);
b.putBoolean(BUNDLE_EXTRA_PRIMARY_ICON_FROM_TITLE, true);
builder.setSearchAction(new SearchAction.Builder(id, id + TITLE)
@@ -96,7 +96,7 @@
}
/**
- * Inside SearchServicePipeline, add following samples to test the search target.
+ * Inside SearchServicePipeline, add following samples to test the search target.
*
* targets.add(SearchTargetUtil.generateThumbnail_SearchAction("blue", Color.BLUE));
* targets.add(SearchTargetUtil.generateThumbnail_SearchAction("red", Color.RED));
@@ -112,6 +112,7 @@
Intent intent = new Intent(Intent.ACTION_VIEW)
.setData(Uri.parse("uri blah blah"))
.setType("image/*")
+ .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Bitmap bitmap = Bitmap.createBitmap(1000, 500, Bitmap.Config.ARGB_8888);
@@ -129,11 +130,10 @@
}
/**
- *
* targets.add(SearchTargetUtil.generateIconHorizontalText_SearchAction(
- * mContext, "red", Color.RED));
+ * mContext, "red", Color.RED));
* targets.add(SearchTargetUtil.generateIconHorizontalText_SearchAction(
- * mContext, "yellow", Color.YELLOW));
+ * mContext, "yellow", Color.YELLOW));
*/
public static SearchTarget generateIconHorizontalText_SearchAction(
Context context, String id, int color) {
diff --git a/quickstep/src/com/android/launcher3/uioverrides/plugins/PluginInitializerImpl.java b/quickstep/src/com/android/launcher3/uioverrides/plugins/PluginInitializerImpl.java
index 7beb9db..d14e8ef 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/plugins/PluginInitializerImpl.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/plugins/PluginInitializerImpl.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.os.Looper;
+import com.android.launcher3.Utilities;
import com.android.systemui.shared.plugins.PluginInitializer;
public class PluginInitializerImpl implements PluginInitializer {
@@ -44,4 +45,8 @@
@Override
public void handleWtfs() {
}
+
+ public boolean isDebuggable() {
+ return Utilities.IS_DEBUG_DEVICE;
+ }
}
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 13b7d8d..39a3a7c 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -721,11 +721,12 @@
@UiThread
public void onGestureStarted(boolean isLikelyToStartNewTask) {
- // Temporarily disable this until we have a view that we can use
- // InteractionJankMonitorWrapper.begin(mRecentsView,
- // InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH, 2000 /* ms timeout */);
- // InteractionJankMonitorWrapper.begin(mRecentsView,
- // InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME);
+ if (mRecentsView != null) {
+ InteractionJankMonitorWrapper.begin(mRecentsView,
+ InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH, 2000 /* ms timeout */);
+ InteractionJankMonitorWrapper.begin(mRecentsView,
+ InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME);
+ }
notifyGestureStartedAsync();
setIsLikelyToStartNewTask(isLikelyToStartNewTask, false /* animate */);
mStateCallback.setStateOnUiThread(STATE_GESTURE_STARTED);
@@ -1450,7 +1451,10 @@
private void finishCurrentTransitionToRecents() {
if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED);
- mRecentsView.getRunningTaskView().setIsClickableAsLiveTile(true);
+ 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/ImageActionsApi.java b/quickstep/src/com/android/quickstep/ImageActionsApi.java
index b04905c..cb4d53a 100644
--- a/quickstep/src/com/android/quickstep/ImageActionsApi.java
+++ b/quickstep/src/com/android/quickstep/ImageActionsApi.java
@@ -83,8 +83,8 @@
* Share the image this api was constructed with.
*/
@UiThread
- public void startShareActivity() {
- ImageActionUtils.startShareActivity(mContext, mBitmapSupplier, null, null, TAG);
+ public void startShareActivity(Rect crop) {
+ ImageActionUtils.startShareActivity(mContext, mBitmapSupplier, crop, null, TAG);
}
/**
diff --git a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java
index 80308a5..65847f1 100644
--- a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java
+++ b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java
@@ -26,6 +26,7 @@
import com.android.launcher3.MainProcessInitializer;
import com.android.launcher3.util.Executors;
import com.android.quickstep.logging.SettingsChangeLogger;
+import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
import com.android.systemui.shared.system.ThreadedRendererCompat;
@SuppressWarnings("unused")
@@ -35,7 +36,11 @@
private static final String TAG = "QuickstepProcessInitializer";
private static final int SETUP_DELAY_MILLIS = 5000;
- public QuickstepProcessInitializer(Context context) { }
+ public QuickstepProcessInitializer(Context context) {
+ // Fake call to create an instance of InteractionJankMonitor to avoid binder calls during
+ // its initialization during transitions.
+ InteractionJankMonitorWrapper.cancel(-1);
+ }
@Override
protected void init(Context context) {
diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
index 6677724..93ebd5a 100644
--- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
@@ -159,7 +159,7 @@
@Override
public void onShare() {
if (isAllowedByPolicy) {
- endLiveTileMode(mImageApi::startShareActivity);
+ endLiveTileMode(() -> mImageApi.startShareActivity(null));
} else {
showBlockedByPolicyMessage();
}
diff --git a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java
index 9ee9f00..cb81d36 100644
--- a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java
+++ b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java
@@ -27,6 +27,7 @@
import com.android.launcher3.LauncherState;
import com.android.launcher3.Workspace;
+import com.android.launcher3.allapps.AllAppsInsetTransitionController;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.hybridhotseat.HotseatPredictionController;
import com.android.launcher3.search.DeviceSearchEdu;
@@ -139,8 +140,12 @@
@Override
public void onStateTransitionStart(LauncherState toState) {
if (toState == ALL_APPS) {
- mLauncher.getAllAppsController().getInsetController().setSearchEduRunnable(
- () -> DeviceSearchEdu.show(launcher));
+ AllAppsInsetTransitionController insetTransitionController =
+ mLauncher.getAllAppsController().getInsetController();
+ insetTransitionController.setSearchEduRunnable(() -> {
+ DeviceSearchEdu.show(launcher);
+ insetTransitionController.setSearchEduRunnable(null);
+ });
stateManager.removeStateListener(this);
}
}
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 22eb15a..575d6cd 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -301,7 +301,7 @@
verifyHighRes();
if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
- applyProgressLevel(info.getProgressLevel());
+ applyProgressLevel();
}
applyDotState(info, false /* animate */);
}
@@ -603,21 +603,20 @@
* with the total download progress.
*/
public void applyLoadingState(boolean promiseStateChanged) {
- if (getTag() instanceof WorkspaceItemInfo) {
+ if (getTag() instanceof ItemInfoWithIcon) {
WorkspaceItemInfo info = (WorkspaceItemInfo) getTag();
- int progressLevel = info.getProgressLevel();
if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_INCREMENTAL_DOWNLOAD_ACTIVE)
!= 0) {
- updateProgressBarUi(progressLevel, progressLevel == 100);
+ updateProgressBarUi(info.getProgressLevel() == 100);
} else if (info.hasPromiseIconUi() || (info.runtimeStatusFlags
- & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
- updateProgressBarUi(progressLevel, promiseStateChanged);
+ & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
+ updateProgressBarUi(promiseStateChanged);
}
}
}
- private void updateProgressBarUi(int progressLevel, boolean maybePerformFinishedAnimation) {
- PreloadIconDrawable preloadDrawable = applyProgressLevel(progressLevel);
+ private void updateProgressBarUi(boolean maybePerformFinishedAnimation) {
+ PreloadIconDrawable preloadDrawable = applyProgressLevel();
if (preloadDrawable != null && maybePerformFinishedAnimation) {
preloadDrawable.maybePerformFinishedAnimation();
}
@@ -625,38 +624,59 @@
/** Applies the given progress level to the this icon's progress bar. */
@Nullable
- public PreloadIconDrawable applyProgressLevel(int progressLevel) {
- if (getTag() instanceof ItemInfoWithIcon) {
- ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
- if (progressLevel >= 100) {
- setContentDescription(info.contentDescription != null
- ? info.contentDescription : "");
- } else if (progressLevel > 0) {
- setContentDescription(getContext()
- .getString(R.string.app_downloading_title, info.title,
- NumberFormat.getPercentInstance().format(progressLevel * 0.01)));
+ public PreloadIconDrawable applyProgressLevel() {
+ if (!(getTag() instanceof ItemInfoWithIcon)) {
+ return null;
+ }
+
+ ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
+ int progressLevel = info.getProgressLevel();
+ if (progressLevel >= 100) {
+ setContentDescription(info.contentDescription != null
+ ? info.contentDescription : "");
+ } else if (progressLevel > 0) {
+ setContentDescription(getContext()
+ .getString(R.string.app_downloading_title, info.title,
+ NumberFormat.getPercentInstance().format(progressLevel * 0.01)));
+ } else {
+ setContentDescription(getContext()
+ .getString(R.string.app_waiting_download_title, info.title));
+ }
+ if (mIcon != null) {
+ PreloadIconDrawable preloadIconDrawable;
+ if (mIcon instanceof PreloadIconDrawable) {
+ preloadIconDrawable = (PreloadIconDrawable) mIcon;
+ preloadIconDrawable.setLevel(progressLevel);
+ preloadIconDrawable.setIsDisabled(!info.isAppStartable());
} else {
- setContentDescription(getContext()
- .getString(R.string.app_waiting_download_title, info.title));
+ preloadIconDrawable = makePreloadIcon();
+ setIcon(preloadIconDrawable);
}
- if (mIcon != null) {
- final PreloadIconDrawable preloadDrawable;
- if (mIcon instanceof PreloadIconDrawable) {
- preloadDrawable = (PreloadIconDrawable) mIcon;
- preloadDrawable.setLevel(progressLevel);
- preloadDrawable.setIsDisabled(!info.isAppStartable());
- } else {
- preloadDrawable = newPendingIcon(getContext(), info);
- preloadDrawable.setLevel(progressLevel);
- preloadDrawable.setIsDisabled(!info.isAppStartable());
- setIcon(preloadDrawable);
- }
- return preloadDrawable;
- }
+ return preloadIconDrawable;
}
return null;
}
+ /**
+ * Creates a PreloadIconDrawable with the appropriate progress level without mutating this
+ * object.
+ */
+ @Nullable
+ public PreloadIconDrawable makePreloadIcon() {
+ if (!(getTag() instanceof ItemInfoWithIcon)) {
+ return null;
+ }
+
+ ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
+ int progressLevel = info.getProgressLevel();
+ final PreloadIconDrawable preloadDrawable = newPendingIcon(getContext(), info);
+
+ preloadDrawable.setLevel(progressLevel);
+ preloadDrawable.setIsDisabled(!info.isAppStartable());
+
+ return preloadDrawable;
+ }
+
public void applyDotState(ItemInfo itemInfo, boolean animate) {
if (mIcon instanceof FastBitmapDrawable) {
boolean wasDotted = mDotInfo != null;
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 12ce9f3..f681d75 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -607,8 +607,9 @@
*/
public boolean updateIsSeascape(Context context) {
if (isVerticalBarLayout()) {
- boolean isSeascape = DisplayController.getDefaultDisplay(context).getInfo().rotation
- == Surface.ROTATION_270;
+ // Check an up-to-date info.
+ boolean isSeascape = DisplayController.getDefaultDisplay(context)
+ .createInfoForContext(context).rotation == Surface.ROTATION_270;
if (mIsSeascape != isSeascape) {
mIsSeascape = isSeascape;
return true;
diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java
index 139d4a8..b1fe4a2 100644
--- a/src/com/android/launcher3/FastBitmapDrawable.java
+++ b/src/com/android/launcher3/FastBitmapDrawable.java
@@ -276,15 +276,15 @@
@Override
public ConstantState getConstantState() {
- return new MyConstantState(mBitmap, mIconColor, mIsDisabled);
+ return new FastBitmapConstantState(mBitmap, mIconColor, mIsDisabled);
}
- protected static class MyConstantState extends ConstantState {
+ protected static class FastBitmapConstantState extends ConstantState {
protected final Bitmap mBitmap;
protected final int mIconColor;
protected final boolean mIsDisabled;
- public MyConstantState(Bitmap bitmap, int color, boolean isDisabled) {
+ public FastBitmapConstantState(Bitmap bitmap, int color, boolean isDisabled) {
mBitmap = bitmap;
mIconColor = color;
mIsDisabled = isDisabled;
diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java
index 00bdb70..769cb5e 100644
--- a/src/com/android/launcher3/allapps/AllAppsStore.java
+++ b/src/com/android/launcher3/allapps/AllAppsStore.java
@@ -154,7 +154,7 @@
public void updateProgressBar(AppInfo app) {
updateAllIcons((child) -> {
if (child.getTag() == app) {
- child.applyProgressLevel(app.getProgressLevel());
+ child.applyProgressLevel();
}
});
}
diff --git a/src/com/android/launcher3/graphics/PreloadIconDrawable.java b/src/com/android/launcher3/graphics/PreloadIconDrawable.java
index 9971990..304d496 100644
--- a/src/com/android/launcher3/graphics/PreloadIconDrawable.java
+++ b/src/com/android/launcher3/graphics/PreloadIconDrawable.java
@@ -105,6 +105,10 @@
private ObjectAnimator mCurrentAnim;
public PreloadIconDrawable(ItemInfoWithIcon info, Context context) {
+ this(info, IconPalette.getPreloadProgressColor(context, info.bitmap.color));
+ }
+
+ public PreloadIconDrawable(ItemInfoWithIcon info, int indicatorColor) {
super(info.bitmap);
mItem = info;
mShapePath = getShapePath();
@@ -114,7 +118,7 @@
mProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
mProgressPaint.setStyle(Paint.Style.STROKE);
mProgressPaint.setStrokeCap(Paint.Cap.ROUND);
- mIndicatorColor = IconPalette.getPreloadProgressColor(context, mIconColor);
+ mIndicatorColor = indicatorColor;
setInternalProgress(0);
@@ -297,4 +301,42 @@
public static PreloadIconDrawable newPendingIcon(Context context, ItemInfoWithIcon info) {
return new PreloadIconDrawable(info, context);
}
+
+ @Override
+ public ConstantState getConstantState() {
+ return new PreloadIconConstantState(
+ mBitmap, mIconColor, !mItem.isAppStartable(), mItem, mIndicatorColor);
+ }
+
+ protected static class PreloadIconConstantState extends FastBitmapConstantState {
+
+ protected final ItemInfoWithIcon mInfo;
+ protected final int mIndicatorColor;
+ protected final int mLevel;
+
+ public PreloadIconConstantState(
+ Bitmap bitmap,
+ int iconColor,
+ boolean isDisabled,
+ ItemInfoWithIcon info,
+ int indicatorcolor) {
+ super(bitmap, iconColor, isDisabled);
+ mInfo = info;
+ mIndicatorColor = indicatorcolor;
+ mLevel = info.getProgressLevel();
+ }
+
+ @Override
+ public PreloadIconDrawable newDrawable() {
+ PreloadIconDrawable drawable = new PreloadIconDrawable(mInfo, mIndicatorColor);
+ drawable.setLevel(mLevel);
+ drawable.setIsDisabled(mIsDisabled);
+ return drawable;
+ }
+
+ @Override
+ public int getChangingConfigurations() {
+ return 0;
+ }
+ }
}
diff --git a/src/com/android/launcher3/icons/ClockDrawableWrapper.java b/src/com/android/launcher3/icons/ClockDrawableWrapper.java
index b7dd092..1bd252b 100644
--- a/src/com/android/launcher3/icons/ClockDrawableWrapper.java
+++ b/src/com/android/launcher3/icons/ClockDrawableWrapper.java
@@ -308,7 +308,7 @@
return new ClockConstantState(mInfo, isDisabled());
}
- private static class ClockConstantState extends MyConstantState {
+ private static class ClockConstantState extends FastBitmapConstantState {
private final ClockBitmapInfo mInfo;
diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java
index f74c8b5..8438622 100644
--- a/src/com/android/launcher3/model/LoaderTask.java
+++ b/src/com/android/launcher3/model/LoaderTask.java
@@ -588,27 +588,26 @@
if (isSafeMode && !isSystemApp(context, intent)) {
info.runtimeStatusFlags |= FLAG_DISABLED_SAFEMODE;
}
+ LauncherActivityInfo activityInfo = c.getLauncherActivityInfo();
+ if (activityInfo != null) {
+ info.setProgressLevel(
+ PackageManagerHelper
+ .getLoadingProgress(activityInfo),
+ PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
+ }
if (c.restoreFlag != 0 && !TextUtils.isEmpty(targetPkg)) {
tempPackageKey.update(targetPkg, c.user);
SessionInfo si = installingPkgs.get(tempPackageKey);
- LauncherActivityInfo activityInfo =
- c.getLauncherActivityInfo();
if (si == null) {
info.runtimeStatusFlags &=
- ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE;
+ ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE;
} else if (activityInfo == null) {
int installProgress = (int) (si.getProgress() * 100);
info.setProgressLevel(
installProgress,
PackageInstallInfo.STATUS_INSTALLING);
- } else {
- info.setProgressLevel(
- PackageManagerHelper
- .getLoadingProgress(activityInfo),
- PackageInstallInfo
- .STATUS_INSTALLED_DOWNLOADING);
}
}
diff --git a/src/com/android/launcher3/model/data/AppInfo.java b/src/com/android/launcher3/model/data/AppInfo.java
index dde0cf4..7f70bad 100644
--- a/src/com/android/launcher3/model/data/AppInfo.java
+++ b/src/com/android/launcher3/model/data/AppInfo.java
@@ -179,7 +179,7 @@
// Sets the progress level, installation and incremental download flags.
info.setProgressLevel(
PackageManagerHelper.getLoadingProgress(lai),
- PackageInstallInfo.STATUS_INSTALLED);
+ PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
}
@Override
diff --git a/src/com/android/launcher3/model/data/SearchActionItemInfo.java b/src/com/android/launcher3/model/data/SearchActionItemInfo.java
index 36afe50..8469569 100644
--- a/src/com/android/launcher3/model/data/SearchActionItemInfo.java
+++ b/src/com/android/launcher3/model/data/SearchActionItemInfo.java
@@ -30,7 +30,7 @@
public static final int FLAG_SHOULD_START = 1 << 1;
public static final int FLAG_SHOULD_START_FOR_RESULT = FLAG_SHOULD_START | 1 << 2;
- public static final int FLAG_BADGE_FROM_ICON = 1 << 3;
+ public static final int FLAG_BADGE_WITH_PACKAGE = 1 << 3;
public static final int FLAG_PRIMARY_ICON_FROM_TITLE = 1 << 4;
private final String mFallbackPackageName;
diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java
index 355c949..3b7bcc2 100644
--- a/src/com/android/launcher3/util/DisplayController.java
+++ b/src/com/android/launcher3/util/DisplayController.java
@@ -31,6 +31,8 @@
import androidx.annotation.VisibleForTesting;
+import com.android.launcher3.Utilities;
+
import java.util.ArrayList;
/**
@@ -179,23 +181,35 @@
return mInfo;
}
+ /** Creates and up-to-date DisplayController.Info for the given context. */
+ public Info createInfoForContext(Context context) {
+ Display display = Utilities.ATLEAST_R
+ ? context.getDisplay()
+ : context
+ .getSystemService(DisplayManager.class)
+ .getDisplay(mId);
+ return display == null
+ ? new Info(context)
+ : new Info(context, display);
+ }
+
protected void handleOnChange() {
Info oldInfo = mInfo;
- Info info = new Info(mDisplayContext);
+ Info newInfo = createInfoForContext(mDisplayContext);
int change = 0;
- if (info.hasDifferentSize(oldInfo)) {
+ if (newInfo.hasDifferentSize(oldInfo)) {
change |= CHANGE_SIZE;
}
- if (oldInfo.rotation != info.rotation) {
+ if (newInfo.rotation != oldInfo.rotation) {
change |= CHANGE_ROTATION;
}
- if (info.singleFrameMs != oldInfo.singleFrameMs) {
+ if (newInfo.singleFrameMs != oldInfo.singleFrameMs) {
change |= CHANGE_FRAME_DELAY;
}
if (change != 0) {
- mInfo = info;
+ mInfo = newInfo;
final int flags = change;
MAIN_EXECUTOR.execute(() -> notifyChange(flags));
}
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index 1857c5a..23c3722 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -51,8 +51,10 @@
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.FolderAdaptiveIcon;
import com.android.launcher3.folder.FolderIcon;
+import com.android.launcher3.graphics.PreloadIconDrawable;
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.model.data.ItemInfo;
+import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.shortcuts.DeepShortcutView;
@@ -252,12 +254,26 @@
@SuppressWarnings("WrongThread")
private static void getIconResult(Launcher l, View originalView, ItemInfo info, RectF pos,
IconLoadResult iconLoadResult) {
- Drawable drawable = null;
+ Drawable drawable;
+ Drawable btvIcon;
Drawable badge = null;
boolean supportsAdaptiveIcons = ADAPTIVE_ICON_WINDOW_ANIM.get()
&& !info.isDisabled(); // Use original icon for disabled icons.
- Drawable btvIcon = originalView instanceof BubbleTextView
- ? ((BubbleTextView) originalView).getIcon() : null;
+
+ if (originalView instanceof BubbleTextView) {
+ BubbleTextView btv = (BubbleTextView) originalView;
+
+ if (info instanceof ItemInfoWithIcon
+ && (((ItemInfoWithIcon) info).runtimeStatusFlags
+ & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
+ btvIcon = btv.makePreloadIcon();
+ } else {
+ btvIcon = btv.getIcon();
+ }
+ } else {
+ btvIcon = null;
+ }
+
if (info instanceof SystemShortcut) {
if (originalView instanceof ImageView) {
drawable = ((ImageView) originalView).getDrawable();
@@ -266,6 +282,9 @@
} else {
drawable = originalView.getBackground();
}
+ } else if (btvIcon instanceof PreloadIconDrawable) {
+ // Force the progress bar to display.
+ drawable = btvIcon;
} else {
int width = (int) pos.width();
int height = (int) pos.height();
diff --git a/src_plugins/com/android/systemui/plugins/shared/SearchTargetEventLegacy.java b/src_plugins/com/android/systemui/plugins/shared/SearchTargetEventLegacy.java
index 7fbd6ac..0fc61f0 100644
--- a/src_plugins/com/android/systemui/plugins/shared/SearchTargetEventLegacy.java
+++ b/src_plugins/com/android/systemui/plugins/shared/SearchTargetEventLegacy.java
@@ -20,7 +20,7 @@
/**
* Event used for the feedback loop to the plugin. (and future aiai)
*
- * @deprecated Use SearchTargetEvent
+ * @deprecated Use {@link android.app.search.SearchTargetEvent}
*/
@Deprecated
public class SearchTargetEventLegacy {