Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2c1c3cb authored by Miranda Kephart's avatar Miranda Kephart
Browse files

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
parent a389edcf
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -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);