Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 239f835f authored by Christoph Studer's avatar Christoph Studer
Browse files

Notification: Optimize L icon processing

Bug: 16862480
Change-Id: I6c71eba232184ce948aafe81fec3a313fecbbaf1
parent 5369d7a9
Loading
Loading
Loading
Loading
+10 −11
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.media.AudioManager;
import android.media.session.MediaSession;
import android.net.Uri;
import android.os.BadParcelableException;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
@@ -1904,7 +1905,8 @@ public class Notification implements Parcelable
            mPriority = PRIORITY_DEFAULT;
            mPeople = new ArrayList<String>();

            mColorUtil = NotificationColorUtil.getInstance();
            mColorUtil = context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.L ?
                    NotificationColorUtil.getInstance() : null;
        }

        /**
@@ -2610,7 +2612,7 @@ public class Notification implements Parcelable

            if (mLargeIcon != null) {
                contentView.setImageViewBitmap(R.id.icon, mLargeIcon);
                processLargeIcon(mLargeIcon, contentView);
                processLargeLegacyIcon(mLargeIcon, contentView);
                contentView.setImageViewResource(R.id.right_icon, mSmallIcon);
                contentView.setViewVisibility(R.id.right_icon, View.VISIBLE);
                processSmallRightIcon(mSmallIcon, contentView);
@@ -2813,15 +2815,12 @@ public class Notification implements Parcelable
        }

        private void processLegacyAction(Action action, RemoteViews button) {
            if (isLegacy()) {
                if (mColorUtil.isGrayscale(mContext, action.icon)) {
            if (!isLegacy() || mColorUtil.isGrayscale(mContext, action.icon)) {
                button.setTextViewCompoundDrawablesRelativeColorFilter(R.id.action0, 0,
                            mContext.getResources().getColor(
                                    R.color.notification_action_legacy_color_filter),
                        mContext.getResources().getColor(R.color.notification_action_color_filter),
                        PorterDuff.Mode.MULTIPLY);
            }
        }
        }

        private CharSequence processLegacyText(CharSequence charSequence) {
            if (isLegacy()) {
@@ -2845,8 +2844,8 @@ public class Notification implements Parcelable
         * if it's grayscale).
         */
        // TODO: also check bounds, transparency, that sort of thing.
        private void processLargeIcon(Bitmap largeIcon, RemoteViews contentView) {
            if (!isLegacy() || mColorUtil.isGrayscale(largeIcon)) {
        private void processLargeLegacyIcon(Bitmap largeIcon, RemoteViews contentView) {
            if (isLegacy() && mColorUtil.isGrayscale(largeIcon)) {
                applyLargeIconBackground(contentView);
            } else {
                removeLargeIconBackground(contentView);
+1 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@
    <drawable name="notification_template_divider">#29000000</drawable>

    <color name="notification_icon_bg_color">#ff9e9e9e</color>
    <color name="notification_action_legacy_color_filter">#ff555555</color>
    <color name="notification_action_color_filter">@color/secondary_text_material_light</color>

    <color name="notification_media_action_bg">#00000000</color>
    <color name="notification_media_progress">#FFFFFFFF</color>
+1 −1
Original line number Diff line number Diff line
@@ -1718,7 +1718,7 @@
  <java-symbol type="layout" name="notification_template_material_big_text" />
  <java-symbol type="layout" name="notification_template_icon_group" />
  <java-symbol type="layout" name="notification_material_media_action" />
  <java-symbol type="color" name="notification_action_legacy_color_filter" />
  <java-symbol type="color" name="notification_action_color_filter" />
  <java-symbol type="color" name="notification_icon_bg_color" />
  <java-symbol type="drawable" name="notification_icon_legacy_bg" />
  <java-symbol type="drawable" name="notification_material_media_progress" />