From 84b98954d07d8c1ab19007ac69254ead2995f8c0 Mon Sep 17 00:00:00 2001 From: Evan Laird Date: Mon, 2 Jul 2018 17:43:59 -0400 Subject: [PATCH] Use minimumHeight in QS header Allow QuickStatusBarHeader to use a minimum hieight so that it doesn't draw underneath of a notch when display densities are low. Bug: 78110564 Test: visual Change-Id: I44df89c3b98dc0bdb8455b36e7ad023b92676c9d --- packages/SystemUI/res/values/dimens.xml | 3 ++ .../systemui/qs/QuickStatusBarHeader.java | 30 ++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index f62249a74cdba..a9d995c889c7a 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -252,6 +252,9 @@ --> 48dp + + 128dp + 54dp diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java index a21886891e3d8..35d2f90748c34 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java @@ -33,6 +33,7 @@ import android.media.AudioManager; import android.os.Handler; import android.provider.AlarmClock; import android.service.notification.ZenModeConfig; +import android.widget.FrameLayout; import androidx.annotation.VisibleForTesting; import android.text.format.DateUtils; import android.util.AttributeSet; @@ -270,8 +271,22 @@ public class QuickStatusBarHeader extends RelativeLayout implements updateResources(); } + /** + * The height of QQS should always be the status bar height + 128dp. This is normally easy, but + * when there is a notch involved the status bar can remain a fixed pixel size. + */ + private void updateMinimumHeight() { + int sbHeight = mContext.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.status_bar_height); + int qqsHeight = mContext.getResources().getDimensionPixelSize( + R.dimen.qs_quick_header_panel_height); + + setMinimumHeight(sbHeight + qqsHeight); + } + private void updateResources() { Resources resources = mContext.getResources(); + updateMinimumHeight(); // Update height for a few views, especially due to landscape mode restricting space. mHeaderTextContainerView.getLayoutParams().height = @@ -282,10 +297,17 @@ public class QuickStatusBarHeader extends RelativeLayout implements com.android.internal.R.dimen.quick_qs_offset_height); mSystemIconsView.setLayoutParams(mSystemIconsView.getLayoutParams()); - getLayoutParams().height = resources.getDimensionPixelSize(mQsDisabled - ? com.android.internal.R.dimen.quick_qs_offset_height - : com.android.internal.R.dimen.quick_qs_total_height); - setLayoutParams(getLayoutParams()); + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams(); + if (mQsDisabled) { + lp.height = resources.getDimensionPixelSize( + com.android.internal.R.dimen.quick_qs_offset_height); + } else { + lp.height = Math.max(getMinimumHeight(), + resources.getDimensionPixelSize( + com.android.internal.R.dimen.quick_qs_offset_height)); + } + + setLayoutParams(lp); updateStatusIconAlphaAnimator(); updateHeaderTextContainerAlphaAnimator();