diff options
author | Jeff Sharkey <jsharkey@android.com> | 2011-08-09 14:01:09 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-08-09 14:01:09 -0700 |
commit | 82f006f672d3562aef9a36a44fbd76b8a7e3aae5 (patch) | |
tree | cb6a8e5d328144af24e1051aa2c468ef4eb645b7 /core/java/android/app | |
parent | 541d8ea32dbc9b2ca931fae98d2150d197d4b34c (diff) | |
parent | 1c40013bb2afbd76050ac681d7880476aa7fc70d (diff) | |
download | frameworks_base-82f006f672d3562aef9a36a44fbd76b8a7e3aae5.zip frameworks_base-82f006f672d3562aef9a36a44fbd76b8a7e3aae5.tar.gz frameworks_base-82f006f672d3562aef9a36a44fbd76b8a7e3aae5.tar.bz2 |
Merge "Add progress to Notification.Builder."
Diffstat (limited to 'core/java/android/app')
-rw-r--r-- | core/java/android/app/Notification.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 170d2b5..9490b96 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -26,6 +26,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import android.view.View; +import android.widget.ProgressBar; import android.widget.RemoteViews; import java.text.NumberFormat; @@ -645,6 +646,9 @@ public class Notification implements Parcelable private int mLedOffMs; private int mDefaults; private int mFlags; + private int mProgressMax; + private int mProgress; + private boolean mProgressIndeterminate; /** * Constructor. @@ -736,6 +740,17 @@ public class Notification implements Parcelable } /** + * Set the progress this notification represents, which may be + * represented as a {@link ProgressBar}. + */ + public Builder setProgress(int max, int progress, boolean indeterminate) { + mProgressMax = max; + mProgress = progress; + mProgressIndeterminate = indeterminate; + return this; + } + + /** * Supply a custom RemoteViews to use instead of the standard one. */ public Builder setContent(RemoteViews views) { @@ -917,17 +932,24 @@ public class Notification implements Parcelable private RemoteViews makeRemoteViews(int resId) { RemoteViews contentView = new RemoteViews(mContext.getPackageName(), resId); + boolean hasLine3 = false; if (mSmallIcon != 0) { contentView.setImageViewResource(R.id.icon, mSmallIcon); + contentView.setViewVisibility(R.id.icon, View.VISIBLE); + } else { + contentView.setViewVisibility(R.id.icon, View.GONE); } if (mContentTitle != null) { contentView.setTextViewText(R.id.title, mContentTitle); } if (mContentText != null) { contentView.setTextViewText(R.id.text, mContentText); + hasLine3 = true; } if (mContentInfo != null) { contentView.setTextViewText(R.id.info, mContentInfo); + contentView.setViewVisibility(R.id.info, View.VISIBLE); + hasLine3 = true; } else if (mNumber > 0) { final int tooBig = mContext.getResources().getInteger( R.integer.status_bar_notification_info_maxnum); @@ -938,12 +960,22 @@ public class Notification implements Parcelable NumberFormat f = NumberFormat.getIntegerInstance(); contentView.setTextViewText(R.id.info, f.format(mNumber)); } + contentView.setViewVisibility(R.id.info, View.VISIBLE); + hasLine3 = true; } else { contentView.setViewVisibility(R.id.info, View.GONE); } + if (mProgressMax != 0 || mProgressIndeterminate) { + contentView.setProgressBar( + R.id.progress, mProgressMax, mProgress, mProgressIndeterminate); + contentView.setViewVisibility(R.id.progress, View.VISIBLE); + } else { + contentView.setViewVisibility(R.id.progress, View.GONE); + } if (mWhen != 0) { contentView.setLong(R.id.time, "setTime", mWhen); } + contentView.setViewVisibility(R.id.line3, hasLine3 ? View.VISIBLE : View.GONE); return contentView; } |