From 2750ad0d59551d14eb7667e28b44a713ce3b2c16 Mon Sep 17 00:00:00 2001 From: Miranda Kephart Date: Mon, 24 Feb 2020 13:12:41 -0500 Subject: [PATCH] Fix screenshot scaling bug Occasionally, the screenshot preview would not reach the correct final scale, instead getting "stuck" at some larger size. This is because there was no final condition for the scale, so the final state depended on exactly which values the ValueAnimator update listener was called with. Setting a final state correctly fixes this problem. (Also fixes the equivalent bug for the x position.) Bug: 150134649 Test: manual -- there was not a reliable repro for the bug, but it hasn't been seen since making the change Change-Id: Ia383ca9336db382fd54087ce12accafd35b48a22 --- .../android/systemui/screenshot/GlobalScreenshot.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index f06cd54f77561..3afd5dc313821 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -514,12 +514,17 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset 1, cornerScale, mFastOutSlowIn.getInterpolation(t / scalePct)); mScreenshotView.setScaleX(scale); mScreenshotView.setScaleY(scale); + } else { + mScreenshotView.setScaleX(cornerScale); + mScreenshotView.setScaleY(cornerScale); } if (t < xPositionPct) { float xCenter = MathUtils.lerp(startPos.x, finalPos.x, mFastOutSlowIn.getInterpolation(t / xPositionPct)); mScreenshotView.setX(xCenter - width * mScreenshotView.getScaleX() / 2f); + } else { + mScreenshotView.setX(finalPos.x - width * mScreenshotView.getScaleX() / 2f); } float yCenter = MathUtils.lerp(startPos.y, finalPos.y, mFastOutSlowIn.getInterpolation(t)); @@ -544,6 +549,10 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); + mScreenshotView.setScaleX(cornerScale); + mScreenshotView.setScaleY(cornerScale); + mScreenshotView.setX(finalPos.x - height * cornerScale / 2f); + mScreenshotView.setY(finalPos.y - height * cornerScale / 2f); Rect bounds = new Rect(); mScreenshotView.getBoundsOnScreen(bounds); mDismissButton.setX(bounds.right - mDismissButtonSize / 2f);