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
This commit is contained in:
Roy Chou
2023-05-26 09:18:12 +00:00
parent 6450c2e670
commit c6386ab106
2 changed files with 8 additions and 0 deletions

View File

@@ -266,6 +266,7 @@ constructor(
lastInsets?.let { updateConstraintsForInsets(header, it) }
updateResources()
updateCarrierGroupPadding()
clock.onDensityOrFontScaleChanged()
}
}

View File

@@ -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(