summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java22
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java20
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/VerticalNavigationHandle.java15
3 files changed, 52 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
index 26e80adafd3d..bf53a2f113e9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
@@ -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);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 6b37ac317cdd..4821d8c46ed4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -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());
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/VerticalNavigationHandle.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/VerticalNavigationHandle.java
index a15ca9532a88..0cdf1d32d6a0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/VerticalNavigationHandle.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/VerticalNavigationHandle.java
@@ -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;
}
}