Bug 528544: When there are no downloads, downloads manager looks odd [r=gavin.sharp]
authorMark Finkle <mfinkle@mozilla.com>
Wed, 18 Nov 2009 15:42:19 -0500
changeset 65817 beb5315258324fc4d72b3f9d35b570880ddd719e
parent 65816 578e5ab8342fd7289eb3d0b4344653f7f85d3f69
child 65818 2bda136861dd17f8297f4bd3554559ddf84aa7ec
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)
reviewersgavin
bugs528544
Bug 528544: When there are no downloads, downloads manager looks odd [r=gavin.sharp]
mobile/chrome/content/downloads.js
mobile/locales/en-US/chrome/browser.properties
mobile/themes/hildon/browser.css
mobile/themes/wince/browser.css
--- a/mobile/chrome/content/downloads.js
+++ b/mobile/chrome/content/downloads.js
@@ -103,16 +103,24 @@ var DownloadsView = {
   },
 
   _clearList: function dv__clearList() {
     // Clear the list by replacing with a shallow copy
     let empty = this._list.cloneNode(false);
     this._list.parentNode.replaceChild(empty, this._list);
     this._list = empty;
   },
+  
+  _ifEmptyShowMessage: function dv__ifEmptyShowMessage() {
+    if (this._list.itemCount == 0) {
+      let strings = document.getElementById("bundle_browser");
+      let emptyItem = this._list.appendItem(strings.getString("downloadsEmpty"));
+      emptyItem.id = "dl-empty-message";
+    }
+  },
 
   get visible() {
     let panel = document.getElementById("panel-container");
     let items = document.getElementById("panel-items");
     if (panel.hidden == false && items.selectedPanel.id == "downloads-container")
       return true;
     return false;
   },
@@ -180,16 +188,19 @@ var DownloadsView = {
       self._list.selectedIndex = 0;
     }, 0);
   },
 
   _stepDownloads: function dv__stepDownloads(aNumItems) {
     try {
       // If we're done adding all items, we can quit
       if (!this._stmt.executeStep()) {
+        // Show empty message if needed
+        this._ifEmptyShowMessage();
+        
         // Send a notification that we finished, but wait for clear list to update
         setTimeout(function() {
           let os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
           os.notifyObservers(window, "download-manager-ui-done", null);
         }, 0);
         return;
       }
 
@@ -248,16 +259,21 @@ var DownloadsView = {
       state: aDownload.state,
       progress: aDownload.percentComplete,
       startTime: Math.round(aDownload.startTime / 1000),
       endTime: Date.now(),
       currBytes: aDownload.amountTransferred,
       maxBytes: aDownload.size
     };
 
+    // Remove the "no downloads" item, if visible
+    let emptyItem = document.getElementById("dl-empty-message");
+    if (emptyItem)
+      this._list.removeChild(emptyItem);
+      
     // Make the item and add it to the beginning
     let item = this._createItem(attrs);
     this._list.insertBefore(item, this._list.firstChild);
   },
 
   downloadCompleted: function dv_downloadCompleted(aDownload) {
     // Move the download below active
     let element = this.getElementForDownload(aDownload.id);
@@ -392,16 +408,19 @@ var DownloadsView = {
         this.getDownloads();
         return;
       }
 
       // Otherwise, remove a single download
       let id = aSubject.QueryInterface(Ci.nsISupportsPRUint32);
       let element = this.getElementForDownload(id.data);
       this._removeItem(element);
+
+      // Show empty message if needed
+      this._ifEmptyShowMessage();
     }
     else {
       // We only show alerts if the download view is not visible
       if (this.visible)
         return;
 
       let download = aSubject.QueryInterface(Ci.nsIDownload);
       let strings = document.getElementById("bundle_browser");
--- a/mobile/locales/en-US/chrome/browser.properties
+++ b/mobile/locales/en-US/chrome/browser.properties
@@ -31,16 +31,17 @@ addonUpdate.error=An error occurred
 # #1 download size for FINISHED or download state; #2 host (e.g., eTLD + 1, IP)
 downloadsStatus=#1 — #2
 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
 
 # Alerts
 alertAddons=Add-ons
 alertAddonsInstalling=Installing add-on
 alertAddonsInstalled=Installation complete. Restart required.
 alertAddonsFail=Installation failed
 
 # LOCALIZATION NOTE (alertAddonsDisabled): Semi-colon list of plural forms.
--- a/mobile/themes/hildon/browser.css
+++ b/mobile/themes/hildon/browser.css
@@ -409,16 +409,33 @@ toolbarbutton.page-button {
   -moz-image-region: rect(90px 78px 108px 0px);
 }
 
 /* downloads panel UI   ---------------------------------------------------- */
 .download-retry-failed {
   color: red !important;
 }
 
+/* special "no downloads" items */
+#dl-empty-message {
+  margin-top: 12mm; /* 2 times row height */
+  font-style: italic;
+  border-bottom: none;
+}
+
+#dl-empty-message:active {
+  background-color: white;
+}
+
+#dl-empty-message > label {
+  text-align: center;
+  color: grey;
+}
+
+
 /* console panel UI   ------------------------------------------------------ */
 @media (orientation: landscape) {
   #console-filter-warnings,
   #console-filter-messages {
     visibility: visible;
   }
 }
 
--- a/mobile/themes/wince/browser.css
+++ b/mobile/themes/wince/browser.css
@@ -193,16 +193,32 @@ toolbarbutton.page-button {
   color: #aaa !important;
 }
 
 /* downloads panel UI   ---------------------------------------------------- */
 .download-retry-failed {
   color: red !important;
 }
 
+/* special "no downloads" items */
+#dl-empty-message {
+  margin-top: 12mm; /* 2 times row height */
+  font-style: italic;
+  border-bottom: none;
+}
+
+#dl-empty-message:active {
+  background-color: white;
+}
+
+#dl-empty-message > label {
+  text-align: center;
+  color: grey;
+}
+
 /* console panel UI   ------------------------------------------------------ */
 @media (orientation: landscape) {
   #console-filter-warnings,
   #console-filter-messages {
     visibility: visible;
   }
 }