Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +21 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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); } } Loading Loading @@ -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() { Loading Loading @@ -621,6 +640,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback } if (mNavigationBarView != null) { mNavigationBarView.setVisibility(View.VISIBLE); mNavigationBarView.setOrientedHandleSamplingRegion(null); } } Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +20 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -327,6 +336,10 @@ public class NavigationBarView extends FrameLayout implements @Override public Rect getSampledRegion(View sampledView) { if (mOrientedHandleSamplingRegion != null) { return mOrientedHandleSamplingRegion; } updateSamplingRect(); return mSamplingBounds; } Loading Loading @@ -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); Loading Loading @@ -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()); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/VerticalNavigationHandle.java +11 −4 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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; } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +21 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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); } } Loading Loading @@ -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() { Loading Loading @@ -621,6 +640,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback } if (mNavigationBarView != null) { mNavigationBarView.setVisibility(View.VISIBLE); mNavigationBarView.setOrientedHandleSamplingRegion(null); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +20 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -327,6 +336,10 @@ public class NavigationBarView extends FrameLayout implements @Override public Rect getSampledRegion(View sampledView) { if (mOrientedHandleSamplingRegion != null) { return mOrientedHandleSamplingRegion; } updateSamplingRect(); return mSamplingBounds; } Loading Loading @@ -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); Loading Loading @@ -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()); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/VerticalNavigationHandle.java +11 −4 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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; } }