diff --git a/core/res/res/layout/notification_material_action_tombstone.xml b/core/res/res/layout/notification_material_action_tombstone.xml
index 817f298f0c6f5..9fa7c6a280207 100644
--- a/core/res/res/layout/notification_material_action_tombstone.xml
+++ b/core/res/res/layout/notification_material_action_tombstone.xml
@@ -27,7 +27,7 @@
android:singleLine="true"
android:ellipsize="end"
android:textAlignment="viewStart"
- android:alpha="0.5"
+ android:alpha="@dimen/notification_action_disabled_alpha"
android:enabled="false"
android:background="@drawable/notification_material_action_background"
/>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 08e2f455cacf7..c478f8e6b6781 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -615,6 +615,8 @@
280dp
38dp
+
+ - 0.5
208dp
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index e0dfa00f7dbfa..96ac1207195bb 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2877,6 +2877,7 @@
+
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
index 9ed5b7fd45743..c9dcc5c688ec5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
@@ -18,16 +18,20 @@ package com.android.systemui.statusbar.notification;
import android.app.PendingIntent;
import android.content.Context;
+import android.content.res.ColorStateList;
import android.graphics.Color;
+import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.service.notification.StatusBarNotification;
import android.util.ArraySet;
import android.view.View;
+import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
-import com.android.internal.R;
+import com.android.internal.util.NotificationColorUtil;
import com.android.internal.widget.NotificationActionListLayout;
import com.android.systemui.Dependency;
import com.android.systemui.UiOffloadThread;
@@ -48,7 +52,7 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp
private TextView mTitle;
private TextView mText;
protected View mActionsContainer;
- private View mReplyAction;
+ private ImageView mReplyAction;
private Rect mTmpRect = new Rect();
private int mContentHeight;
@@ -151,25 +155,60 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp
if (mActions != null) {
int numActions = mActions.getChildCount();
for (int i = 0; i < numActions; i++) {
- View action = mActions.getChildAt(i);
+ Button action = (Button) mActions.getChildAt(i);
performOnPendingIntentCancellation(action, () -> {
- action.setEnabled(false);
- // The visual appearance doesn't look disabled enough yet, let's add the
- // alpha as well. Selectors unfortunately don't seem to work here.
- action.setAlpha(0.5f);
+ if (action.isEnabled()) {
+ action.setEnabled(false);
+ // The visual appearance doesn't look disabled enough yet, let's add the
+ // alpha as well. Since Alpha doesn't play nicely right now with the
+ // transformation, we rather blend it manually with the background color.
+ ColorStateList textColors = action.getTextColors();
+ int[] colors = textColors.getColors();
+ int[] newColors = new int[colors.length];
+ float disabledAlpha = mView.getResources().getFloat(
+ com.android.internal.R.dimen.notification_action_disabled_alpha);
+ for (int j = 0; j < colors.length; j++) {
+ int color = colors[j];
+ color = blendColorWithBackground(color, disabledAlpha);
+ newColors[j] = color;
+ }
+ ColorStateList newColorStateList = new ColorStateList(
+ textColors.getStates(), newColors);
+ action.setTextColor(newColorStateList);
+ }
});
}
}
if (mReplyAction != null) {
performOnPendingIntentCancellation(mReplyAction, () -> {
- mReplyAction.setEnabled(false);
- // The visual appearance doesn't look disabled enough yet, let's add the
- // alpha as well. Selectors unfortunately don't seem to work here.
- mReplyAction.setAlpha(0.5f);
+ if (mReplyAction != null && mReplyAction.isEnabled()) {
+ mReplyAction.setEnabled(false);
+ // The visual appearance doesn't look disabled enough yet, let's add the
+ // alpha as well. Since Alpha doesn't play nicely right now with the
+ // transformation, we rather blend it manually with the background color.
+ Drawable drawable = mReplyAction.getDrawable().mutate();
+ PorterDuffColorFilter colorFilter =
+ (PorterDuffColorFilter) drawable.getColorFilter();
+ float disabledAlpha = mView.getResources().getFloat(
+ com.android.internal.R.dimen.notification_action_disabled_alpha);
+ if (colorFilter != null) {
+ int color = colorFilter.getColor();
+ color = blendColorWithBackground(color, disabledAlpha);
+ drawable.mutate().setColorFilter(color, colorFilter.getMode());
+ } else {
+ mReplyAction.setAlpha(disabledAlpha);
+ }
+ }
});
}
}
+ private int blendColorWithBackground(int color, float alpha) {
+ // alpha doesn't go well for color filters, so let's blend it manually
+ return NotificationColorUtil.compositeColors(Color.argb((int) (alpha * 255),
+ Color.red(color), Color.green(color), Color.blue(color)), resolveBackgroundColor());
+ }
+
private void performOnPendingIntentCancellation(View view, Runnable cancellationRunnable) {
PendingIntent pendingIntent = (PendingIntent) view.getTag(
com.android.internal.R.id.pending_intent_tag);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
index b09df158072c4..93a9947a3c9b8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
@@ -175,6 +175,15 @@ public abstract class NotificationViewWrapper implements TransformableView {
return mRow.isSummaryWithChildren() ? 0 : mBackgroundColor;
}
+ protected int resolveBackgroundColor() {
+ int customBackgroundColor = getCustomBackgroundColor();
+ if (customBackgroundColor != 0) {
+ return customBackgroundColor;
+ }
+ return mView.getContext().getColor(
+ com.android.internal.R.color.notification_material_background_color);
+ }
+
public void setLegacy(boolean legacy) {
}