Fix bug where icon 'jumps' on long press.
Bug: 76155869 Change-Id: I739b00564b0ebe00b3aff326b3c1d62deea9d1d3
This commit is contained in:
committed by
Jonathan Miranda
parent
159d6949a1
commit
31942e788b
@@ -1552,6 +1552,14 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
|
||||
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<WorkspacePageIndicator>
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user