From ad6a3e029024bcef48b4508642a042bef0ac9601 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Thu, 24 Feb 2022 11:21:18 -0500 Subject: [PATCH] [DO NOT MERGE] Lockscreen/Shade upscaling Aligns shade width and clock placement with latest UX specs. Removes concept of a fixed stack scroller width in favor of margins that adjust across various swXXXdp files. For phones, this means the shade takes up the entire width, for larger portrait devices, a sizeable margin, and for larger landscape devices, a smaller but visible margin. Remove unused code from KeyguardStatusView Fixes: 214596698 Test: atest NotificationPanelViewControllerTest && Tested landscape and portrait across all device categories Change-Id: Ie384d88c9a2c20516c29dc49b9b7cc54de89917c Change-Id: I82764f776aa43ba69d7bf93b76af111e20fd07b8 --- .../layout/keyguard_status_view.xml | 1 + .../SystemUI/res/layout/notif_half_shelf.xml | 2 +- .../res/layout/status_bar_expanded.xml | 6 ++- .../status_bar_expanded_plugin_frame.xml | 2 +- .../res/values-sw600dp-land/dimens.xml | 1 + .../res/values-sw600dp-port/dimens.xml | 7 ++-- .../res/values-sw720dp-land/dimens.xml | 2 + .../res/values-sw720dp-port/dimens.xml | 27 +++++++++++++ .../res/values-w650dp-land/dimens.xml | 20 ---------- packages/SystemUI/res/values/dimens.xml | 7 ++-- .../android/keyguard/KeyguardStatusView.java | 36 ----------------- .../NotificationPanelViewController.java | 20 ++++++---- .../NotificationPanelViewControllerTest.java | 40 +++++++++++-------- 13 files changed, 80 insertions(+), 91 deletions(-) create mode 100644 packages/SystemUI/res/values-sw720dp-port/dimens.xml delete mode 100644 packages/SystemUI/res/values-w650dp-land/dimens.xml diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_status_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_status_view.xml index 31d848d3e4d56..16a1d944c4d39 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_status_view.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_status_view.xml @@ -26,6 +26,7 @@ systemui:layout_constraintStart_toStartOf="parent" systemui:layout_constraintEnd_toEndOf="parent" systemui:layout_constraintTop_toTopOf="parent" + android:layout_marginHorizontal="@dimen/status_view_margin_horizontal" android:layout_width="0dp" android:layout_height="wrap_content"> 200dp + 12dp diff --git a/packages/SystemUI/res/values-sw600dp-port/dimens.xml b/packages/SystemUI/res/values-sw600dp-port/dimens.xml index da2403a96afa5..56dc4a1026b59 100644 --- a/packages/SystemUI/res/values-sw600dp-port/dimens.xml +++ b/packages/SystemUI/res/values-sw600dp-port/dimens.xml @@ -15,7 +15,8 @@ ~ limitations under the License. --> - - 504dp - + 60dp + 62dp + 40dp + 40dp diff --git a/packages/SystemUI/res/values-sw720dp-land/dimens.xml b/packages/SystemUI/res/values-sw720dp-land/dimens.xml index e897f75470a9d..71c1958960515 100644 --- a/packages/SystemUI/res/values-sw720dp-land/dimens.xml +++ b/packages/SystemUI/res/values-sw720dp-land/dimens.xml @@ -22,4 +22,6 @@ 56dp 72dp + + 24dp diff --git a/packages/SystemUI/res/values-sw720dp-port/dimens.xml b/packages/SystemUI/res/values-sw720dp-port/dimens.xml new file mode 100644 index 0000000000000..594df346fab1a --- /dev/null +++ b/packages/SystemUI/res/values-sw720dp-port/dimens.xml @@ -0,0 +1,27 @@ + + + + + + 124dp + 120dp + 80dp + 80dp + diff --git a/packages/SystemUI/res/values-w650dp-land/dimens.xml b/packages/SystemUI/res/values-w650dp-land/dimens.xml deleted file mode 100644 index 97b6da1ac6a7a..0000000000000 --- a/packages/SystemUI/res/values-w650dp-land/dimens.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - -1px - diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 92bc8642b75c9..65c17b9028e1a 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -388,13 +388,10 @@ 0dp - @dimen/match_parent + 0dp 48dp - - @dimen/notification_panel_width - 8dp 20dp @@ -1391,4 +1388,6 @@ 0dp + + 0dp diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java index a72a050ee023c..31f466f0fdf9d 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java @@ -16,8 +16,6 @@ package com.android.keyguard; -import android.app.ActivityManager; -import android.app.IActivityManager; import android.content.Context; import android.graphics.Color; import android.util.AttributeSet; @@ -27,7 +25,6 @@ import android.widget.GridLayout; import androidx.core.graphics.ColorUtils; -import com.android.internal.widget.LockPatternUtils; import com.android.systemui.R; import com.android.systemui.statusbar.CrossFadeHelper; @@ -44,9 +41,6 @@ public class KeyguardStatusView extends GridLayout { private static final boolean DEBUG = KeyguardConstants.DEBUG; private static final String TAG = "KeyguardStatusView"; - private final LockPatternUtils mLockPatternUtils; - private final IActivityManager mIActivityManager; - private ViewGroup mStatusViewContainer; private KeyguardClockSwitch mClockView; private KeyguardSliceView mKeyguardSlice; @@ -56,14 +50,6 @@ public class KeyguardStatusView extends GridLayout { private int mTextColor; private float mChildrenAlphaExcludingSmartSpace = 1f; - /** - * Bottom margin that defines the margin between bottom of smart space and top of notification - * icons on AOD. - */ - private int mIconTopMargin; - private int mIconTopMarginWithHeader; - private boolean mShowingHeader; - public KeyguardStatusView(Context context) { this(context, null, 0); } @@ -74,8 +60,6 @@ public class KeyguardStatusView extends GridLayout { public KeyguardStatusView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - mIActivityManager = ActivityManager.getService(); - mLockPatternUtils = new LockPatternUtils(getContext()); } @Override @@ -91,25 +75,11 @@ public class KeyguardStatusView extends GridLayout { mKeyguardSlice = findViewById(R.id.keyguard_slice_view); mTextColor = mClockView.getCurrentTextColor(); - mKeyguardSlice.setContentChangeListener(this::onSliceContentChanged); - onSliceContentChanged(); - mMediaHostContainer = findViewById(R.id.status_view_media_container); updateDark(); } - /** - * Moves clock, adjusting margins when slice content changes. - */ - private void onSliceContentChanged() { - final boolean hasHeader = mKeyguardSlice.hasHeader(); - if (mShowingHeader == hasHeader) { - return; - } - mShowingHeader = hasHeader; - } - void setDarkAmount(float darkAmount) { if (mDarkAmount == darkAmount) { return; @@ -158,10 +128,4 @@ public class KeyguardStatusView extends GridLayout { mKeyguardSlice.dump(fd, pw, args); } } - - private void loadBottomMargin() { - mIconTopMargin = getResources().getDimensionPixelSize(R.dimen.widget_vertical_padding); - mIconTopMarginWithHeader = getResources().getDimensionPixelSize( - R.dimen.widget_vertical_padding_with_header); - } } 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 61760fb8c78c4..01860a822503b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -1144,8 +1144,9 @@ public class NotificationPanelViewController extends PanelViewController mSplitShadeNotificationsScrimMarginBottom = mResources.getDimensionPixelSize( R.dimen.split_shade_notifications_scrim_margin_bottom); - int qsWidth = mResources.getDimensionPixelSize(R.dimen.qs_panel_width); - int panelWidth = mResources.getDimensionPixelSize(R.dimen.notification_panel_width); + + int panelMarginHorizontal = mResources.getDimensionPixelSize( + R.dimen.notification_panel_margin_horizontal); final boolean newShouldUseSplitNotificationShade = Utils.shouldUseSplitNotificationShade(mResources); @@ -1167,11 +1168,12 @@ public class NotificationPanelViewController extends PanelViewController ensureAllViewsHaveIds(mNotificationContainerParent); ConstraintSet constraintSet = new ConstraintSet(); constraintSet.clone(mNotificationContainerParent); - + int statusViewMarginHorizontal = mResources.getDimensionPixelSize( + R.dimen.status_view_margin_horizontal); + constraintSet.setMargin(R.id.keyguard_status_view, START, statusViewMarginHorizontal); + constraintSet.setMargin(R.id.keyguard_status_view, END, statusViewMarginHorizontal); if (mShouldUseSplitNotificationShade) { // width = 0 to take up all available space within constraints - qsWidth = 0; - panelWidth = 0; constraintSet.connect(R.id.qs_frame, END, R.id.qs_edge_guideline, END); constraintSet.connect( R.id.notification_stack_scroller, START, @@ -1184,11 +1186,15 @@ public class NotificationPanelViewController extends PanelViewController constraintSet.constrainHeight(R.id.split_shade_status_bar, WRAP_CONTENT); } } - 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, START, + mShouldUseSplitNotificationShade ? 0 : panelMarginHorizontal); + constraintSet.setMargin(R.id.notification_stack_scroller, END, panelMarginHorizontal); constraintSet.setMargin(R.id.notification_stack_scroller, TOP, topMargin); constraintSet.setMargin(R.id.notification_stack_scroller, BOTTOM, notificationsBottomMargin); + constraintSet.setMargin(R.id.qs_frame, START, panelMarginHorizontal); + constraintSet.setMargin(R.id.qs_frame, END, + mShouldUseSplitNotificationShade ? 0 : panelMarginHorizontal); constraintSet.setMargin(R.id.qs_frame, TOP, topMargin); constraintSet.applyTo(mNotificationContainerParent); mAmbientState.setStackTopMargin(topMargin); 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 38412fd1fa9bc..1af7035a441b9 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 @@ -390,8 +390,8 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { when(mResources.getBoolean(R.bool.config_enableNotificationShadeDrag)).thenReturn(true); when(mResources.getDimensionPixelSize(R.dimen.notifications_top_padding_split_shade)) .thenReturn(NOTIFICATION_SCRIM_TOP_PADDING_IN_SPLIT_SHADE); - when(mResources.getDimensionPixelSize(R.dimen.qs_panel_width)).thenReturn(400); - when(mResources.getDimensionPixelSize(R.dimen.notification_panel_width)).thenReturn(400); + when(mResources.getDimensionPixelSize(R.dimen.notification_panel_margin_horizontal)) + .thenReturn(10); when(mView.getContext()).thenReturn(getContext()); when(mView.findViewById(R.id.keyguard_header)).thenReturn(mKeyguardStatusBar); when(mView.findViewById(R.id.keyguard_user_switcher_view)).thenReturn(mUserSwitcherView); @@ -790,25 +790,31 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { } @Test - public void testSinglePaneShadeLayout_childrenHaveConstantWidth() { - enableSplitShade(/* enabled= */ false); - - mNotificationPanelViewController.updateResources(); - - assertThat(getConstraintSetLayout(R.id.qs_frame).mWidth) - .isEqualTo(mResources.getDimensionPixelSize(R.dimen.qs_panel_width)); - assertThat(getConstraintSetLayout(R.id.notification_stack_scroller).mWidth) - .isEqualTo(mResources.getDimensionPixelSize(R.dimen.notification_panel_width)); - } - - @Test - public void testSplitShadeLayout_childrenHaveZeroWidth() { + public void testSplitShadeLayout_childrenHaveInsideMarginsOfZero() { enableSplitShade(/* enabled= */ true); mNotificationPanelViewController.updateResources(); - assertThat(getConstraintSetLayout(R.id.qs_frame).mWidth).isEqualTo(0); - assertThat(getConstraintSetLayout(R.id.notification_stack_scroller).mWidth).isEqualTo(0); + assertThat(getConstraintSetLayout(R.id.qs_frame).startMargin).isEqualTo(10); + assertThat(getConstraintSetLayout(R.id.qs_frame).endMargin).isEqualTo(0); + assertThat(getConstraintSetLayout(R.id.notification_stack_scroller).startMargin) + .isEqualTo(0); + assertThat(getConstraintSetLayout(R.id.notification_stack_scroller).endMargin) + .isEqualTo(10); + } + + @Test + public void testSinglePaneLayout_childrenHaveEqualMargins() { + enableSplitShade(/* enabled= */ false); + + mNotificationPanelViewController.updateResources(); + + assertThat(getConstraintSetLayout(R.id.qs_frame).startMargin).isEqualTo(10); + assertThat(getConstraintSetLayout(R.id.qs_frame).endMargin).isEqualTo(10); + assertThat(getConstraintSetLayout(R.id.notification_stack_scroller).startMargin) + .isEqualTo(10); + assertThat(getConstraintSetLayout(R.id.notification_stack_scroller).endMargin) + .isEqualTo(10); } @Test