Merge "Fixing navbar and notification shade overlap"

This commit is contained in:
Michał Brzeziński
2022-02-01 19:27:42 +00:00
committed by Android (Google) Code Review
11 changed files with 71 additions and 21 deletions

View File

@@ -122,7 +122,7 @@
android:layout_marginTop="@dimen/notification_panel_margin_top"
android:layout_width="@dimen/notification_panel_width"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/close_handle_underlap"
android:layout_marginBottom="@dimen/notification_panel_margin_bottom"
android:importantForAccessibility="no"
systemui:layout_constraintStart_toStartOf="parent"
systemui:layout_constraintEnd_toEndOf="parent"

View File

@@ -26,6 +26,10 @@
keyguard_split_shade_top_margin - status_bar_header_height_keyguard = 8dp -->
<dimen name="keyguard_clock_top_margin">8dp</dimen>
<dimen name="split_shade_notifications_scrim_margin_bottom">16dp</dimen>
<dimen name="notification_panel_margin_bottom">48dp</dimen>
<!-- Limit the TaskView to this percentage of the overall screen width (0.0 - 1.0) -->
<item name="controls_task_view_width_percentage" translatable="false" format="float" type="dimen">0.45</item>
<dimen name="controls_task_view_right_margin">8dp</dimen>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
* Copyright (c) 2022, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<resources>
<dimen name="split_shade_notifications_scrim_margin_bottom">16dp</dimen>
<dimen name="notification_panel_margin_bottom">56dp</dimen>
</resources>

View File

@@ -311,9 +311,6 @@
<!-- Move the back button drawable for 3 button layout upwards in ime mode and in portrait -->
<dimen name="navbar_back_button_ime_offset">2dp</dimen>
<!-- Amount of close_handle that will NOT overlap the notification list -->
<dimen name="close_handle_underlap">32dp</dimen>
<!-- Height of the status bar header bar in the car setting. -->
<dimen name="car_status_bar_header_height">128dp</dimen>
@@ -376,8 +373,12 @@
-->
<dimen name="nssl_split_shade_min_content_height">256dp</dimen>
<!-- The bottom margin of the panel that holds the list of notifications. -->
<dimen name="notification_panel_margin_bottom">0dp</dimen>
<dimen name="notification_panel_margin_bottom">32dp</dimen>
<!-- The bottom padding of the panel that holds the list of notifications. -->
<dimen name="notification_panel_padding_bottom">0dp</dimen>
<dimen name="split_shade_notifications_scrim_margin_bottom">0dp</dimen>
<dimen name="notification_panel_width">@dimen/match_parent</dimen>

View File

@@ -199,7 +199,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
private int mMaxTopPadding;
private int mTopPadding;
private boolean mAnimateNextTopPaddingChange;
private int mBottomMargin;
private int mBottomPadding;
private int mBottomInset = 0;
private float mQsExpansionFraction;
private final int mSplitShadeMinContentHeight;
@@ -981,7 +981,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
mMinTopOverScrollToEscape = res.getDimensionPixelSize(
R.dimen.min_top_overscroll_to_qs);
mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
mBottomMargin = res.getDimensionPixelSize(R.dimen.notification_panel_margin_bottom);
mBottomPadding = res.getDimensionPixelSize(R.dimen.notification_panel_padding_bottom);
mMinimumPaddings = res.getDimensionPixelSize(R.dimen.notification_side_paddings);
mQsTilePadding = res.getDimensionPixelOffset(R.dimen.qs_tile_margin_horizontal);
mSkinnyNotifsInLandscape = res.getBoolean(R.bool.config_skinnyNotifsInLandscape);
@@ -2280,7 +2280,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
// The topPadding can be bigger than the regular padding when qs is expanded, in that
// state the maxPanelHeight and the contentHeight should be bigger
mContentHeight = height + Math.max(mIntrinsicPadding, mTopPadding) + mBottomMargin;
mContentHeight = height + Math.max(mIntrinsicPadding, mTopPadding) + mBottomPadding;
updateScrollability();
clampScrollPosition();
updateStackPosition();

