summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/DownloadNotification.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/providers/downloads/DownloadNotification.java')
-rw-r--r--src/com/android/providers/downloads/DownloadNotification.java107
1 files changed, 58 insertions, 49 deletions
diff --git a/src/com/android/providers/downloads/DownloadNotification.java b/src/com/android/providers/downloads/DownloadNotification.java
index ed17ab7a..9f54190e 100644
--- a/src/com/android/providers/downloads/DownloadNotification.java
+++ b/src/com/android/providers/downloads/DownloadNotification.java
@@ -43,14 +43,15 @@ class DownloadNotification {
static final String LOGTAG = "DownloadNotification";
static final String WHERE_RUNNING =
- "(" + Downloads.STATUS + " >= '100') AND (" +
- Downloads.STATUS + " <= '199') AND (" +
- Downloads.VISIBILITY + " IS NULL OR " +
- Downloads.VISIBILITY + " == '" + Downloads.VISIBILITY_VISIBLE + "' OR " +
- Downloads.VISIBILITY + " == '" + Downloads.VISIBILITY_VISIBLE_NOTIFY_COMPLETED + "')";
+ "(" + Downloads.COLUMN_STATUS + " >= '100') AND (" +
+ Downloads.COLUMN_STATUS + " <= '199') AND (" +
+ Downloads.COLUMN_VISIBILITY + " IS NULL OR " +
+ Downloads.COLUMN_VISIBILITY + " == '" + Downloads.VISIBILITY_VISIBLE + "' OR " +
+ Downloads.COLUMN_VISIBILITY +
+ " == '" + Downloads.VISIBILITY_VISIBLE_NOTIFY_COMPLETED + "')";
static final String WHERE_COMPLETED =
- Downloads.STATUS + " >= '200' AND " +
- Downloads.VISIBILITY + " == '" + Downloads.VISIBILITY_VISIBLE_NOTIFY_COMPLETED + "'";
+ Downloads.COLUMN_STATUS + " >= '200' AND " +
+ Downloads.COLUMN_VISIBILITY + " == '" + Downloads.VISIBILITY_VISIBLE_NOTIFY_COMPLETED + "'";
/**
@@ -60,28 +61,28 @@ class DownloadNotification {
*
*/
static class NotificationItem {
- int id; // This first db _id for the download for the app
- int totalCurrent = 0;
- int totalTotal = 0;
- int titleCount = 0;
- String packageName; // App package name
- String description;
- String[] titles = new String[2]; // download titles.
+ int mId; // This first db _id for the download for the app
+ int mTotalCurrent = 0;
+ int mTotalTotal = 0;
+ int mTitleCount = 0;
+ String mPackageName; // App package name
+ String mDescription;
+ String[] mTitles = new String[2]; // download titles.
/*
* Add a second download to this notification item.
*/
void addItem(String title, int currentBytes, int totalBytes) {
- totalCurrent += currentBytes;
- if (totalBytes <= 0 || totalTotal == -1) {
- totalTotal = -1;
+ mTotalCurrent += currentBytes;
+ if (totalBytes <= 0 || mTotalTotal == -1) {
+ mTotalTotal = -1;
} else {
- totalTotal += totalBytes;
+ mTotalTotal += totalBytes;
}
- if (titleCount < 2) {
- titles[titleCount] = title;
+ if (mTitleCount < 2) {
+ mTitles[mTitleCount] = title;
}
- titleCount++;
+ mTitleCount++;
}
}
@@ -110,11 +111,14 @@ class DownloadNotification {
// Active downloads
Cursor c = mContext.getContentResolver().query(
Downloads.CONTENT_URI, new String [] {
- Downloads._ID, Downloads.TITLE, Downloads.DESCRIPTION,
- Downloads.NOTIFICATION_PACKAGE,
- Downloads.NOTIFICATION_CLASS,
- Downloads.CURRENT_BYTES, Downloads.TOTAL_BYTES,
- Downloads.STATUS, Downloads._DATA
+ Downloads._ID,
+ Downloads.COLUMN_TITLE,
+ Downloads.COLUMN_DESCRIPTION,
+ Downloads.COLUMN_NOTIFICATION_PACKAGE,
+ Downloads.COLUMN_NOTIFICATION_CLASS,
+ Downloads.COLUMN_CURRENT_BYTES,
+ Downloads.COLUMN_TOTAL_BYTES,
+ Downloads.COLUMN_STATUS, Downloads._DATA
},
WHERE_RUNNING, null, Downloads._ID);
@@ -148,9 +152,9 @@ class DownloadNotification {
mNotifications.get(packageName).addItem(title, progress, max);
} else {
NotificationItem item = new NotificationItem();
- item.id = c.getInt(idColumn);
- item.packageName = packageName;
- item.description = c.getString(descColumn);
+ item.mId = c.getInt(idColumn);
+ item.mPackageName = packageName;
+ item.mDescription = c.getString(descColumn);
String className = c.getString(classOwnerColumn);
item.addItem(title, progress, max);
mNotifications.put(packageName, item);
@@ -171,26 +175,26 @@ class DownloadNotification {
RemoteViews expandedView = new RemoteViews(
"com.android.providers.downloads",
R.layout.status_bar_ongoing_event_progress_bar);
- StringBuilder title = new StringBuilder(item.titles[0]);
- if (item.titleCount > 1) {
+ StringBuilder title = new StringBuilder(item.mTitles[0]);
+ if (item.mTitleCount > 1) {
title.append(mContext.getString(R.string.notification_filename_separator));
- title.append(item.titles[1]);
- n.number = item.titleCount;
- if (item.titleCount > 2) {
+ title.append(item.mTitles[1]);
+ n.number = item.mTitleCount;
+ if (item.mTitleCount > 2) {
title.append(mContext.getString(R.string.notification_filename_extras,
- new Object[] { Integer.valueOf(item.titleCount - 2) }));
+ new Object[] { Integer.valueOf(item.mTitleCount - 2) }));
}
} else {
expandedView.setTextViewText(R.id.description,
- item.description);
+ item.mDescription);
}
expandedView.setTextViewText(R.id.title, title);
expandedView.setProgressBar(R.id.progress_bar,
- item.totalTotal,
- item.totalCurrent,
- item.totalTotal == -1);
+ item.mTotalTotal,
+ item.mTotalCurrent,
+ item.mTotalTotal == -1);
expandedView.setTextViewText(R.id.progress_text,
- getDownloadingText(item.totalTotal, item.totalCurrent));
+ getDownloadingText(item.mTotalTotal, item.mTotalCurrent));
expandedView.setImageViewResource(R.id.appIcon,
android.R.drawable.stat_sys_download);
n.contentView = expandedView;
@@ -198,12 +202,12 @@ class DownloadNotification {
Intent intent = new Intent(Constants.ACTION_LIST);
intent.setClassName("com.android.providers.downloads",
DownloadReceiver.class.getName());
- intent.setData(Uri.parse(Downloads.CONTENT_URI + "/" + item.id));
- intent.putExtra("multiple", item.titleCount > 1);
+ intent.setData(Uri.parse(Downloads.CONTENT_URI + "/" + item.mId));
+ intent.putExtra("multiple", item.mTitleCount > 1);
n.contentIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
- mNotificationMgr.notify(item.id, n);
+ mNotificationMgr.notify(item.mId, n);
}
}
@@ -212,12 +216,17 @@ class DownloadNotification {
// Completed downloads
Cursor c = mContext.getContentResolver().query(
Downloads.CONTENT_URI, new String [] {
- Downloads._ID, Downloads.TITLE, Downloads.DESCRIPTION,
- Downloads.NOTIFICATION_PACKAGE,
- Downloads.NOTIFICATION_CLASS,
- Downloads.CURRENT_BYTES, Downloads.TOTAL_BYTES,
- Downloads.STATUS, Downloads._DATA,
- Downloads.LAST_MODIFICATION, Downloads.DESTINATION
+ Downloads._ID,
+ Downloads.COLUMN_TITLE,
+ Downloads.COLUMN_DESCRIPTION,
+ Downloads.COLUMN_NOTIFICATION_PACKAGE,
+ Downloads.COLUMN_NOTIFICATION_CLASS,
+ Downloads.COLUMN_CURRENT_BYTES,
+ Downloads.COLUMN_TOTAL_BYTES,
+ Downloads.COLUMN_STATUS,
+ Downloads._DATA,
+ Downloads.COLUMN_LAST_MODIFICATION,
+ Downloads.COLUMN_DESTINATION
},
WHERE_COMPLETED, null, Downloads._ID);