Bug 589725 - "Fennec should support showing remain time for download." [r=mark.finkle]
authorZhu, Junmin <junmin.zhu@intel.com>
Sat, 16 Oct 2010 05:03:00 -0400
changeset 66953 f17972b11bb0ff4abb3f38f3dfed4527ec2e4240
parent 66952 c0db687cabe62466c6a50fb2580fd56e38a1040e
child 66954 433a8d03f32e7d15e04b60d4d919f25517d84d16
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmark
bugs589725
Bug 589725 - "Fennec should support showing remain time for download." [r=mark.finkle]
mobile/chrome/content/downloads.js
mobile/locales/en-US/chrome/browser.properties
--- a/mobile/chrome/content/downloads.js
+++ b/mobile/chrome/content/downloads.js
@@ -308,17 +308,30 @@ var DownloadsView = {
     }
 
     // Insert 1 is the download size
     status = this._replaceInsert(strings.getString("downloadsStatus"), 1, sizeText);
 
     // Insert 2 is the eTLD + 1 or other variations of the host
     let [displayHost, fullHost] = DownloadUtils.getURIHost(this._getReferrerOrSource(aItem));
     status = this._replaceInsert(status, 2, displayHost);
+  
+    // Insert 3 is the left time if download status is DOWNLOADING
+    let currstate = Number(aItem.getAttribute("state"));
+    if (currstate == Ci.nsIDownloadManager.DOWNLOAD_DOWNLOADING) {
+      let downloadSize = Number(aItem.getAttribute("currBytes"));
+      let passedTime = (Date.now() - aItem.getAttribute("startTime"))/1000;
+      let totalTime = (passedTime / downloadSize) * fileSize;
+      let leftTime = totalTime - passedTime;
+      let [time, lastTime] = DownloadUtils.getTimeLeft(leftTime);
 
+      let stringTime = this._replaceInsert(strings.getString("downloadsTime"), 1, time);
+      status = status + " " + stringTime;
+    } 
+      
     aItem.setAttribute("status", status);
   },
 
   _updateTime: function dv__updateTime(aItem) {
     // Don't bother updating for things that aren't finished
     if (aItem.inProgress)
       return;
 
--- a/mobile/locales/en-US/chrome/browser.properties
+++ b/mobile/locales/en-US/chrome/browser.properties
@@ -66,16 +66,18 @@ addonLocalError-3=This add-on could not 
 addonLocalError-4=#1 could not be installed because #3 cannot modify the needed file.
 addonErrorIncompatible=#1 could not be installed because it is not compatible with #3 #4.
 addonErrorBlocklisted=#1 could not be installed because it has a high risk of causing stability or security problems.
 
 # Download Manager
 # LOCALIZATION NOTE (Status): — is the "em dash" (long dash)
 # #1 download size for FINISHED or download state; #2 host (e.g., eTLD + 1, IP)
 downloadsStatus=#1 — #2
+# LOCALIZATION NOTE (Time): #1 left time for UNFINISHED, total time for FINISHED
+downloadsTime= — #1
 downloadsUnknownSize=Unknown size
 # LOCALIZATION NOTE (KnownSize): #1 size number; #2 size unit
 downloadsKnownSize=#1 #2
 donwloadsYesterday=Yesterday
 # LOCALIZATION NOTE (MonthDate): #1 month name; #2 date number; e.g., January 22
 downloadsMonthDate=#1 #2
 downloadsEmpty=No downloads
 downloadsDeleteTitle=Delete File