Merge "Draw BubbleTextView drawable behind ClipIconView during app close animation." into ub-launcher3-master
This commit is contained in:
commit
80eaab99e7
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package com.android.launcher3.views;
|
package com.android.launcher3.views;
|
||||||
|
|
||||||
import static com.android.launcher3.LauncherAnimUtils.DRAWABLE_ALPHA;
|
|
||||||
import static com.android.launcher3.Utilities.getBadge;
|
import static com.android.launcher3.Utilities.getBadge;
|
||||||
import static com.android.launcher3.Utilities.getFullDrawable;
|
import static com.android.launcher3.Utilities.getFullDrawable;
|
||||||
import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM;
|
import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM;
|
||||||
|
@ -23,9 +22,6 @@ import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
|
||||||
import static com.android.launcher3.views.IconLabelDotView.setIconAndDotVisible;
|
import static com.android.launcher3.views.IconLabelDotView.setIconAndDotVisible;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
|
||||||
import android.animation.AnimatorSet;
|
|
||||||
import android.animation.ObjectAnimator;
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
@ -74,7 +70,6 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
private static @Nullable IconLoadResult sIconLoadResult;
|
private static @Nullable IconLoadResult sIconLoadResult;
|
||||||
|
|
||||||
public static final float SHAPE_PROGRESS_DURATION = 0.10f;
|
public static final float SHAPE_PROGRESS_DURATION = 0.10f;
|
||||||
private static final int FADE_DURATION_MS = 200;
|
|
||||||
private static final RectF sTmpRectF = new RectF();
|
private static final RectF sTmpRectF = new RectF();
|
||||||
private static final Object[] sTmpObjArray = new Object[1];
|
private static final Object[] sTmpObjArray = new Object[1];
|
||||||
|
|
||||||
|
@ -89,6 +84,9 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
|
|
||||||
private IconLoadResult mIconLoadResult;
|
private IconLoadResult mIconLoadResult;
|
||||||
|
|
||||||
|
// Draw the drawable of the BubbleTextView behind ClipIconView to reveal the built in shadow.
|
||||||
|
private View mBtvDrawable;
|
||||||
|
|
||||||
private ClipIconView mClipIconView;
|
private ClipIconView mClipIconView;
|
||||||
private @Nullable Drawable mBadge;
|
private @Nullable Drawable mBadge;
|
||||||
|
|
||||||
|
@ -98,7 +96,6 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
|
|
||||||
private final Rect mFinalDrawableBounds = new Rect();
|
private final Rect mFinalDrawableBounds = new Rect();
|
||||||
|
|
||||||
private AnimatorSet mFadeAnimatorSet;
|
|
||||||
private ListenerView mListenerView;
|
private ListenerView mListenerView;
|
||||||
private Runnable mFastFinishRunnable;
|
private Runnable mFastFinishRunnable;
|
||||||
|
|
||||||
|
@ -116,6 +113,8 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
mIsRtl = Utilities.isRtl(getResources());
|
mIsRtl = Utilities.isRtl(getResources());
|
||||||
mListenerView = new ListenerView(context, attrs);
|
mListenerView = new ListenerView(context, attrs);
|
||||||
mClipIconView = new ClipIconView(context, attrs);
|
mClipIconView = new ClipIconView(context, attrs);
|
||||||
|
mBtvDrawable = new ImageView(context, attrs);
|
||||||
|
addView(mBtvDrawable);
|
||||||
addView(mClipIconView);
|
addView(mClipIconView);
|
||||||
setWillNotDraw(false);
|
setWillNotDraw(false);
|
||||||
}
|
}
|
||||||
|
@ -176,6 +175,7 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
setLayoutParams(lp);
|
setLayoutParams(lp);
|
||||||
|
|
||||||
mClipIconView.setLayoutParams(new FrameLayout.LayoutParams(lp.width, lp.height));
|
mClipIconView.setLayoutParams(new FrameLayout.LayoutParams(lp.width, lp.height));
|
||||||
|
mBtvDrawable.setLayoutParams(new FrameLayout.LayoutParams(lp.width, lp.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePosition(RectF pos, InsettableFrameLayout.LayoutParams lp) {
|
private void updatePosition(RectF pos, InsettableFrameLayout.LayoutParams lp) {
|
||||||
|
@ -292,6 +292,8 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
drawable = drawable == null ? null : drawable.getConstantState().newDrawable();
|
drawable = drawable == null ? null : drawable.getConstantState().newDrawable();
|
||||||
int iconOffset = getOffsetForIconBounds(l, drawable, pos);
|
int iconOffset = getOffsetForIconBounds(l, drawable, pos);
|
||||||
synchronized (iconLoadResult) {
|
synchronized (iconLoadResult) {
|
||||||
|
iconLoadResult.btvDrawable = btvIcon == null || drawable == btvIcon
|
||||||
|
? null : btvIcon.getConstantState().newDrawable();
|
||||||
iconLoadResult.drawable = drawable;
|
iconLoadResult.drawable = drawable;
|
||||||
iconLoadResult.badge = badge;
|
iconLoadResult.badge = badge;
|
||||||
iconLoadResult.iconOffset = iconOffset;
|
iconLoadResult.iconOffset = iconOffset;
|
||||||
|
@ -311,7 +313,8 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
* @param iconOffset The amount of offset needed to match this view with the original view.
|
* @param iconOffset The amount of offset needed to match this view with the original view.
|
||||||
*/
|
*/
|
||||||
@UiThread
|
@UiThread
|
||||||
private void setIcon(@Nullable Drawable drawable, @Nullable Drawable badge, int iconOffset) {
|
private void setIcon(@Nullable Drawable drawable, @Nullable Drawable badge,
|
||||||
|
@Nullable Drawable btvIcon, int iconOffset) {
|
||||||
final InsettableFrameLayout.LayoutParams lp =
|
final InsettableFrameLayout.LayoutParams lp =
|
||||||
(InsettableFrameLayout.LayoutParams) getLayoutParams();
|
(InsettableFrameLayout.LayoutParams) getLayoutParams();
|
||||||
mBadge = badge;
|
mBadge = badge;
|
||||||
|
@ -342,6 +345,10 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
mBadge.setBounds(0, 0, clipViewOgWidth, clipViewOgHeight);
|
mBadge.setBounds(0, 0, clipViewOgWidth, clipViewOgHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mIsOpening && btvIcon != null) {
|
||||||
|
mBtvDrawable.setBackground(btvIcon);
|
||||||
|
}
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +367,7 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
synchronized (mIconLoadResult) {
|
synchronized (mIconLoadResult) {
|
||||||
if (mIconLoadResult.isIconLoaded) {
|
if (mIconLoadResult.isIconLoaded) {
|
||||||
setIcon(mIconLoadResult.drawable, mIconLoadResult.badge,
|
setIcon(mIconLoadResult.drawable, mIconLoadResult.badge,
|
||||||
mIconLoadResult.iconOffset);
|
mIconLoadResult.btvDrawable, mIconLoadResult.iconOffset);
|
||||||
setIconAndDotVisible(originalView, false);
|
setIconAndDotVisible(originalView, false);
|
||||||
} else {
|
} else {
|
||||||
mIconLoadResult.onIconLoaded = () -> {
|
mIconLoadResult.onIconLoaded = () -> {
|
||||||
|
@ -369,7 +376,7 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
}
|
}
|
||||||
|
|
||||||
setIcon(mIconLoadResult.drawable, mIconLoadResult.badge,
|
setIcon(mIconLoadResult.drawable, mIconLoadResult.badge,
|
||||||
mIconLoadResult.iconOffset);
|
mIconLoadResult.btvDrawable, mIconLoadResult.iconOffset);
|
||||||
|
|
||||||
setVisibility(VISIBLE);
|
setVisibility(VISIBLE);
|
||||||
setIconAndDotVisible(originalView, false);
|
setIconAndDotVisible(originalView, false);
|
||||||
|
@ -434,10 +441,6 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
mEndRunnable.run();
|
mEndRunnable.run();
|
||||||
mEndRunnable = null;
|
mEndRunnable = null;
|
||||||
}
|
}
|
||||||
if (mFadeAnimatorSet != null) {
|
|
||||||
mFadeAnimatorSet.end();
|
|
||||||
mFadeAnimatorSet = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -546,8 +549,16 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
setIconAndDotVisible(originalView, true);
|
setIconAndDotVisible(originalView, true);
|
||||||
view.finish(dragLayer);
|
view.finish(dragLayer);
|
||||||
} else {
|
} else {
|
||||||
view.mFadeAnimatorSet = view.createFadeAnimation(originalView, dragLayer);
|
originalView.setVisibility(VISIBLE);
|
||||||
view.mFadeAnimatorSet.start();
|
if (originalView instanceof IconLabelDotView) {
|
||||||
|
setIconAndDotVisible(originalView, true);
|
||||||
|
}
|
||||||
|
if (originalView instanceof BubbleTextView) {
|
||||||
|
BubbleTextView btv = (BubbleTextView) originalView;
|
||||||
|
btv.setIconVisible(true);
|
||||||
|
btv.setForceHideDot(true);
|
||||||
|
}
|
||||||
|
view.finish(dragLayer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
view.finish(dragLayer);
|
view.finish(dragLayer);
|
||||||
|
@ -564,47 +575,6 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AnimatorSet createFadeAnimation(View originalView, DragLayer dragLayer) {
|
|
||||||
AnimatorSet fade = new AnimatorSet();
|
|
||||||
fade.setDuration(FADE_DURATION_MS);
|
|
||||||
fade.addListener(new AnimatorListenerAdapter() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationStart(Animator animation) {
|
|
||||||
originalView.setVisibility(VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
finish(dragLayer);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (originalView instanceof IconLabelDotView) {
|
|
||||||
fade.addListener(new AnimatorListenerAdapter() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
setIconAndDotVisible(originalView, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (originalView instanceof BubbleTextView) {
|
|
||||||
BubbleTextView btv = (BubbleTextView) originalView;
|
|
||||||
fade.addListener(new AnimatorListenerAdapter() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationStart(Animator animation) {
|
|
||||||
btv.setIconVisible(true);
|
|
||||||
btv.setForceHideDot(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fade.play(ObjectAnimator.ofInt(btv.getIcon(), DRAWABLE_ALPHA, 0, 255));
|
|
||||||
} else if (!(originalView instanceof FolderIcon)) {
|
|
||||||
fade.play(ObjectAnimator.ofFloat(originalView, ALPHA, 0f, 1f));
|
|
||||||
}
|
|
||||||
|
|
||||||
return fade;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void finish(DragLayer dragLayer) {
|
private void finish(DragLayer dragLayer) {
|
||||||
((ViewGroup) dragLayer.getParent()).removeView(this);
|
((ViewGroup) dragLayer.getParent()).removeView(this);
|
||||||
dragLayer.removeView(mListenerView);
|
dragLayer.removeView(mListenerView);
|
||||||
|
@ -628,11 +598,7 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
mLoadIconSignal = null;
|
mLoadIconSignal = null;
|
||||||
mEndRunnable = null;
|
mEndRunnable = null;
|
||||||
mFinalDrawableBounds.setEmpty();
|
mFinalDrawableBounds.setEmpty();
|
||||||
if (mFadeAnimatorSet != null) {
|
|
||||||
mFadeAnimatorSet.cancel();
|
|
||||||
}
|
|
||||||
mPositionOut = null;
|
mPositionOut = null;
|
||||||
mFadeAnimatorSet = null;
|
|
||||||
mListenerView.setListener(null);
|
mListenerView.setListener(null);
|
||||||
mOriginalIcon = null;
|
mOriginalIcon = null;
|
||||||
mOnTargetChangeRunnable = null;
|
mOnTargetChangeRunnable = null;
|
||||||
|
@ -640,11 +606,13 @@ public class FloatingIconView extends FrameLayout implements
|
||||||
sTmpObjArray[0] = null;
|
sTmpObjArray[0] = null;
|
||||||
mIconLoadResult = null;
|
mIconLoadResult = null;
|
||||||
mClipIconView.recycle();
|
mClipIconView.recycle();
|
||||||
|
mBtvDrawable.setBackground(null);
|
||||||
mFastFinishRunnable = null;
|
mFastFinishRunnable = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class IconLoadResult {
|
private static class IconLoadResult {
|
||||||
final ItemInfo itemInfo;
|
final ItemInfo itemInfo;
|
||||||
|
Drawable btvDrawable;
|
||||||
Drawable drawable;
|
Drawable drawable;
|
||||||
Drawable badge;
|
Drawable badge;
|
||||||
int iconOffset;
|
int iconOffset;
|
||||||
|
|
Loading…
Reference in New Issue