View File

@@ -61,7 +61,7 @@ public class StackScrollAlgorithm {
@VisibleForTesting float mHeadsUpInset;
private int mPinnedZTranslationExtra;
private float mNotificationScrimPadding;
private int mCloseHandleUnderlapHeight;
private int mMarginBottom;
public StackScrollAlgorithm(
Context context,
@@ -87,7 +87,7 @@ public class StackScrollAlgorithm {
R.dimen.heads_up_pinned_elevation);
mGapHeight = res.getDimensionPixelSize(R.dimen.notification_section_divider_height);
mNotificationScrimPadding = res.getDimensionPixelSize(R.dimen.notification_side_paddings);
mCloseHandleUnderlapHeight = res.getDimensionPixelSize(R.dimen.close_handle_underlap);
mMarginBottom = res.getDimensionPixelSize(R.dimen.notification_panel_margin_bottom);
}
/**
@@ -463,7 +463,7 @@ public class StackScrollAlgorithm {
}
} else {
if (view instanceof EmptyShadeView) {
float fullHeight = ambientState.getLayoutMaxHeight() + mCloseHandleUnderlapHeight
float fullHeight = ambientState.getLayoutMaxHeight() + mMarginBottom
- ambientState.getStackY();
viewState.yTranslation = (fullHeight - getMaxAllowedChildHeight(view)) / 2f;
} else if (view != ambientState.getTrackedHeadsUpRow()) {

View File

@@ -20,6 +20,7 @@ import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
import static android.view.View.GONE;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static androidx.constraintlayout.widget.ConstraintSet.BOTTOM;
import static androidx.constraintlayout.widget.ConstraintSet.END;
import static androidx.constraintlayout.widget.ConstraintSet.PARENT_ID;
import static androidx.constraintlayout.widget.ConstraintSet.START;
@@ -414,6 +415,7 @@ public class NotificationPanelViewController extends PanelViewController
private int mDisplayTopInset = 0; // in pixels
private int mDisplayRightInset = 0; // in pixels
private int mSplitShadeStatusBarHeight;
private int mSplitShadeNotificationsScrimMarginBottom;
private final KeyguardClockPositionAlgorithm
mClockPositionAlgorithm =
@@ -1168,6 +1170,9 @@ public class NotificationPanelViewController extends PanelViewController
public void updateResources() {
mQuickQsOffsetHeight = SystemBarUtils.getQuickQsOffsetHeight(mView.getContext());
mSplitShadeStatusBarHeight = Utils.getSplitShadeStatusBarHeight(mView.getContext());
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);
mShouldUseSplitNotificationShade =
@@ -1177,6 +1182,8 @@ public class NotificationPanelViewController extends PanelViewController
mQs.setInSplitShade(mShouldUseSplitNotificationShade);
}
int notificationsBottomMargin = mResources.getDimensionPixelSize(
R.dimen.notification_panel_margin_bottom);
int topMargin = mShouldUseSplitNotificationShade ? mSplitShadeStatusBarHeight :
mResources.getDimensionPixelSize(R.dimen.notification_panel_margin_top);
mSplitShadeHeaderController.setSplitShadeMode(mShouldUseSplitNotificationShade);
@@ -1205,9 +1212,12 @@ 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.notification_stack_scroller, BOTTOM,
notificationsBottomMargin);
constraintSet.setMargin(R.id.qs_frame, TOP, topMargin);
constraintSet.applyTo(mNotificationContainerParent);
mAmbientState.setStackTopMargin(topMargin);
mNotificationsQSContainerController.updateMargins();
mNotificationsQSContainerController.setSplitShadeEnabled(mShouldUseSplitNotificationShade);
updateKeyguardStatusViewAlignment(/* animate= */false);
@@ -2565,7 +2575,8 @@ public class NotificationPanelViewController extends PanelViewController
right = getView().getRight() + mDisplayRightInset;
} else {
top = Math.min(qsPanelBottomY, mSplitShadeStatusBarHeight);
bottom = top + mNotificationStackScrollLayoutController.getHeight();
bottom = top + mNotificationStackScrollLayoutController.getHeight()
- mSplitShadeNotificationsScrimMarginBottom;
left = mNotificationStackScrollLayoutController.getLeft();
right = mNotificationStackScrollLayoutController.getRight();
}

