Fix screenshot to corner animation

We now offset the location of the screenshot preview based on its
location in the screen, but we were setting the scale in between
making the "location in window" and "location in screen"
measurements, which meant that the preview got offset to the wrong
place.

This change moves any changes to the actual views into the
onAnimationStart method, to logically separate the animation setup
calculations from the animation itself.

Bug: 191894245
Fix: 191894245

Test: manual

Change-Id: Idc3d7654268d277f7416a025952ee6654e1a0630
This commit is contained in:
Miranda Kephart
2021-06-23 15:39:20 -04:00
parent a389edcf51
commit f2c1c3cba8

View File

@@ -453,14 +453,6 @@ public class ScreenshotView extends FrameLayout implements
mCornerSizeX / (mOrientationPortrait ? bounds.width() : bounds.height());
final float currentScale = 1 / cornerScale;
mScreenshotPreview.setScaleX(currentScale);
mScreenshotPreview.setScaleY(currentScale);
if (mAccessibilityManager.isEnabled()) {
mDismissButton.setAlpha(0);
mDismissButton.setVisibility(View.VISIBLE);
}
AnimatorSet dropInAnimation = new AnimatorSet();
ValueAnimator flashInAnimator = ValueAnimator.ofFloat(0, 1);
flashInAnimator.setDuration(SCREENSHOT_FLASH_IN_DURATION_MS);
@@ -491,6 +483,20 @@ public class ScreenshotView extends FrameLayout implements
ValueAnimator toCorner = ValueAnimator.ofFloat(0, 1);
toCorner.setDuration(SCREENSHOT_TO_CORNER_Y_DURATION_MS);
toCorner.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mScreenshotPreview.setScaleX(currentScale);
mScreenshotPreview.setScaleY(currentScale);
mScreenshotPreview.setVisibility(View.VISIBLE);
if (mAccessibilityManager.isEnabled()) {
mDismissButton.setAlpha(0);
mDismissButton.setVisibility(View.VISIBLE);
}
}
});
float xPositionPct =
SCREENSHOT_TO_CORNER_X_DURATION_MS / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS;
float dismissPct =
@@ -534,13 +540,6 @@ public class ScreenshotView extends FrameLayout implements
}
});
toCorner.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mScreenshotPreview.setVisibility(View.VISIBLE);
}
});
mScreenshotFlash.setAlpha(0f);
mScreenshotFlash.setVisibility(View.VISIBLE);