Merge "Show secondary home handle in immersive apps" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
babd08b5b1
@@ -25,6 +25,7 @@ import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
|||||||
import static android.view.InsetsState.containsType;
|
import static android.view.InsetsState.containsType;
|
||||||
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
|
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
|
||||||
import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_NAVIGATION_BARS;
|
import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_NAVIGATION_BARS;
|
||||||
|
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
|
||||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
||||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||||
|
|
||||||
@@ -219,12 +220,13 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
* original handle hidden and we'll flip the visibilities once the
|
* original handle hidden and we'll flip the visibilities once the
|
||||||
* {@link #mTasksFrozenListener} fires
|
* {@link #mTasksFrozenListener} fires
|
||||||
*/
|
*/
|
||||||
private VerticalNavigationHandle mOrientationHandle;
|
private QuickswitchOrientedNavHandle mOrientationHandle;
|
||||||
private WindowManager.LayoutParams mOrientationParams;
|
private WindowManager.LayoutParams mOrientationParams;
|
||||||
private int mStartingQuickSwitchRotation = -1;
|
private int mStartingQuickSwitchRotation = -1;
|
||||||
private int mCurrentRotation;
|
private int mCurrentRotation;
|
||||||
private ViewTreeObserver.OnGlobalLayoutListener mOrientationHandleGlobalLayoutListener;
|
private ViewTreeObserver.OnGlobalLayoutListener mOrientationHandleGlobalLayoutListener;
|
||||||
private UiEventLogger mUiEventLogger;
|
private UiEventLogger mUiEventLogger;
|
||||||
|
private boolean mShowOrientedHandleForImmersiveMode;
|
||||||
|
|
||||||
@com.android.internal.annotations.VisibleForTesting
|
@com.android.internal.annotations.VisibleForTesting
|
||||||
public enum NavBarActionEvent implements UiEventLogger.UiEventEnum {
|
public enum NavBarActionEvent implements UiEventLogger.UiEventEnum {
|
||||||
@@ -296,6 +298,9 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
@Override
|
@Override
|
||||||
public void onQuickSwitchToNewTask(@Surface.Rotation int rotation) {
|
public void onQuickSwitchToNewTask(@Surface.Rotation int rotation) {
|
||||||
mStartingQuickSwitchRotation = rotation;
|
mStartingQuickSwitchRotation = rotation;
|
||||||
|
if (rotation == -1) {
|
||||||
|
mShowOrientedHandleForImmersiveMode = false;
|
||||||
|
}
|
||||||
orientSecondaryHomeHandle();
|
orientSecondaryHomeHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,7 +590,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
getContext().getSystemService(DisplayManager.class)
|
getContext().getSystemService(DisplayManager.class)
|
||||||
.registerDisplayListener(this, new Handler(Looper.getMainLooper()));
|
.registerDisplayListener(this, new Handler(Looper.getMainLooper()));
|
||||||
|
|
||||||
mOrientationHandle = new VerticalNavigationHandle(getContext());
|
mOrientationHandle = new QuickswitchOrientedNavHandle(getContext());
|
||||||
|
|
||||||
getBarTransitions().addDarkIntensityListener(mOrientationHandleIntensityListener);
|
getBarTransitions().addDarkIntensityListener(mOrientationHandleIntensityListener);
|
||||||
mOrientationParams = new WindowManager.LayoutParams(0, 0,
|
mOrientationParams = new WindowManager.LayoutParams(0, 0,
|
||||||
@@ -596,8 +601,11 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH
|
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH
|
||||||
| WindowManager.LayoutParams.FLAG_SLIPPERY,
|
| WindowManager.LayoutParams.FLAG_SLIPPERY,
|
||||||
PixelFormat.TRANSLUCENT);
|
PixelFormat.TRANSLUCENT);
|
||||||
|
mOrientationParams.setTitle("SecondaryHomeHandle" + getContext().getDisplayId());
|
||||||
|
mOrientationParams.privateFlags |= PRIVATE_FLAG_NO_MOVE_ANIMATION;
|
||||||
mWindowManager.addView(mOrientationHandle, mOrientationParams);
|
mWindowManager.addView(mOrientationHandle, mOrientationParams);
|
||||||
mOrientationHandle.setVisibility(View.GONE);
|
mOrientationHandle.setVisibility(View.GONE);
|
||||||
|
mOrientationParams.setFitInsetsTypes(0 /* types*/);
|
||||||
mOrientationHandleGlobalLayoutListener =
|
mOrientationHandleGlobalLayoutListener =
|
||||||
() -> {
|
() -> {
|
||||||
if (mStartingQuickSwitchRotation == -1) {
|
if (mStartingQuickSwitchRotation == -1) {
|
||||||
@@ -634,22 +642,28 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
int height = 0;
|
int height = 0;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
Rect dispSize = mWindowManager.getCurrentWindowMetrics().getBounds();
|
Rect dispSize = mWindowManager.getCurrentWindowMetrics().getBounds();
|
||||||
|
mOrientationHandle.setDeltaRotation(deltaRotation);
|
||||||
switch (deltaRotation) {
|
switch (deltaRotation) {
|
||||||
case Surface.ROTATION_90:
|
case Surface.ROTATION_90:
|
||||||
case Surface.ROTATION_270:
|
case Surface.ROTATION_270:
|
||||||
height = dispSize.height();
|
height = dispSize.height();
|
||||||
width = getResources()
|
width = mNavigationBarView.getHeight();
|
||||||
.getDimensionPixelSize(R.dimen.navigation_bar_height);
|
|
||||||
break;
|
break;
|
||||||
case Surface.ROTATION_180:
|
case Surface.ROTATION_180:
|
||||||
case Surface.ROTATION_0:
|
case Surface.ROTATION_0:
|
||||||
// TODO(b/152683657): Need to determine best UX for this
|
// TODO(b/152683657): Need to determine best UX for this
|
||||||
resetSecondaryHandle();
|
if (!mShowOrientedHandleForImmersiveMode) {
|
||||||
return;
|
resetSecondaryHandle();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
width = dispSize.width();
|
||||||
|
height = mNavigationBarView.getHeight();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mOrientationParams.gravity =
|
mOrientationParams.gravity =
|
||||||
deltaRotation == Surface.ROTATION_90 ? Gravity.LEFT : Gravity.RIGHT;
|
deltaRotation == Surface.ROTATION_0 ? Gravity.BOTTOM :
|
||||||
|
(deltaRotation == Surface.ROTATION_90 ? Gravity.LEFT : Gravity.RIGHT);
|
||||||
mOrientationParams.height = height;
|
mOrientationParams.height = height;
|
||||||
mOrientationParams.width = width;
|
mOrientationParams.width = width;
|
||||||
mWindowManager.updateViewLayout(mOrientationHandle, mOrientationParams);
|
mWindowManager.updateViewLayout(mOrientationHandle, mOrientationParams);
|
||||||
@@ -743,6 +757,11 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
&& mNavigationBarWindowState != state) {
|
&& mNavigationBarWindowState != state) {
|
||||||
mNavigationBarWindowState = state;
|
mNavigationBarWindowState = state;
|
||||||
updateSystemUiStateFlags(-1);
|
updateSystemUiStateFlags(-1);
|
||||||
|
mShowOrientedHandleForImmersiveMode = state == WINDOW_STATE_HIDDEN;
|
||||||
|
if (mOrientationHandle != null
|
||||||
|
&& mStartingQuickSwitchRotation != -1) {
|
||||||
|
orientSecondaryHomeHandle();
|
||||||
|
}
|
||||||
if (DEBUG_WINDOW_STATE) Log.d(TAG, "Navigation bar " + windowStateToString(state));
|
if (DEBUG_WINDOW_STATE) Log.d(TAG, "Navigation bar " + windowStateToString(state));
|
||||||
|
|
||||||
if (mNavigationBarView != null) {
|
if (mNavigationBarView != null) {
|
||||||
|
|||||||
@@ -19,19 +19,25 @@ package com.android.systemui.statusbar.phone;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
import android.view.Surface;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
|
||||||
/** Temporarily shown view when using QuickSwitch to switch between apps of different rotations */
|
/** Temporarily shown view when using QuickSwitch to switch between apps of different rotations */
|
||||||
public class VerticalNavigationHandle extends NavigationHandle {
|
public class QuickswitchOrientedNavHandle extends NavigationHandle {
|
||||||
private final int mWidth;
|
private final int mWidth;
|
||||||
private final RectF mTmpBoundsRectF = new RectF();
|
private final RectF mTmpBoundsRectF = new RectF();
|
||||||
|
private @Surface.Rotation int mDeltaRotation;
|
||||||
|
|
||||||
public VerticalNavigationHandle(Context context) {
|
public QuickswitchOrientedNavHandle(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
mWidth = context.getResources().getDimensionPixelSize(R.dimen.navigation_home_handle_width);
|
mWidth = context.getResources().getDimensionPixelSize(R.dimen.navigation_home_handle_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setDeltaRotation(@Surface.Rotation int rotation) {
|
||||||
|
mDeltaRotation = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
canvas.drawRoundRect(computeHomeHandleBounds(), mRadius, mRadius, mPaint);
|
canvas.drawRoundRect(computeHomeHandleBounds(), mRadius, mRadius, mPaint);
|
||||||
@@ -42,12 +48,32 @@ public class VerticalNavigationHandle extends NavigationHandle {
|
|||||||
int top;
|
int top;
|
||||||
int bottom;
|
int bottom;
|
||||||
int right;
|
int right;
|
||||||
int topStart = getLocationOnScreen()[1];
|
|
||||||
int radiusOffset = mRadius * 2;
|
int radiusOffset = mRadius * 2;
|
||||||
right = getWidth() - mBottom;
|
int topStart = getLocationOnScreen()[1];
|
||||||
top = getHeight() / 2 - (mWidth / 2) - (topStart / 2);
|
|
||||||
left = getWidth() - mBottom - radiusOffset;
|
switch (mDeltaRotation) {
|
||||||
bottom = top + mWidth;
|
default:
|
||||||
|
case Surface.ROTATION_0:
|
||||||
|
case Surface.ROTATION_180:
|
||||||
|
int height = mRadius * 2;
|
||||||
|
left = getWidth() / 2 - mWidth / 2;
|
||||||
|
top = (getHeight() - mBottom - height);
|
||||||
|
right = getWidth() / 2 + mWidth / 2;
|
||||||
|
bottom = top + height;
|
||||||
|
break;
|
||||||
|
case Surface.ROTATION_90:
|
||||||
|
left = mBottom;
|
||||||
|
right = left + radiusOffset;
|
||||||
|
top = getHeight() / 2 - (mWidth / 2) - (topStart / 2);
|
||||||
|
bottom = top + mWidth;
|
||||||
|
break;
|
||||||
|
case Surface.ROTATION_270:
|
||||||
|
right = getWidth() - mBottom;
|
||||||
|
left = right - radiusOffset;
|
||||||
|
top = getHeight() / 2 - (mWidth / 2) - (topStart / 2);
|
||||||
|
bottom = top + mWidth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
mTmpBoundsRectF.set(left, top, right, bottom);
|
mTmpBoundsRectF.set(left, top, right, bottom);
|
||||||
return mTmpBoundsRectF;
|
return mTmpBoundsRectF;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user