View File

@@ -63,7 +63,7 @@ class NotificationsQSContainerController @Inject constructor(
}
public override fun onViewAttached() {
notificationsBottomMargin = mView.defaultNotificationsMarginBottom
updateMargins()
overviewProxyService.addCallback(taskbarVisibilityListener)
mView.setInsetsChangedListener(windowInsetsListener)
mView.setQSFragmentAttachedListener { qs: QS -> qs.setContainerController(this) }
@@ -75,6 +75,10 @@ class NotificationsQSContainerController @Inject constructor(
mView.removeQSFragmentAttachedListener()
}
fun updateMargins() {
notificationsBottomMargin = mView.defaultNotificationsMarginBottom
}
override fun setCustomizerAnimating(animating: Boolean) {
if (isQSCustomizerAnimating != animating) {
isQSCustomizerAnimating = animating

View File

@@ -45,7 +45,6 @@ public class NotificationsQuickSettingsContainer extends ConstraintLayout
private View mStackScroller;
private View mKeyguardStatusBar;
private int mStackScrollerMargin;
private ArrayList<View> mDrawingOrderedChildren = new ArrayList<>();
private ArrayList<View> mLayoutDrawingOrder = new ArrayList<>();
private final Comparator<View> mIndexComparator = Comparator.comparingInt(this::indexOfChild);
@@ -63,7 +62,6 @@ public class NotificationsQuickSettingsContainer extends ConstraintLayout
super.onFinishInflate();
mQsFrame = findViewById(R.id.qs_frame);
mStackScroller = findViewById(R.id.notification_stack_scroller);
mStackScrollerMargin = ((LayoutParams) mStackScroller.getLayoutParams()).bottomMargin;
mKeyguardStatusBar = findViewById(R.id.keyguard_header);
}
@@ -97,7 +95,7 @@ public class NotificationsQuickSettingsContainer extends ConstraintLayout
}
public int getDefaultNotificationsMarginBottom() {
return mStackScrollerMargin;
return ((LayoutParams) mStackScroller.getLayoutParams()).bottomMargin;
}
public void setInsetsChangedListener(Consumer<WindowInsets> onInsetsChangedListener) {

View File

@@ -69,10 +69,9 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
stackScrollAlgorithm.resetViewStates(ambientState, /* speedBumpIndex= */ 0)
val closeHandleUnderlapHeight =
context.resources.getDimensionPixelSize(R.dimen.close_handle_underlap)
val fullHeight =
ambientState.layoutMaxHeight + closeHandleUnderlapHeight - ambientState.stackY
val marginBottom =
context.resources.getDimensionPixelSize(R.dimen.notification_panel_margin_bottom)
val fullHeight = ambientState.layoutMaxHeight + marginBottom - ambientState.stackY
val centeredY = ambientState.stackY + fullHeight / 2f - emptyShadeView.height / 2f
assertThat(emptyShadeView.viewState?.yTranslation).isEqualTo(centeredY)
}

View File

@@ -215,6 +215,18 @@ class NotificationQSContainerControllerTest : SysuiTestCase() {
then(expectedContainerPadding = 0)
}
@Test
fun testNotificationsMarginBottomIsUpdated() {
notificationsQSContainerController.splitShadeEnabled = true
verify(notificationsQSContainer).setNotificationsMarginBottom(NOTIFICATIONS_MARGIN)
whenever(notificationsQSContainer.defaultNotificationsMarginBottom).thenReturn(100)
notificationsQSContainerController.updateMargins()
notificationsQSContainerController.splitShadeEnabled = false
verify(notificationsQSContainer).setNotificationsMarginBottom(100)
}
private fun given(
taskbarVisible: Boolean,
navigationMode: Int,