diff options
| -rw-r--r-- | api/current.xml | 13 | ||||
| -rw-r--r-- | core/java/android/app/DownloadManager.java | 17 | ||||
| -rw-r--r-- | core/java/android/provider/Downloads.java | 11 |
3 files changed, 39 insertions, 2 deletions
diff --git a/api/current.xml b/api/current.xml index fad598b4fba6..f44da4750c92 100644 --- a/api/current.xml +++ b/api/current.xml @@ -28829,6 +28829,8 @@ </parameter> <parameter name="length" type="long"> </parameter> +<parameter name="showNotification" type="boolean"> +</parameter> </method> <method name="enqueue" return="long" @@ -29635,6 +29637,17 @@ visibility="public" > </field> +<field name="VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION" + type="int" + transient="false" + volatile="false" + value="3" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> </class> <class name="ExpandableListActivity" extends="android.app.Activity" diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java index e82bad70d3b0..178567fdd881 100644 --- a/core/java/android/app/DownloadManager.java +++ b/core/java/android/app/DownloadManager.java @@ -373,8 +373,17 @@ public class DownloadManager { */ public static final int VISIBILITY_HIDDEN = 2; + /** + * This download shows in the notifications after completion ONLY. + * It is usuable only with + * {@link DownloadManager#completedDownload(String, String, boolean, String, + * String, long, boolean)}. + */ + public static final int VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION = 3; + /** can take any of the following values: {@link #VISIBILITY_HIDDEN} - * {@link #VISIBILITY_VISIBLE_NOTIFY_COMPLETED}, {@link #VISIBILITY_VISIBLE} + * {@link #VISIBILITY_VISIBLE_NOTIFY_COMPLETED}, {@link #VISIBILITY_VISIBLE}, + * {@link #VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION} */ private int mNotificationVisibility = VISIBILITY_VISIBLE; @@ -1098,11 +1107,13 @@ public class DownloadManager { * be managed by the Downloads App and any other app that is used to read it (for example, * Gallery app to display the file, if the file contents represent a video/image). * @param length length of the downloaded file + * @param showNotification true if a notification is to be sent, false otherwise * @return an ID for the download entry added to the downloads app, unique across the system * This ID is used to make future calls related to this download. */ public long completedDownload(String title, String description, - boolean isMediaScannerScannable, String mimeType, String path, long length) { + boolean isMediaScannerScannable, String mimeType, String path, long length, + boolean showNotification) { // make sure the input args are non-null/non-zero validateArgumentIsNonEmpty("title", title); validateArgumentIsNonEmpty("description", description); @@ -1126,6 +1137,8 @@ public class DownloadManager { values.put(Downloads.Impl.COLUMN_MEDIA_SCANNED, (isMediaScannerScannable) ? Request.SCANNABLE_VALUE_YES : Request.SCANNABLE_VALUE_NO); + values.put(Downloads.Impl.COLUMN_VISIBILITY, (showNotification) ? + Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION : Request.VISIBILITY_HIDDEN); Uri downloadUri = mResolver.insert(Downloads.Impl.CONTENT_URI, values); if (downloadUri == null) { return -1; diff --git a/core/java/android/provider/Downloads.java b/core/java/android/provider/Downloads.java index 16990a522466..3c4bb793b926 100644 --- a/core/java/android/provider/Downloads.java +++ b/core/java/android/provider/Downloads.java @@ -528,6 +528,17 @@ public final class Downloads { } /** + * this method determines if a notification should be displayed for a + * given {@link #COLUMN_VISIBILITY} value + * @param visibility the value of {@link #COLUMN_VISIBILITY}. + * @return true if the notification should be displayed. false otherwise. + */ + public static boolean isNotificationToBeDisplayed(int visibility) { + return visibility == DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED || + visibility == DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION; + } + + /** * Returns whether the download has completed (either with success or * error). */ |