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
This commit is contained in:
@@ -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"
|
||||
/>
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user