From a501b9b9cb394f42b4ceaede8586f438a8f94e6e Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Tue, 6 Jul 2021 16:29:23 +0200 Subject: [PATCH] DO NOT MERGE Fixed the padding of quick settings Quick settings was accounting for double the padding / or not enough in most cases. The padding is now only on the quick settings itself and the various workarounds in the build are reverted. Media and the horizontal layout would obtain negative margins for example, which where just cancelling themselves out. Fixes: 192937466 Test: add media / no media, observe proper 24dp padding below Change-Id: I635afaaf9185c32a9f04851453ac7c0d20612c11 Merged-In: I635afaaf9185c32a9f04851453ac7c0d20612c11 --- .../quick_status_bar_expanded_header.xml | 2 +- .../src/com/android/systemui/qs/QSPanel.java | 19 ++++++++++++--- .../com/android/systemui/qs/QuickQSPanel.java | 6 ++++- .../com/android/systemui/qs/TileLayout.java | 5 +--- .../stack/StackScrollAlgorithm.java | 11 ++++++--- .../NotificationPanelViewController.java | 23 ++++++------------- 6 files changed, 38 insertions(+), 28 deletions(-) diff --git a/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml b/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml index f9dcd390cd510..f3b8b0bfaf36f 100644 --- a/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml +++ b/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml @@ -55,7 +55,7 @@ android:clipChildren="false" android:clipToPadding="false" android:focusable="true" - android:paddingBottom="10dp" + android:paddingBottom="24dp" android:importantForAccessibility="yes" /> diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java index 7c7f566589199..425bdc24fe1b1 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java @@ -56,6 +56,8 @@ public class QSPanel extends LinearLayout implements Tunable { private static final String TAG = "QSPanel"; protected final Context mContext; + private final int mMediaTopMargin; + private final int mMediaTotalBottomMargin; /** * The index where the content starts that needs to be moved between parents @@ -99,13 +101,14 @@ public class QSPanel extends LinearLayout implements Tunable { protected LinearLayout mHorizontalContentContainer; protected QSTileLayout mTileLayout; - private int mMediaTotalBottomMargin; public QSPanel(Context context, AttributeSet attrs) { super(context, attrs); mUsingMediaPlayer = useQsMediaPlayer(context); mMediaTotalBottomMargin = getResources().getDimensionPixelSize( R.dimen.quick_settings_bottom_margin_media); + mMediaTopMargin = getResources().getDimensionPixelSize( + R.dimen.qs_tile_margin_vertical); mContext = context; setOrientation(VERTICAL); @@ -328,7 +331,7 @@ public class QSPanel extends LinearLayout implements Tunable { private void updateHorizontalLinearLayoutMargins() { if (mHorizontalLinearLayout != null && !displayMediaMarginsOnMedia()) { LayoutParams lp = (LayoutParams) mHorizontalLinearLayout.getLayoutParams(); - lp.bottomMargin = mMediaTotalBottomMargin - getPaddingBottom(); + lp.bottomMargin = Math.max(mMediaTotalBottomMargin - getPaddingBottom(), 0); mHorizontalLinearLayout.setLayoutParams(lp); } } @@ -343,6 +346,13 @@ public class QSPanel extends LinearLayout implements Tunable { return true; } + /** + * @return true if the media view needs margin on the top to separate it from the qs tiles + */ + protected boolean mediaNeedsTopMargin() { + return false; + } + private boolean needsDynamicRowsAndColumns() { return true; } @@ -411,7 +421,9 @@ public class QSPanel extends LinearLayout implements Tunable { // necessary if the view isn't horizontal, since otherwise the padding is // carried in the parent of this view (to ensure correct vertical alignment) layoutParams.bottomMargin = !horizontal || displayMediaMarginsOnMedia() - ? mMediaTotalBottomMargin - getPaddingBottom() : 0; + ? Math.max(mMediaTotalBottomMargin - getPaddingBottom(), 0) : 0; + layoutParams.topMargin = mediaNeedsTopMargin() && !horizontal + ? mMediaTopMargin : 0; } } @@ -674,6 +686,7 @@ public class QSPanel extends LinearLayout implements Tunable { mTileLayout.setMaxColumns(horizontal ? 2 : 4); } updateMargins(mediaHostView); + mHorizontalLinearLayout.setVisibility(horizontal ? View.VISIBLE : View.GONE); } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java index 4cd4048f72868..985943bc8b054 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java @@ -72,6 +72,11 @@ public class QuickQSPanel extends QSPanel { return false; } + @Override + protected boolean mediaNeedsTopMargin() { + return true; + } + @Override protected void updatePadding() { // QS Panel is setting a top padding by default, which we don't need. @@ -180,7 +185,6 @@ public class QuickQSPanel extends QSPanel { LayoutParams.WRAP_CONTENT); setLayoutParams(lp); setMaxColumns(4); - mLastRowPadding = true; } @Override diff --git a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java index 2b96a34967f49..1a890a7ad07bb 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java +++ b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java @@ -31,7 +31,6 @@ public class TileLayout extends ViewGroup implements QSTileLayout { protected int mCellMarginVertical; protected int mSidePadding; protected int mRows = 1; - protected boolean mLastRowPadding = false; protected final ArrayList mRecords = new ArrayList<>(); protected boolean mListening; @@ -168,9 +167,7 @@ public class TileLayout extends ViewGroup implements QSTileLayout { } int height = (mCellHeight + mCellMarginVertical) * mRows; - if (!mLastRowPadding) { - height -= mCellMarginVertical; - } + height -= mCellMarginVertical; if (height < 0) height = 0; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java index d0507e1e136ca..b36dc56ffdf95 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java @@ -274,7 +274,9 @@ public class StackScrollAlgorithm { // expanded. Consider updating these states in updateContentView instead so that we don't // have to recalculate in every frame. float currentY = -ambientState.getScrollY(); - if (!ambientState.isOnKeyguard()) { + if (!ambientState.isOnKeyguard() + || (ambientState.isBypassEnabled() && ambientState.isPulseExpanding())) { + // add top padding at the start as long as we're not on the lock screen currentY += mNotificationScrimPadding; } state.firstViewInShelf = null; @@ -324,7 +326,8 @@ public class StackScrollAlgorithm { */ private void updatePositionsForState(StackScrollAlgorithmState algorithmState, AmbientState ambientState) { - if (!ambientState.isOnKeyguard()) { + if (!ambientState.isOnKeyguard() + || (ambientState.isBypassEnabled() && ambientState.isPulseExpanding())) { algorithmState.mCurrentYPosition += mNotificationScrimPadding; algorithmState.mCurrentExpandedYPosition += mNotificationScrimPadding; } @@ -355,7 +358,9 @@ public class StackScrollAlgorithm { && algorithmState.firstViewInShelf != null; final float shelfHeight = showingShelf ? ambientState.getShelf().getIntrinsicHeight() : 0f; - final float scrimPadding = ambientState.isOnKeyguard() ? 0 : mNotificationScrimPadding; + final float scrimPadding = ambientState.isOnKeyguard() + && (!ambientState.isBypassEnabled() || !ambientState.isPulseExpanding()) + ? 0 : mNotificationScrimPadding; final float stackHeight = ambientState.getStackHeight() - shelfHeight - scrimPadding; final float stackEndHeight = ambientState.getStackEndHeight() - shelfHeight - scrimPadding; 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 2725e4b4579b8..a49f828bd5f7f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -934,8 +934,6 @@ public class NotificationPanelViewController extends PanelViewController { R.dimen.notification_panel_min_side_margin); mIndicationBottomPadding = mResources.getDimensionPixelSize( R.dimen.keyguard_indication_bottom_padding); - mQsNotificationTopPadding = mResources.getDimensionPixelSize( - R.dimen.qs_notification_padding); mShelfHeight = mResources.getDimensionPixelSize(R.dimen.notification_shelf_height); mDarkIconSize = mResources.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size_dark); int statusbarHeight = mResources.getDimensionPixelSize( @@ -1333,8 +1331,7 @@ public class NotificationPanelViewController extends PanelViewController { * @return the padding of the stackscroller when unlocked */ private int getUnlockedStackScrollerPadding() { - return (mQs != null ? mQs.getHeader().getHeight() : 0) + mQsPeekHeight - + mQsNotificationTopPadding; + return (mQs != null ? mQs.getHeader().getHeight() : 0) + mQsPeekHeight; } /** @@ -2459,7 +2456,7 @@ public class NotificationPanelViewController extends PanelViewController { private float calculateNotificationsTopPadding() { if (mShouldUseSplitNotificationShade && !mKeyguardShowing) { - return mSplitShadeNotificationsTopPadding + mQsNotificationTopPadding; + return mSplitShadeNotificationsTopPadding; } if (mKeyguardShowing && (mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted)) { @@ -2470,7 +2467,7 @@ public class NotificationPanelViewController extends PanelViewController { // panel. We need to take the maximum and linearly interpolate with the panel expansion // for a nice motion. int maxNotificationPadding = getKeyguardNotificationStaticPadding(); - int maxQsPadding = mQsMaxExpansionHeight + mQsNotificationTopPadding; + int maxQsPadding = mQsMaxExpansionHeight; int max = mBarState == KEYGUARD ? Math.max( maxNotificationPadding, maxQsPadding) : maxQsPadding; return (int) MathUtils.lerp((float) mQsMinExpansionHeight, (float) max, @@ -2483,10 +2480,10 @@ public class NotificationPanelViewController extends PanelViewController { // We can only do the smoother transition on Keyguard when we also are not collapsing // from a scrolled quick settings. return MathUtils.lerp((float) getKeyguardNotificationStaticPadding(), - (float) (mQsMaxExpansionHeight + mQsNotificationTopPadding), + (float) (mQsMaxExpansionHeight), computeQsExpansionFraction()); } else { - return mQsExpansionHeight + mQsNotificationTopPadding; + return mQsExpansionHeight; } } @@ -2873,10 +2870,6 @@ public class NotificationPanelViewController extends PanelViewController { } int maxQsHeight = mQsMaxExpansionHeight; - if (mKeyguardShowing) { - maxQsHeight += mQsNotificationTopPadding; - } - // If an animation is changing the size of the QS panel, take the animated value. if (mQsSizeChangeAnimator != null) { maxQsHeight = (int) mQsSizeChangeAnimator.getAnimatedValue(); @@ -4306,8 +4299,7 @@ public class NotificationPanelViewController extends PanelViewController { if (mAccessibilityManager.isEnabled()) { mView.setAccessibilityPaneTitle(determineAccessibilityPaneTitle()); } - mNotificationStackScrollLayoutController.setMaxTopPadding( - mQsMaxExpansionHeight + mQsNotificationTopPadding); + mNotificationStackScrollLayoutController.setMaxTopPadding(mQsMaxExpansionHeight); } } @@ -4515,8 +4507,7 @@ public class NotificationPanelViewController extends PanelViewController { if (mQs != null) { updateQSMinHeight(); mQsMaxExpansionHeight = mQs.getDesiredHeight(); - mNotificationStackScrollLayoutController.setMaxTopPadding( - mQsMaxExpansionHeight + mQsNotificationTopPadding); + mNotificationStackScrollLayoutController.setMaxTopPadding(mQsMaxExpansionHeight); } positionClockAndNotifications(); if (mQsExpanded && mQsFullyExpanded) {