summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/OpenDownloadReceiver.java
diff options
context:
space:
mode:
authorLeon Scroggins III <scroggo@google.com>2010-09-27 12:32:40 -0400
committerLeon Scroggins III <scroggo@google.com>2010-09-27 17:46:59 -0400
commita682a3ccac02db69bd8708258aae263be4b22e72 (patch)
treee5ccd94da2e15d825d999e6f4ff0293e31c8bdbc /src/com/android/browser/OpenDownloadReceiver.java
parentcc14c8c4da26ff93a96078c7c9108682c23bd1af (diff)
downloadandroid_packages_apps_Gello-a682a3ccac02db69bd8708258aae263be4b22e72.tar.gz
android_packages_apps_Gello-a682a3ccac02db69bd8708258aae263be4b22e72.tar.bz2
android_packages_apps_Gello-a682a3ccac02db69bd8708258aae263be4b22e72.zip
Use the system downloads UI, instead of browser specific 1.
Bug:3034564 Change-Id: Id850854da7db9c1a36500c9eee9debad64bdf97e
Diffstat (limited to 'src/com/android/browser/OpenDownloadReceiver.java')
-rw-r--r--src/com/android/browser/OpenDownloadReceiver.java42
1 files changed, 7 insertions, 35 deletions
diff --git a/src/com/android/browser/OpenDownloadReceiver.java b/src/com/android/browser/OpenDownloadReceiver.java
index 814aa9c7..26bf51ec 100644
--- a/src/com/android/browser/OpenDownloadReceiver.java
+++ b/src/com/android/browser/OpenDownloadReceiver.java
@@ -22,17 +22,18 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
-import android.database.DatabaseUtils;
+import android.net.DownloadManager;
import android.net.Uri;
import android.provider.Downloads;
-import android.provider.MediaStore;
import android.widget.Toast;
import java.io.File;
/**
- * This {@link BroadcastReceiver} handles {@link Intent}s to open and delete
- * files downloaded by the Browser.
+ * This {@link BroadcastReceiver} handles clicks to notifications that
+ * downloads from the browser are in progress/complete. Clicking on an
+ * in-progress or failed download will open the download manager. Clicking on
+ * a complete, successful download will open the file.
*/
public class OpenDownloadReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
@@ -69,44 +70,15 @@ public class OpenDownloadReceiver extends BroadcastReceiver {
}
} else {
// Open the downloads page
- Intent pageView = new Intent(context,
- BrowserDownloadPage.class);
- pageView.setData(data);
+ Intent pageView = new Intent(
+ DownloadManager.ACTION_VIEW_DOWNLOADS);
pageView.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(pageView);
}
- } else if (Intent.ACTION_DELETE.equals(action)) {
- if (deleteFile(cr, filename, mimetype)) {
- cr.delete(data, null, null);
- }
}
}
} finally {
if (cursor != null) cursor.close();
}
}
-
- /**
- * Remove the file from the SD card
- * @param cr ContentResolver used to delete the file.
- * @param filename Name of the file to delete.
- * @param mimetype Mimetype of the file to delete.
- * @return boolean True on success, false on failure.
- */
- private boolean deleteFile(ContentResolver cr, String filename,
- String mimetype) {
- Uri uri;
- if (mimetype.startsWith("image")) {
- uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
- } else if (mimetype.startsWith("audio")) {
- uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
- } else if (mimetype.startsWith("video")) {
- uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
- } else {
- uri = null;
- }
- return (uri != null && cr.delete(uri, MediaStore.MediaColumns.DATA
- + " = " + DatabaseUtils.sqlEscapeString(filename), null) > 0)
- || new File(filename).delete();
- }
}