From 4d3a380d338b1f6ee120fb9de2001f138be398ff Mon Sep 17 00:00:00 2001 From: Leon Scroggins Date: Thu, 21 Jan 2010 16:21:46 -0500 Subject: Update the title of the download based on the filename. Now that the downloads page is not necessarily opened when a download starts, we need to provide a name even if the downloads page isn't shown. So when we create a notification, provide the title. Depends on a change to frameworks/base --- .../providers/downloads/DownloadNotification.java | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src/com/android/providers') diff --git a/src/com/android/providers/downloads/DownloadNotification.java b/src/com/android/providers/downloads/DownloadNotification.java index fd62e6f8..4c7cec4e 100644 --- a/src/com/android/providers/downloads/DownloadNotification.java +++ b/src/com/android/providers/downloads/DownloadNotification.java @@ -145,16 +145,23 @@ class DownloadNotification { String packageName = c.getString(ownerColumn); int max = c.getInt(totalBytesColumn); int progress = c.getInt(currentBytesColumn); + long id = c.getLong(idColumn); String title = c.getString(titleColumn); if (title == null || title.length() == 0) { - title = mContext.getResources().getString( - R.string.download_unknown_title); + String filename = c.getString(filenameColumnId); + if (filename == null) { + title = mContext.getResources().getString( + R.string.download_unknown_title); + } else { + title = Downloads.Impl.createTitleFromFilename(mContext, + filename, id); + } } if (mNotifications.containsKey(packageName)) { mNotifications.get(packageName).addItem(title, progress, max); } else { NotificationItem item = new NotificationItem(); - item.mId = c.getInt(idColumn); + item.mId = (int) id; item.mPackageName = packageName; item.mDescription = c.getString(descColumn); String className = c.getString(classOwnerColumn); @@ -256,12 +263,19 @@ class DownloadNotification { Notification n = new Notification(); n.icon = android.R.drawable.stat_sys_download_done; + long id = c.getLong(idColumn); String title = c.getString(titleColumn); if (title == null || title.length() == 0) { - title = mContext.getResources().getString( - R.string.download_unknown_title); + String filename = c.getString(filenameColumnId); + if (filename == null) { + title = mContext.getResources().getString( + R.string.download_unknown_title); + } else { + title = Downloads.Impl.createTitleFromFilename(mContext, + filename, id); + } } - Uri contentUri = Uri.parse(Downloads.Impl.CONTENT_URI + "/" + c.getInt(idColumn)); + Uri contentUri = Uri.parse(Downloads.Impl.CONTENT_URI + "/" + id); String caption; Intent intent; if (Downloads.Impl.isStatusError(c.getInt(statusColumn))) { -- cgit v1.2.3