From 7bbec50031ed4f482d615e9516ec5be5432cb565 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Thu, 29 Oct 2020 11:39:24 -0400 Subject: [PATCH] Fix AllAppsSearchPlugin icon redrawing without special-casing. Preventing icon animations in deep shortcuts fixed the icon redrawing issue in the all apps search page, however other icons could still be redrawn, yet could not be special-cased without removing icon update animations altogether. Added logic to only animate icon updates outside of the all apps search page. Demo: https://drive.google.com/file/d/1ReT2O_1tV20terY0Jr1NJGxIxPblHCK4/view?usp=sharing Change-Id: Ibe0b43801ec5340c3551125aef13170d569d2c55 --- src/com/android/launcher3/BubbleTextView.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 5cd63721d3..3eb52adf1a 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -171,6 +171,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, private IconLoadRequest mIconLoadRequest; + private boolean mEnableIconUpdateAnimation = false; + public BubbleTextView(Context context) { this(context, null, 0); } @@ -697,6 +699,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, applyCompoundDrawables(icon); } + protected boolean iconUpdateAnimationEnabled() { + return mEnableIconUpdateAnimation; + } + protected void applyCompoundDrawables(Drawable icon) { // If we had already set an icon before, disable relayout as the icon size is the // same as before. @@ -706,13 +712,10 @@ 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 - && (itemInfo == null - || itemInfo.itemType != LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT)) { + && iconUpdateAnimationEnabled()) { animateIconUpdate((PlaceHolderIconDrawable) mIcon, icon); } @@ -734,6 +737,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, if (getTag() == info) { mIconLoadRequest = null; mDisableRelayout = true; + mEnableIconUpdateAnimation = true; // Optimization: Starting in N, pre-uploads the bitmap to RenderThread. info.bitmap.icon.prepareToDraw(); @@ -750,6 +754,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } mDisableRelayout = false; + mEnableIconUpdateAnimation = false; } }