Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2498)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java

Issue 1054573002: Implement support for notification.vibrate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
index 476649c033582edc57650aacd2cff7e3363ef4ee..22e5f2d1be48d7a1397e34f68f81b9a5b39b1439 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
@@ -303,11 +303,13 @@ public class NotificationUIManager {
* text by the Android notification system.
* @param icon Icon to be displayed in the notification. When this isn't a valid Bitmap, a
* default icon will be generated instead.
+ * @param vibrate Vibrate pettern for notification. Pass in an array of ints that are the
Peter Beverloo 2015/04/21 17:58:22 Can we keep this vague ("Vibration pattern for the
Sanghyun Park 2015/04/23 11:08:25 Okay, I'll double-check about this comment.
+ * durations for which to turn on or off the vibrator in milliseconds.
* @param silent Whether the default sound, vibration and lights should be suppressed.
*/
@CalledByNative
private void displayNotification(long persistentNotificationId, String origin, String tag,
- String title, String body, Bitmap icon, boolean silent) {
+ String title, String body, Bitmap icon, long[] vibrate, boolean silent) {
if (icon == null || icon.getWidth() == 0) {
icon = getIconGenerator().generateIconForUrl(origin, true);
}
@@ -349,7 +351,16 @@ public class NotificationUIManager {
// Use the system's default ringtone, vibration and indicator lights unless the notification
// has been marked as being silent, for example because it's low priority.
- if (!silent) notificationBuilder.setDefaults(Notification.DEFAULT_ALL);
+ // If vibrate is presented and silent set false, notification should use developer's
Peter Beverloo 2015/04/21 17:58:22 We should assert for vibration to be empty here wh
Sanghyun Park 2015/04/23 11:08:25 I agree your opinion. I'll add assert check.
+ // vibrate value.
Peter Beverloo 2015/04/21 17:58:22 "If a vibration pattern is set, the notification s
Sanghyun Park 2015/04/23 11:08:25 Done.
+ if (!silent) {
+ int defaults = Notification.DEFAULT_ALL;
+ if (vibrate.length > 0) {
+ defaults &= ~Notification.DEFAULT_VIBRATE;
+ notificationBuilder.setVibrate(vibrate);
+ }
+ notificationBuilder.setDefaults(defaults);
+ }
String platformTag = makePlatformTag(persistentNotificationId, origin, tag);
mNotificationManager.notify(platformTag, PLATFORM_ID, notificationBuilder.build());

Powered by Google App Engine
This is Rietveld 408576698