Fix juttering problem with split staging animation
This patch makes it so that app icons no longer jutter uncomfortably when staging and confirming a split from home.
The problem occurred because I used Math.round when calculating the position at which to center the app icon within the SplitPlaceholderView. When an inexact integer is used to calculate the x and y position on every frame, it creates juttering, especially when numerical values are small.
Solved by removing Math.round and using floats going forward.
Fixes: 262308025
Test: Manual
Change-Id: If91d1d3ee52652c155ed7e4e1d4f4620fdc41cc9
diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
index 820162c..097823b 100644
--- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
+++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
@@ -432,10 +432,10 @@
int drawableWidth, int drawableHeight, DeviceProfile dp,
@StagePosition int stagePosition) {
float insetAdjustment = getPlaceholderSizeAdjustment(dp) / 2f;
- out.setX(Math.round(onScreenRectCenterX / fullscreenScaleX
- - 1.0f * drawableWidth / 2));
- out.setY(Math.round((onScreenRectCenterY + insetAdjustment) / fullscreenScaleY
- - 1.0f * drawableHeight / 2));
+ out.setX(onScreenRectCenterX / fullscreenScaleX
+ - 1.0f * drawableWidth / 2);
+ out.setY((onScreenRectCenterY + insetAdjustment) / fullscreenScaleY
+ - 1.0f * drawableHeight / 2);
}
/**
diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
index 78e17d8..316cf0e 100644
--- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
+++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
@@ -463,20 +463,20 @@
boolean pinToRight = stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT;
float insetAdjustment = getPlaceholderSizeAdjustment(dp, pinToRight) / 2f;
if (!dp.isLandscape) {
- out.setX(Math.round(onScreenRectCenterX / fullscreenScaleX
- - 1.0f * drawableWidth / 2));
- out.setY(Math.round((onScreenRectCenterY + insetAdjustment) / fullscreenScaleY
- - 1.0f * drawableHeight / 2));
+ out.setX(onScreenRectCenterX / fullscreenScaleX
+ - 1.0f * drawableWidth / 2);
+ out.setY((onScreenRectCenterY + insetAdjustment) / fullscreenScaleY
+ - 1.0f * drawableHeight / 2);
} else {
if (pinToRight) {
- out.setX(Math.round((onScreenRectCenterX - insetAdjustment) / fullscreenScaleX
- - 1.0f * drawableWidth / 2));
+ out.setX((onScreenRectCenterX - insetAdjustment) / fullscreenScaleX
+ - 1.0f * drawableWidth / 2);
} else {
- out.setX(Math.round((onScreenRectCenterX + insetAdjustment) / fullscreenScaleX
- - 1.0f * drawableWidth / 2));
+ out.setX((onScreenRectCenterX + insetAdjustment) / fullscreenScaleX
+ - 1.0f * drawableWidth / 2);
}
- out.setY(Math.round(onScreenRectCenterY / fullscreenScaleY
- - 1.0f * drawableHeight / 2));
+ out.setY(onScreenRectCenterY / fullscreenScaleY
+ - 1.0f * drawableHeight / 2);
}
}