Merge "Fix some sizes that weren't changing for font scale / display size`" into sc-dev

This commit is contained in:
Mady Mellor
2021-05-19 18:18:34 +00:00
committed by Android (Google) Code Review
8 changed files with 71 additions and 25 deletions

View File

@@ -35,6 +35,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusable="true" android:focusable="true"
android:text="@string/manage_bubbles_text" android:text="@string/manage_bubbles_text"
android:textSize="@*android:dimen/text_size_body_2_material"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
/> />

View File

@@ -55,6 +55,7 @@
android:text="@string/bubble_overflow_empty_title" android:text="@string/bubble_overflow_empty_title"
android:fontFamily="@*android:string/config_bodyFontFamilyMedium" android:fontFamily="@*android:string/config_bodyFontFamilyMedium"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2" android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"
android:textSize="@*android:dimen/text_size_body_2_material"
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -66,6 +67,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="@*android:string/config_bodyFontFamily" android:fontFamily="@*android:string/config_bodyFontFamily"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2" android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"
android:textSize="@*android:dimen/text_size_body_2_material"
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
android:text="@string/bubble_overflow_empty_subtitle" android:text="@string/bubble_overflow_empty_subtitle"
android:paddingBottom="@dimen/bubble_empty_overflow_subtitle_padding" android:paddingBottom="@dimen/bubble_empty_overflow_subtitle_padding"

View File

