From 0c2f0faef11a3d6397b96097c32d45f34a191dbc Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Fri, 10 Dec 2021 11:33:58 -0800 Subject: [PATCH] Display in-memory icon for app close while AdaptiveIcon loads. - We already display the BubbleTextView icon during app close since we need the shadows to ensure a clean handoff. - Previously, we waited until the icon and the AdaptiveIcon were both loaded to show the FloatingIconView. - This change immediately shows the BubbleTextView icon so that we can have something displayed in the cases where AdaptiveIcon is slow to load (ie. immediately after killing/restarting launcher). Currently there are cases where we defer some BubbleTextView drawing to ClipIconView. We can refactor in master so that ClipIconView is only used when drawable is an AdaptiveIcon. Bug: 207389002 Test: manual Change-Id: Ie54642fef4258862a155ab0aba6e49cea9c9ead0 --- .../launcher3/views/FloatingIconView.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java index 8b7ad46dfb..41e3da2a65 100644 --- a/src/com/android/launcher3/views/FloatingIconView.java +++ b/src/com/android/launcher3/views/FloatingIconView.java @@ -88,7 +88,6 @@ public class FloatingIconView extends FrameLayout implements private IconLoadResult mIconLoadResult; - // Draw the drawable of the BubbleTextView behind ClipIconView to reveal the built in shadow. private View mBtvDrawable; private ClipIconView mClipIconView; @@ -349,10 +348,23 @@ public class FloatingIconView extends FrameLayout implements } } - if (!mIsOpening && btvIcon != null) { + setOriginalDrawableBackground(btvIcon); + invalidate(); + } + + /** + * Draws the drawable of the BubbleTextView behind ClipIconView + * + * This is used to: + * - Have icon displayed while Adaptive Icon is loading + * - Displays the built in shadow to ensure a clean handoff + * + * Allows nullable as this may be cleared when drawing is deferred to ClipIconView. + */ + private void setOriginalDrawableBackground(@Nullable Drawable btvIcon) { + if (!mIsOpening) { mBtvDrawable.setBackground(btvIcon); } - invalidate(); } /** @@ -457,7 +469,9 @@ public class FloatingIconView extends FrameLayout implements @Override public void onAnimationStart(Animator animator) { - if (mIconLoadResult != null && mIconLoadResult.isIconLoaded) { + if ((mIconLoadResult != null && mIconLoadResult.isIconLoaded) + || (!mIsOpening && mBtvDrawable.getBackground() != null)) { + // No need to wait for icon load since we can display the BubbleTextView drawable. setVisibility(View.VISIBLE); } if (!mIsOpening) { @@ -520,6 +534,7 @@ public class FloatingIconView extends FrameLayout implements IconLoadResult result = new IconLoadResult(info, btvIcon == null ? false : btvIcon.isThemed()); + result.btvDrawable = btvIcon; final long fetchIconId = sFetchIconId++; MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(() -> { @@ -558,6 +573,7 @@ public class FloatingIconView extends FrameLayout implements view.mIconLoadResult = fetchIcon(launcher, originalView, (ItemInfo) originalView.getTag(), isOpening); } + view.setOriginalDrawableBackground(view.mIconLoadResult.btvDrawable); } sIconLoadResult = null;