From af41ea2ac52e1dbf57e46c1b02c5ee302ed4cff1 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 24 May 2018 15:10:50 -0700 Subject: [PATCH 1/2] Fix recents task view launch animation unclipping issue. - Don't apply the scale to app window crop (which should be in app window space) Bug: 79945202 Change-Id: I68862f7f7d69eab64570ab3b1e3996a2e9a9e2ba --- .../quickstep/util/ClipAnimationHelper.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java index cc24f1d8a2..a654482f97 100644 --- a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java +++ b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java @@ -227,12 +227,16 @@ public class ClipAnimationHelper { dl.getDescendantRectRelativeToSelf(ttv, targetRect.rect); updateTargetRect(targetRect); - // Transform the clip relative to the target rect. - float scale = mTargetRect.width() / mSourceRect.width(); - mSourceWindowClipInsets.left = mSourceWindowClipInsets.left * scale; - mSourceWindowClipInsets.top = mSourceWindowClipInsets.top * scale; - mSourceWindowClipInsets.right = mSourceWindowClipInsets.right * scale; - mSourceWindowClipInsets.bottom = mSourceWindowClipInsets.bottom * scale; + if (target == null) { + // Transform the clip relative to the target rect. Only do this in the case where we + // aren't applying the insets to the app windows (where the clip should be in target app + // space) + float scale = mTargetRect.width() / mSourceRect.width(); + mSourceWindowClipInsets.left = mSourceWindowClipInsets.left * scale; + mSourceWindowClipInsets.top = mSourceWindowClipInsets.top * scale; + mSourceWindowClipInsets.right = mSourceWindowClipInsets.right * scale; + mSourceWindowClipInsets.bottom = mSourceWindowClipInsets.bottom * scale; + } } private void updateStackBoundsToMultiWindowTaskSize(BaseDraggingActivity activity) { From 31942e788b6fb47cd2398cefc6f30e2b214f0755 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Thu, 24 May 2018 14:25:27 -0700 Subject: [PATCH 2/2] Fix bug where icon 'jumps' on long press. Bug: 76155869 Change-Id: I739b00564b0ebe00b3aff326b3c1d62deea9d1d3 --- src/com/android/launcher3/Workspace.java | 10 +++++++++- .../android/launcher3/dragndrop/DragController.java | 4 ++-- src/com/android/launcher3/dragndrop/DragView.java | 6 ++++-- .../launcher3/widget/PendingItemDragHelper.java | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 42e8fde3b4..06eb82e3ea 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1552,6 +1552,14 @@ public class Workspace extends PagedView public DragView beginDragShared(View child, DragSource source, ItemInfo dragObject, DragPreviewProvider previewProvider, DragOptions dragOptions) { + float iconScale = 1f; + if (child instanceof BubbleTextView) { + Drawable icon = ((BubbleTextView) child).getIcon(); + if (icon instanceof FastBitmapDrawable) { + iconScale = ((FastBitmapDrawable) icon).getAnimatedScale(); + } + } + child.clearFocus(); child.setPressed(false); mOutlineProvider = previewProvider; @@ -1603,7 +1611,7 @@ public class Workspace extends PagedView } DragView dv = mDragController.startDrag(b, dragLayerX, dragLayerY, source, - dragObject, dragVisualizeOffset, dragRect, scale, dragOptions); + dragObject, dragVisualizeOffset, dragRect, scale * iconScale, scale, dragOptions); dv.setIntrinsicIconScaleFactor(dragOptions.intrinsicIconScaleFactor); return dv; } diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index 5c6946c47c..8a216fc173 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -138,7 +138,7 @@ public class DragController implements DragDriver.EventListener, TouchController */ public DragView startDrag(Bitmap b, int dragLayerX, int dragLayerY, DragSource source, ItemInfo dragInfo, Point dragOffset, Rect dragRegion, - float initialDragViewScale, DragOptions options) { + float initialDragViewScale, float dragViewScaleOnDrop, DragOptions options) { if (PROFILE_DRAWING_DURING_DRAG) { android.os.Debug.startMethodTracing("Launcher"); } @@ -169,7 +169,7 @@ public class DragController implements DragDriver.EventListener, TouchController final float scaleDps = mIsInPreDrag ? res.getDimensionPixelSize(R.dimen.pre_drag_view_scale) : 0f; final DragView dragView = mDragObject.dragView = new DragView(mLauncher, b, registrationX, - registrationY, initialDragViewScale, scaleDps); + registrationY, initialDragViewScale, dragViewScaleOnDrop, scaleDps); dragView.setItemInfo(dragInfo); mDragObject.dragComplete = false; if (mOptions.isAccessibleDrag) { diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java index 1e5f8545b4..551567ae78 100644 --- a/src/com/android/launcher3/dragndrop/DragView.java +++ b/src/com/android/launcher3/dragndrop/DragView.java @@ -89,6 +89,7 @@ public class DragView extends View { private final int mRegistrationX; private final int mRegistrationY; private final float mInitialScale; + private final float mScaleOnDrop; private final int[] mTempLoc = new int[2]; private Point mDragVisualizeOffset = null; @@ -131,7 +132,7 @@ public class DragView extends View { * @param registrationY The y coordinate of the registration point. */ public DragView(Launcher launcher, Bitmap bitmap, int registrationX, int registrationY, - final float initialScale, final float finalScaleDps) { + final float initialScale, final float scaleOnDrop, final float finalScaleDps) { super(launcher); mLauncher = launcher; mDragLayer = launcher.getDragLayer(); @@ -180,6 +181,7 @@ public class DragView extends View { mRegistrationY = registrationY; mInitialScale = initialScale; + mScaleOnDrop = scaleOnDrop; // Force a measure, because Workspace uses getMeasuredHeight() before the layout pass int ms = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); @@ -596,7 +598,7 @@ public class DragView extends View { public void animateTo(int toTouchX, int toTouchY, Runnable onCompleteRunnable, int duration) { mTempLoc[0] = toTouchX - mRegistrationX; mTempLoc[1] = toTouchY - mRegistrationY; - mDragLayer.animateViewIntoPosition(this, mTempLoc, 1f, mInitialScale, mInitialScale, + mDragLayer.animateViewIntoPosition(this, mTempLoc, 1f, mScaleOnDrop, mScaleOnDrop, DragLayer.ANIMATION_END_DISAPPEAR, onCompleteRunnable, duration); } diff --git a/src/com/android/launcher3/widget/PendingItemDragHelper.java b/src/com/android/launcher3/widget/PendingItemDragHelper.java index aa5b7855c6..74ab14f55d 100644 --- a/src/com/android/launcher3/widget/PendingItemDragHelper.java +++ b/src/com/android/launcher3/widget/PendingItemDragHelper.java @@ -149,7 +149,7 @@ public class PendingItemDragHelper extends DragPreviewProvider { // Start the drag launcher.getDragController().startDrag(preview, dragLayerX, dragLayerY, source, mAddInfo, - dragOffset, dragRegion, scale, options); + dragOffset, dragRegion, scale, scale, options); } @Override