summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author felkachang <felkachang@google.com> 2018-06-11 15:56:15 +0800
committer Selim Cinek <cinek@google.com> 2018-06-18 10:37:31 -0700
commit7749c9a5e93b38f795afaa8409771645189dea2e (patch)
tree2bfa9ac6d53252e50757f6e20a503889b5178fd0
parentd54c3a3036430043e6408a6d5de3a09885fdf474 (diff)
Fix NotificaitonPanelView x-axis shift with IME
IME will trigger the fitSystemWindow. And, there is a difference of the parameter insets between IME and no IME. The insets.right and insets.left report 0 without IME but positive number with IME because IME is a type of system window and trigger fitSystemWindow and then take the cutout as part of system window. StatusBarWindowView handle the following condition cutout > 0 && cutout == systemWindowInset and make its children not layout on the safe inset both of cut out and system window. In order to handle that cut out become system window, to take the maximum of cut out and system window to make sure that the safe inset is decided in StatusBarWindowView and its view decent only care about the corner cut out. Because StatusBarWindowView make both of PhoneStatusBarView's parent and NotificationPanelView to have the margin for both of cutout and system window, the counting of the padding and panel translation of the HeadsUpStatusBarView need to do the relative changes. Change-Id: Iafdc6a85e0e7d360b1bfc1e820f6e0779c32753f Fix: 79957419 Fix: 109945733 Fix: 109865908 Test: atest SystemUITests
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java31
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java18
4 files changed, 39 insertions, 28 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java
index 39485c3c8800..29e0edaf25cc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java
@@ -178,11 +178,7 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {
* @param translationX how to translate the horizontal position
*/
public void setPanelTranslation(float translationX) {
- if (isLayoutRtl()) {
- setTranslationX(translationX + mCutOutInset);
- } else {
- setTranslationX(translationX - mCutOutInset);
- }
+ setTranslationX(translationX);
updateDrawingRect();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java
index 409a78391975..4e7f4f38ebd3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone;
import android.graphics.Point;
import android.graphics.Rect;
+import android.view.DisplayCutout;
import android.view.View;
import android.view.WindowInsets;
@@ -159,8 +160,15 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
}
WindowInsets windowInset = mStackScroller.getRootWindowInsets();
- return windowInset.getSystemWindowInsetLeft() + mStackScroller.getRight()
- + windowInset.getSystemWindowInsetRight() - realDisplaySize;
+ DisplayCutout cutout = (windowInset != null) ? windowInset.getDisplayCutout() : null;
+ int sysWinLeft = (windowInset != null) ? windowInset.getStableInsetLeft() : 0;
+ int sysWinRight = (windowInset != null) ? windowInset.getStableInsetRight() : 0;
+ int cutoutLeft = (cutout != null) ? cutout.getSafeInsetLeft() : 0;
+ int cutoutRight = (cutout != null) ? cutout.getSafeInsetRight() : 0;
+ int leftInset = Math.max(sysWinLeft, cutoutLeft);
+ int rightInset = Math.max(sysWinRight, cutoutRight);
+
+ return leftInset + mStackScroller.getRight() + rightInset - realDisplaySize;
}
public void updatePanelTranslation() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index 5477f882e5f9..075883a8ac52 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -331,30 +331,25 @@ public class PhoneStatusBarView extends PanelBar {
// or letterboxing from the right or left sides.
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
- if (mDisplayCutout == null) {
+ if (mDisplayCutout == null || mDisplayCutout.isEmpty()
+ || mLastOrientation != ORIENTATION_PORTRAIT || cornerCutoutMargins == null) {
lp.leftMargin = 0;
lp.rightMargin = 0;
return;
}
- lp.leftMargin = mDisplayCutout.getSafeInsetLeft();
- lp.rightMargin = mDisplayCutout.getSafeInsetRight();
-
- if (cornerCutoutMargins != null) {
- lp.leftMargin = Math.max(lp.leftMargin, cornerCutoutMargins.first);
- lp.rightMargin = Math.max(lp.rightMargin, cornerCutoutMargins.second);
-
- // If we're already inset enough (e.g. on the status bar side), we can have 0 margin
- WindowInsets insets = getRootWindowInsets();
- int leftInset = insets.getSystemWindowInsetLeft();
- int rightInset = insets.getSystemWindowInsetRight();
- if (lp.leftMargin <= leftInset) {
- lp.leftMargin = 0;
- }
- if (lp.rightMargin <= rightInset) {
- lp.rightMargin = 0;
- }
+ lp.leftMargin = Math.max(lp.leftMargin, cornerCutoutMargins.first);
+ lp.rightMargin = Math.max(lp.rightMargin, cornerCutoutMargins.second);
+ // If we're already inset enough (e.g. on the status bar side), we can have 0 margin
+ WindowInsets insets = getRootWindowInsets();
+ int leftInset = insets.getSystemWindowInsetLeft();
+ int rightInset = insets.getSystemWindowInsetRight();
+ if (lp.leftMargin <= leftInset) {
+ lp.leftMargin = 0;
+ }
+ if (lp.rightMargin <= rightInset) {
+ lp.rightMargin = 0;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
index a79a41b07797..43958dba9c0a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
@@ -37,6 +37,7 @@ import android.os.IBinder;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.ActionMode;
+import android.view.DisplayCutout;
import android.view.InputDevice;
import android.view.InputQueue;
import android.view.KeyEvent;
@@ -112,10 +113,21 @@ public class StatusBarWindowView extends FrameLayout {
boolean paddingChanged = insets.top != getPaddingTop()
|| insets.bottom != getPaddingBottom();
+ int rightCutout = 0;
+ int leftCutout = 0;
+ DisplayCutout displayCutout = getRootWindowInsets().getDisplayCutout();
+ if (displayCutout != null) {
+ leftCutout = displayCutout.getSafeInsetLeft();
+ rightCutout = displayCutout.getSafeInsetRight();
+ }
+
+ int targetLeft = Math.max(insets.left, leftCutout);
+ int targetRight = Math.max(insets.right, rightCutout);
+
// Super-special right inset handling, because scrims and backdrop need to ignore it.
- if (insets.right != mRightInset || insets.left != mLeftInset) {
- mRightInset = insets.right;
- mLeftInset = insets.left;
+ if (targetRight != mRightInset || targetLeft != mLeftInset) {
+ mRightInset = targetRight;
+ mLeftInset = targetLeft;
applyMargins();
}
// Drop top inset, and pass through bottom inset.