From 76fa21b5dcb18b65050517cfad683370788ceb13 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Tue, 11 May 2021 12:05:00 -0700 Subject: [PATCH] Fix some sizes that weren't changing for font scale / display size` Test: manual - have some bubbles - change font & display size - add a new bubble => ensure UI elements have changed size & match the size of the new bubble (manage text, overflow empty statei text, pointer size, manage menu contents) Bug: 160284881 Change-Id: I2de45ba0975e2e0295abf8b350b9c2fb11ef73a8 --- .../Shell/res/layout/bubble_expanded_view.xml | 1 + .../res/layout/bubble_overflow_container.xml | 2 + .../wm/shell/bubbles/BubbleController.java | 2 +- .../wm/shell/bubbles/BubbleExpandedView.java | 56 +++++++++++++------ .../wm/shell/bubbles/BubbleFlyoutView.java | 7 +-- .../wm/shell/bubbles/BubbleOverflow.kt | 2 +- .../bubbles/BubbleOverflowContainerView.java | 8 +++ .../wm/shell/bubbles/BubbleStackView.java | 18 +++++- 8 files changed, 71 insertions(+), 25 deletions(-) diff --git a/libs/WindowManager/Shell/res/layout/bubble_expanded_view.xml b/libs/WindowManager/Shell/res/layout/bubble_expanded_view.xml index 81656fe7e80df..33e009efd3716 100644 --- a/libs/WindowManager/Shell/res/layout/bubble_expanded_view.xml +++ b/libs/WindowManager/Shell/res/layout/bubble_expanded_view.xml @@ -35,6 +35,7 @@ android:layout_height="wrap_content" android:focusable="true" android:text="@string/manage_bubbles_text" + android:textSize="@*android:dimen/text_size_body_2_material" android:textColor="?android:attr/textColorPrimary" /> diff --git a/libs/WindowManager/Shell/res/layout/bubble_overflow_container.xml b/libs/WindowManager/Shell/res/layout/bubble_overflow_container.xml index 270186a199bb4..76fe3c9bb8627 100644 --- a/libs/WindowManager/Shell/res/layout/bubble_overflow_container.xml +++ b/libs/WindowManager/Shell/res/layout/bubble_overflow_container.xml @@ -55,6 +55,7 @@ android:text="@string/bubble_overflow_empty_title" android:fontFamily="@*android:string/config_bodyFontFamilyMedium" android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2" + android:textSize="@*android:dimen/text_size_body_2_material" android:textColor="?android:attr/textColorSecondary" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -66,6 +67,7 @@ android:layout_height="wrap_content" android:fontFamily="@*android:string/config_bodyFontFamily" android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2" + android:textSize="@*android:dimen/text_size_body_2_material" android:textColor="?android:attr/textColorSecondary" android:text="@string/bubble_overflow_empty_subtitle" android:paddingBottom="@dimen/bubble_empty_overflow_subtitle_padding" diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index 6a0f061923599..7dcedfe50b37f 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -715,7 +715,7 @@ public class BubbleController { } if (newConfig.fontScale != mFontScale) { mFontScale = newConfig.fontScale; - mStackView.updateFontScale(mFontScale); + mStackView.updateFontScale(); } if (newConfig.getLayoutDirection() != mLayoutDirection) { mLayoutDirection = newConfig.getLayoutDirection(); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java index d8ec6508d77c0..a87da88273ea5 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java @@ -46,6 +46,7 @@ import android.graphics.drawable.ShapeDrawable; import android.os.RemoteException; import android.util.AttributeSet; import android.util.Log; +import android.util.TypedValue; import android.view.LayoutInflater; import android.view.SurfaceControl; import android.view.View; @@ -250,26 +251,14 @@ public class BubbleExpandedView extends LinearLayout { protected void onFinishInflate() { super.onFinishInflate(); - Resources res = getResources(); + mSettingsIcon = findViewById(R.id.settings_button); + mSettingsIconHeight = getContext().getResources().getDimensionPixelSize( + R.dimen.bubble_manage_button_height); mPointerView = findViewById(R.id.pointer_view); - mPointerWidth = res.getDimensionPixelSize(R.dimen.bubble_pointer_width); - mPointerHeight = res.getDimensionPixelSize(R.dimen.bubble_pointer_height); - - mTopPointer = new ShapeDrawable(TriangleShape.create( - mPointerWidth, mPointerHeight, true /* pointUp */)); - mLeftPointer = new ShapeDrawable(TriangleShape.createHorizontal( - mPointerWidth, mPointerHeight, true /* pointLeft */)); - mRightPointer = new ShapeDrawable(TriangleShape.createHorizontal( - mPointerWidth, mPointerHeight, false /* pointLeft */)); - mCurrentPointer = mTopPointer; mPointerView.setVisibility(INVISIBLE); - mSettingsIconHeight = getContext().getResources().getDimensionPixelSize( - R.dimen.bubble_manage_button_height); - mSettingsIcon = findViewById(R.id.settings_button); - - // Set ActivityView's alpha value as zero, since there is no view content to be shown. + // Set TaskView's alpha value as zero, since there is no view content to be shown. setContentVisibility(false); mExpandedViewContainer.setOutlineProvider(new ViewOutlineProvider() { @@ -293,7 +282,6 @@ public class BubbleExpandedView extends LinearLayout { applyThemeAttrs(); - mExpandedViewPadding = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding); setClipToPadding(false); setOnTouchListener((view, motionEvent) -> { if (mTaskView == null) { @@ -354,7 +342,41 @@ public class BubbleExpandedView extends LinearLayout { Resources res = getResources(); mMinHeight = res.getDimensionPixelSize(R.dimen.bubble_expanded_default_height); mOverflowHeight = res.getDimensionPixelSize(R.dimen.bubble_overflow_height); + mExpandedViewPadding = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding); + mPointerMargin = res.getDimensionPixelSize(R.dimen.bubble_pointer_margin); + mPointerWidth = res.getDimensionPixelSize(R.dimen.bubble_pointer_width); + mPointerHeight = res.getDimensionPixelSize(R.dimen.bubble_pointer_height); + + mTopPointer = new ShapeDrawable(TriangleShape.create( + mPointerWidth, mPointerHeight, true /* pointUp */)); + mLeftPointer = new ShapeDrawable(TriangleShape.createHorizontal( + mPointerWidth, mPointerHeight, true /* pointLeft */)); + mRightPointer = new ShapeDrawable(TriangleShape.createHorizontal( + mPointerWidth, mPointerHeight, false /* pointLeft */)); + + final float fontSize = mContext.getResources() + .getDimensionPixelSize(com.android.internal.R.dimen.text_size_body_2_material); + if (mSettingsIcon != null) { + mSettingsIcon.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); + } + if (mOverflowView != null) { + mOverflowView.updateFontSize(); + } + if (mPointerView != null) { + updatePointerView(); + } + } + + void updateFontSize() { + final float fontSize = mContext.getResources() + .getDimensionPixelSize(com.android.internal.R.dimen.text_size_body_2_material); + if (mSettingsIcon != null) { + mSettingsIcon.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); + } + if (mOverflowView != null) { + mOverflowView.updateFontSize(); + } } void applyThemeAttrs() { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java index 57a2b6c7b9db2..bfbb0fdd2a022 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java @@ -216,12 +216,11 @@ public class BubbleFlyoutView extends FrameLayout { super.onDraw(canvas); } - void updateFontSize(float fontScale) { + void updateFontSize() { 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); + mMessageText.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); + mSenderText.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); } /* diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflow.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflow.kt index 36908b854842d..e4b1f64e090b1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflow.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflow.kt @@ -82,7 +82,7 @@ class BubbleOverflow( fun updateResources() { bitmapSize = positioner.bubbleBitmapSize - iconBitmapSize = (bitmapSize * 0.46f).toInt() + iconBitmapSize = (bitmapSize * ICON_BITMAP_SIZE_PERCENT).toInt() val bubbleSize = positioner.bubbleSize overflowBtn?.layoutParams = FrameLayout.LayoutParams(bubbleSize, bubbleSize) expandedView?.updateDimensions() diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java index af5b3a61f3932..d3b7ae21f0c3b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflowContainerView.java @@ -27,6 +27,7 @@ import android.content.res.TypedArray; import android.graphics.Color; import android.util.AttributeSet; import android.util.Log; +import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -181,6 +182,13 @@ public class BubbleOverflowContainerView extends LinearLayout { mEmptyStateSubtitle.setTextColor(textColor); } + public void updateFontSize() { + final float fontSize = mContext.getResources() + .getDimensionPixelSize(com.android.internal.R.dimen.text_size_body_2_material); + mEmptyStateTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); + mEmptyStateSubtitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); + } + private final BubbleData.Listener mDataListener = new BubbleData.Listener() { @Override diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index 07d16b57d675c..64a3b8f0da32c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -1180,8 +1180,17 @@ public class BubbleStackView extends FrameLayout addView(mFlyout, new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); } - void updateFontScale(float fontScale) { - mFlyout.updateFontSize(fontScale); + void updateFontScale() { + setUpManageMenu(); + mFlyout.updateFontSize(); + for (Bubble b : mBubbleData.getBubbles()) { + if (b.getExpandedView() != null) { + b.getExpandedView().updateFontSize(); + } + } + if (mBubbleOverflow != null) { + mBubbleOverflow.getExpandedView().updateFontSize(); + } } private void updateOverflow() { @@ -1244,6 +1253,8 @@ public class BubbleStackView extends FrameLayout /** Respond to the display size change by recalculating view size and location. */ public void onDisplaySizeChanged() { updateOverflow(); + setUpManageMenu(); + setUpFlyout(); mBubbleSize = mPositioner.getBubbleSize(); for (Bubble b : mBubbleData.getBubbles()) { if (b.getIconView() == null) { @@ -1251,6 +1262,9 @@ public class BubbleStackView extends FrameLayout continue; } b.getIconView().setLayoutParams(new LayoutParams(mBubbleSize, mBubbleSize)); + if (b.getExpandedView() != null) { + b.getExpandedView().updateDimensions(); + } } mBubbleOverflow.getIconView().setLayoutParams(new LayoutParams(mBubbleSize, mBubbleSize)); mExpandedAnimationController.updateResources();