Merge "Make sure Manage button updates for display size changes" into sc-dev
This commit is contained in:
@@ -27,19 +27,6 @@
|
|||||||
android:layout_height="@dimen/bubble_pointer_height"
|
android:layout_height="@dimen/bubble_pointer_height"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<com.android.wm.shell.common.AlphaOptimizedButton
|
<!-- Manage button added here. -->
|
||||||
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"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</com.android.wm.shell.bubbles.BubbleExpandedView>
|
</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.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
@@ -80,7 +79,7 @@ public class BubbleExpandedView extends LinearLayout {
|
|||||||
private int mPointerMargin;
|
private int mPointerMargin;
|
||||||
@Nullable private int[] mExpandedViewContainerLocation;
|
@Nullable private int[] mExpandedViewContainerLocation;
|
||||||
|
|
||||||
private AlphaOptimizedButton mSettingsIcon;
|
private AlphaOptimizedButton mManageButton;
|
||||||
private TaskView mTaskView;
|
private TaskView mTaskView;
|
||||||
private BubbleOverflowContainerView mOverflowView;
|
private BubbleOverflowContainerView mOverflowView;
|
||||||
|
|
||||||
@@ -104,7 +103,7 @@ public class BubbleExpandedView extends LinearLayout {
|
|||||||
|
|
||||||
private int mMinHeight;
|
private int mMinHeight;
|
||||||
private int mOverflowHeight;
|
private int mOverflowHeight;
|
||||||
private int mSettingsIconHeight;
|
private int mManageButtonHeight;
|
||||||
private int mPointerWidth;
|
private int mPointerWidth;
|
||||||
private int mPointerHeight;
|
private int mPointerHeight;
|
||||||
private float mPointerRadius;
|
private float mPointerRadius;
|
||||||
@@ -253,17 +252,15 @@ public class BubbleExpandedView extends LinearLayout {
|
|||||||
public BubbleExpandedView(Context context, AttributeSet attrs, int defStyleAttr,
|
public BubbleExpandedView(Context context, AttributeSet attrs, int defStyleAttr,
|
||||||
int defStyleRes) {
|
int defStyleRes) {
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
updateDimensions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
|
mManageButton = (AlphaOptimizedButton) LayoutInflater.from(getContext()).inflate(
|
||||||
mSettingsIcon = findViewById(R.id.settings_button);
|
R.layout.bubble_manage_button, this /* parent */, false /* attach */);
|
||||||
mSettingsIconHeight = getContext().getResources().getDimensionPixelSize(
|
updateDimensions();
|
||||||
R.dimen.bubble_manage_button_height);
|
|
||||||
mPointerView = findViewById(R.id.pointer_view);
|
mPointerView = findViewById(R.id.pointer_view);
|
||||||
mCurrentPointer = mTopPointer;
|
mCurrentPointer = mTopPointer;
|
||||||
mPointerView.setVisibility(INVISIBLE);
|
mPointerView.setVisibility(INVISIBLE);
|
||||||
@@ -288,7 +285,7 @@ public class BubbleExpandedView extends LinearLayout {
|
|||||||
// ==> expanded view
|
// ==> expanded view
|
||||||
// ==> activity view
|
// ==> activity view
|
||||||
// ==> manage button
|
// ==> manage button
|
||||||
bringChildToFront(mSettingsIcon);
|
bringChildToFront(mManageButton);
|
||||||
|
|
||||||
applyThemeAttrs();
|
applyThemeAttrs();
|
||||||
|
|
||||||
@@ -339,7 +336,7 @@ public class BubbleExpandedView extends LinearLayout {
|
|||||||
mExpandedViewContainer.setLayoutParams(
|
mExpandedViewContainer.setLayoutParams(
|
||||||
new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
|
new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
|
||||||
bringChildToFront(mOverflowView);
|
bringChildToFront(mOverflowView);
|
||||||
mSettingsIcon.setVisibility(GONE);
|
mManageButton.setVisibility(GONE);
|
||||||
} else {
|
} else {
|
||||||
mTaskView = new TaskView(mContext, mController.getTaskOrganizer());
|
mTaskView = new TaskView(mContext, mController.getTaskOrganizer());
|
||||||
mTaskView.setListener(mController.getMainExecutor(), mTaskViewListener);
|
mTaskView.setListener(mController.getMainExecutor(), mTaskViewListener);
|
||||||
@@ -354,6 +351,8 @@ public class BubbleExpandedView extends LinearLayout {
|
|||||||
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);
|
mExpandedViewPadding = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding);
|
||||||
|
|
||||||
|
updateFontSize();
|
||||||
|
|
||||||
mPointerMargin = res.getDimensionPixelSize(R.dimen.bubble_pointer_margin);
|
mPointerMargin = res.getDimensionPixelSize(R.dimen.bubble_pointer_margin);
|
||||||
mPointerWidth = res.getDimensionPixelSize(R.dimen.bubble_pointer_width);
|
mPointerWidth = res.getDimensionPixelSize(R.dimen.bubble_pointer_width);
|
||||||
mPointerHeight = res.getDimensionPixelSize(R.dimen.bubble_pointer_height);
|
mPointerHeight = res.getDimensionPixelSize(R.dimen.bubble_pointer_height);
|
||||||
@@ -366,25 +365,26 @@ public class BubbleExpandedView extends LinearLayout {
|
|||||||
mPointerWidth, mPointerHeight, true /* pointLeft */));
|
mPointerWidth, mPointerHeight, true /* pointLeft */));
|
||||||
mRightPointer = new ShapeDrawable(TriangleShape.createHorizontal(
|
mRightPointer = new ShapeDrawable(TriangleShape.createHorizontal(
|
||||||
mPointerWidth, mPointerHeight, false /* pointLeft */));
|
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) {
|
if (mPointerView != null) {
|
||||||
updatePointerView();
|
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() {
|
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);
|
||||||
if (mSettingsIcon != null) {
|
if (mManageButton != null) {
|
||||||
mSettingsIcon.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
|
mManageButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
|
||||||
}
|
}
|
||||||
if (mOverflowView != null) {
|
if (mOverflowView != null) {
|
||||||
mOverflowView.updateFontSize();
|
mOverflowView.updateFontSize();
|
||||||
@@ -396,10 +396,7 @@ public class BubbleExpandedView extends LinearLayout {
|
|||||||
android.R.attr.dialogCornerRadius,
|
android.R.attr.dialogCornerRadius,
|
||||||
android.R.attr.colorBackgroundFloating});
|
android.R.attr.colorBackgroundFloating});
|
||||||
mCornerRadius = ta.getDimensionPixelSize(0, 0);
|
mCornerRadius = ta.getDimensionPixelSize(0, 0);
|
||||||
final int mode =
|
mBackgroundColorFloating = ta.getColor(1, Color.WHITE);
|
||||||
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);
|
|
||||||
mExpandedViewContainer.setBackgroundColor(mBackgroundColorFloating);
|
mExpandedViewContainer.setBackgroundColor(mBackgroundColorFloating);
|
||||||
ta.recycle();
|
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
|
// TODO: Could listener be passed when we pass StackView / can we avoid setting this like this
|
||||||
void setManageClickListener(OnClickListener manageClickListener) {
|
void setManageClickListener(OnClickListener manageClickListener) {
|
||||||
mSettingsIcon.setOnClickListener(manageClickListener);
|
mManageButton.setOnClickListener(manageClickListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -535,6 +532,9 @@ public class BubbleExpandedView extends LinearLayout {
|
|||||||
if (mTaskView != null) {
|
if (mTaskView != null) {
|
||||||
mTaskView.setAlpha(alpha);
|
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);
|
boolean isNew = mBubble == null || didBackingContentChange(bubble);
|
||||||
if (isNew || bubble != null && bubble.getKey().equals(mBubble.getKey())) {
|
if (isNew || bubble != null && bubble.getKey().equals(mBubble.getKey())) {
|
||||||
mBubble = bubble;
|
mBubble = bubble;
|
||||||
mSettingsIcon.setContentDescription(getResources().getString(
|
mManageButton.setContentDescription(getResources().getString(
|
||||||
R.string.bubbles_settings_button_description, bubble.getAppName()));
|
R.string.bubbles_settings_button_description, bubble.getAppName()));
|
||||||
mSettingsIcon.setAccessibilityDelegate(
|
mManageButton.setAccessibilityDelegate(
|
||||||
new AccessibilityDelegate() {
|
new AccessibilityDelegate() {
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeAccessibilityNodeInfo(View host,
|
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
|
// Remove top insets back here because availableRect.height would account for that
|
||||||
? mExpandedViewContainerLocation[1] - mPositioner.getInsets().top
|
? mExpandedViewContainerLocation[1] - mPositioner.getInsets().top
|
||||||
: 0;
|
: 0;
|
||||||
int settingsHeight = mIsOverflow ? 0 : mSettingsIconHeight;
|
int settingsHeight = mIsOverflow ? 0 : mManageButtonHeight;
|
||||||
return mPositioner.getAvailableRect().height()
|
return mPositioner.getAvailableRect().height()
|
||||||
- expandedContainerY
|
- expandedContainerY
|
||||||
- getPaddingTop()
|
- getPaddingTop()
|
||||||
@@ -756,7 +756,7 @@ public class BubbleExpandedView extends LinearLayout {
|
|||||||
* education about the manage button.
|
* education about the manage button.
|
||||||
*/
|
*/
|
||||||
public void getManageButtonBoundsOnScreen(Rect rect) {
|
public void getManageButtonBoundsOnScreen(Rect rect) {
|
||||||
mSettingsIcon.getBoundsOnScreen(rect);
|
mManageButton.getBoundsOnScreen(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user