summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author felkachang <felkachang@google.com> 2018-07-27 15:32:31 +0800
committer felkachang <felkachang@google.com> 2018-08-08 15:09:24 +0800
commitc02c388fde72da9de6546c63dca84ef0bb277527 (patch)
tree19f89d3ed1b6f655d8a5fb2bcccece239766064e
parent642d495ff50cb238687a0a9ebe3b2d7aeec7e87d (diff)
Fix animation in shelf is not notch aware
The NotificationSelf doesn't aware the existence of the notch. It could get the exactly rect of the top cutout/notch by using onApplyWindowInsets. The solution is to use the Interpolators.FAST_OUT_SLOW_IN_REVERSE to interpolate the the new value of openedAmount if there is a top cutout exists. The new openedAmount will impact the parameter 'width'. In order to let the animation more smooth, to add the cutout height to the denominator of the counting formula. Test: manual test Change-Id: I8ed510b6f5de8f566bdc9fa7da95d87643ffb1d4 Fixes: 111724799
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
index 38d266dccc68..55dfd440bcae 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar;
+import static com.android.systemui.Interpolators.FAST_OUT_SLOW_IN_REVERSE;
import static com.android.systemui.statusbar.phone.NotificationIconContainer.IconState.NO_VALUE;
import android.content.Context;
@@ -26,9 +27,11 @@ import android.os.SystemProperties;
import android.util.AttributeSet;
import android.util.Log;
import android.util.MathUtils;
+import android.view.DisplayCutout;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
+import android.view.WindowInsets;
import android.view.accessibility.AccessibilityNodeInfo;
import com.android.systemui.Interpolators;
@@ -89,6 +92,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
private boolean mShowNotificationShelf;
private float mFirstElementRoundness;
private Rect mClipRect = new Rect();
+ private int mCutoutHeight;
public NotificationShelf(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -200,8 +204,12 @@ public class NotificationShelf extends ActivatableNotificationView implements
0 : mAmbientState.getDarkAmount();
mShelfState.yTranslation = MathUtils.lerp(awakenTranslation, darkTranslation, yRatio);
mShelfState.zTranslation = ambientState.getBaseZHeight();
+ // For the small display size, it's not enough to make the icon not covered by
+ // the top cutout so the denominator add the height of cutout.
+ // Totally, (getIntrinsicHeight() * 2 + mCutoutHeight) should be smaller then
+ // mAmbientState.getTopPadding().
float openedAmount = (mShelfState.yTranslation - getFullyClosedTranslation())
- / (getIntrinsicHeight() * 2);
+ / (getIntrinsicHeight() * 2 + mCutoutHeight);
openedAmount = Math.min(1.0f, openedAmount);
mShelfState.openedAmount = openedAmount;
mShelfState.clipTopAmount = 0;
@@ -745,6 +753,22 @@ public class NotificationShelf extends ActivatableNotificationView implements
mRelativeOffset -= mTmp[0];
}
+ @Override
+ public WindowInsets onApplyWindowInsets(WindowInsets insets) {
+ WindowInsets ret = super.onApplyWindowInsets(insets);
+
+ // NotificationShelf drag from the status bar and the status bar dock on the top
+ // of the display for current design so just focus on the top of ScreenDecorations.
+ // In landscape or multiple window split mode, the NotificationShelf still drag from
+ // the top and the physical notch/cutout goes to the right, left, or both side of the
+ // display so it doesn't matter for the NotificationSelf in landscape.
+ DisplayCutout displayCutout = insets.getDisplayCutout();
+ mCutoutHeight = displayCutout == null || displayCutout.getSafeInsetTop() < 0
+ ? 0 : displayCutout.getSafeInsetTop();
+
+ return ret;
+ }
+
private void setOpenedAmount(float openedAmount) {
mNoAnimationsInThisFrame = openedAmount == 1.0f && mOpenedAmount == 0.0f;
mOpenedAmount = openedAmount;
@@ -759,7 +783,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
int width = (int) NotificationUtils.interpolate(
start + mCollapsedIcons.getFinalTranslationX(),
mShelfIcons.getWidth(),
- openedAmount);
+ FAST_OUT_SLOW_IN_REVERSE.getInterpolation(openedAmount));
mShelfIcons.setActualLayoutWidth(width);
boolean hasOverflow = mCollapsedIcons.hasOverflow();
int collapsedPadding = mCollapsedIcons.getPaddingEnd();