Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java

Issue 2716013003: Fixes to enable indication of bytes downloaded for Offline Pages in Download Home. (Closed)
Patch Set: more Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java
index db02e0f0c038481d0cf9e81fc425b7564cd33ff7..99fdffba5db57d8cae36636436afaea03c53a03d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java
@@ -417,6 +417,10 @@ public abstract class DownloadHistoryItemWrapper extends TimedItem {
/** Wraps a {@link OfflinePageDownloadItem}. */
public static class OfflinePageItemWrapper extends DownloadHistoryItemWrapper {
+ /** Strings indicating how many bytes have been downloaded for different units. */
+ static final int[] BYTES_DOWNLOADED_STRINGS = {R.string.file_size_downloaded_kb,
Theresa 2017/02/27 16:01:52 Can you use the string array in DownloadUtils rath
Dmitry Titov 2017/02/27 20:02:17 Done. Had to make it public which brings more OWNE
+ R.string.file_size_downloaded_mb, R.string.file_size_downloaded_gb};
+
private OfflinePageDownloadItem mItem;
OfflinePageItemWrapper(OfflinePageDownloadItem item, BackendProvider provider,
@@ -460,8 +464,7 @@ public abstract class DownloadHistoryItemWrapper extends TimedItem {
public String getDisplayFileName() {
String title = mItem.getTitle();
if (TextUtils.isEmpty(title)) {
- File path = new File(getFilePath());
- return path.getName();
+ return getDisplayHostname();
} else {
return title;
}
@@ -484,7 +487,7 @@ public abstract class DownloadHistoryItemWrapper extends TimedItem {
@Override
public String getMimeType() {
- return "text/plain";
+ return "text/html";
}
@Override
@@ -506,7 +509,28 @@ public abstract class DownloadHistoryItemWrapper extends TimedItem {
@Override
public String getStatusString() {
Context context = ContextUtils.getApplicationContext();
- return context.getString(R.string.download_notification_completed);
+
+ int state = mItem.getDownloadState();
+
+ if (state == org.chromium.components.offlinepages.downloads.DownloadState.COMPLETE) {
+ return context.getString(R.string.download_notification_completed);
+ }
+
+ if (state == org.chromium.components.offlinepages.downloads.DownloadState.PENDING) {
+ return context.getString(R.string.download_notification_pending);
+ }
+
+ if (state == org.chromium.components.offlinepages.downloads.DownloadState.PAUSED) {
+ return context.getString(R.string.download_notification_paused);
+ }
+
+ long bytesReceived = mItem.getDownloadProgressBytes();
+ if (bytesReceived == 0) {
+ return context.getString(R.string.download_started);
+ } else {
+ return DownloadUtils.getStringForBytes(
+ context, BYTES_DOWNLOADED_STRINGS, bytesReceived);
+ }
}
@Override

Powered by Google App Engine
This is Rietveld 408576698