From d3bd6bfbf3b0a3a335c08cddaa549bc39d3b1e79 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Wed, 12 May 2021 21:13:50 -0700 Subject: Make sure Manage button updates for display size changes Bug: 160284881 Test: visual - have a bubble, expand / collapse it, update display size, expand the bubble & check that the sizes have increased & look correct Change-Id: If6db9ae1b720f7f37fab31cbb6a67a48bee2e0f8 --- .../Shell/res/layout/bubble_expanded_view.xml | 15 +----- .../Shell/res/layout/bubble_manage_button.xml | 31 +++++++++++ .../wm/shell/bubbles/BubbleExpandedView.java | 60 +++++++++++----------- 3 files changed, 62 insertions(+), 44 deletions(-) create mode 100644 libs/WindowManager/Shell/res/layout/bubble_manage_button.xml (limited to 'libs/WindowManager/Shell') diff --git a/libs/WindowManager/Shell/res/layout/bubble_expanded_view.xml b/libs/WindowManager/Shell/res/layout/bubble_expanded_view.xml index cd15f25877fd..880e0e46b4a1 100644 --- a/libs/WindowManager/Shell/res/layout/bubble_expanded_view.xml +++ b/libs/WindowManager/Shell/res/layout/bubble_expanded_view.xml @@ -27,19 +27,6 @@ android:layout_height="@dimen/bubble_pointer_height" /> - + diff --git a/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml b/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml new file mode 100644 index 000000000000..ab02a2e6f91a --- /dev/null +++ b/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml @@ -0,0 +1,31 @@ + + + \ No newline at end of file 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 51964b4031ec..f5c453d942e1 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 @@ -34,7 +34,6 @@ import android.app.PendingIntent; import android.content.ComponentName; import android.content.Context; import android.content.Intent; -import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; @@ -80,7 +79,7 @@ public class BubbleExpandedView extends LinearLayout { private int mPointerMargin; @Nullable private int[] mExpandedViewContainerLocation; - private AlphaOptimizedButton mSettingsIcon; + private AlphaOptimizedButton mManageButton; private TaskView mTaskView; private BubbleOverflowContainerView mOverflowView; @@ -104,7 +103,7 @@ public class BubbleExpandedView extends LinearLayout { private int mMinHeight; private int mOverflowHeight; - private int mSettingsIconHeight; + private int mManageButtonHeight; private int mPointerWidth; private int mPointerHeight; private float mPointerRadius; @@ -253,17 +252,15 @@ public class BubbleExpandedView extends LinearLayout { public BubbleExpandedView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); - updateDimensions(); } @SuppressLint("ClickableViewAccessibility") @Override protected void onFinishInflate() { super.onFinishInflate(); - - mSettingsIcon = findViewById(R.id.settings_button); - mSettingsIconHeight = getContext().getResources().getDimensionPixelSize( - R.dimen.bubble_manage_button_height); + mManageButton = (AlphaOptimizedButton) LayoutInflater.from(getContext()).inflate( + R.layout.bubble_manage_button, this /* parent */, false /* attach */); + updateDimensions(); mPointerView = findViewById(R.id.pointer_view); mCurrentPointer = mTopPointer; mPointerView.setVisibility(INVISIBLE); @@ -288,7 +285,7 @@ public class BubbleExpandedView extends LinearLayout { // ==> expanded view // ==> activity view // ==> manage button - bringChildToFront(mSettingsIcon); + bringChildToFront(mManageButton); applyThemeAttrs(); @@ -339,7 +336,7 @@ public class BubbleExpandedView extends LinearLayout { mExpandedViewContainer.setLayoutParams( new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT)); bringChildToFront(mOverflowView); - mSettingsIcon.setVisibility(GONE); + mManageButton.setVisibility(GONE); } else { mTaskView = new TaskView(mContext, mController.getTaskOrganizer()); mTaskView.setListener(mController.getMainExecutor(), mTaskViewListener); @@ -354,6 +351,8 @@ public class BubbleExpandedView extends LinearLayout { mOverflowHeight = res.getDimensionPixelSize(R.dimen.bubble_overflow_height); mExpandedViewPadding = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding); + updateFontSize(); + mPointerMargin = res.getDimensionPixelSize(R.dimen.bubble_pointer_margin); mPointerWidth = res.getDimensionPixelSize(R.dimen.bubble_pointer_width); mPointerHeight = res.getDimensionPixelSize(R.dimen.bubble_pointer_height); @@ -366,25 +365,26 @@ public class BubbleExpandedView extends LinearLayout { 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(); } + + mManageButtonHeight = res.getDimensionPixelSize(R.dimen.bubble_manage_button_height); + if (mManageButton != null) { + int visibility = mManageButton.getVisibility(); + removeView(mManageButton); + mManageButton = (AlphaOptimizedButton) LayoutInflater.from(getContext()).inflate( + R.layout.bubble_manage_button, this /* parent */, false /* attach */); + addView(mManageButton); + mManageButton.setVisibility(visibility); + } } 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 (mManageButton != null) { + mManageButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); } if (mOverflowView != null) { mOverflowView.updateFontSize(); @@ -396,10 +396,7 @@ public class BubbleExpandedView extends LinearLayout { android.R.attr.dialogCornerRadius, android.R.attr.colorBackgroundFloating}); mCornerRadius = ta.getDimensionPixelSize(0, 0); - final int mode = - getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; - final boolean isNightMode = (mode == Configuration.UI_MODE_NIGHT_YES); - mBackgroundColorFloating = ta.getColor(1, isNightMode ? Color.BLACK : Color.WHITE); + mBackgroundColorFloating = ta.getColor(1, Color.WHITE); mExpandedViewContainer.setBackgroundColor(mBackgroundColorFloating); ta.recycle(); @@ -489,7 +486,7 @@ public class BubbleExpandedView extends LinearLayout { // TODO: Could listener be passed when we pass StackView / can we avoid setting this like this void setManageClickListener(OnClickListener manageClickListener) { - mSettingsIcon.setOnClickListener(manageClickListener); + mManageButton.setOnClickListener(manageClickListener); } /** @@ -535,6 +532,9 @@ public class BubbleExpandedView extends LinearLayout { if (mTaskView != null) { mTaskView.setAlpha(alpha); } + if (mManageButton != null && mManageButton.getVisibility() == View.VISIBLE) { + mManageButton.setAlpha(alpha); + } } /** @@ -579,9 +579,9 @@ public class BubbleExpandedView extends LinearLayout { boolean isNew = mBubble == null || didBackingContentChange(bubble); if (isNew || bubble != null && bubble.getKey().equals(mBubble.getKey())) { mBubble = bubble; - mSettingsIcon.setContentDescription(getResources().getString( + mManageButton.setContentDescription(getResources().getString( R.string.bubbles_settings_button_description, bubble.getAppName())); - mSettingsIcon.setAccessibilityDelegate( + mManageButton.setAccessibilityDelegate( new AccessibilityDelegate() { @Override public void onInitializeAccessibilityNodeInfo(View host, @@ -666,7 +666,7 @@ public class BubbleExpandedView extends LinearLayout { // Remove top insets back here because availableRect.height would account for that ? mExpandedViewContainerLocation[1] - mPositioner.getInsets().top : 0; - int settingsHeight = mIsOverflow ? 0 : mSettingsIconHeight; + int settingsHeight = mIsOverflow ? 0 : mManageButtonHeight; return mPositioner.getAvailableRect().height() - expandedContainerY - getPaddingTop() @@ -756,7 +756,7 @@ public class BubbleExpandedView extends LinearLayout { * education about the manage button. */ public void getManageButtonBoundsOnScreen(Rect rect) { - mSettingsIcon.getBoundsOnScreen(rect); + mManageButton.getBoundsOnScreen(rect); } /** -- cgit v1.2.3-59-g8ed1b