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

Commit 3a50eb36 authored by Doris Liu's avatar Doris Liu Committed by Android (Google) Code Review
Browse files

Merge "Restrict checking for device flip" into gb-ub-photos-bryce

parents 1e3bc7d4 9ee99847
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -62,12 +62,7 @@ public class CameraControls extends RotatableLayout {

                @Override
                public void onDisplayChanged(int arg0) {
                    int currentRotation = Util.getDisplayRotation((Activity) getContext());
                    if ((currentRotation - mLastRotation) % 180 == 0) {
                        flipChildren();
                        getParent().requestLayout();
                    }
                    mLastRotation = currentRotation;
                    checkLayoutFlip();
                }

                @Override
@@ -76,6 +71,15 @@ public class CameraControls extends RotatableLayout {
        }
    }

    private void checkLayoutFlip() {
        int currentRotation = Util.getDisplayRotation((Activity) getContext());
        if ((currentRotation - mLastRotation + 360) % 360 == 180) {
            mLastRotation = currentRotation;
            flipChildren();
            getParent().requestLayout();
        }
    }

    @Override
    public void onFinishInflate() {
        super.onFinishInflate();
@@ -98,6 +102,14 @@ public class CameraControls extends RotatableLayout {
        }
    }

    @Override
    public void onWindowVisibilityChanged(int visibility) {
        if (visibility == View.VISIBLE) {
            // Make sure when coming back from onPause, the layout is rotated correctly
            checkLayoutFlip();
        }
    }

    @Override
    public void onDetachedFromWindow () {
        super.onDetachedFromWindow();
@@ -109,6 +121,7 @@ public class CameraControls extends RotatableLayout {

    @Override
    public void onLayout(boolean changed, int l, int t, int r, int b) {
        mLastRotation = Util.getDisplayRotation((Activity) getContext());
        int orientation = getResources().getConfiguration().orientation;
        int size = getResources().getDimensionPixelSize(R.dimen.camera_controls_size);
        int rotation = getUnifiedRotation();
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ public class RotatableLayout extends FrameLayout {
        super.onConfigurationChanged(config);
        int rotation = Util.getDisplayRotation((Activity) getContext());
        if ((rotation - mPrevRotation + 360) % 180 == 0) {
            flipChildren();
            mPrevRotation = rotation;
            return;
        }
        boolean clockwise = isClockWiseRotation(mPrevRotation, rotation);