From 28110ae6ba20d7b20eced754cb5455c6ed0fbfa5 Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Tue, 6 Jul 2021 13:40:43 +0100 Subject: [PATCH] Extracting status bar from quick settings in split shade First phase of moving status bar from quick settings to upper layer so status bar takes full width of the screen. This change: - hides status bar in quick settings and adjusts all paddings/margins - reuses QS status bar as a full width status bar <- this will be fixed in following CLs - creates controller for new status bar, which manages its (dis)appearing <- alpha/shift revealing animation TODO Bug: 182981830 Test: manual (automated coming in next CLs if this approach looks good) Change-Id: I84adf101d050ccbd286bc02808a9ad93aeda2039 --- .../values-sw600dp-land/dimens.xml | 4 +++ .../res/layout/qs_customize_panel_content.xml | 2 +- .../quick_status_bar_expanded_header.xml | 28 +++++++-------- .../res/layout/status_bar_expanded.xml | 2 ++ packages/SystemUI/res/values/dimens.xml | 8 ++++- .../android/systemui/qs/QSContainerImpl.java | 4 +-- .../systemui/qs/QuickStatusBarHeader.java | 34 +++++++++---------- .../systemui/qs/customize/QSCustomizer.java | 4 +-- .../NotificationPanelViewController.java | 29 ++++++++++++---- .../phone/SplitShadeStatusBarController.kt | 29 ++++++++++++++++ .../phone/dagger/StatusBarComponent.java | 7 ++++ .../phone/dagger/StatusBarViewModule.java | 15 ++++++++ .../phone/NotificationPanelViewTest.java | 3 ++ 13 files changed, 124 insertions(+), 45 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/SplitShadeStatusBarController.kt diff --git a/packages/SystemUI/res-keyguard/values-sw600dp-land/dimens.xml b/packages/SystemUI/res-keyguard/values-sw600dp-land/dimens.xml index c34012dc85a8c..d816b3a461cd9 100644 --- a/packages/SystemUI/res-keyguard/values-sw600dp-land/dimens.xml +++ b/packages/SystemUI/res-keyguard/values-sw600dp-land/dimens.xml @@ -21,4 +21,8 @@ 88dp + + 0dp + 0dp + \ No newline at end of file diff --git a/packages/SystemUI/res/layout/qs_customize_panel_content.xml b/packages/SystemUI/res/layout/qs_customize_panel_content.xml index 8ca1b8e856343..3be99939ba0fb 100644 --- a/packages/SystemUI/res/layout/qs_customize_panel_content.xml +++ b/packages/SystemUI/res/layout/qs_customize_panel_content.xml @@ -19,7 +19,7 @@ - - + + - + diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml index dbbf641e4bf7e..7b82f1d18b8df 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded.xml @@ -64,6 +64,8 @@ android:clipToPadding="false" android:clipChildren="false"> + + diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index b5156b6f5003e..f202645ded578 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -402,8 +402,11 @@ 48dp - 48dp + @*android:dimen/quick_qs_offset_height 128dp @@ -455,6 +458,9 @@ -1px + + @*android:dimen/quick_qs_offset_height + 0dp diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java index e9b19e5cfa6f2..eeae652eb408a 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java @@ -160,8 +160,8 @@ public class QSContainerImpl extends FrameLayout { QuickStatusBarHeaderController quickStatusBarHeaderController) { mQSPanelContainer.setPaddingRelative( getPaddingStart(), - mContext.getResources().getDimensionPixelSize( - com.android.internal.R.dimen.quick_qs_offset_height), + mContext.getResources() + .getDimensionPixelSize(R.dimen.qs_header_system_icons_area_height), getPaddingEnd(), getPaddingBottom() ); diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java index 03a2c843a15e0..cd7ad1672af4a 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java @@ -57,9 +57,8 @@ public class QuickStatusBarHeader extends FrameLayout { protected QuickQSPanel mHeaderQsPanel; private View mDatePrivacyView; - private View mDateView; private View mSecurityHeaderView; - private View mClockIconsView; + private View mStatusIconsView; private View mContainer; private View mQSCarriers; @@ -82,7 +81,6 @@ public class QuickStatusBarHeader extends FrameLayout { private int mWaterfallTopInset; private int mCutOutPaddingLeft; private int mCutOutPaddingRight; - private float mViewAlpha = 1.0f; private float mKeyguardExpansionFraction; private int mTextColorPrimary = Color.TRANSPARENT; private int mTopViewMeasureHeight; @@ -115,12 +113,11 @@ public class QuickStatusBarHeader extends FrameLayout { mHeaderQsPanel = findViewById(R.id.quick_qs_panel); mDatePrivacyView = findViewById(R.id.quick_status_bar_date_privacy); - mClockIconsView = findViewById(R.id.quick_qs_status_icons); + mStatusIconsView = findViewById(R.id.quick_qs_status_icons); mQSCarriers = findViewById(R.id.carrier_group); mContainer = findViewById(R.id.qs_container); mIconContainer = findViewById(R.id.statusIcons); mPrivacyChip = findViewById(R.id.privacy_chip); - mDateView = findViewById(R.id.date); mSecurityHeaderView = findViewById(R.id.header_text_container); mClockIconsSeparator = findViewById(R.id.separator); mRightLayout = findViewById(R.id.rightLayout); @@ -161,10 +158,6 @@ public class QuickStatusBarHeader extends FrameLayout { updateAnimators(); } - public QuickQSPanel getHeaderQsPanel() { - return mHeaderQsPanel; - } - @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); @@ -201,6 +194,11 @@ public class QuickStatusBarHeader extends FrameLayout { void updateResources() { Resources resources = mContext.getResources(); + // status bar is already displayed out of QS in split shade + boolean shouldUseSplitShade = + resources.getBoolean(R.bool.config_use_split_notification_shade); + mStatusIconsView.setVisibility(shouldUseSplitShade ? View.GONE : View.VISIBLE); + mDatePrivacyView.setVisibility(shouldUseSplitShade ? View.GONE : View.VISIBLE); mRoundedCornerPadding = resources.getDimensionPixelSize( R.dimen.rounded_corner_content_padding); @@ -212,13 +210,13 @@ public class QuickStatusBarHeader extends FrameLayout { Math.max(qsOffsetHeight, mDatePrivacyView.getMinimumHeight()); mDatePrivacyView.setLayoutParams(mDatePrivacyView.getLayoutParams()); - mClockIconsView.getLayoutParams().height = - Math.max(qsOffsetHeight, mClockIconsView.getMinimumHeight()); - mClockIconsView.setLayoutParams(mClockIconsView.getLayoutParams()); + mStatusIconsView.getLayoutParams().height = + Math.max(qsOffsetHeight, mStatusIconsView.getMinimumHeight()); + mStatusIconsView.setLayoutParams(mStatusIconsView.getLayoutParams()); ViewGroup.LayoutParams lp = getLayoutParams(); if (mQsDisabled) { - lp.height = mClockIconsView.getLayoutParams().height; + lp.height = mStatusIconsView.getLayoutParams().height; } else { lp.height = WRAP_CONTENT; } @@ -364,7 +362,7 @@ public class QuickStatusBarHeader extends FrameLayout { if (disabled == mQsDisabled) return; mQsDisabled = disabled; mHeaderQsPanel.setDisabledByPolicy(disabled); - mClockIconsView.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE); + mStatusIconsView.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE); updateResources(); } @@ -378,7 +376,7 @@ public class QuickStatusBarHeader extends FrameLayout { StatusBarWindowView.paddingNeededForCutoutAndRoundedCorner( cutout, cornerCutoutPadding, -1); mDatePrivacyView.setPadding(padding.first, 0, padding.second, 0); - mClockIconsView.setPadding(padding.first, 0, padding.second, 0); + mStatusIconsView.setPadding(padding.first, 0, padding.second, 0); LinearLayout.LayoutParams datePrivacySeparatorLayoutParams = (LinearLayout.LayoutParams) mDatePrivacySeparator.getLayoutParams(); LinearLayout.LayoutParams mClockIconsSeparatorLayoutParams = @@ -440,7 +438,7 @@ public class QuickStatusBarHeader extends FrameLayout { private void updateHeadersPadding() { setContentMargins(mDatePrivacyView, 0, 0); - setContentMargins(mClockIconsView, 0, 0); + setContentMargins(mStatusIconsView, 0, 0); int paddingLeft = 0; int paddingRight = 0; @@ -466,7 +464,7 @@ public class QuickStatusBarHeader extends FrameLayout { mWaterfallTopInset, paddingRight, 0); - mClockIconsView.setPadding(paddingLeft, + mStatusIconsView.setPadding(paddingLeft, mWaterfallTopInset, paddingRight, 0); @@ -493,7 +491,7 @@ public class QuickStatusBarHeader extends FrameLayout { * @param scrollY the scroll of the QSPanel container */ public void setExpandedScrollAmount(int scrollY) { - mClockIconsView.setScrollY(scrollY); + mStatusIconsView.setScrollY(scrollY); mDatePrivacyView.setScrollY(scrollY); } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java index 7518b200c7e27..d33982c6e1725 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java +++ b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java @@ -84,8 +84,8 @@ public class QSCustomizer extends LinearLayout { void updateResources() { LayoutParams lp = (LayoutParams) mTransparentView.getLayoutParams(); - lp.height = mContext.getResources().getDimensionPixelSize( - com.android.internal.R.dimen.quick_qs_offset_height); + lp.height = mContext.getResources() + .getDimensionPixelSize(R.dimen.qs_header_system_icons_area_height); mTransparentView.setLayoutParams(lp); } 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 920e2a55a89c8..1c9b7b7489fd6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -21,6 +21,7 @@ import static android.view.View.GONE; import static androidx.constraintlayout.widget.ConstraintSet.END; import static androidx.constraintlayout.widget.ConstraintSet.PARENT_ID; import static androidx.constraintlayout.widget.ConstraintSet.START; +import static androidx.constraintlayout.widget.ConstraintSet.TOP; import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE; import static com.android.keyguard.KeyguardClockSwitch.LARGE; @@ -28,6 +29,8 @@ import static com.android.keyguard.KeyguardClockSwitch.SMALL; import static com.android.systemui.classifier.Classifier.QS_COLLAPSE; import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS; import static com.android.systemui.statusbar.StatusBarState.KEYGUARD; +import static com.android.systemui.statusbar.StatusBarState.SHADE; +import static com.android.systemui.statusbar.StatusBarState.SHADE_LOCKED; import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL; import static java.lang.Float.isNaN; @@ -331,6 +334,7 @@ public class NotificationPanelViewController extends PanelViewController { private final int mMaxKeyguardNotifications; private final LockscreenShadeTransitionController mLockscreenShadeTransitionController; private final TapAgainViewController mTapAgainViewController; + private final SplitShadeStatusBarController mSplitShadeStatusBarController; private boolean mShouldUseSplitNotificationShade; // Current max allowed keyguard notifications determined by measuring the panel private int mMaxAllowedKeyguardNotifications; @@ -393,7 +397,7 @@ public class NotificationPanelViewController extends PanelViewController { private float mDownY; private int mDisplayTopInset = 0; // in pixels private int mDisplayRightInset = 0; // in pixels - private int mSplitShadeNotificationsTopPadding; + private int mSplitShadeStatusBarHeight; private final KeyguardClockPositionAlgorithm mClockPositionAlgorithm = @@ -719,6 +723,7 @@ public class NotificationPanelViewController extends PanelViewController { QuickAccessWalletController quickAccessWalletController, @Main Executor uiExecutor, SecureSettings secureSettings, + SplitShadeStatusBarController splitShadeStatusBarController, UnlockedScreenOffAnimationController unlockedScreenOffAnimationController, NotificationRemoteInputManager remoteInputManager) { super(view, falsingManager, dozeLog, keyguardStateController, @@ -752,6 +757,7 @@ public class NotificationPanelViewController extends PanelViewController { mShouldUseSplitNotificationShade = Utils.shouldUseSplitNotificationShade(mFeatureFlags, mResources); mView.setWillNotDraw(!DEBUG); + mSplitShadeStatusBarController = splitShadeStatusBarController; mLayoutInflater = layoutInflater; mFalsingManager = falsingManager; mFalsingCollector = falsingCollector; @@ -1020,8 +1026,8 @@ public class NotificationPanelViewController extends PanelViewController { public void updateResources() { mQuickQsOffsetHeight = mResources.getDimensionPixelSize( com.android.internal.R.dimen.quick_qs_offset_height); - mSplitShadeNotificationsTopPadding = - mResources.getDimensionPixelSize(R.dimen.notifications_top_padding_split_shade); + mSplitShadeStatusBarHeight = + mResources.getDimensionPixelSize(R.dimen.split_shade_status_bar_height); int qsWidth = mResources.getDimensionPixelSize(R.dimen.qs_panel_width); int panelWidth = mResources.getDimensionPixelSize(R.dimen.notification_panel_width); mShouldUseSplitNotificationShade = @@ -1030,6 +1036,11 @@ public class NotificationPanelViewController extends PanelViewController { if (mQs != null) { mQs.setTranslateWhileExpanding(mShouldUseSplitNotificationShade); } + + int topMargin = mShouldUseSplitNotificationShade ? mSplitShadeStatusBarHeight : + mResources.getDimensionPixelSize(R.dimen.notification_panel_margin_top); + mSplitShadeStatusBarController.setSplitShadeMode(mShouldUseSplitNotificationShade); + // To change the constraints at runtime, all children of the ConstraintLayout must have ids ensureAllViewsHaveIds(mNotificationContainerParent); ConstraintSet constraintSet = new ConstraintSet(); @@ -1048,6 +1059,8 @@ public class NotificationPanelViewController extends PanelViewController { } constraintSet.getConstraint(R.id.notification_stack_scroller).layout.mWidth = panelWidth; constraintSet.getConstraint(R.id.qs_frame).layout.mWidth = qsWidth; + constraintSet.setMargin(R.id.notification_stack_scroller, TOP, topMargin); + constraintSet.setMargin(R.id.qs_frame, TOP, topMargin); constraintSet.applyTo(mNotificationContainerParent); updateKeyguardStatusViewAlignment(false /* animate */); @@ -2333,8 +2346,8 @@ public class NotificationPanelViewController extends PanelViewController { left = 0; right = getView().getRight() + mDisplayRightInset; } else { - top = Math.min(qsPanelBottomY, mSplitShadeNotificationsTopPadding); - bottom = mNotificationStackScrollLayoutController.getHeight(); + top = Math.min(qsPanelBottomY, mSplitShadeStatusBarHeight); + bottom = top + mNotificationStackScrollLayoutController.getHeight(); left = mNotificationStackScrollLayoutController.getLeft(); right = mNotificationStackScrollLayoutController.getRight(); } @@ -2432,7 +2445,7 @@ public class NotificationPanelViewController extends PanelViewController { int nsslLeft = left - mNotificationStackScrollLayoutController.getLeft(); int nsslRight = right - mNotificationStackScrollLayoutController.getLeft(); int nsslTop = top - mNotificationStackScrollLayoutController.getTop(); - int nsslBottom = bottom - mNotificationStackScrollLayoutController.getTop(); + int nsslBottom = bottom; int bottomRadius = mShouldUseSplitNotificationShade ? radius : 0; mNotificationStackScrollLayoutController.setRoundedClippingBounds( nsslLeft, nsslTop, nsslRight, nsslBottom, radius, bottomRadius); @@ -2473,7 +2486,7 @@ public class NotificationPanelViewController extends PanelViewController { private float calculateNotificationsTopPadding() { if (mShouldUseSplitNotificationShade && !mKeyguardShowing) { - return mSplitShadeNotificationsTopPadding + mQsNotificationTopPadding; + return 0; } if (mKeyguardShowing && (mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted)) { @@ -4453,6 +4466,8 @@ public class NotificationPanelViewController extends PanelViewController { maybeAnimateBottomAreaAlpha(); resetHorizontalPanelPosition(); updateQsState(); + mSplitShadeStatusBarController.setShadeExpanded( + mBarState == SHADE || mBarState == SHADE_LOCKED); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SplitShadeStatusBarController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SplitShadeStatusBarController.kt new file mode 100644 index 0000000000000..724d5e256475e --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SplitShadeStatusBarController.kt @@ -0,0 +1,29 @@ +package com.android.systemui.statusbar.phone + +import android.view.View +import com.android.systemui.statusbar.phone.dagger.StatusBarComponent.StatusBarScope +import com.android.systemui.statusbar.phone.dagger.StatusBarViewModule.SPLIT_SHADE_STATUS_BAR +import javax.inject.Inject +import javax.inject.Named + +@StatusBarScope +class SplitShadeStatusBarController @Inject constructor( + @Named(SPLIT_SHADE_STATUS_BAR) val view: View +) { + + var shadeExpanded = false + set(value) { + field = value + updateVisibility() + } + + var splitShadeMode = false + set(value) { + field = value + updateVisibility() + } + + private fun updateVisibility() { + view.visibility = if (shadeExpanded && splitShadeMode) View.VISIBLE else View.GONE + } +} \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java index fb25ae37ea741..028b6d9e615df 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java @@ -23,6 +23,7 @@ import com.android.systemui.biometrics.AuthRippleController; import com.android.systemui.statusbar.phone.NotificationPanelViewController; import com.android.systemui.statusbar.phone.NotificationShadeWindowView; import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController; +import com.android.systemui.statusbar.phone.SplitShadeStatusBarController; import com.android.systemui.statusbar.phone.StatusBarWindowController; import java.lang.annotation.Documented; @@ -86,4 +87,10 @@ public interface StatusBarComponent { */ @StatusBarScope AuthRippleController getAuthRippleController(); + + /** + * Creates a SplitShadeStatusBarController. + */ + @StatusBarScope + SplitShadeStatusBarController getSplitShadeStatusBarController(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java index 27d71edd5e8ad..6fa369fe4938b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.phone.dagger; import android.annotation.Nullable; +import android.view.View; import com.android.keyguard.LockIconView; import com.android.systemui.R; @@ -25,11 +26,16 @@ import com.android.systemui.statusbar.phone.NotificationPanelView; import com.android.systemui.statusbar.phone.NotificationShadeWindowView; import com.android.systemui.statusbar.phone.TapAgainView; +import javax.inject.Named; + import dagger.Module; import dagger.Provides; @Module public abstract class StatusBarViewModule { + + public static final String SPLIT_SHADE_STATUS_BAR = "split_shade_status_bar"; + /** */ @Provides @StatusBarComponent.StatusBarScope @@ -55,6 +61,15 @@ public abstract class StatusBarViewModule { return notificationShadeWindowView.findViewById(R.id.auth_ripple); } + /** */ + @Provides + @Named(SPLIT_SHADE_STATUS_BAR) + @StatusBarComponent.StatusBarScope + public static View getSlitShadeStatusBarView( + NotificationShadeWindowView notificationShadeWindowView) { + return notificationShadeWindowView.findViewById(R.id.quick_qs_status_icons); + } + /** */ @Provides @StatusBarComponent.StatusBarScope diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java index 1540b14e172e7..e9c4c5e5659d4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java @@ -283,6 +283,8 @@ public class NotificationPanelViewTest extends SysuiTestCase { @Mock private SecureSettings mSecureSettings; @Mock + private SplitShadeStatusBarController mSplitShadeStatusBarController; + @Mock private ContentResolver mContentResolver; @Mock private TapAgainViewController mTapAgainViewController; @@ -438,6 +440,7 @@ public class NotificationPanelViewTest extends SysuiTestCase { mQuickAccessWalletController, new FakeExecutor(new FakeSystemClock()), mSecureSettings, + mSplitShadeStatusBarController, mUnlockedScreenOffAnimationController, mNotificationRemoteInputManager); mNotificationPanelViewController.initDependencies(