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
This commit is contained in:
@@ -27,19 +27,6 @@
|
||||
android:layout_height="@dimen/bubble_pointer_height"
|
||||
/>
|
||||
|
||||
<com.android.wm.shell.common.AlphaOptimizedButton
|
||||
style="@android:style/Widget.DeviceDefault.Button.Borderless"
|
||||
android:id="@+id/settings_button"
|
||||
android:layout_gravity="start"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:focusable="true"
|
||||
android:text="@string/manage_bubbles_text"
|
||||
android:textSize="@*android:dimen/text_size_body_2_material"
|
||||
android:background="@drawable/bubble_manage_btn_bg"
|
||||
android:textColor="@*android:color/system_neutral1_50"
|
||||
/>
|
||||
<!-- Manage button added here. -->
|
||||
|
||||
</com.android.wm.shell.bubbles.BubbleExpandedView>
|
||||
|
||||
31
libs/WindowManager/Shell/res/layout/bubble_manage_button.xml
Normal file
31
libs/WindowManager/Shell/res/layout/bubble_manage_button.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<com.android.wm.shell.common.AlphaOptimizedButton
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@android:style/Widget.DeviceDefault.Button.Borderless"
|
||||
android:id="@+id/settings_button"
|
||||
android:layout_gravity="start"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:focusable="true"
|
||||
android:text="@string/manage_bubbles_text"
|
||||
android:textSize="@*android:dimen/text_size_body_2_material"
|
||||
android:textColor="@*android:color/system_neutral1_50"
|
||||
android:background="@drawable/bubble_manage_btn_bg"
|
||||
/>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user