Replace bubble header with adaptive settings icon
Bug: 128010178
Test: manual
Change-Id: Ia0a0f72d7ed1da3fd7dbdcff235cf0bcb39100c4
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
index de887ff..6c2db76e 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
@@ -38,8 +38,11 @@
import android.graphics.Color;
import android.graphics.Insets;
import android.graphics.Point;
+import android.graphics.drawable.AdaptiveIconDrawable;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.InsetDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -53,7 +56,6 @@
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.widget.FrameLayout;
-import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -80,10 +82,7 @@
private View mPointerView;
private int mPointerMargin;
- // Header
- private View mHeaderView;
- private ImageButton mDeepLinkIcon;
- private ImageButton mSettingsIcon;
+ private ImageView mSettingsIcon;
// Permission view
private View mPermissionView;
@@ -195,7 +194,6 @@
mPointerView.setBackground(triangleDrawable);
FrameLayout viewWrapper = findViewById(R.id.header_permission_wrapper);
- viewWrapper.setBackground(createHeaderPermissionBackground(bgColor));
LayoutTransition transition = new LayoutTransition();
transition.setDuration(200);
@@ -212,18 +210,16 @@
viewWrapper.setLayoutTransition(transition);
viewWrapper.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
-
mHeaderHeight = getContext().getResources().getDimensionPixelSize(
R.dimen.bubble_expanded_header_height);
mPermissionHeight = getContext().getResources().getDimensionPixelSize(
R.dimen.bubble_permission_height);
- mHeaderView = findViewById(R.id.header_layout);
- mDeepLinkIcon = findViewById(R.id.deep_link_button);
- mSettingsIcon = findViewById(R.id.settings_button);
- mDeepLinkIcon.setOnClickListener(this);
- mSettingsIcon.setOnClickListener(this);
mPermissionView = findViewById(R.id.permission_layout);
+ mSettingsIcon = findViewById(R.id.settings_button);
+ mSettingsIcon.setOnClickListener(this);
+ updateHeaderColor();
+
findViewById(R.id.no_bubbles_button).setOnClickListener(this);
findViewById(R.id.yes_bubbles_button).setOnClickListener(this);
@@ -381,25 +377,31 @@
}
/**
- * Update header color when user toggles dark mode.
+ * Update header color and icon shape when theme changes.
*/
void updateHeaderColor() {
TypedArray ta = mContext.obtainStyledAttributes(
new int[] {android.R.attr.colorBackgroundFloating, android.R.attr.colorForeground});
- int bgColor = ta.getColor(0, Color.WHITE /* default */);
- int btnColor = ta.getColor(1, Color.BLACK /* default */);
+ int backgroundColor = ta.getColor(0, Color.WHITE /* default */);
+ int foregroundColor = ta.getColor(1, Color.BLACK /* default */);
ta.recycle();
- mHeaderView.setBackgroundColor(bgColor);
- mSettingsIcon.setColorFilter(btnColor);
- mDeepLinkIcon.setColorFilter(btnColor);
+ mPermissionView.setBackground(createHeaderPermissionBackground(backgroundColor));
+
+ Drawable settingsIcon = mSettingsIcon.getDrawable();
+ settingsIcon.setTint(foregroundColor);
+
+ int mIconInset = getResources().getDimensionPixelSize(R.dimen.bubble_icon_inset);
+ InsetDrawable foreground = new InsetDrawable(settingsIcon, mIconInset);
+ ColorDrawable background = new ColorDrawable(backgroundColor);
+ AdaptiveIconDrawable adaptiveIcon = new AdaptiveIconDrawable(background,
+ foreground);
+ mSettingsIcon.setImageDrawable(adaptiveIcon);
}
private void updateHeaderView() {
mSettingsIcon.setContentDescription(getResources().getString(
R.string.bubbles_settings_button_description, mAppName));
- mDeepLinkIcon.setContentDescription(getResources().getString(
- R.string.bubbles_deep_link_button_description, mAppName));
}
private void updatePermissionView() {
@@ -412,11 +414,9 @@
Log.w(TAG, e);
}
if (hasUserApprovedBubblesForPackage) {
- mHeaderView.setVisibility(VISIBLE);
- mPermissionView.setVisibility(GONE);
+ showSettingsIcon();
} else {
- mHeaderView.setVisibility(GONE);
- mPermissionView.setVisibility(VISIBLE);
+ showPermissionView();
((ImageView) mPermissionView.findViewById(R.id.pkgicon)).setImageDrawable(mAppIcon);
((TextView) mPermissionView.findViewById(R.id.pkgname)).setText(mAppName);
((TextView) mPermissionView.findViewById(R.id.prompt)).setText(
@@ -513,18 +513,7 @@
}
Notification n = mEntry.notification.getNotification();
int id = view.getId();
- if (id == R.id.deep_link_button) {
- mStackView.collapseStack(() -> {
- try {
- n.contentIntent.send();
- logBubbleClickEvent(mEntry,
- StatsLog.BUBBLE_UICHANGED__ACTION__HEADER_GO_TO_APP);
- } catch (PendingIntent.CanceledException e) {
- Log.w(TAG, "Failed to send intent for bubble with key: "
- + (mEntry != null ? mEntry.key : " null entry"));
- }
- });
- } else if (id == R.id.settings_button) {
+ if (id == R.id.settings_button) {
Intent intent = getSettingsIntent(mEntry.notification.getPackageName(),
mEntry.notification.getUid());
mStackView.collapseStack(() -> {
@@ -546,8 +535,7 @@
mEntry.notification.getUid(),
allowed);
if (allowed) {
- mPermissionView.setVisibility(GONE);
- mHeaderView.setVisibility(VISIBLE);
+ showSettingsIcon();
} else if (mOnBubbleBlockedListener != null) {
mOnBubbleBlockedListener.onBubbleBlocked(mEntry);
}
@@ -560,6 +548,17 @@
}
}
+ void showSettingsIcon() {
+ mPermissionView.setVisibility(GONE);
+ mSettingsIcon.setVisibility(VISIBLE);
+ }
+
+ void showPermissionView() {
+ mSettingsIcon.setVisibility(GONE);
+ mPermissionView.setVisibility(VISIBLE);
+
+ }
+
/**
* Update appearance of the expanded view being displayed.
*/