Fixed a bug where the media notification image was wrong
In RTL the gradient was being applied the wrong way.
Test: switch to RTL, play music
Change-Id: Ie1686719d56436712fd0e6c99ba2723ba53d0025
Fixes: 37996998
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ImageGradientColorizer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ImageGradientColorizer.java
index f65d3e6..454edbb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ImageGradientColorizer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ImageGradientColorizer.java
@@ -34,7 +34,7 @@
* A utility class to colorize bitmaps with a color gradient and a special blending mode
*/
public class ImageGradientColorizer {
- public Bitmap colorize(Drawable drawable, int backgroundColor) {
+ public Bitmap colorize(Drawable drawable, int backgroundColor, boolean isRtl) {
int width = drawable.getIntrinsicWidth();
int height = drawable.getIntrinsicHeight();
int size = Math.min(width, height);
@@ -79,6 +79,12 @@
Canvas fadeInCanvas = new Canvas(fadeIn);
drawable.clearColorFilter();
drawable.draw(fadeInCanvas);
+
+ if (isRtl) {
+ // Let's flip the gradient
+ fadeInCanvas.translate(size, 0);
+ fadeInCanvas.scale(-1, 1);
+ }
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
fadeInCanvas.drawPaint(paint);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/MediaNotificationProcessor.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/MediaNotificationProcessor.java
index cef225b..52c053f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/MediaNotificationProcessor.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/MediaNotificationProcessor.java
@@ -25,6 +25,7 @@
import android.graphics.drawable.Icon;
import android.support.v4.graphics.ColorUtils;
import android.support.v7.graphics.Palette;
+import android.util.LayoutDirection;
import com.android.systemui.R;
@@ -187,7 +188,9 @@
: R.color.notification_material_background_color;
backgroundColor = mContext.getColor(id);
}
- Bitmap colorized = mColorizer.colorize(drawable, backgroundColor);
+ Bitmap colorized = mColorizer.colorize(drawable, backgroundColor,
+ mContext.getResources().getConfiguration().getLayoutDirection() ==
+ LayoutDirection.RTL);
builder.setLargeIcon(Icon.createWithBitmap(colorized));
}
}