Merge "Simplifying code around multiple translation components" into tm-qpr-dev
This commit is contained in:
commit
33c3e77411
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -338,18 +341,34 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
|||
croppedTransX = newLeft - iconLeft;
|
||||
}
|
||||
|
||||
as.play(ObjectAnimator.ofFloat(child, ICON_REVEAL_TRANSLATE_X, isStashed
|
||||
? new float[] {croppedTransX}
|
||||
: new float[] {croppedTransX, 0}));
|
||||
|
||||
float croppedTransY = child.getHeight() - stashedBounds.height();
|
||||
as.play(ObjectAnimator.ofFloat(child, ICON_REVEAL_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);
|
||||
}));
|
||||
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}));
|
||||
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(() -> {
|
||||
child.setTranslationX(0);
|
||||
child.setTranslationY(0);
|
||||
}));
|
||||
}
|
||||
}
|
||||
return as;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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 MultiTranslateDelegate getTranslateDelegate() {
|
||||
return mTranslateDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReorderPreviewOffset(float x, float y) {
|
||||
mTranslationForReorderPreview.set(x, y);
|
||||
updateTranslation();
|
||||
}
|
||||
|
||||
@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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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() {
|
||||
|
@ -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)) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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];
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import static android.view.MotionEvent.ACTION_DOWN;
|
|||
import static com.android.launcher3.CellLayout.FOLDER;
|
||||
import static com.android.launcher3.CellLayout.HOTSEAT;
|
||||
import static com.android.launcher3.CellLayout.WORKSPACE;
|
||||
import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_WIDGET_CENTERING;
|
||||
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.Context;
|
||||
|
@ -208,7 +209,8 @@ public class ShortcutAndWidgetContainer extends ViewGroup implements FolderIcon.
|
|||
float scaleY = appWidgetScale.y;
|
||||
|
||||
nahv.setScaleToFit(Math.min(scaleX, scaleY));
|
||||
nahv.setTranslationForCentering(-(lp.width - (lp.width * scaleX)) / 2.0f,
|
||||
nahv.getTranslateDelegate().setTranslation(INDEX_WIDGET_CENTERING,
|
||||
-(lp.width - (lp.width * scaleX)) / 2.0f,
|
||||
-(lp.height - (lp.height * scaleY)) / 2.0f);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import android.animation.AnimatorListenerAdapter;
|
|||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
|
@ -77,6 +76,7 @@ import com.android.launcher3.model.data.WorkspaceItemFactory;
|
|||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.touch.ItemClickHandler;
|
||||
import com.android.launcher3.util.Executors;
|
||||
import com.android.launcher3.util.MultiTranslateDelegate;
|
||||
import com.android.launcher3.util.Thunk;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.launcher3.views.IconLabelDotView;
|
||||
|
@ -93,6 +93,7 @@ import java.util.function.Predicate;
|
|||
public class FolderIcon extends FrameLayout implements FolderListener, IconLabelDotView,
|
||||
DraggableView, Reorderable {
|
||||
|
||||
private final MultiTranslateDelegate mTranslateDelegate = new MultiTranslateDelegate(this);
|
||||
@Thunk ActivityContext mActivity;
|
||||
@Thunk Folder mFolder;
|
||||
public FolderInfo mInfo;
|
||||
|
@ -133,14 +134,6 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
|
|||
|
||||
private Rect mTouchArea = new Rect();
|
||||
|
||||
private final PointF mTranslationForMoveFromCenterAnimation = new PointF(0, 0);
|
||||
private float mTranslationXForTaskbarAlignmentAnimation = 0f;
|
||||
private float mTranslationYForTaskbarAlignmentAnimation = 0f;
|
||||
private float mTranslationXForTaskbarRevealAnimation = 0f;
|
||||
private float mTranslationYForTaskbarRevealAnimation = 0f;
|
||||
|
||||
private final PointF mTranslationForReorderBounce = new PointF(0, 0);
|
||||
private final PointF mTranslationForReorderPreview = new PointF(0, 0);
|
||||
private float mScaleForReorderBounce = 1f;
|
||||
|
||||
private static final Property<FolderIcon, Float> DOT_SCALE_PROPERTY
|
||||
|
@ -770,120 +763,23 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
|
|||
mPreviewItemManager.onFolderClose(currentPage);
|
||||
}
|
||||
|
||||
private void updateTranslation() {
|
||||
super.setTranslationX(mTranslationForReorderBounce.x
|
||||
+ mTranslationForReorderPreview.x
|
||||
+ mTranslationForMoveFromCenterAnimation.x
|
||||
+ mTranslationXForTaskbarAlignmentAnimation
|
||||
+ mTranslationXForTaskbarRevealAnimation);
|
||||
super.setTranslationY(mTranslationForReorderBounce.y + mTranslationForReorderPreview.y
|
||||
+ mTranslationForMoveFromCenterAnimation.y
|
||||
+ mTranslationYForTaskbarAlignmentAnimation
|
||||
+ mTranslationYForTaskbarRevealAnimation);
|
||||
}
|
||||
|
||||
public void setReorderBounceOffset(float x, float y) {
|
||||
mTranslationForReorderBounce.set(x, y);
|
||||
updateTranslation();
|
||||
}
|
||||
|
||||
public void getReorderBounceOffset(PointF offset) {
|
||||
offset.set(mTranslationForReorderBounce);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets translationX value for taskbar to launcher alignment animation
|
||||
*/
|
||||
public void setTranslationXForTaskbarAlignmentAnimation(float translationX) {
|
||||
mTranslationXForTaskbarAlignmentAnimation = translationX;
|
||||
updateTranslation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns translation values for taskbar to launcher alignment animation
|
||||
*/
|
||||
public float getTranslationXForTaskbarAlignmentAnimation() {
|
||||
return mTranslationXForTaskbarAlignmentAnimation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets translationY value for taskbar to launcher alignment animation
|
||||
*/
|
||||
public void setTranslationYForTaskbarAlignmentAnimation(float translationY) {
|
||||
mTranslationYForTaskbarAlignmentAnimation = translationY;
|
||||
updateTranslation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns translation values 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets translation values for move from center animation
|
||||
*/
|
||||
public void setTranslationForMoveFromCenterAnimation(float x, float y) {
|
||||
mTranslationForMoveFromCenterAnimation.set(x, y);
|
||||
updateTranslation();
|
||||
@Override
|
||||
public MultiTranslateDelegate getTranslateDelegate() {
|
||||
return mTranslateDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReorderPreviewOffset(float x, float y) {
|
||||
mTranslationForReorderPreview.set(x, y);
|
||||
updateTranslation();
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewType() {
|
||||
return DRAGGABLE_ICON;
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.launcher3.util;
|
||||
|
||||
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
|
||||
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
|
||||
|
||||
/**
|
||||
* A utility class to split translation components for various workspace items
|
||||
*/
|
||||
public class MultiTranslateDelegate {
|
||||
|
||||
// offset related to reorder hint and bounce animations
|
||||
public static final int INDEX_REORDER_BOUNCE_OFFSET = 0;
|
||||
// offset related to previewing the new reordered position
|
||||
public static final int INDEX_REORDER_PREVIEW_OFFSET = 1;
|
||||
public static final int INDEX_MOVE_FROM_CENTER_ANIM = 2;
|
||||
|
||||
// Specific for icons and folders
|
||||
public static final int INDEX_TASKBAR_ALIGNMENT_ANIM = 3;
|
||||
public static final int INDEX_TASKBAR_REVEAL_ANIM = 4;
|
||||
|
||||
// Specific for widgets
|
||||
public static final int INDEX_WIDGET_CENTERING = 3;
|
||||
|
||||
public static final int COUNT = 5;
|
||||
|
||||
private final MultiPropertyFactory<View> mTranslationX;
|
||||
private final MultiPropertyFactory<View> mTranslationY;
|
||||
|
||||
public MultiTranslateDelegate(View target) {
|
||||
this(target, COUNT, COUNT);
|
||||
}
|
||||
|
||||
public MultiTranslateDelegate(View target, int countX, int countY) {
|
||||
mTranslationX = new MultiPropertyFactory<>(target, VIEW_TRANSLATE_X, countX, Float::sum);
|
||||
mTranslationY = new MultiPropertyFactory<>(target, VIEW_TRANSLATE_Y, countY, Float::sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set both translations, x and y at a given index
|
||||
*/
|
||||
public void setTranslation(int index, float x, float y) {
|
||||
getTranslationX(index).setValue(x);
|
||||
getTranslationY(index).setValue(y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the translation x for the provided index
|
||||
*/
|
||||
public MultiProperty getTranslationX(int index) {
|
||||
return mTranslationX.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the translation y for the provided index
|
||||
*/
|
||||
public MultiProperty getTranslationY(int index) {
|
||||
return mTranslationY.get(index);
|
||||
}
|
||||
}
|
|
@ -37,6 +37,7 @@ import com.android.launcher3.BubbleTextView;
|
|||
import com.android.launcher3.icons.BaseIconFactory;
|
||||
import com.android.launcher3.icons.FastBitmapDrawable;
|
||||
import com.android.launcher3.icons.LauncherIcons;
|
||||
import com.android.launcher3.util.MultiTranslateDelegate;
|
||||
|
||||
/**
|
||||
* Button in Taskbar that shows a tinted background and foreground.
|
||||
|
@ -45,6 +46,12 @@ public class IconButtonView extends BubbleTextView {
|
|||
|
||||
private static final int[] ATTRS = {android.R.attr.icon};
|
||||
|
||||
private static final int INDEX_TASKBAR_ALL_APPS_ICON = MultiTranslateDelegate.COUNT;
|
||||
private static final int MY_COUNT = MultiTranslateDelegate.COUNT + 1;
|
||||
|
||||
private final MultiTranslateDelegate mTranslateDelegate =
|
||||
new MultiTranslateDelegate(this, MY_COUNT, MultiTranslateDelegate.COUNT);
|
||||
|
||||
public IconButtonView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
@ -88,6 +95,18 @@ public class IconButtonView extends BubbleTextView {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiTranslateDelegate getTranslateDelegate() {
|
||||
return mTranslateDelegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets translationX for taskbar all apps icon
|
||||
*/
|
||||
public void setTranslationXForTaskbarAllAppsIcon(float translationX) {
|
||||
getTranslateDelegate().getTranslationX(INDEX_TASKBAR_ALL_APPS_ICON).setValue(translationX);
|
||||
}
|
||||
|
||||
private static class IconDrawable extends FastBitmapDrawable {
|
||||
|
||||
private final Drawable mFg;
|
||||
|
|
|
@ -19,7 +19,6 @@ package com.android.launcher3.widget;
|
|||
import android.appwidget.AppWidgetHostView;
|
||||
import android.appwidget.AppWidgetProviderInfo;
|
||||
import android.content.Context;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
|
@ -29,6 +28,7 @@ import android.view.ViewGroup;
|
|||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Reorderable;
|
||||
import com.android.launcher3.dragndrop.DraggableView;
|
||||
import com.android.launcher3.util.MultiTranslateDelegate;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -39,20 +39,13 @@ import java.util.ArrayList;
|
|||
public abstract class NavigableAppWidgetHostView extends AppWidgetHostView
|
||||
implements DraggableView, Reorderable {
|
||||
|
||||
private final MultiTranslateDelegate mTranslateDelegate = new MultiTranslateDelegate(this);
|
||||
|
||||
/**
|
||||
* The scaleX and scaleY value such that the widget fits within its cellspans, scaleX = scaleY.
|
||||
*/
|
||||
private float mScaleToFit = 1f;
|
||||
|
||||
/**
|
||||
* The translation values to center the widget within its cellspans.
|
||||
*/
|
||||
private final PointF mTranslationForCentering = new PointF(0, 0);
|
||||
|
||||
private final PointF mTranslationForMoveFromCenterAnimation = new PointF(0, 0);
|
||||
|
||||
private final PointF mTranslationForReorderBounce = new PointF(0, 0);
|
||||
private final PointF mTranslationForReorderPreview = new PointF(0, 0);
|
||||
private float mScaleForReorderBounce = 1f;
|
||||
|
||||
private final Rect mTempRect = new Rect();
|
||||
|
@ -163,57 +156,23 @@ public abstract class NavigableAppWidgetHostView extends AppWidgetHostView
|
|||
setSelected(childIsFocused);
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private void updateTranslation() {
|
||||
super.setTranslationX(mTranslationForReorderBounce.x + mTranslationForReorderPreview.x
|
||||
+ mTranslationForCentering.x + mTranslationForMoveFromCenterAnimation.x);
|
||||
super.setTranslationY(mTranslationForReorderBounce.y + mTranslationForReorderPreview.y
|
||||
+ mTranslationForCentering.y + mTranslationForMoveFromCenterAnimation.y);
|
||||
}
|
||||
|
||||
public void setTranslationForCentering(float x, float y) {
|
||||
mTranslationForCentering.set(x, y);
|
||||
updateTranslation();
|
||||
}
|
||||
|
||||
public void setTranslationForMoveFromCenterAnimation(float x, float y) {
|
||||
mTranslationForMoveFromCenterAnimation.set(x, y);
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getReorderPreviewOffset(PointF offset) {
|
||||
offset.set(mTranslationForReorderPreview);
|
||||
}
|
||||
|
||||
private void updateScale() {
|
||||
super.setScaleX(mScaleToFit * mScaleForReorderBounce);
|
||||
super.setScaleY(mScaleToFit * mScaleForReorderBounce);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiTranslateDelegate getTranslateDelegate() {
|
||||
return mTranslateDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReorderBounceScale(float scale) {
|
||||
mScaleForReorderBounce = scale;
|
||||
updateScale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getReorderBounceScale() {
|
||||
return mScaleForReorderBounce;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
|||
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_TRAY;
|
||||
import static com.android.launcher3.Utilities.ATLEAST_S;
|
||||
import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_WIDGET_CENTERING;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -314,7 +315,7 @@ public class WidgetCell extends LinearLayout {
|
|||
setScaleToFit(1.0f);
|
||||
}
|
||||
// When the drag start, translations need to be set to zero to center the view
|
||||
setTranslationForCentering(0f, 0f);
|
||||
getTranslateDelegate().setTranslation(INDEX_WIDGET_CENTERING, 0f, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,7 +465,8 @@ public class WidgetCell extends LinearLayout {
|
|||
} else {
|
||||
mAppWidgetHostViewPreview.setScaleToFit(mAppWidgetHostViewScale);
|
||||
}
|
||||
mAppWidgetHostViewPreview.setTranslationForCentering(
|
||||
mAppWidgetHostViewPreview.getTranslateDelegate().setTranslation(
|
||||
INDEX_WIDGET_CENTERING,
|
||||
-(params.width - (params.width * mPreviewContainerScale)) / 2.0f,
|
||||
-(params.height - (params.height * mPreviewContainerScale)) / 2.0f);
|
||||
mWidgetImageContainer.addView(mAppWidgetHostViewPreview, /* index= */ 0);
|
||||
|
|
Loading…
Reference in New Issue