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

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: fix build break 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..ece06d3fd8b62c51712ea965bc650c36a78c3dc6 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
@@ -460,8 +460,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 +483,7 @@ public abstract class DownloadHistoryItemWrapper extends TimedItem {
@Override
public String getMimeType() {
- return "text/plain";
+ return "text/html";
}
@Override
@@ -506,7 +505,27 @@ 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.getStringForDownloadedBytes(context, bytesReceived);
+ }
}
@Override

Powered by Google App Engine
This is Rietveld 408576698