Loading packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +22 −22 Original line number Original line Diff line number Diff line Loading @@ -642,13 +642,10 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset private void startAnimation(final Consumer<Uri> finisher, int w, int h, private void startAnimation(final Consumer<Uri> finisher, int w, int h, @Nullable Rect screenRect) { @Nullable Rect screenRect) { // If power save is on, show a toast so there is some visual indication that a // If power save is on, show a toast so there is some visual indication that a // screenshot // screenshot has been taken. // has been taken. PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); PowerManager powerManager = (PowerManager) mContext.getSystemService( Context.POWER_SERVICE); if (powerManager.isPowerSaveMode()) { if (powerManager.isPowerSaveMode()) { Toast.makeText(mContext, R.string.screenshot_saved_title, Toast.makeText(mContext, R.string.screenshot_saved_title, Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show(); } } mScreenshotAnimation = createScreenshotDropInAnimation(w, h, screenRect); mScreenshotAnimation = createScreenshotDropInAnimation(w, h, screenRect); Loading Loading @@ -712,18 +709,23 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset } } private AnimatorSet createScreenshotDropInAnimation(int width, int height, Rect bounds) { private AnimatorSet createScreenshotDropInAnimation(int width, int height, Rect bounds) { float screenWidth = mDisplayMetrics.widthPixels; float screenHeight = mDisplayMetrics.heightPixels; int rotation = mContext.getDisplay().getRotation(); int rotation = mContext.getDisplay().getRotation(); float cornerScale; float cornerScale; if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { cornerScale = (mCornerSizeX / (float) height); cornerScale = (mCornerSizeX / screenHeight); } else { } else { cornerScale = (mCornerSizeX / (float) width); cornerScale = (mCornerSizeX / screenWidth); } } float currentScale = width / screenWidth; mScreenshotAnimatedView.setScaleX(1); mScreenshotAnimatedView.setScaleX(currentScale); mScreenshotAnimatedView.setScaleY(1); mScreenshotAnimatedView.setScaleY(currentScale); mScreenshotAnimatedView.setX(0); mScreenshotAnimatedView.setY(0); mScreenshotAnimatedView.setPivotX(0); mScreenshotAnimatedView.setPivotY(0); mScreenshotAnimatedView.setImageBitmap(mScreenBitmap); mScreenshotAnimatedView.setImageBitmap(mScreenBitmap); mScreenshotPreview.setImageBitmap(mScreenBitmap); mScreenshotPreview.setImageBitmap(mScreenBitmap); Loading @@ -744,12 +746,11 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset final PointF startPos = new PointF(bounds.centerX(), bounds.centerY()); final PointF startPos = new PointF(bounds.centerX(), bounds.centerY()); float finalX; float finalX; if (mDirectionLTR) { if (mDirectionLTR) { finalX = mScreenshotOffsetXPx + width * cornerScale / 2f; finalX = mScreenshotOffsetXPx + screenWidth * cornerScale / 2f; } else { } else { finalX = width - mScreenshotOffsetXPx - width * cornerScale / 2f; finalX = screenWidth - mScreenshotOffsetXPx - screenWidth * cornerScale / 2f; } } float finalY = float finalY = screenHeight - mScreenshotOffsetYPx - screenHeight * cornerScale / 2f; mDisplayMetrics.heightPixels - mScreenshotOffsetYPx - height * cornerScale / 2f; final PointF finalPos = new PointF(finalX, finalY); final PointF finalPos = new PointF(finalX, finalY); ValueAnimator toCorner = ValueAnimator.ofFloat(0, 1); ValueAnimator toCorner = ValueAnimator.ofFloat(0, 1); Loading @@ -757,13 +758,12 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset float xPositionPct = float xPositionPct = SCREENSHOT_TO_CORNER_X_DURATION_MS / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS; SCREENSHOT_TO_CORNER_X_DURATION_MS / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS; float scalePct = float scalePct = SCREENSHOT_TO_CORNER_SCALE_DURATION_MS SCREENSHOT_TO_CORNER_SCALE_DURATION_MS / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS; / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS; toCorner.addUpdateListener(animation -> { toCorner.addUpdateListener(animation -> { float t = animation.getAnimatedFraction(); float t = animation.getAnimatedFraction(); if (t < scalePct) { if (t < scalePct) { float scale = MathUtils.lerp( float scale = MathUtils.lerp( 1, cornerScale, mFastOutSlowIn.getInterpolation(t / scalePct)); currentScale, cornerScale, mFastOutSlowIn.getInterpolation(t / scalePct)); mScreenshotAnimatedView.setScaleX(scale); mScreenshotAnimatedView.setScaleX(scale); mScreenshotAnimatedView.setScaleY(scale); mScreenshotAnimatedView.setScaleY(scale); } else { } else { Loading @@ -777,13 +777,13 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset if (t < xPositionPct) { if (t < xPositionPct) { float xCenter = MathUtils.lerp(startPos.x, finalPos.x, float xCenter = MathUtils.lerp(startPos.x, finalPos.x, mFastOutSlowIn.getInterpolation(t / xPositionPct)); mFastOutSlowIn.getInterpolation(t / xPositionPct)); mScreenshotAnimatedView.setX(xCenter - width * currentScaleX / 2f); mScreenshotAnimatedView.setX(xCenter - screenWidth * currentScaleX / 2f); } else { } else { mScreenshotAnimatedView.setX(finalPos.x - width * currentScaleX / 2f); mScreenshotAnimatedView.setX(finalPos.x - screenWidth * currentScaleX / 2f); } } float yCenter = MathUtils.lerp(startPos.y, finalPos.y, float yCenter = MathUtils.lerp(startPos.y, finalPos.y, mFastOutSlowIn.getInterpolation(t)); mFastOutSlowIn.getInterpolation(t)); mScreenshotAnimatedView.setY(yCenter - height * currentScaleY / 2f); mScreenshotAnimatedView.setY(yCenter - screenHeight * currentScaleY / 2f); }); }); toCorner.addListener(new AnimatorListenerAdapter() { toCorner.addListener(new AnimatorListenerAdapter() { Loading Loading
packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +22 −22 Original line number Original line Diff line number Diff line Loading @@ -642,13 +642,10 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset private void startAnimation(final Consumer<Uri> finisher, int w, int h, private void startAnimation(final Consumer<Uri> finisher, int w, int h, @Nullable Rect screenRect) { @Nullable Rect screenRect) { // If power save is on, show a toast so there is some visual indication that a // If power save is on, show a toast so there is some visual indication that a // screenshot // screenshot has been taken. // has been taken. PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); PowerManager powerManager = (PowerManager) mContext.getSystemService( Context.POWER_SERVICE); if (powerManager.isPowerSaveMode()) { if (powerManager.isPowerSaveMode()) { Toast.makeText(mContext, R.string.screenshot_saved_title, Toast.makeText(mContext, R.string.screenshot_saved_title, Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show(); } } mScreenshotAnimation = createScreenshotDropInAnimation(w, h, screenRect); mScreenshotAnimation = createScreenshotDropInAnimation(w, h, screenRect); Loading Loading @@ -712,18 +709,23 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset } } private AnimatorSet createScreenshotDropInAnimation(int width, int height, Rect bounds) { private AnimatorSet createScreenshotDropInAnimation(int width, int height, Rect bounds) { float screenWidth = mDisplayMetrics.widthPixels; float screenHeight = mDisplayMetrics.heightPixels; int rotation = mContext.getDisplay().getRotation(); int rotation = mContext.getDisplay().getRotation(); float cornerScale; float cornerScale; if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { cornerScale = (mCornerSizeX / (float) height); cornerScale = (mCornerSizeX / screenHeight); } else { } else { cornerScale = (mCornerSizeX / (float) width); cornerScale = (mCornerSizeX / screenWidth); } } float currentScale = width / screenWidth; mScreenshotAnimatedView.setScaleX(1); mScreenshotAnimatedView.setScaleX(currentScale); mScreenshotAnimatedView.setScaleY(1); mScreenshotAnimatedView.setScaleY(currentScale); mScreenshotAnimatedView.setX(0); mScreenshotAnimatedView.setY(0); mScreenshotAnimatedView.setPivotX(0); mScreenshotAnimatedView.setPivotY(0); mScreenshotAnimatedView.setImageBitmap(mScreenBitmap); mScreenshotAnimatedView.setImageBitmap(mScreenBitmap); mScreenshotPreview.setImageBitmap(mScreenBitmap); mScreenshotPreview.setImageBitmap(mScreenBitmap); Loading @@ -744,12 +746,11 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset final PointF startPos = new PointF(bounds.centerX(), bounds.centerY()); final PointF startPos = new PointF(bounds.centerX(), bounds.centerY()); float finalX; float finalX; if (mDirectionLTR) { if (mDirectionLTR) { finalX = mScreenshotOffsetXPx + width * cornerScale / 2f; finalX = mScreenshotOffsetXPx + screenWidth * cornerScale / 2f; } else { } else { finalX = width - mScreenshotOffsetXPx - width * cornerScale / 2f; finalX = screenWidth - mScreenshotOffsetXPx - screenWidth * cornerScale / 2f; } } float finalY = float finalY = screenHeight - mScreenshotOffsetYPx - screenHeight * cornerScale / 2f; mDisplayMetrics.heightPixels - mScreenshotOffsetYPx - height * cornerScale / 2f; final PointF finalPos = new PointF(finalX, finalY); final PointF finalPos = new PointF(finalX, finalY); ValueAnimator toCorner = ValueAnimator.ofFloat(0, 1); ValueAnimator toCorner = ValueAnimator.ofFloat(0, 1); Loading @@ -757,13 +758,12 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset float xPositionPct = float xPositionPct = SCREENSHOT_TO_CORNER_X_DURATION_MS / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS; SCREENSHOT_TO_CORNER_X_DURATION_MS / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS; float scalePct = float scalePct = SCREENSHOT_TO_CORNER_SCALE_DURATION_MS SCREENSHOT_TO_CORNER_SCALE_DURATION_MS / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS; / (float) SCREENSHOT_TO_CORNER_Y_DURATION_MS; toCorner.addUpdateListener(animation -> { toCorner.addUpdateListener(animation -> { float t = animation.getAnimatedFraction(); float t = animation.getAnimatedFraction(); if (t < scalePct) { if (t < scalePct) { float scale = MathUtils.lerp( float scale = MathUtils.lerp( 1, cornerScale, mFastOutSlowIn.getInterpolation(t / scalePct)); currentScale, cornerScale, mFastOutSlowIn.getInterpolation(t / scalePct)); mScreenshotAnimatedView.setScaleX(scale); mScreenshotAnimatedView.setScaleX(scale); mScreenshotAnimatedView.setScaleY(scale); mScreenshotAnimatedView.setScaleY(scale); } else { } else { Loading @@ -777,13 +777,13 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset if (t < xPositionPct) { if (t < xPositionPct) { float xCenter = MathUtils.lerp(startPos.x, finalPos.x, float xCenter = MathUtils.lerp(startPos.x, finalPos.x, mFastOutSlowIn.getInterpolation(t / xPositionPct)); mFastOutSlowIn.getInterpolation(t / xPositionPct)); mScreenshotAnimatedView.setX(xCenter - width * currentScaleX / 2f); mScreenshotAnimatedView.setX(xCenter - screenWidth * currentScaleX / 2f); } else { } else { mScreenshotAnimatedView.setX(finalPos.x - width * currentScaleX / 2f); mScreenshotAnimatedView.setX(finalPos.x - screenWidth * currentScaleX / 2f); } } float yCenter = MathUtils.lerp(startPos.y, finalPos.y, float yCenter = MathUtils.lerp(startPos.y, finalPos.y, mFastOutSlowIn.getInterpolation(t)); mFastOutSlowIn.getInterpolation(t)); mScreenshotAnimatedView.setY(yCenter - height * currentScaleY / 2f); mScreenshotAnimatedView.setY(yCenter - screenHeight * currentScaleY / 2f); }); }); toCorner.addListener(new AnimatorListenerAdapter() { toCorner.addListener(new AnimatorListenerAdapter() { Loading