OSDN Git Service

Remove the option to clear all downloads.
authorLeon Scroggins <scroggo@google.com>
Thu, 21 Jan 2010 15:05:59 +0000 (10:05 -0500)
committerLeon Scroggins <scroggo@google.com>
Thu, 21 Jan 2010 17:48:51 +0000 (12:48 -0500)
Clearing all downloads would remove completed downloads from the
list, while leaving them on the SD card, and there would not
necessarily be a way to delete them using the phone.

res/menu/downloadhistory.xml
src/com/android/browser/BrowserDownloadPage.java

index ee3b751..195b0db 100644 (file)
@@ -16,9 +16,6 @@
 
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <item android:id="@+id/download_menu_clear_all"
-        android:title="@string/download_menu_clear_all" 
-        android:icon="@*android:drawable/ic_menu_clear_playlist" />
     <item android:id="@+id/download_menu_cancel_all"
         android:title="@string/download_menu_cancel_all" 
         android:icon="@android:drawable/ic_menu_close_clear_cancel" />
index 3483c30..a2b144b 100644 (file)
@@ -122,9 +122,6 @@ public class BrowserDownloadPage extends ExpandableListActivity {
     public boolean onPrepareOptionsMenu(Menu menu) {
         boolean showCancel = getCancelableCount() > 0;
         menu.findItem(R.id.download_menu_cancel_all).setEnabled(showCancel);
-        
-        boolean showClear = getClearableCount() > 0;
-        menu.findItem(R.id.download_menu_clear_all).setEnabled(showClear);
         return super.onPrepareOptionsMenu(menu);
     }
     
@@ -134,10 +131,6 @@ public class BrowserDownloadPage extends ExpandableListActivity {
             case R.id.download_menu_cancel_all:
                 promptCancelAll();
                 return true;
-                
-            case R.id.download_menu_clear_all:
-                promptClearList();
-                return true;
         }
         return false;
     }
@@ -300,25 +293,6 @@ public class BrowserDownloadPage extends ExpandableListActivity {
     }
     
     /**
-     * Prompt the user if they would like to clear the download history
-     */
-    private void promptClearList() {
-        new AlertDialog.Builder(this)
-               .setTitle(R.string.download_clear_dlg_title)
-               .setIcon(R.drawable.ssl_icon)
-               .setMessage(R.string.download_clear_dlg_msg)
-               .setPositiveButton(R.string.ok, 
-                       new DialogInterface.OnClickListener() {
-                           public void onClick(DialogInterface dialog, 
-                                   int whichButton) {
-                               clearAllDownloads();
-                           }
-                       })
-                .setNegativeButton(R.string.cancel, null)
-                .show();
-    }
-    
-    /**
      * Return the number of items in the list that can be canceled.
      * @return count
      */
@@ -416,38 +390,7 @@ public class BrowserDownloadPage extends ExpandableListActivity {
         }
         return count;
     }
-    
-    /**
-     * Clear all stopped downloads, ie canceled (though should not be
-     * there), error and success download items.
-     */
-    private void clearAllDownloads() {
-        if (mDownloadCursor.moveToFirst()) {
-            StringBuilder where = new StringBuilder();
-            boolean firstTime = true;
-            while (!mDownloadCursor.isAfterLast()) {
-                int status = mDownloadCursor.getInt(mStatusColumnId);
-                if (Downloads.Impl.isStatusCompleted(status)) {
-                    if (firstTime) {
-                        firstTime = false;
-                    } else {
-                        where.append(" OR ");
-                    }
-                    where.append("( ");
-                    where.append(Downloads.Impl._ID);
-                    where.append(" = '");
-                    where.append(mDownloadCursor.getLong(mIdColumnId));
-                    where.append("' )");
-                }
-                mDownloadCursor.moveToNext();
-            }
-            if (!firstTime) {
-                getContentResolver().delete(Downloads.Impl.CONTENT_URI,
-                        where.toString(), null);
-            }
-        }
-    }
-    
+
     /**
      * Open the content where the download db cursor currently is
      */