From 3ee70182271ec0cf1a379ec194b478b24f7e7f32 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Wed, 21 Oct 2020 14:01:53 -0400 Subject: [PATCH] Fix All Apps Search plugin shortcut icon redrawing issue. BubbleTextViews animate the update from their placeholder icons to their high res icons. Added a field to allow restricting what BubbleTextViews' icon updates should be animated. Updated SearchResultIconRow to store the icon Drawable rather than the resource id to prevent unecessary redrawing. Fixes: 170966269 Demo: https://drive.google.com/file/d/1FBdEl11mHZk1SpCMRY4XZAGt5TVZ01W4/view?usp=sharing Change-Id: Ib55dafdf5b5fed00d343af5f95f3dd3f08c4ee8e --- src/com/android/launcher3/BubbleTextView.java | 7 ++++++- .../launcher3/views/SearchResultIconRow.java | 18 +++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 6245637407..1015a322e8 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -705,8 +705,13 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, updateIcon(icon); + ItemInfo itemInfo = (ItemInfo) getTag(); + // If the current icon is a placeholder color, animate its update. - if (mIcon != null && mIcon instanceof PlaceHolderIconDrawable) { + if (mIcon != null + && mIcon instanceof PlaceHolderIconDrawable + && (itemInfo == null + || itemInfo.itemType != LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT)) { animateIconUpdate((PlaceHolderIconDrawable) mIcon, icon); } diff --git a/src/com/android/launcher3/views/SearchResultIconRow.java b/src/com/android/launcher3/views/SearchResultIconRow.java index fe904ff115..bdbe890e8d 100644 --- a/src/com/android/launcher3/views/SearchResultIconRow.java +++ b/src/com/android/launcher3/views/SearchResultIconRow.java @@ -63,11 +63,11 @@ public class SearchResultIconRow extends DoubleShadowBubbleTextView implements public static final String REMOTE_ACTION_SHOULD_START = "should_start_for_result"; public static final String REMOTE_ACTION_TOKEN = "action_token"; - private final int mCustomIconResId; private final boolean mMatchesInset; private SearchTarget mSearchTarget; + @Nullable private Drawable mCustomIcon; public SearchResultIconRow(@NonNull Context context) { this(context, null, 0); @@ -83,10 +83,15 @@ public class SearchResultIconRow extends DoubleShadowBubbleTextView implements super(context, attrs, defStyleAttr); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SearchResultIconRow, defStyleAttr, 0); - mCustomIconResId = a.getResourceId(R.styleable.SearchResultIconRow_customIcon, 0); mMatchesInset = a.getBoolean(R.styleable.SearchResultIconRow_matchTextInsetWithQuery, false); + int customIconResId = a.getResourceId(R.styleable.SearchResultIconRow_customIcon, 0); + + if (customIconResId != 0) { + mCustomIcon = Launcher.getLauncher(context).getDrawable(customIconResId); + } + a.recycle(); } @@ -172,13 +177,16 @@ public class SearchResultIconRow extends DoubleShadowBubbleTextView implements } private boolean loadIconFromResource() { - if (mCustomIconResId == 0) return false; - setIcon(Launcher.getLauncher(getContext()).getDrawable(mCustomIconResId)); + if (mCustomIcon == null) return false; + setIcon(mCustomIcon); return true; } void reapplyItemInfoAsync(ItemInfoWithIcon itemInfoWithIcon) { - MAIN_EXECUTOR.post(() -> reapplyItemInfo(itemInfoWithIcon)); + MAIN_EXECUTOR.post(() -> { + reapplyItemInfo(itemInfoWithIcon); + mCustomIcon = getIcon(); + }); } @Override