Loading quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +45 −121 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.launcher3.taskbar; import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.anim.AnimatedFloat.VALUE; Loading @@ -27,13 +28,15 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH import static com.android.launcher3.taskbar.TaskbarManager.isPhoneMode; import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_NEGATIVE; import static com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL; import static com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_TASKBAR_ALIGNMENT_ANIM; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_TASKBAR_REVEAL_ANIM; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.annotation.NonNull; import android.graphics.Rect; import android.util.FloatProperty; import android.util.Log; import android.view.MotionEvent; import android.view.View; Loading @@ -43,10 +46,10 @@ import androidx.annotation.Nullable; import androidx.core.graphics.ColorUtils; import androidx.core.view.OneShotPreDrawListener; import com.android.launcher3.BubbleTextView; import com.android.launcher3.DeviceProfile; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; import com.android.launcher3.Reorderable; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AlphaUpdateListener; import com.android.launcher3.anim.AnimatedFloat; Loading @@ -56,7 +59,6 @@ import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.anim.RevealOutlineAnimation; import com.android.launcher3.anim.RoundedRectRevealOutlineProvider; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.icons.ThemedIconDrawable; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.touch.SingleAxisSwipeDetector; Loading @@ -65,6 +67,7 @@ import com.android.launcher3.util.HorizontalInsettableView; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.LauncherBindableItemsContainer; import com.android.launcher3.util.MultiPropertyFactory; import com.android.launcher3.util.MultiTranslateDelegate; import com.android.launcher3.util.MultiValueAlpha; import java.io.PrintWriter; Loading Loading @@ -338,19 +341,35 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar croppedTransX = newLeft - iconLeft; } as.play(ObjectAnimator.ofFloat(child, ICON_REVEAL_TRANSLATE_X, isStashed float croppedTransY = child.getHeight() - stashedBounds.height(); if (child instanceof Reorderable) { MultiTranslateDelegate mtd = ((Reorderable) child).getTranslateDelegate(); as.play(ObjectAnimator.ofFloat(mtd.getTranslationX(INDEX_TASKBAR_REVEAL_ANIM), MULTI_PROPERTY_VALUE, isStashed ? new float[] {croppedTransX} : new float[] {croppedTransX, 0})); float croppedTransY = child.getHeight() - stashedBounds.height(); as.play(ObjectAnimator.ofFloat(child, ICON_REVEAL_TRANSLATE_Y, isStashed as.play(ObjectAnimator.ofFloat(mtd.getTranslationX(INDEX_TASKBAR_REVEAL_ANIM), MULTI_PROPERTY_VALUE, isStashed ? new float[] {croppedTransY} : new float[] {croppedTransY, 0})); as.addListener(forEndCallback(() -> mtd.setTranslation(INDEX_TASKBAR_REVEAL_ANIM, 0, 0))); } else { as.play(ObjectAnimator.ofFloat(child, VIEW_TRANSLATE_X, isStashed ? new float[] {croppedTransX} : new float[] {croppedTransX, 0})); as.play(ObjectAnimator.ofFloat(child, VIEW_TRANSLATE_Y, isStashed ? new float[] {croppedTransY} : new float[] {croppedTransY, 0})); as.addListener(forEndCallback(() -> { ICON_REVEAL_TRANSLATE_X.set(child, 0f); ICON_REVEAL_TRANSLATE_Y.set(child, 0f); child.setTranslationX(0); child.setTranslationY(0); })); } } return as; } Loading Loading @@ -435,7 +454,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar float childCenter = (child.getLeft() + child.getRight()) / 2f; float halfQsbIconWidthDiff = (launcherDp.hotseatQsbWidth - taskbarDp.iconSizePx) / 2f; setter.addFloat(child, ICON_TRANSLATE_X, setter.addFloat(child, VIEW_TRANSLATE_X, isRtl ? -halfQsbIconWidthDiff : halfQsbIconWidthDiff, hotseatIconCenter - childCenter, interpolator); Loading Loading @@ -479,10 +498,18 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar + hotseatCellSize / 2f; float childCenter = (child.getLeft() + child.getRight()) / 2f; setter.setFloat(child, ICON_TRANSLATE_X, hotseatIconCenter - childCenter, interpolator); setter.setFloat(child, ICON_TRANSLATE_Y, mTaskbarBottomMargin, interpolator); if (child instanceof Reorderable) { MultiTranslateDelegate mtd = ((Reorderable) child).getTranslateDelegate(); setter.setFloat(mtd.getTranslationX(INDEX_TASKBAR_ALIGNMENT_ANIM), MULTI_PROPERTY_VALUE, hotseatIconCenter - childCenter, interpolator); setter.setFloat(mtd.getTranslationX(INDEX_TASKBAR_ALIGNMENT_ANIM), MULTI_PROPERTY_VALUE, mTaskbarBottomMargin, interpolator); } else { setter.setFloat(child, VIEW_TRANSLATE_X, hotseatIconCenter - childCenter, interpolator); setter.setFloat(child, VIEW_TRANSLATE_Y, mTaskbarBottomMargin, interpolator); } setter.setFloat(child, SCALE_PROPERTY, scaleUp, interpolator); } Loading Loading @@ -667,107 +694,4 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar mControllers.uiController.onIconLayoutBoundsChanged(); } } public static final FloatProperty<View> ICON_TRANSLATE_X = new FloatProperty<View>("taskbarAlignmentTranslateX") { @Override public void setValue(View view, float v) { if (view instanceof BubbleTextView) { ((BubbleTextView) view).setTranslationXForTaskbarAlignmentAnimation(v); } else if (view instanceof FolderIcon) { ((FolderIcon) view).setTranslationXForTaskbarAlignmentAnimation(v); } else { view.setTranslationX(v); } } @Override public Float get(View view) { if (view instanceof BubbleTextView) { return ((BubbleTextView) view) .getTranslationXForTaskbarAlignmentAnimation(); } else if (view instanceof FolderIcon) { return ((FolderIcon) view).getTranslationXForTaskbarAlignmentAnimation(); } return view.getTranslationX(); } }; public static final FloatProperty<View> ICON_TRANSLATE_Y = new FloatProperty<View>("taskbarAlignmentTranslateY") { @Override public void setValue(View view, float v) { if (view instanceof BubbleTextView) { ((BubbleTextView) view).setTranslationYForTaskbarAlignmentAnimation(v); } else if (view instanceof FolderIcon) { ((FolderIcon) view).setTranslationYForTaskbarAlignmentAnimation(v); } else { view.setTranslationY(v); } } @Override public Float get(View view) { if (view instanceof BubbleTextView) { return ((BubbleTextView) view) .getTranslationYForTaskbarAlignmentAnimation(); } else if (view instanceof FolderIcon) { return ((FolderIcon) view).getTranslationYForTaskbarAlignmentAnimation(); } return view.getTranslationY(); } }; public static final FloatProperty<View> ICON_REVEAL_TRANSLATE_X = new FloatProperty<View>("taskbarRevealTranslateX") { @Override public void setValue(View view, float v) { if (view instanceof BubbleTextView) { ((BubbleTextView) view).setTranslationXForTaskbarRevealAnimation(v); } else if (view instanceof FolderIcon) { ((FolderIcon) view).setTranslationXForTaskbarRevealAnimation(v); } else { view.setTranslationX(v); } } @Override public Float get(View view) { if (view instanceof BubbleTextView) { return ((BubbleTextView) view).getTranslationXForTaskbarRevealAnimation(); } else if (view instanceof FolderIcon) { return ((FolderIcon) view).getTranslationXForTaskbarRevealAnimation(); } return view.getTranslationX(); } }; public static final FloatProperty<View> ICON_REVEAL_TRANSLATE_Y = new FloatProperty<View>("taskbarRevealTranslateY") { @Override public void setValue(View view, float v) { if (view instanceof BubbleTextView) { ((BubbleTextView) view).setTranslationYForTaskbarRevealAnimation(v); } else if (view instanceof FolderIcon) { ((FolderIcon) view).setTranslationYForTaskbarRevealAnimation(v); } else { view.setTranslationY(v); } } @Override public Float get(View view) { if (view instanceof BubbleTextView) { return ((BubbleTextView) view).getTranslationYForTaskbarRevealAnimation(); } else if (view instanceof FolderIcon) { return ((FolderIcon) view).getTranslationYForTaskbarRevealAnimation(); } return view.getTranslationY(); } }; } quickstep/src/com/android/quickstep/util/LauncherViewsMoveFromCenterTranslationApplier.java +7 −9 Original line number Diff line number Diff line Loading @@ -15,12 +15,13 @@ */ package com.android.quickstep.util; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_MOVE_FROM_CENTER_ANIM; import android.annotation.NonNull; import android.view.View; import com.android.launcher3.BubbleTextView; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.widget.NavigableAppWidgetHostView; import com.android.launcher3.Reorderable; import com.android.launcher3.util.MultiTranslateDelegate; import com.android.systemui.shared.animation.UnfoldMoveFromCenterAnimator.TranslationApplier; /** Loading @@ -31,12 +32,9 @@ public class LauncherViewsMoveFromCenterTranslationApplier implements Translatio @Override public void apply(@NonNull View view, float x, float y) { if (view instanceof NavigableAppWidgetHostView) { ((NavigableAppWidgetHostView) view).setTranslationForMoveFromCenterAnimation(x, y); } else if (view instanceof BubbleTextView) { ((BubbleTextView) view).setTranslationForMoveFromCenterAnimation(x, y); } else if (view instanceof FolderIcon) { ((FolderIcon) view).setTranslationForMoveFromCenterAnimation(x, y); if (view instanceof Reorderable) { MultiTranslateDelegate mtd = ((Reorderable) view).getTranslateDelegate(); mtd.setTranslation(INDEX_MOVE_FROM_CENTER_ANIM, x, y); } else { view.setTranslationX(x); view.setTranslationY(y); Loading src/com/android/launcher3/BubbleTextView.java +5 −125 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; Loading Loading @@ -71,6 +70,7 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.popup.PopupContainerWithArrow; import com.android.launcher3.util.MultiTranslateDelegate; import com.android.launcher3.util.SafeCloseable; import com.android.launcher3.util.ShortcutUtil; import com.android.launcher3.views.ActivityContext; Loading Loading @@ -100,21 +100,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, private static final int[] STATE_PRESSED = new int[]{android.R.attr.state_pressed}; private final PointF mTranslationForReorderBounce = new PointF(0, 0); private final PointF mTranslationForReorderPreview = new PointF(0, 0); private float mTranslationXForTaskbarAlignmentAnimation = 0f; private float mTranslationYForTaskbarAlignmentAnimation = 0f; private float mTranslationXForTaskbarRevealAnimation = 0f; private float mTranslationYForTaskbarRevealAnimation = 0f; private final PointF mTranslationForMoveFromCenterAnimation = new PointF(0, 0); private float mScaleForReorderBounce = 1f; private float mTranslationXForTaskbarAllAppsIcon = 0f; private static final Property<BubbleTextView, Float> DOT_SCALE_PROPERTY = new Property<BubbleTextView, Float>(Float.TYPE, "dotScale") { @Override Loading Loading @@ -142,6 +129,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } }; private final MultiTranslateDelegate mTranslateDelegate = new MultiTranslateDelegate(this); private final ActivityContext mActivity; private FastBitmapDrawable mIcon; private boolean mCenterVertically; Loading Loading @@ -960,131 +948,23 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, mDisplay == DISPLAY_SEARCH_RESULT_SMALL; } private void updateTranslation() { super.setTranslationX(mTranslationForReorderBounce.x + mTranslationForReorderPreview.x + mTranslationXForTaskbarAllAppsIcon + mTranslationForMoveFromCenterAnimation.x + mTranslationXForTaskbarAlignmentAnimation + mTranslationXForTaskbarRevealAnimation ); super.setTranslationY(mTranslationForReorderBounce.y + mTranslationForReorderPreview.y + mTranslationForMoveFromCenterAnimation.y + mTranslationYForTaskbarAlignmentAnimation + mTranslationYForTaskbarRevealAnimation); } /** * Sets translationX for taskbar all apps icon */ public void setTranslationXForTaskbarAllAppsIcon(float translationX) { mTranslationXForTaskbarAllAppsIcon = translationX; updateTranslation(); } public void setReorderBounceOffset(float x, float y) { mTranslationForReorderBounce.set(x, y); updateTranslation(); } public void getReorderBounceOffset(PointF offset) { offset.set(mTranslationForReorderBounce); } @Override public void setReorderPreviewOffset(float x, float y) { mTranslationForReorderPreview.set(x, y); updateTranslation(); public MultiTranslateDelegate getTranslateDelegate() { return mTranslateDelegate; } @Override public void getReorderPreviewOffset(PointF offset) { offset.set(mTranslationForReorderPreview); } public void setReorderBounceScale(float scale) { mScaleForReorderBounce = scale; super.setScaleX(scale); super.setScaleY(scale); } @Override public float getReorderBounceScale() { return mScaleForReorderBounce; } /** * Sets translation values for move from center animation */ public void setTranslationForMoveFromCenterAnimation(float x, float y) { mTranslationForMoveFromCenterAnimation.set(x, y); updateTranslation(); } /** * Sets translationX for taskbar to launcher alignment animation */ public void setTranslationXForTaskbarAlignmentAnimation(float translationX) { mTranslationXForTaskbarAlignmentAnimation = translationX; updateTranslation(); } /** * Returns translationX value for taskbar to launcher alignment animation */ public float getTranslationXForTaskbarAlignmentAnimation() { return mTranslationXForTaskbarAlignmentAnimation; } /** * Sets translationX for taskbar to launcher alignment animation */ public void setTranslationYForTaskbarAlignmentAnimation(float translationY) { mTranslationYForTaskbarAlignmentAnimation = translationY; updateTranslation(); } /** * Returns translationY value for taskbar to launcher alignment animation */ public float getTranslationYForTaskbarAlignmentAnimation() { return mTranslationYForTaskbarAlignmentAnimation; } /** * Sets translationX value for taskbar reveal animation */ public void setTranslationXForTaskbarRevealAnimation(float translationX) { mTranslationXForTaskbarRevealAnimation = translationX; updateTranslation(); } /** * Returns translation values for taskbar reveal animation */ public float getTranslationXForTaskbarRevealAnimation() { return mTranslationXForTaskbarRevealAnimation; } /** * Sets translationY value for taskbar reveal animation */ public void setTranslationYForTaskbarRevealAnimation(float translationY) { mTranslationYForTaskbarRevealAnimation = translationY; updateTranslation(); } /** * Returns translationY values for taskbar reveal animation */ public float getTranslationYForTaskbarRevealAnimation() { return mTranslationYForTaskbarRevealAnimation; } public View getView() { return this; } @Override public int getViewType() { return DRAGGABLE_ICON; Loading src/com/android/launcher3/CellLayout.java +19 −16 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static com.android.launcher3.anim.Interpolators.DEACCEL_1_5; import static com.android.launcher3.config.FeatureFlags.SHOW_HOME_GARDENING; import static com.android.launcher3.dragndrop.DraggableView.DRAGGABLE_ICON; import static com.android.launcher3.icons.IconNormalizer.ICON_VISIBLE_AREA_FACTOR; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_REORDER_BOUNCE_OFFSET; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_REORDER_PREVIEW_OFFSET; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; Loading Loading @@ -70,6 +72,7 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.util.CellAndSpan; import com.android.launcher3.util.GridOccupancy; import com.android.launcher3.util.MultiTranslateDelegate; import com.android.launcher3.util.ParcelableSparseArray; import com.android.launcher3.util.Themes; import com.android.launcher3.util.Thunk; Loading Loading @@ -1099,13 +1102,12 @@ public class CellLayout extends ViewGroup { lp.isLockedToGrid = false; // End compute new x and y item.getReorderPreviewOffset(mTmpPointF); final float initPreviewOffsetX = mTmpPointF.x; final float initPreviewOffsetY = mTmpPointF.y; MultiTranslateDelegate mtd = item.getTranslateDelegate(); float initPreviewOffsetX = mtd.getTranslationX(INDEX_REORDER_PREVIEW_OFFSET).getValue(); float initPreviewOffsetY = mtd.getTranslationY(INDEX_REORDER_PREVIEW_OFFSET).getValue(); final float finalPreviewOffsetX = newX - oldX; final float finalPreviewOffsetY = newY - oldY; // Exit early if we're not actually moving the view if (finalPreviewOffsetX == 0 && finalPreviewOffsetY == 0 && initPreviewOffsetX == 0 && initPreviewOffsetY == 0) { Loading @@ -1123,7 +1125,7 @@ public class CellLayout extends ViewGroup { float r = (Float) animation.getAnimatedValue(); float x = (1 - r) * initPreviewOffsetX + r * finalPreviewOffsetX; float y = (1 - r) * initPreviewOffsetY + r * finalPreviewOffsetY; item.setReorderPreviewOffset(x, y); item.getTranslateDelegate().setTranslation(INDEX_REORDER_PREVIEW_OFFSET, x, y); } }); va.addListener(new AnimatorListenerAdapter() { Loading @@ -1134,7 +1136,8 @@ public class CellLayout extends ViewGroup { // place just yet. if (!cancelled) { lp.isLockedToGrid = true; item.setReorderPreviewOffset(0, 0); item.getTranslateDelegate() .setTranslation(INDEX_REORDER_PREVIEW_OFFSET, 0, 0); child.requestLayout(); } if (mReorderAnimators.containsKey(lp)) { Loading Loading @@ -1434,7 +1437,7 @@ public class CellLayout extends ViewGroup { CellLayoutLayoutParams lp = (CellLayoutLayoutParams) child.getLayoutParams(); if (c != null && !skip && (child instanceof Reorderable)) { ReorderPreviewAnimation rha = new ReorderPreviewAnimation((Reorderable) child, ReorderPreviewAnimation rha = new ReorderPreviewAnimation(child, mode, lp.getCellX(), lp.getCellY(), c.cellX, c.cellY, c.spanX, c.spanY); rha.animate(); } Loading @@ -1456,8 +1459,8 @@ public class CellLayout extends ViewGroup { // Class which represents the reorder preview animations. These animations show that an item is // in a temporary state, and hint at where the item will return to. class ReorderPreviewAnimation { final Reorderable child; class ReorderPreviewAnimation<T extends View & Reorderable> { final T child; float finalDeltaX; float finalDeltaY; float initDeltaX; Loading @@ -1477,7 +1480,7 @@ public class CellLayout extends ViewGroup { float animationProgress = 0; ValueAnimator a; public ReorderPreviewAnimation(Reorderable child, int mode, int cellX0, int cellY0, ReorderPreviewAnimation(View childView, int mode, int cellX0, int cellY0, int cellX1, int cellY1, int spanX, int spanY) { regionToCenterPoint(cellX0, cellY0, spanX, spanY, mTmpPoint); final int x0 = mTmpPoint[0]; Loading @@ -1488,16 +1491,16 @@ public class CellLayout extends ViewGroup { final int dX = x1 - x0; final int dY = y1 - y0; this.child = child; this.child = (T) childView; this.mode = mode; finalDeltaX = 0; finalDeltaY = 0; child.getReorderBounceOffset(mTmpPointF); initDeltaX = mTmpPointF.x; initDeltaY = mTmpPointF.y; MultiTranslateDelegate mtd = child.getTranslateDelegate(); initDeltaX = mtd.getTranslationX(INDEX_REORDER_BOUNCE_OFFSET).getValue(); initDeltaY = mtd.getTranslationY(INDEX_REORDER_BOUNCE_OFFSET).getValue(); initScale = child.getReorderBounceScale(); finalScale = mChildScale - (CHILD_DIVIDEND / child.getView().getWidth()) * initScale; finalScale = mChildScale - (CHILD_DIVIDEND / child.getWidth()) * initScale; int dir = mode == MODE_HINT ? -1 : 1; if (dX == dY && dX == 0) { Loading Loading @@ -1573,7 +1576,7 @@ public class CellLayout extends ViewGroup { float r1 = (mode == MODE_HINT && repeating) ? 1.0f : animationProgress; float x = r1 * finalDeltaX + (1 - r1) * initDeltaX; float y = r1 * finalDeltaY + (1 - r1) * initDeltaY; child.setReorderBounceOffset(x, y); child.getTranslateDelegate().setTranslation(INDEX_REORDER_BOUNCE_OFFSET, x, y); float s = animationProgress * finalScale + (1 - animationProgress) * initScale; child.setReorderBounceScale(s); } Loading src/com/android/launcher3/Reorderable.java +4 −18 Original line number Diff line number Diff line Loading @@ -16,33 +16,19 @@ package com.android.launcher3; import android.graphics.PointF; import android.view.View; import com.android.launcher3.util.MultiTranslateDelegate; public interface Reorderable { /** * Set the offset related to reorder hint and bounce animations * Returns the delegate to control translation */ void setReorderBounceOffset(float x, float y); void getReorderBounceOffset(PointF offset); /** * Set the offset related to previewing the new reordered position */ void setReorderPreviewOffset(float x, float y); void getReorderPreviewOffset(PointF offset); MultiTranslateDelegate getTranslateDelegate(); /** * Set the scale related to reorder hint and "bounce" animations */ void setReorderBounceScale(float scale); float getReorderBounceScale(); /** * Get the com.android.view related to this object */ View getView(); float getReorderBounceScale(); } Loading
quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +45 −121 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.launcher3.taskbar; import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.anim.AnimatedFloat.VALUE; Loading @@ -27,13 +28,15 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH import static com.android.launcher3.taskbar.TaskbarManager.isPhoneMode; import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_NEGATIVE; import static com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL; import static com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_TASKBAR_ALIGNMENT_ANIM; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_TASKBAR_REVEAL_ANIM; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.annotation.NonNull; import android.graphics.Rect; import android.util.FloatProperty; import android.util.Log; import android.view.MotionEvent; import android.view.View; Loading @@ -43,10 +46,10 @@ import androidx.annotation.Nullable; import androidx.core.graphics.ColorUtils; import androidx.core.view.OneShotPreDrawListener; import com.android.launcher3.BubbleTextView; import com.android.launcher3.DeviceProfile; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; import com.android.launcher3.Reorderable; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AlphaUpdateListener; import com.android.launcher3.anim.AnimatedFloat; Loading @@ -56,7 +59,6 @@ import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.anim.RevealOutlineAnimation; import com.android.launcher3.anim.RoundedRectRevealOutlineProvider; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.icons.ThemedIconDrawable; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.touch.SingleAxisSwipeDetector; Loading @@ -65,6 +67,7 @@ import com.android.launcher3.util.HorizontalInsettableView; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.LauncherBindableItemsContainer; import com.android.launcher3.util.MultiPropertyFactory; import com.android.launcher3.util.MultiTranslateDelegate; import com.android.launcher3.util.MultiValueAlpha; import java.io.PrintWriter; Loading Loading @@ -338,19 +341,35 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar croppedTransX = newLeft - iconLeft; } as.play(ObjectAnimator.ofFloat(child, ICON_REVEAL_TRANSLATE_X, isStashed float croppedTransY = child.getHeight() - stashedBounds.height(); if (child instanceof Reorderable) { MultiTranslateDelegate mtd = ((Reorderable) child).getTranslateDelegate(); as.play(ObjectAnimator.ofFloat(mtd.getTranslationX(INDEX_TASKBAR_REVEAL_ANIM), MULTI_PROPERTY_VALUE, isStashed ? new float[] {croppedTransX} : new float[] {croppedTransX, 0})); float croppedTransY = child.getHeight() - stashedBounds.height(); as.play(ObjectAnimator.ofFloat(child, ICON_REVEAL_TRANSLATE_Y, isStashed as.play(ObjectAnimator.ofFloat(mtd.getTranslationX(INDEX_TASKBAR_REVEAL_ANIM), MULTI_PROPERTY_VALUE, isStashed ? new float[] {croppedTransY} : new float[] {croppedTransY, 0})); as.addListener(forEndCallback(() -> mtd.setTranslation(INDEX_TASKBAR_REVEAL_ANIM, 0, 0))); } else { as.play(ObjectAnimator.ofFloat(child, VIEW_TRANSLATE_X, isStashed ? new float[] {croppedTransX} : new float[] {croppedTransX, 0})); as.play(ObjectAnimator.ofFloat(child, VIEW_TRANSLATE_Y, isStashed ? new float[] {croppedTransY} : new float[] {croppedTransY, 0})); as.addListener(forEndCallback(() -> { ICON_REVEAL_TRANSLATE_X.set(child, 0f); ICON_REVEAL_TRANSLATE_Y.set(child, 0f); child.setTranslationX(0); child.setTranslationY(0); })); } } return as; } Loading Loading @@ -435,7 +454,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar float childCenter = (child.getLeft() + child.getRight()) / 2f; float halfQsbIconWidthDiff = (launcherDp.hotseatQsbWidth - taskbarDp.iconSizePx) / 2f; setter.addFloat(child, ICON_TRANSLATE_X, setter.addFloat(child, VIEW_TRANSLATE_X, isRtl ? -halfQsbIconWidthDiff : halfQsbIconWidthDiff, hotseatIconCenter - childCenter, interpolator); Loading Loading @@ -479,10 +498,18 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar + hotseatCellSize / 2f; float childCenter = (child.getLeft() + child.getRight()) / 2f; setter.setFloat(child, ICON_TRANSLATE_X, hotseatIconCenter - childCenter, interpolator); setter.setFloat(child, ICON_TRANSLATE_Y, mTaskbarBottomMargin, interpolator); if (child instanceof Reorderable) { MultiTranslateDelegate mtd = ((Reorderable) child).getTranslateDelegate(); setter.setFloat(mtd.getTranslationX(INDEX_TASKBAR_ALIGNMENT_ANIM), MULTI_PROPERTY_VALUE, hotseatIconCenter - childCenter, interpolator); setter.setFloat(mtd.getTranslationX(INDEX_TASKBAR_ALIGNMENT_ANIM), MULTI_PROPERTY_VALUE, mTaskbarBottomMargin, interpolator); } else { setter.setFloat(child, VIEW_TRANSLATE_X, hotseatIconCenter - childCenter, interpolator); setter.setFloat(child, VIEW_TRANSLATE_Y, mTaskbarBottomMargin, interpolator); } setter.setFloat(child, SCALE_PROPERTY, scaleUp, interpolator); } Loading Loading @@ -667,107 +694,4 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar mControllers.uiController.onIconLayoutBoundsChanged(); } } public static final FloatProperty<View> ICON_TRANSLATE_X = new FloatProperty<View>("taskbarAlignmentTranslateX") { @Override public void setValue(View view, float v) { if (view instanceof BubbleTextView) { ((BubbleTextView) view).setTranslationXForTaskbarAlignmentAnimation(v); } else if (view instanceof FolderIcon) { ((FolderIcon) view).setTranslationXForTaskbarAlignmentAnimation(v); } else { view.setTranslationX(v); } } @Override public Float get(View view) { if (view instanceof BubbleTextView) { return ((BubbleTextView) view) .getTranslationXForTaskbarAlignmentAnimation(); } else if (view instanceof FolderIcon) { return ((FolderIcon) view).getTranslationXForTaskbarAlignmentAnimation(); } return view.getTranslationX(); } }; public static final FloatProperty<View> ICON_TRANSLATE_Y = new FloatProperty<View>("taskbarAlignmentTranslateY") { @Override public void setValue(View view, float v) { if (view instanceof BubbleTextView) { ((BubbleTextView) view).setTranslationYForTaskbarAlignmentAnimation(v); } else if (view instanceof FolderIcon) { ((FolderIcon) view).setTranslationYForTaskbarAlignmentAnimation(v); } else { view.setTranslationY(v); } } @Override public Float get(View view) { if (view instanceof BubbleTextView) { return ((BubbleTextView) view) .getTranslationYForTaskbarAlignmentAnimation(); } else if (view instanceof FolderIcon) { return ((FolderIcon) view).getTranslationYForTaskbarAlignmentAnimation(); } return view.getTranslationY(); } }; public static final FloatProperty<View> ICON_REVEAL_TRANSLATE_X = new FloatProperty<View>("taskbarRevealTranslateX") { @Override public void setValue(View view, float v) { if (view instanceof BubbleTextView) { ((BubbleTextView) view).setTranslationXForTaskbarRevealAnimation(v); } else if (view instanceof FolderIcon) { ((FolderIcon) view).setTranslationXForTaskbarRevealAnimation(v); } else { view.setTranslationX(v); } } @Override public Float get(View view) { if (view instanceof BubbleTextView) { return ((BubbleTextView) view).getTranslationXForTaskbarRevealAnimation(); } else if (view instanceof FolderIcon) { return ((FolderIcon) view).getTranslationXForTaskbarRevealAnimation(); } return view.getTranslationX(); } }; public static final FloatProperty<View> ICON_REVEAL_TRANSLATE_Y = new FloatProperty<View>("taskbarRevealTranslateY") { @Override public void setValue(View view, float v) { if (view instanceof BubbleTextView) { ((BubbleTextView) view).setTranslationYForTaskbarRevealAnimation(v); } else if (view instanceof FolderIcon) { ((FolderIcon) view).setTranslationYForTaskbarRevealAnimation(v); } else { view.setTranslationY(v); } } @Override public Float get(View view) { if (view instanceof BubbleTextView) { return ((BubbleTextView) view).getTranslationYForTaskbarRevealAnimation(); } else if (view instanceof FolderIcon) { return ((FolderIcon) view).getTranslationYForTaskbarRevealAnimation(); } return view.getTranslationY(); } }; }
quickstep/src/com/android/quickstep/util/LauncherViewsMoveFromCenterTranslationApplier.java +7 −9 Original line number Diff line number Diff line Loading @@ -15,12 +15,13 @@ */ package com.android.quickstep.util; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_MOVE_FROM_CENTER_ANIM; import android.annotation.NonNull; import android.view.View; import com.android.launcher3.BubbleTextView; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.widget.NavigableAppWidgetHostView; import com.android.launcher3.Reorderable; import com.android.launcher3.util.MultiTranslateDelegate; import com.android.systemui.shared.animation.UnfoldMoveFromCenterAnimator.TranslationApplier; /** Loading @@ -31,12 +32,9 @@ public class LauncherViewsMoveFromCenterTranslationApplier implements Translatio @Override public void apply(@NonNull View view, float x, float y) { if (view instanceof NavigableAppWidgetHostView) { ((NavigableAppWidgetHostView) view).setTranslationForMoveFromCenterAnimation(x, y); } else if (view instanceof BubbleTextView) { ((BubbleTextView) view).setTranslationForMoveFromCenterAnimation(x, y); } else if (view instanceof FolderIcon) { ((FolderIcon) view).setTranslationForMoveFromCenterAnimation(x, y); if (view instanceof Reorderable) { MultiTranslateDelegate mtd = ((Reorderable) view).getTranslateDelegate(); mtd.setTranslation(INDEX_MOVE_FROM_CENTER_ANIM, x, y); } else { view.setTranslationX(x); view.setTranslationY(y); Loading
src/com/android/launcher3/BubbleTextView.java +5 −125 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; Loading Loading @@ -71,6 +70,7 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.popup.PopupContainerWithArrow; import com.android.launcher3.util.MultiTranslateDelegate; import com.android.launcher3.util.SafeCloseable; import com.android.launcher3.util.ShortcutUtil; import com.android.launcher3.views.ActivityContext; Loading Loading @@ -100,21 +100,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, private static final int[] STATE_PRESSED = new int[]{android.R.attr.state_pressed}; private final PointF mTranslationForReorderBounce = new PointF(0, 0); private final PointF mTranslationForReorderPreview = new PointF(0, 0); private float mTranslationXForTaskbarAlignmentAnimation = 0f; private float mTranslationYForTaskbarAlignmentAnimation = 0f; private float mTranslationXForTaskbarRevealAnimation = 0f; private float mTranslationYForTaskbarRevealAnimation = 0f; private final PointF mTranslationForMoveFromCenterAnimation = new PointF(0, 0); private float mScaleForReorderBounce = 1f; private float mTranslationXForTaskbarAllAppsIcon = 0f; private static final Property<BubbleTextView, Float> DOT_SCALE_PROPERTY = new Property<BubbleTextView, Float>(Float.TYPE, "dotScale") { @Override Loading Loading @@ -142,6 +129,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } }; private final MultiTranslateDelegate mTranslateDelegate = new MultiTranslateDelegate(this); private final ActivityContext mActivity; private FastBitmapDrawable mIcon; private boolean mCenterVertically; Loading Loading @@ -960,131 +948,23 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, mDisplay == DISPLAY_SEARCH_RESULT_SMALL; } private void updateTranslation() { super.setTranslationX(mTranslationForReorderBounce.x + mTranslationForReorderPreview.x + mTranslationXForTaskbarAllAppsIcon + mTranslationForMoveFromCenterAnimation.x + mTranslationXForTaskbarAlignmentAnimation + mTranslationXForTaskbarRevealAnimation ); super.setTranslationY(mTranslationForReorderBounce.y + mTranslationForReorderPreview.y + mTranslationForMoveFromCenterAnimation.y + mTranslationYForTaskbarAlignmentAnimation + mTranslationYForTaskbarRevealAnimation); } /** * Sets translationX for taskbar all apps icon */ public void setTranslationXForTaskbarAllAppsIcon(float translationX) { mTranslationXForTaskbarAllAppsIcon = translationX; updateTranslation(); } public void setReorderBounceOffset(float x, float y) { mTranslationForReorderBounce.set(x, y); updateTranslation(); } public void getReorderBounceOffset(PointF offset) { offset.set(mTranslationForReorderBounce); } @Override public void setReorderPreviewOffset(float x, float y) { mTranslationForReorderPreview.set(x, y); updateTranslation(); public MultiTranslateDelegate getTranslateDelegate() { return mTranslateDelegate; } @Override public void getReorderPreviewOffset(PointF offset) { offset.set(mTranslationForReorderPreview); } public void setReorderBounceScale(float scale) { mScaleForReorderBounce = scale; super.setScaleX(scale); super.setScaleY(scale); } @Override public float getReorderBounceScale() { return mScaleForReorderBounce; } /** * Sets translation values for move from center animation */ public void setTranslationForMoveFromCenterAnimation(float x, float y) { mTranslationForMoveFromCenterAnimation.set(x, y); updateTranslation(); } /** * Sets translationX for taskbar to launcher alignment animation */ public void setTranslationXForTaskbarAlignmentAnimation(float translationX) { mTranslationXForTaskbarAlignmentAnimation = translationX; updateTranslation(); } /** * Returns translationX value for taskbar to launcher alignment animation */ public float getTranslationXForTaskbarAlignmentAnimation() { return mTranslationXForTaskbarAlignmentAnimation; } /** * Sets translationX for taskbar to launcher alignment animation */ public void setTranslationYForTaskbarAlignmentAnimation(float translationY) { mTranslationYForTaskbarAlignmentAnimation = translationY; updateTranslation(); } /** * Returns translationY value for taskbar to launcher alignment animation */ public float getTranslationYForTaskbarAlignmentAnimation() { return mTranslationYForTaskbarAlignmentAnimation; } /** * Sets translationX value for taskbar reveal animation */ public void setTranslationXForTaskbarRevealAnimation(float translationX) { mTranslationXForTaskbarRevealAnimation = translationX; updateTranslation(); } /** * Returns translation values for taskbar reveal animation */ public float getTranslationXForTaskbarRevealAnimation() { return mTranslationXForTaskbarRevealAnimation; } /** * Sets translationY value for taskbar reveal animation */ public void setTranslationYForTaskbarRevealAnimation(float translationY) { mTranslationYForTaskbarRevealAnimation = translationY; updateTranslation(); } /** * Returns translationY values for taskbar reveal animation */ public float getTranslationYForTaskbarRevealAnimation() { return mTranslationYForTaskbarRevealAnimation; } public View getView() { return this; } @Override public int getViewType() { return DRAGGABLE_ICON; Loading
src/com/android/launcher3/CellLayout.java +19 −16 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static com.android.launcher3.anim.Interpolators.DEACCEL_1_5; import static com.android.launcher3.config.FeatureFlags.SHOW_HOME_GARDENING; import static com.android.launcher3.dragndrop.DraggableView.DRAGGABLE_ICON; import static com.android.launcher3.icons.IconNormalizer.ICON_VISIBLE_AREA_FACTOR; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_REORDER_BOUNCE_OFFSET; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_REORDER_PREVIEW_OFFSET; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; Loading Loading @@ -70,6 +72,7 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.util.CellAndSpan; import com.android.launcher3.util.GridOccupancy; import com.android.launcher3.util.MultiTranslateDelegate; import com.android.launcher3.util.ParcelableSparseArray; import com.android.launcher3.util.Themes; import com.android.launcher3.util.Thunk; Loading Loading @@ -1099,13 +1102,12 @@ public class CellLayout extends ViewGroup { lp.isLockedToGrid = false; // End compute new x and y item.getReorderPreviewOffset(mTmpPointF); final float initPreviewOffsetX = mTmpPointF.x; final float initPreviewOffsetY = mTmpPointF.y; MultiTranslateDelegate mtd = item.getTranslateDelegate(); float initPreviewOffsetX = mtd.getTranslationX(INDEX_REORDER_PREVIEW_OFFSET).getValue(); float initPreviewOffsetY = mtd.getTranslationY(INDEX_REORDER_PREVIEW_OFFSET).getValue(); final float finalPreviewOffsetX = newX - oldX; final float finalPreviewOffsetY = newY - oldY; // Exit early if we're not actually moving the view if (finalPreviewOffsetX == 0 && finalPreviewOffsetY == 0 && initPreviewOffsetX == 0 && initPreviewOffsetY == 0) { Loading @@ -1123,7 +1125,7 @@ public class CellLayout extends ViewGroup { float r = (Float) animation.getAnimatedValue(); float x = (1 - r) * initPreviewOffsetX + r * finalPreviewOffsetX; float y = (1 - r) * initPreviewOffsetY + r * finalPreviewOffsetY; item.setReorderPreviewOffset(x, y); item.getTranslateDelegate().setTranslation(INDEX_REORDER_PREVIEW_OFFSET, x, y); } }); va.addListener(new AnimatorListenerAdapter() { Loading @@ -1134,7 +1136,8 @@ public class CellLayout extends ViewGroup { // place just yet. if (!cancelled) { lp.isLockedToGrid = true; item.setReorderPreviewOffset(0, 0); item.getTranslateDelegate() .setTranslation(INDEX_REORDER_PREVIEW_OFFSET, 0, 0); child.requestLayout(); } if (mReorderAnimators.containsKey(lp)) { Loading Loading @@ -1434,7 +1437,7 @@ public class CellLayout extends ViewGroup { CellLayoutLayoutParams lp = (CellLayoutLayoutParams) child.getLayoutParams(); if (c != null && !skip && (child instanceof Reorderable)) { ReorderPreviewAnimation rha = new ReorderPreviewAnimation((Reorderable) child, ReorderPreviewAnimation rha = new ReorderPreviewAnimation(child, mode, lp.getCellX(), lp.getCellY(), c.cellX, c.cellY, c.spanX, c.spanY); rha.animate(); } Loading @@ -1456,8 +1459,8 @@ public class CellLayout extends ViewGroup { // Class which represents the reorder preview animations. These animations show that an item is // in a temporary state, and hint at where the item will return to. class ReorderPreviewAnimation { final Reorderable child; class ReorderPreviewAnimation<T extends View & Reorderable> { final T child; float finalDeltaX; float finalDeltaY; float initDeltaX; Loading @@ -1477,7 +1480,7 @@ public class CellLayout extends ViewGroup { float animationProgress = 0; ValueAnimator a; public ReorderPreviewAnimation(Reorderable child, int mode, int cellX0, int cellY0, ReorderPreviewAnimation(View childView, int mode, int cellX0, int cellY0, int cellX1, int cellY1, int spanX, int spanY) { regionToCenterPoint(cellX0, cellY0, spanX, spanY, mTmpPoint); final int x0 = mTmpPoint[0]; Loading @@ -1488,16 +1491,16 @@ public class CellLayout extends ViewGroup { final int dX = x1 - x0; final int dY = y1 - y0; this.child = child; this.child = (T) childView; this.mode = mode; finalDeltaX = 0; finalDeltaY = 0; child.getReorderBounceOffset(mTmpPointF); initDeltaX = mTmpPointF.x; initDeltaY = mTmpPointF.y; MultiTranslateDelegate mtd = child.getTranslateDelegate(); initDeltaX = mtd.getTranslationX(INDEX_REORDER_BOUNCE_OFFSET).getValue(); initDeltaY = mtd.getTranslationY(INDEX_REORDER_BOUNCE_OFFSET).getValue(); initScale = child.getReorderBounceScale(); finalScale = mChildScale - (CHILD_DIVIDEND / child.getView().getWidth()) * initScale; finalScale = mChildScale - (CHILD_DIVIDEND / child.getWidth()) * initScale; int dir = mode == MODE_HINT ? -1 : 1; if (dX == dY && dX == 0) { Loading Loading @@ -1573,7 +1576,7 @@ public class CellLayout extends ViewGroup { float r1 = (mode == MODE_HINT && repeating) ? 1.0f : animationProgress; float x = r1 * finalDeltaX + (1 - r1) * initDeltaX; float y = r1 * finalDeltaY + (1 - r1) * initDeltaY; child.setReorderBounceOffset(x, y); child.getTranslateDelegate().setTranslation(INDEX_REORDER_BOUNCE_OFFSET, x, y); float s = animationProgress * finalScale + (1 - animationProgress) * initScale; child.setReorderBounceScale(s); } Loading
src/com/android/launcher3/Reorderable.java +4 −18 Original line number Diff line number Diff line Loading @@ -16,33 +16,19 @@ package com.android.launcher3; import android.graphics.PointF; import android.view.View; import com.android.launcher3.util.MultiTranslateDelegate; public interface Reorderable { /** * Set the offset related to reorder hint and bounce animations * Returns the delegate to control translation */ void setReorderBounceOffset(float x, float y); void getReorderBounceOffset(PointF offset); /** * Set the offset related to previewing the new reordered position */ void setReorderPreviewOffset(float x, float y); void getReorderPreviewOffset(PointF offset); MultiTranslateDelegate getTranslateDelegate(); /** * Set the scale related to reorder hint and "bounce" animations */ void setReorderBounceScale(float scale); float getReorderBounceScale(); /** * Get the com.android.view related to this object */ View getView(); float getReorderBounceScale(); }