am 782994ef: am 51650235: Merge "Apply color to progress bar for notifications" into lmp-mr1-dev

* commit '782994efd30a153af44c38a9871d24fecb0eb609':
  Apply color to progress bar for notifications
This commit is contained in:
Jorim Jaggi
2014-10-10 17:01:07 +00:00
committed by Android Git Automerger
5 changed files with 65 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ import android.content.Context;
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 @@ public class Notification implements Parcelable
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);

View File

@@ -604,6 +604,7 @@ public class ProgressBar extends View {
* @see #getIndeterminateTintList()
* @see Drawable#setTintList(ColorStateList)
*/
@RemotableViewMethod
public void setIndeterminateTintList(@Nullable ColorStateList tint) {
if (mProgressTintInfo == null) {
mProgressTintInfo = new ProgressTintInfo();
@@ -842,6 +843,7 @@ public class ProgressBar extends View {
* @see #getProgressTintList()
* @see Drawable#setTintList(ColorStateList)
*/
@RemotableViewMethod
public void setProgressTintList(@Nullable ColorStateList tint) {
if (mProgressTintInfo == null) {
mProgressTintInfo = new ProgressTintInfo();
@@ -923,6 +925,7 @@ public class ProgressBar extends View {
* @see #getProgressBackgroundTintList()
* @see Drawable#setTintList(ColorStateList)
*/
@RemotableViewMethod
public void setProgressBackgroundTintList(@Nullable ColorStateList tint) {
if (mProgressTintInfo == null) {
mProgressTintInfo = new ProgressTintInfo();

View File

@@ -27,6 +27,7 @@ import android.content.Intent;
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 @@ public class RemoteViews implements Parcelable, Filter {
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 @@ public class RemoteViews implements Parcelable, Filter {
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 @@ public class RemoteViews implements Parcelable, Filter {
((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 @@ public class RemoteViews implements Parcelable, Filter {
return Bundle.class;
case INTENT:
return Intent.class;
case COLOR_STATE_LIST:
return ColorStateList.class;
default:
return null;
}
@@ -2206,6 +2220,42 @@ public class RemoteViews implements Parcelable, Filter {
colorFilter, mode, level));
}
/**
* @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)}.
*

View File

@@ -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>

View File

@@ -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 -->