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

Commit aa4071bf authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Sample region under secondary home handle" into rvc-dev am: aadbf05a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11741298

Change-Id: I9adca91519e4c4353be3598e93ddeb2248d67784
parents dab94a16 aadbf05a
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import android.content.res.Configuration;
import android.database.ContentObserver;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.RectF;
import android.hardware.display.DisplayManager;
import android.inputmethodservice.InputMethodService;
import android.net.Uri;
@@ -83,6 +84,7 @@ import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowInsetsController.Appearance;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
@@ -217,11 +219,12 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
     * original handle hidden and we'll flip the visibilities once the
     * {@link #mTasksFrozenListener} fires
     */
    private NavigationHandle mOrientationHandle;
    private VerticalNavigationHandle mOrientationHandle;
    private WindowManager.LayoutParams mOrientationParams;
    private int mStartingQuickSwitchRotation;
    private int mCurrentRotation;
    private boolean mFixedRotationEnabled;
    private ViewTreeObserver.OnGlobalLayoutListener mOrientationHandleGlobalLayoutListener;

    /** Only for default display */
    @Nullable
@@ -519,6 +522,8 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
            getContext().getSystemService(DisplayManager.class).unregisterDisplayListener(this);
            getBarTransitions().removeDarkIntensityListener(mOrientationHandleIntensityListener);
            mWindowManager.removeView(mOrientationHandle);
            mOrientationHandle.getViewTreeObserver().removeOnGlobalLayoutListener(
                    mOrientationHandleGlobalLayoutListener);
        }
    }

@@ -573,6 +578,20 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
                PixelFormat.TRANSLUCENT);
        mWindowManager.addView(mOrientationHandle, mOrientationParams);
        mOrientationHandle.setVisibility(View.GONE);
        mOrientationHandleGlobalLayoutListener =
                () -> {
                    if (mStartingQuickSwitchRotation == -1) {
                        return;
                    }

                    RectF boundsOnScreen = mOrientationHandle.computeHomeHandleBounds();
                    mOrientationHandle.mapRectFromViewToScreenCoords(boundsOnScreen, true);
                    Rect boundsRounded = new Rect();
                    boundsOnScreen.roundOut(boundsRounded);
                    mNavigationBarView.setOrientedHandleSamplingRegion(boundsRounded);
                };
        mOrientationHandle.getViewTreeObserver().addOnGlobalLayoutListener(
                mOrientationHandleGlobalLayoutListener);
    }

    private void orientSecondaryHomeHandle() {
@@ -621,6 +640,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
        }
        if (mNavigationBarView != null) {
            mNavigationBarView.setVisibility(View.VISIBLE);
            mNavigationBarView.setOrientedHandleSamplingRegion(null);
        }
    }

+20 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.animation.PropertyValuesHolder;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.annotation.DrawableRes;
import android.annotation.Nullable;
import android.app.StatusBarManager;
import android.content.Context;
import android.content.res.Configuration;
@@ -158,6 +159,14 @@ public class NavigationBarView extends FrameLayout implements
     */
    private ScreenPinningNotify mScreenPinningNotify;
    private Rect mSamplingBounds = new Rect();
    /**
     * When quickswitching between apps of different orientations, we draw a secondary home handle
     * in the position of the first app's orientation. This rect represents the region of that
     * home handle so we can apply the correct light/dark luma on that.
     * @see {@link NavigationBarFragment#mOrientationHandle}
     */
    @Nullable
    private Rect mOrientedHandleSamplingRegion;

    private class NavTransitionListener implements TransitionListener {
        private boolean mBackTransitioning;
@@ -327,6 +336,10 @@ public class NavigationBarView extends FrameLayout implements

                    @Override
                    public Rect getSampledRegion(View sampledView) {
                        if (mOrientedHandleSamplingRegion != null) {
                            return mOrientedHandleSamplingRegion;
                        }

                        updateSamplingRect();
                        return mSamplingBounds;
                    }
@@ -897,6 +910,11 @@ public class NavigationBarView extends FrameLayout implements
        }
    }

    void setOrientedHandleSamplingRegion(Rect orientedHandleSamplingRegion) {
        mOrientedHandleSamplingRegion = orientedHandleSamplingRegion;
        mRegionSamplingHelper.updateSamplingRect();
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
@@ -1190,6 +1208,8 @@ public class NavigationBarView extends FrameLayout implements
                        mIsVertical ? "true" : "false",
                        getLightTransitionsController().getCurrentDarkIntensity()));

        pw.println("      mOrientedHandleSamplingRegion: " + mOrientedHandleSamplingRegion);

        dumpButton(pw, "back", getBackButton());
        dumpButton(pw, "home", getHomeButton());
        dumpButton(pw, "rcnt", getRecentsButton());
+11 −4
Original line number Diff line number Diff line
@@ -18,12 +18,14 @@ package com.android.systemui.statusbar.phone;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.RectF;

import com.android.systemui.R;

/** Temporarily shown view when using QuickSwitch to switch between apps of different rotations */
public class VerticalNavigationHandle extends NavigationHandle {
    private final int mWidth;
    private final RectF mTmpBoundsRectF = new RectF();

    public VerticalNavigationHandle(Context context) {
        super(context);
@@ -32,16 +34,21 @@ public class VerticalNavigationHandle extends NavigationHandle {

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.drawRoundRect(computeHomeHandleBounds(), mRadius, mRadius, mPaint);
    }

    RectF computeHomeHandleBounds() {
        int left;
        int top;
        int bottom;
        int right;

        int topStart = getLocationOnScreen()[1];
        int radiusOffset = mRadius * 2;
        right = getWidth() - mBottom;
        top = getHeight() / 2 - (mWidth / 2); /* (height of screen / 2) - (height of bar / 2) */
        top = getHeight() / 2 - (mWidth / 2) - (topStart / 2);
        left = getWidth() - mBottom - radiusOffset;
        bottom = getHeight() / 2 + (mWidth / 2);
        canvas.drawRoundRect(left, top, right, bottom, mRadius, mRadius, mPaint);
        bottom = top + mWidth;
        mTmpBoundsRectF.set(left, top, right, bottom);
        return mTmpBoundsRectF;
    }
}