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

Commit 206ec09d authored by Dan Sandler's avatar Dan Sandler Committed by Android (Google) Code Review
Browse files

Merge "Enable tinting of notification backgrounds."

parents c40c0c9d fe266a3c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@
            android:layout_height="12dp"
            android:layout_marginStart="8dp"
            android:visibility="gone"
            style="@style/Widget.Quantum.Light.ProgressBar.Horizontal"
            style="@style/Widget.StatusBar.Quantum.ProgressBar"
            />
        <LinearLayout
            android:id="@+id/line3"
+4 −4
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ please see styles_device_defaults.xml.
    <style name="TextAppearance.StatusBar.Quantum">
    </style>
    <style name="TextAppearance.StatusBar.Quantum.EventContent">
        <item name="android:textColor">#888888</item>
        <item name="android:textColor">#88000000</item>
        <item name="android:textSize">@dimen/notification_text_size</item>
    </style>
    <style name="TextAppearance.StatusBar.Quantum.EventContent.Title">
@@ -294,14 +294,14 @@ please see styles_device_defaults.xml.
    </style>
    <style name="TextAppearance.StatusBar.Quantum.EventContent.Info">
        <item name="android:textSize">@dimen/notification_subtext_size</item>
        <item name="android:textColor">#888888</item>
        <item name="android:textColor">#88000000</item>
    </style>
    <style name="TextAppearance.StatusBar.Quantum.EventContent.Time">
        <item name="android:textSize">@dimen/notification_subtext_size</item>
        <item name="android:textColor">#888888</item>
        <item name="android:textColor">#88000000</item>
    </style>
    <style name="TextAppearance.StatusBar.Quantum.EventContent.Emphasis">
        <item name="android:textColor">#555555</item>
        <item name="android:textColor">#55000000</item>
    </style>

    <style name="TextAppearance.Small.CalendarViewWeekDayView">
+27 −9
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
@@ -45,6 +46,9 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    private int mBgResId = R.drawable.notification_quantum_bg;
    private int mDimmedBgResId = R.drawable.notification_quantum_bg_dim;

    private int mBgTint = 0;
    private int mDimmedBgTint = 0;

    /**
     * Flag to indicate that the notification has been touched once and the second touch will
     * click it.
@@ -209,17 +213,23 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
     * @param bgResId The background resource to use in normal state.
     * @param dimmedBgResId The background resource to use in dimmed state.
     */
    public void setBackgroundResourceIds(int bgResId, int dimmedBgResId) {
    public void setBackgroundResourceIds(int bgResId, int bgTint, int dimmedBgResId, int dimmedTint) {
        mBgResId = bgResId;
        mBgTint = bgTint;
        mDimmedBgResId = dimmedBgResId;
        mDimmedBgTint = dimmedTint;
        updateBackgroundResource();
    }

    public void setBackgroundResourceIds(int bgResId, int dimmedBgResId) {
        setBackgroundResourceIds(bgResId, 0, dimmedBgResId, 0);
    }

    private void fadeBackgroundResource() {
        if (mDimmed) {
            setBackgroundDimmed(mDimmedBgResId);
            setBackgroundDimmed(mDimmedBgResId, mDimmedBgTint);
        } else {
            setBackgroundNormal(mBgResId);
            setBackgroundNormal(mBgResId, mBgTint);
        }
        int startAlpha = mDimmed ? 255 : 0;
        int endAlpha = mDimmed ? 0 : 255;
@@ -256,12 +266,12 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView

    private void updateBackgroundResource() {
        if (mDimmed) {
            setBackgroundDimmed(mDimmedBgResId);
            setBackgroundDimmed(mDimmedBgResId, mDimmedBgTint);
            mBackgroundDimmed.setAlpha(255);
            setBackgroundNormal(null);
        } else {
            setBackgroundDimmed(null);
            setBackgroundNormal(mBgResId);
            setBackgroundNormal(mBgResId, mBgTint);
            mBackgroundNormal.setAlpha(255);
        }
    }
@@ -295,12 +305,20 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        invalidate();
    }

    private void setBackgroundNormal(int drawableResId) {
        setBackgroundNormal(getResources().getDrawable(drawableResId));
    private void setBackgroundNormal(int drawableResId, int tintColor) {
        final Drawable d = getResources().getDrawable(drawableResId);
        if (tintColor != 0) {
            d.setColorFilter(tintColor, PorterDuff.Mode.SRC_ATOP);
        }
        setBackgroundNormal(d);
    }

    private void setBackgroundDimmed(int drawableResId) {
        setBackgroundDimmed(getResources().getDrawable(drawableResId));
    private void setBackgroundDimmed(int drawableResId, int tintColor) {
        final Drawable d = getResources().getDrawable(drawableResId);
        if (tintColor != 0) {
            d.setColorFilter(tintColor, PorterDuff.Mode.SRC_ATOP);
        }
        setBackgroundDimmed(d);
    }

    @Override
+9 −7
Original line number Diff line number Diff line
@@ -428,7 +428,6 @@ public abstract class BaseStatusBar extends SystemUI implements

    protected void applyLegacyRowBackground(StatusBarNotification sbn,
            NotificationData.Entry entry) {
        if (entry.expanded.getId() != com.android.internal.R.id.status_bar_latest_event_content) {
        int version = 0;
        try {
            ApplicationInfo info = mContext.getPackageManager().getApplicationInfo(sbn.getPackageName(), 0);
@@ -436,6 +435,9 @@ public abstract class BaseStatusBar extends SystemUI implements
        } catch (NameNotFoundException ex) {
            Log.e(TAG, "Failed looking up ApplicationInfo for " + sbn.getPackageName(), ex);
        }

        if (entry.expanded.getId() != com.android.internal.R.id.status_bar_latest_event_content) {
            // Using custom RemoteViews
            if (version > 0 && version < Build.VERSION_CODES.GINGERBREAD) {
                entry.row.setBackgroundResource(R.drawable.notification_row_legacy_bg);
            } else if (version < Build.VERSION_CODES.L) {