Apply color to progress bar for notifications
Bug: 17128179
Change-Id: Ia642ff2a352bbabf2d1e468367d45dc188ee0e73
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index fb10e17..9849c51 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -23,6 +23,7 @@
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
@@ -2773,6 +2774,14 @@
contentView.setViewVisibility(R.id.progress, View.VISIBLE);
contentView.setProgressBar(
R.id.progress, mProgressMax, mProgress, mProgressIndeterminate);
+ contentView.setProgressBackgroundTintList(
+ R.id.progress, ColorStateList.valueOf(mContext.getResources().getColor(
+ R.color.notification_progress_background_color)));
+ if (mColor != COLOR_DEFAULT) {
+ ColorStateList colorStateList = ColorStateList.valueOf(mColor);
+ contentView.setProgressTintList(R.id.progress, colorStateList);
+ contentView.setProgressIndeterminateTintList(R.id.progress, colorStateList);
+ }
showLine2 = true;
} else {
contentView.setViewVisibility(R.id.progress, View.GONE);
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java
index e9298c2..1c190c3 100644
--- a/core/java/android/widget/ProgressBar.java
+++ b/core/java/android/widget/ProgressBar.java
@@ -604,6 +604,7 @@
* @see #getIndeterminateTintList()
* @see Drawable#setTintList(ColorStateList)
*/
+ @RemotableViewMethod
public void setIndeterminateTintList(@Nullable ColorStateList tint) {
if (mProgressTintInfo == null) {
mProgressTintInfo = new ProgressTintInfo();
@@ -842,6 +843,7 @@
* @see #getProgressTintList()
* @see Drawable#setTintList(ColorStateList)
*/
+ @RemotableViewMethod
public void setProgressTintList(@Nullable ColorStateList tint) {
if (mProgressTintInfo == null) {
mProgressTintInfo = new ProgressTintInfo();
@@ -923,6 +925,7 @@
* @see #getProgressBackgroundTintList()
* @see Drawable#setTintList(ColorStateList)
*/
+ @RemotableViewMethod
public void setProgressBackgroundTintList(@Nullable ColorStateList tint) {
if (mProgressTintInfo == null) {
mProgressTintInfo = new ProgressTintInfo();
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 7cb3c37..80f364b 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -27,6 +27,7 @@
import android.content.IntentSender;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -1069,6 +1070,7 @@
static final int BITMAP = 12;
static final int BUNDLE = 13;
static final int INTENT = 14;
+ static final int COLOR_STATE_LIST = 15;
String methodName;
int type;
@@ -1142,6 +1144,11 @@
this.value = Intent.CREATOR.createFromParcel(in);
}
break;
+ case COLOR_STATE_LIST:
+ if (in.readInt() != 0) {
+ this.value = ColorStateList.CREATOR.createFromParcel(in);
+ }
+ break;
default:
break;
}
@@ -1212,6 +1219,11 @@
((Intent)this.value).writeToParcel(out, flags);
}
break;
+ case COLOR_STATE_LIST:
+ out.writeInt(this.value != null ? 1 : 0);
+ if (this.value != null) {
+ ((ColorStateList)this.value).writeToParcel(out, flags);
+ }
default:
break;
}
@@ -1247,6 +1259,8 @@
return Bundle.class;
case INTENT:
return Intent.class;
+ case COLOR_STATE_LIST:
+ return ColorStateList.class;
default:
return null;
}
@@ -2207,6 +2221,42 @@
}
/**
+ * @hide
+ * Equivalent to calling {@link android.widget.ProgressBar#setProgressTintList}.
+ *
+ * @param viewId The id of the view whose tint should change
+ * @param tint the tint to apply, may be {@code null} to clear tint
+ */
+ public void setProgressTintList(int viewId, ColorStateList tint) {
+ addAction(new ReflectionAction(viewId, "setProgressTintList",
+ ReflectionAction.COLOR_STATE_LIST, tint));
+ }
+
+ /**
+ * @hide
+ * Equivalent to calling {@link android.widget.ProgressBar#setProgressBackgroundTintList}.
+ *
+ * @param viewId The id of the view whose tint should change
+ * @param tint the tint to apply, may be {@code null} to clear tint
+ */
+ public void setProgressBackgroundTintList(int viewId, ColorStateList tint) {
+ addAction(new ReflectionAction(viewId, "setProgressBackgroundTintList",
+ ReflectionAction.COLOR_STATE_LIST, tint));
+ }
+
+ /**
+ * @hide
+ * Equivalent to calling {@link android.widget.ProgressBar#setIndeterminateTintList}.
+ *
+ * @param viewId The id of the view whose tint should change
+ * @param tint the tint to apply, may be {@code null} to clear tint
+ */
+ public void setProgressIndeterminateTintList(int viewId, ColorStateList tint) {
+ addAction(new ReflectionAction(viewId, "setIndeterminateTintList",
+ ReflectionAction.COLOR_STATE_LIST, tint));
+ }
+
+ /**
* Equivalent to calling {@link android.widget.TextView#setTextColor(int)}.
*
* @param viewId The id of the view whose text color should change
diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml
index cbaf54f..d420e91 100644
--- a/core/res/res/values/colors.xml
+++ b/core/res/res/values/colors.xml
@@ -136,6 +136,8 @@
<color name="notification_media_primary_color">@color/primary_text_material_dark</color>
<color name="notification_media_secondary_color">@color/secondary_text_material_dark</color>
+ <color name="notification_progress_background_color">@color/secondary_text_material_light</color>
+
<!-- Keyguard colors -->
<color name="keyguard_avatar_frame_color">#ffffffff</color>
<color name="keyguard_avatar_frame_shadow_color">#80000000</color>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 82d398e..d9129fe 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1782,6 +1782,7 @@
<java-symbol type="drawable" name="notification_icon_legacy_bg" />
<java-symbol type="color" name="notification_media_primary_color" />
<java-symbol type="color" name="notification_media_secondary_color" />
+ <java-symbol type="color" name="notification_progress_background_color" />
<java-symbol type="id" name="media_actions" />
<!-- From SystemUI -->