From 67486e578df35e167ec14860537132426ce89c56 Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Mon, 28 Sep 2020 16:59:09 -0500 Subject: [PATCH] Update flyout post fontScale change Fixes: 168682294 Test: change font size repeatedly => flyout text updates correctly Change-Id: I150bbfecc04a1e18476cd9fce3a2998ceaf047c1 --- core/res/res/values/symbols.xml | 1 + .../com/android/systemui/bubbles/BubbleController.java | 9 +++++++++ .../com/android/systemui/bubbles/BubbleFlyoutView.java | 9 +++++++++ .../com/android/systemui/bubbles/BubbleStackView.java | 4 ++++ 4 files changed, 23 insertions(+) diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 996e1f9fde9a1..d0a3a41041b9e 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3544,6 +3544,7 @@ + diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index dff405cb162cc..cbbeb64b92fda 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -231,6 +231,11 @@ public class BubbleController implements Bubbles, ConfigurationController.Config */ private int mDensityDpi = Configuration.DENSITY_DPI_UNDEFINED; + /** + * Last known font scale, used to detect font size changes in {@link #onConfigChanged}. + */ + private float mFontScale = 0; + /** Last known direction, used to detect layout direction changes @link #onConfigChanged}. */ private int mLayoutDirection = View.LAYOUT_DIRECTION_UNDEFINED; @@ -955,6 +960,10 @@ public class BubbleController implements Bubbles, ConfigurationController.Config mBubbleIconFactory = new BubbleIconFactory(mContext); mStackView.onDisplaySizeChanged(); } + if (newConfig.fontScale != mFontScale) { + mFontScale = newConfig.fontScale; + mStackView.updateFlyout(mFontScale); + } if (newConfig.getLayoutDirection() != mLayoutDirection) { mLayoutDirection = newConfig.getLayoutDirection(); mStackView.onLayoutDirectionChanged(mLayoutDirection); diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleFlyoutView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleFlyoutView.java index 1fa3aaae5e617..69f7828ff8fc0 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleFlyoutView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleFlyoutView.java @@ -34,6 +34,7 @@ import android.graphics.RectF; import android.graphics.drawable.Drawable; import android.graphics.drawable.ShapeDrawable; import android.text.TextUtils; +import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -212,6 +213,14 @@ public class BubbleFlyoutView extends FrameLayout { super.onDraw(canvas); } + void updateFontSize(float fontScale) { + final float fontSize = mContext.getResources() + .getDimensionPixelSize(com.android.internal.R.dimen.text_size_body_2_material); + final float newFontSize = fontSize * fontScale; + mMessageText.setTextSize(TypedValue.COMPLEX_UNIT_PX, newFontSize); + mSenderText.setTextSize(TypedValue.COMPLEX_UNIT_PX, newFontSize); + } + /** Configures the flyout, collapsed into to dot form. */ void setupFlyoutStartingAsDot( Bubble.FlyoutMessage flyoutMessage, diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java index f2fba23564da4..351e61f7ee61d 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java @@ -1155,6 +1155,10 @@ public class BubbleStackView extends FrameLayout addView(mFlyout, new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); } + void updateFlyout(float fontScale) { + mFlyout.updateFontSize(fontScale); + } + private void updateOverflow() { mBubbleOverflow.update(); mBubbleContainer.reorderView(mBubbleOverflow.getIconView(),