From 4cbf1b636c270657e8cc8175b503a09b517ea50c Mon Sep 17 00:00:00 2001 From: Caitlin Cassidy Date: Fri, 1 Oct 2021 02:55:17 +0000 Subject: [PATCH] [Status Bar Refactor] Remove some indirection about minFraction between NotificationPanelViewController and PanelBar. The current code flow is NPVC#setPanelScrimMinFraction => PanelBar#onPanelMinFractionChanged => NPVC#setMinFraction. The minFraction doesn't need to flow through PanelBar if it's going to go right back to NPVC. Test: Test steps from ag/15759151 Bug: 200063118 Change-Id: If31a0d78cf4ac4a4d4bc6fcc7423a8006ab309fa --- .../phone/NotificationPanelViewController.java | 15 ++++++--------- .../systemui/statusbar/phone/PanelBar.java | 6 +----- .../statusbar/phone/PanelViewController.java | 7 ------- .../statusbar/phone/PhoneStatusBarView.java | 1 - .../NotificationPanelViewControllerTest.java | 4 ++-- 5 files changed, 9 insertions(+), 24 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index d36fae199072f..c88303a09d1da 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -1801,15 +1801,6 @@ public class NotificationPanelViewController extends PanelViewController { return !mQsTouchAboveFalsingThreshold; } - /** - * Percentage of panel expansion offset, caused by pulling down on a heads-up. - */ - @Override - public void setMinFraction(float minFraction) { - mMinFraction = minFraction; - mDepthController.setPanelPullDownMinFraction(mMinFraction); - } - private float computeQsExpansionFraction() { if (mQSAnimatingHiddenFromCollapsed) { // When hiding QS from collapsed state, the expansion can sometimes temporarily @@ -3337,8 +3328,14 @@ public class NotificationPanelViewController extends PanelViewController { return mBarState == KEYGUARD; } + /** + * Sets the minimum fraction for the panel expansion offset. This may be non-zero in certain + * cases, such as if there's a heads-up notification. + */ public void setPanelScrimMinFraction(float minFraction) { mBar.onPanelMinFractionChanged(minFraction); + mMinFraction = minFraction; + mDepthController.setPanelPullDownMinFraction(mMinFraction); } public void clearNotificationEffects() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java index 430edfdd9d19d..1f1090d7168b1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java @@ -19,7 +19,6 @@ package com.android.systemui.statusbar.phone; import static java.lang.Float.isNaN; import static java.lang.annotation.RetentionPolicy.SOURCE; -import android.annotation.CallSuper; import android.annotation.IntDef; import android.content.Context; import android.os.Bundle; @@ -149,10 +148,7 @@ public abstract class PanelBar extends FrameLayout { /** * Percentage of panel expansion offset, caused by pulling down on a heads-up. */ - @CallSuper - public void onPanelMinFractionChanged(float minFraction) { - mPanel.setMinFraction(minFraction); - } + abstract void onPanelMinFractionChanged(float minFraction); /** * @param frac the fraction from the expansion in [0, 1] diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java index 54adac098a334..768567b8b4741 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java @@ -342,13 +342,6 @@ public abstract class PanelViewController { protected abstract float getOpeningHeight(); - /** - * Minimum fraction from where expansion should start. This is set when pulling down on a - * heads-up notification. - * @param minFraction Fraction from 0 to 1. - */ - public abstract void setMinFraction(float minFraction); - /** * @return whether the swiping direction is upwards and above a 45 degree angle compared to the * horizontal direction 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 815f6fe850225..1cca4777da0a1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java @@ -272,7 +272,6 @@ public class PhoneStatusBarView extends PanelBar { if (isNaN(minFraction)) { throw new IllegalArgumentException("minFraction cannot be NaN"); } - super.onPanelMinFractionChanged(minFraction); if (mMinFraction != minFraction) { mMinFraction = minFraction; updateScrimFraction(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java index f7423bb7951df..e286ea986fded 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java @@ -469,8 +469,8 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { } @Test - public void testSetMinFraction() { - mNotificationPanelViewController.setMinFraction(0.5f); + public void testSetPanelScrimMinFraction() { + mNotificationPanelViewController.setPanelScrimMinFraction(0.5f); verify(mNotificationShadeDepthController).setPanelPullDownMinFraction(eq(0.5f)); }