From c6386ab106fda479a7f675fd965777bf66ae753e Mon Sep 17 00:00:00 2001 From: Roy Chou Date: Fri, 26 May 2023 09:18:12 +0000 Subject: [PATCH] fix(non linear font scaling): fix QQS clock text right padding may not proper when font sclaing changed After increasing the font size and resetting to normal, the clock text in QQS has too much right padding. The reason is the clock cached wid th are not reset so it would keep using the width that cached for large font size. Therefore, we reset the cached width when font scaling changed so that it would be updated when next onMeasure for clock view. Bug: 282111042 Test: manually - video attached in bug Change-Id: If1a0855e8676435721913d714b4fa584ef9377e6 --- .../com/android/systemui/shade/ShadeHeaderController.kt | 1 + .../src/com/android/systemui/statusbar/policy/Clock.java | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt index 8789a8b3b7f4d..6c4d8fb03766f 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt @@ -266,6 +266,7 @@ constructor( lastInsets?.let { updateConstraintsForInsets(header, it) } updateResources() updateCarrierGroupPadding() + clock.onDensityOrFontScaleChanged() } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java index 6875b523a9621..f9943729ac7d9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java @@ -374,6 +374,13 @@ public class Clock extends TextView implements @Override public void onDensityOrFontScaleChanged() { + reloadDimens(); + } + + private void reloadDimens() { + // reset mCachedWidth so the new width would be updated properly when next onMeasure + mCachedWidth = -1; + FontSizeUtils.updateFontSize(this, R.dimen.status_bar_clock_size); setPaddingRelative( mContext.getResources().getDimensionPixelSize(