@@ -715,7 +715,7 @@ public class BubbleController {
} }
if (newConfig.fontScale != mFontScale) { if (newConfig.fontScale != mFontScale) {
mFontScale = newConfig.fontScale; mFontScale = newConfig.fontScale;
mStackView.updateFontScale(mFontScale); mStackView.updateFontScale();
} }
if (newConfig.getLayoutDirection() != mLayoutDirection) { if (newConfig.getLayoutDirection() != mLayoutDirection) {
mLayoutDirection = newConfig.getLayoutDirection(); mLayoutDirection = newConfig.getLayoutDirection();

View File

@@ -46,6 +46,7 @@ import android.graphics.drawable.ShapeDrawable;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.SurfaceControl; import android.view.SurfaceControl;
import android.view.View; import android.view.View;
@@ -250,26 +251,14 @@ public class BubbleExpandedView extends LinearLayout {
protected void onFinishInflate() { protected void onFinishInflate() {
super.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); 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; mCurrentPointer = mTopPointer;
mPointerView.setVisibility(INVISIBLE); mPointerView.setVisibility(INVISIBLE);
mSettingsIconHeight = getContext().getResources().getDimensionPixelSize( // Set TaskView's alpha value as zero, since there is no view content to be shown.
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.
setContentVisibility(false); setContentVisibility(false);
mExpandedViewContainer.setOutlineProvider(new ViewOutlineProvider() { mExpandedViewContainer.setOutlineProvider(new ViewOutlineProvider() {
@@ -293,7 +282,6 @@ public class BubbleExpandedView extends LinearLayout {
applyThemeAttrs(); applyThemeAttrs();
mExpandedViewPadding = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding);
setClipToPadding(false); setClipToPadding(false);
setOnTouchListener((view, motionEvent) -> { setOnTouchListener((view, motionEvent) -> {
if (mTaskView == null) { if (mTaskView == null) {
@@ -354,7 +342,41 @@ public class BubbleExpandedView extends LinearLayout {
Resources res = getResources(); Resources res = getResources();
mMinHeight = res.getDimensionPixelSize(R.dimen.bubble_expanded_default_height); mMinHeight = res.getDimensionPixelSize(R.dimen.bubble_expanded_default_height);
mOverflowHeight = res.getDimensionPixelSize(R.dimen.bubble_overflow_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); 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() { void applyThemeAttrs() {

View File

@@ -216,12 +216,11 @@ public class BubbleFlyoutView extends FrameLayout {
super.onDraw(canvas); super.onDraw(canvas);
} }
void updateFontSize(float fontScale) { void updateFontSize() {
final float fontSize = mContext.getResources() final float fontSize = mContext.getResources()
.getDimensionPixelSize(com.android.internal.R.dimen.text_size_body_2_material); .getDimensionPixelSize(com.android.internal.R.dimen.text_size_body_2_material);
final float newFontSize = fontSize * fontScale; mMessageText.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
mMessageText.setTextSize(TypedValue.COMPLEX_UNIT_PX, newFontSize); mSenderText.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
mSenderText.setTextSize(TypedValue.COMPLEX_UNIT_PX, newFontSize);
} }
/* /*

View File

@@ -82,7 +82,7 @@ class BubbleOverflow(
fun updateResources() { fun updateResources() {
bitmapSize = positioner.bubbleBitmapSize bitmapSize = positioner.bubbleBitmapSize
iconBitmapSize = (bitmapSize * 0.46f).toInt() iconBitmapSize = (bitmapSize * ICON_BITMAP_SIZE_PERCENT).toInt()
val bubbleSize = positioner.bubbleSize val bubbleSize = positioner.bubbleSize
overflowBtn?.layoutParams = FrameLayout.LayoutParams(bubbleSize, bubbleSize) overflowBtn?.layoutParams = FrameLayout.LayoutParams(bubbleSize, bubbleSize)
expandedView?.updateDimensions() expandedView?.updateDimensions()

View File

@@ -27,6 +27,7 @@ import android.content.res.TypedArray;
import android.graphics.Color; import android.graphics.Color;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -181,6 +182,13 @@ public class BubbleOverflowContainerView extends LinearLayout {
mEmptyStateSubtitle.setTextColor(textColor); 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() { private final BubbleData.Listener mDataListener = new BubbleData.Listener() {
@Override @Override

View File

@@ -1180,8 +1180,17 @@ public class BubbleStackView extends FrameLayout
addView(mFlyout, new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); addView(mFlyout, new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
} }
void updateFontScale(float fontScale) { void updateFontScale() {
mFlyout.updateFontSize(fontScale); setUpManageMenu();
mFlyout.updateFontSize();
for (Bubble b : mBubbleData.getBubbles()) {
if (b.getExpandedView() != null) {
b.getExpandedView().updateFontSize();
}
}
if (mBubbleOverflow != null) {
mBubbleOverflow.getExpandedView().updateFontSize();
}
} }
private void updateOverflow() { private void updateOverflow() {
@@ -1244,6 +1253,8 @@ public class BubbleStackView extends FrameLayout
/** Respond to the display size change by recalculating view size and location. */ /** Respond to the display size change by recalculating view size and location. */
public void onDisplaySizeChanged() { public void onDisplaySizeChanged() {
updateOverflow(); updateOverflow();
setUpManageMenu();
setUpFlyout();
mBubbleSize = mPositioner.getBubbleSize(); mBubbleSize = mPositioner.getBubbleSize();
for (Bubble b : mBubbleData.getBubbles()) { for (Bubble b : mBubbleData.getBubbles()) {
if (b.getIconView() == null) { if (b.getIconView() == null) {
@@ -1251,6 +1262,9 @@ public class BubbleStackView extends FrameLayout
continue; continue;
} }
b.getIconView().setLayoutParams(new LayoutParams(mBubbleSize, mBubbleSize)); b.getIconView().setLayoutParams(new LayoutParams(mBubbleSize, mBubbleSize));
if (b.getExpandedView() != null) {
b.getExpandedView().updateDimensions();
}
} }
mBubbleOverflow.getIconView().setLayoutParams(new LayoutParams(mBubbleSize, mBubbleSize)); mBubbleOverflow.getIconView().setLayoutParams(new LayoutParams(mBubbleSize, mBubbleSize));
mExpandedAnimationController.updateResources(); mExpandedAnimationController.updateResources();