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

Commit cf69c56b authored by John Spurlock's avatar John Spurlock
Browse files

"Fix camera widget scale-up regression." -> frameworks/base

lockhotness change-id: I69ccfa3a873943ab2e159d15937d5fb13f7acabd

Bug:7439300
Change-Id: I9e9eeae16b4e76d85a8145f3b198c22ad2e923e9
parent 567fa759
Loading
Loading
Loading
Loading
+25 −12
Original line number Diff line number Diff line
@@ -169,32 +169,45 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
    }

    private void transitionToCamera() {
        final View child = getChildAt(0);
        if (mTransitioning || mChallengeActive || mDown) return;
        if (DEBUG) Log.d(TAG, "Transitioning to camera...");

        mTransitioning = true;
        int startWidth = child.getWidth();
        int startHeight = child.getHeight();

        int finishWidth = getRootView().getWidth();
        int finishHeight = getRootView().getHeight();
        final View child = getChildAt(0);
        final View root = getRootView();

        final int startWidth = child.getWidth();
        final int startHeight = child.getHeight();

        float scaleX = (float) finishWidth / startWidth;
        float scaleY = (float) finishHeight / startHeight;
        final int finishWidth = root.getWidth();
        final int finishHeight = root.getHeight();

        float scale = Math.max(scaleX, scaleY);
        final int screenCenter = getResources().getDisplayMetrics().heightPixels / 2;
        final float scaleX = (float) finishWidth / startWidth;
        final float scaleY = (float) finishHeight / startHeight;
        final float scale = Math.round( Math.max(scaleX, scaleY) * 100) / 100f;

        final int[] loc = new int[2];
        root.getLocationInWindow(loc);
        final int finishCenter = loc[1] + finishHeight / 2;

        child.getLocationInWindow(loc);
        final int childCenter = loc[1] + startHeight / 2;
        final int startCenter = loc[1] + startHeight / 2;

        if (DEBUG) Log.d(TAG, String.format("Transitioning to camera. " +
                "(start=%sx%s, finish=%sx%s, scale=%s,%s, startCenter=%s, finishCenter=%s)",
                startWidth, startHeight,
                finishWidth, finishHeight,
                scaleX, scaleY,
                startCenter, finishCenter));

        animate()
            .scaleX(scale)
            .scaleY(scale)
            .translationY(screenCenter - childCenter)
            .translationY(finishCenter - startCenter)
            .setDuration(WIDGET_ANIMATION_DURATION)
            .withEndAction(mLaunchCameraRunnable)
            .start();

        mCallbacks.onLaunchingCamera();
    }