diff options
| author | Fabian Kozynski <kozynski@google.com> | 2021-05-11 13:26:35 -0400 |
|---|---|---|
| committer | Fabian Kozynski <kozynski@google.com> | 2021-05-11 14:14:05 -0400 |
| commit | f1f142ec2af5ddc9ee81da3ccf3d06bcba325019 (patch) | |
| tree | 395d74f946ae67290021974785b5eb018a657417 | |
| parent | 16864cd9df2989f50e4781aed116ac776b8d5a17 (diff) | |
Hide icons in QS Header if there's a cutout
If there's a cutout, put a blocking view in the space of the cutout.
Also, make the views on each side to be 0dp, weight 1. That way, the
view remains centered.
Fixes: 187145236
Test: manual
Change-Id: Ide54995afba92fbc559fdbe4c77bf5ca495b7b57
| -rw-r--r-- | packages/SystemUI/res/layout/quick_qs_status_icons.xml | 38 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java | 109 |
2 files changed, 103 insertions, 44 deletions
diff --git a/packages/SystemUI/res/layout/quick_qs_status_icons.xml b/packages/SystemUI/res/layout/quick_qs_status_icons.xml index f0229a648612..a62310be9bac 100644 --- a/packages/SystemUI/res/layout/quick_qs_status_icons.xml +++ b/packages/SystemUI/res/layout/quick_qs_status_icons.xml @@ -28,7 +28,7 @@ <com.android.systemui.statusbar.policy.Clock android:id="@+id/clock" - android:layout_width="wrap_content" + android:layout_width="0dp" android:layout_height="match_parent" android:minWidth="48dp" android:minHeight="48dp" @@ -49,17 +49,35 @@ android:layout_gravity="end|center_vertical" android:focusable="false"/> - <com.android.systemui.statusbar.phone.StatusIconContainer - android:id="@+id/statusIcons" - android:layout_width="wrap_content" + <View + android:id="@+id/separator" + android:layout_width="0dp" android:layout_height="match_parent" - android:paddingEnd="@dimen/signal_cluster_battery_padding" /> + android:layout_gravity="center" + android:layout_marginStart="8dp" + android:layout_marginEnd="8dp" + android:visibility="gone" + /> - <com.android.systemui.BatteryMeterView - android:id="@+id/batteryRemainingIcon" + <LinearLayout + android:id="@+id/rightLayout" + android:layout_width="0dp" android:layout_height="match_parent" - android:layout_width="wrap_content" - systemui:textAppearance="@style/TextAppearance.QS.Status" - android:paddingEnd="2dp" /> + android:layout_weight="1" + > + <com.android.systemui.statusbar.phone.StatusIconContainer + android:id="@+id/statusIcons" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:paddingEnd="@dimen/signal_cluster_battery_padding" /> + + <com.android.systemui.BatteryMeterView + android:id="@+id/batteryRemainingIcon" + android:layout_height="match_parent" + android:layout_width="0dp" + android:layout_weight="1" + systemui:textAppearance="@style/TextAppearance.QS.Status" + android:paddingEnd="2dp" /> + </LinearLayout> </LinearLayout> diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java index 73a6b34c612e..b9a5b7984dde 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java @@ -38,7 +38,6 @@ import com.android.systemui.BatteryMeterView; import com.android.systemui.R; import com.android.systemui.animation.Interpolators; import com.android.systemui.qs.QSDetail.Callback; -import com.android.systemui.statusbar.StatusBarIconView; import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager; import com.android.systemui.statusbar.phone.StatusBarWindowView; import com.android.systemui.statusbar.phone.StatusIconContainer; @@ -67,7 +66,11 @@ public class QuickStatusBarHeader extends FrameLayout { private View mQSCarriers; private Clock mClockView; - private Space mSpace; + private Space mDatePrivacySeparator; + private View mClockIconsSeparator; + private boolean mShowClockIconsSeparator; + private ViewGroup mRightLayout; + private BatteryMeterView mBatteryRemainingIcon; private StatusIconContainer mIconContainer; private View mPrivacyChip; @@ -117,9 +120,11 @@ public class QuickStatusBarHeader extends FrameLayout { 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); mClockView = findViewById(R.id.clock); - mSpace = findViewById(R.id.space); + mDatePrivacySeparator = findViewById(R.id.space); // Tint for the battery icons are handled in setupHost() mBatteryRemainingIcon = findViewById(R.id.batteryRemainingIcon); @@ -230,36 +235,36 @@ public class QuickStatusBarHeader extends FrameLayout { } private void updateAlphaAnimator() { - StatusBarIconView noCallingIcon = - ((StatusBarIconView) mIconContainer.getViewForSlot(mMobileSlotName)); - StatusBarIconView callStrengthIcon = - ((StatusBarIconView) mIconContainer.getViewForSlot(mCallStrengthSlotName)); TouchAnimator.Builder builder = new TouchAnimator.Builder() // The following two views have to be hidden manually, so as not to hide the // Privacy chip in QQS .addFloat(mDateView, "alpha", 0, 1) .addFloat(mSecurityHeaderView, "alpha", 0, 1) - .addFloat(mQSCarriers, "alpha", 0, 1); - builder.setListener(new TouchAnimator.ListenerAdapter() { - @Override - public void onAnimationAtEnd() { - mIconContainer.addIgnoredSlot(mMobileSlotName); - mIconContainer.addIgnoredSlot(mCallStrengthSlotName); - } - - @Override - public void onAnimationStarted() { - mIconContainer.addIgnoredSlot(mMobileSlotName); - mIconContainer.addIgnoredSlot(mCallStrengthSlotName); - } - - @Override - public void onAnimationAtStart() { - super.onAnimationAtStart(); - mIconContainer.removeIgnoredSlot(mMobileSlotName); - mIconContainer.removeIgnoredSlot(mCallStrengthSlotName); - } - }); + .addFloat(mQSCarriers, "alpha", 0, 1) + .setListener(new TouchAnimator.ListenerAdapter() { + @Override + public void onAnimationAtEnd() { + mIconContainer.addIgnoredSlot(mMobileSlotName); + mIconContainer.addIgnoredSlot(mCallStrengthSlotName); + } + + @Override + public void onAnimationStarted() { + mIconContainer.addIgnoredSlot(mMobileSlotName); + mIconContainer.addIgnoredSlot(mCallStrengthSlotName); + + setSeparatorVisibility(false); + } + + @Override + public void onAnimationAtStart() { + super.onAnimationAtStart(); + mIconContainer.removeIgnoredSlot(mMobileSlotName); + mIconContainer.removeIgnoredSlot(mCallStrengthSlotName); + + setSeparatorVisibility(mShowClockIconsSeparator); + } + }); mAlphaAnimator = builder.build(); } @@ -337,20 +342,30 @@ public class QuickStatusBarHeader extends FrameLayout { cutout, cornerCutoutPadding, -1); mDatePrivacyView.setPadding(padding.first, 0, padding.second, 0); mClockIconsView.setPadding(padding.first, 0, padding.second, 0); - LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mSpace.getLayoutParams(); + LinearLayout.LayoutParams datePrivacySeparatorLayoutParams = + (LinearLayout.LayoutParams) mDatePrivacySeparator.getLayoutParams(); + LinearLayout.LayoutParams mClockIconsSeparatorLayoutParams = + (LinearLayout.LayoutParams) mClockIconsSeparator.getLayoutParams(); boolean cornerCutout = cornerCutoutPadding != null && (cornerCutoutPadding.first == 0 || cornerCutoutPadding.second == 0); if (cutout != null) { Rect topCutout = cutout.getBoundingRectTop(); if (topCutout.isEmpty() || cornerCutout) { - lp.width = 0; - mSpace.setVisibility(View.GONE); + datePrivacySeparatorLayoutParams.width = 0; + mDatePrivacySeparator.setVisibility(View.GONE); + mClockIconsSeparatorLayoutParams.width = 0; + setSeparatorVisibility(false); + mShowClockIconsSeparator = false; } else { - lp.width = topCutout.width(); - mSpace.setVisibility(View.VISIBLE); + datePrivacySeparatorLayoutParams.width = topCutout.width(); + mDatePrivacySeparator.setVisibility(View.VISIBLE); + mClockIconsSeparatorLayoutParams.width = topCutout.width(); + mShowClockIconsSeparator = true; + setSeparatorVisibility(mKeyguardExpansionFraction == 0f); } } - mSpace.setLayoutParams(lp); + mDatePrivacySeparator.setLayoutParams(datePrivacySeparatorLayoutParams); + mClockIconsSeparator.setLayoutParams(mClockIconsSeparatorLayoutParams); mCutOutPaddingLeft = padding.first; mCutOutPaddingRight = padding.second; mWaterfallTopInset = cutout == null ? 0 : cutout.getWaterfallInsets().top; @@ -358,6 +373,32 @@ public class QuickStatusBarHeader extends FrameLayout { return super.onApplyWindowInsets(insets); } + /** + * Sets the visibility of the separator between clock and icons. + * + * This separator is "visible" when there is a center cutout, to block that space. In that + * case, the clock and the layout on the right (containing the icons and the battery meter) are + * set to weight 1 to take the available space. + * @param visible whether the separator between clock and icons should be visible. + */ + private void setSeparatorVisibility(boolean visible) { + int newVisibility = visible ? View.VISIBLE : View.GONE; + if (mClockIconsSeparator.getVisibility() == newVisibility) return; + + mClockIconsSeparator.setVisibility(visible ? View.VISIBLE : View.GONE); + mQSCarriers.setVisibility(visible ? View.GONE : View.VISIBLE); + + LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mClockView.getLayoutParams(); + lp.width = visible ? 0 : WRAP_CONTENT; + lp.weight = visible ? 1f : 0f; + mClockView.setLayoutParams(lp); + + lp = (LinearLayout.LayoutParams) mRightLayout.getLayoutParams(); + lp.width = visible ? 0 : WRAP_CONTENT; + lp.weight = visible ? 1f : 0f; + mRightLayout.setLayoutParams(lp); + } + private void updateHeadersPadding() { setContentMargins(mDatePrivacyView, 0, 0); setContentMargins(mClockIconsView, 0, 0); |
