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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.notifications; 5 package org.chromium.chrome.browser.notifications;
6 6
7 import android.app.Notification; 7 import android.app.Notification;
8 import android.app.NotificationManager; 8 import android.app.NotificationManager;
9 import android.app.PendingIntent; 9 import android.app.PendingIntent;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 * @param origin Full text of the origin, including the protocol, owning thi s notification. 296 * @param origin Full text of the origin, including the protocol, owning thi s notification.
297 * @param tag A string identifier for this notification. If the tag is not e mpty, the new 297 * @param tag A string identifier for this notification. If the tag is not e mpty, the new
298 * notification will replace the previous notification with the s ame tag and origin, 298 * notification will replace the previous notification with the s ame tag and origin,
299 * if present. If no matching previous notification is present, t he new one will just 299 * if present. If no matching previous notification is present, t he new one will just
300 * be added. 300 * be added.
301 * @param title Title to be displayed in the notification. 301 * @param title Title to be displayed in the notification.
302 * @param body Message to be displayed in the notification. Will be trimmed to one line of 302 * @param body Message to be displayed in the notification. Will be trimmed to one line of
303 * text by the Android notification system. 303 * text by the Android notification system.
304 * @param icon Icon to be displayed in the notification. When this isn't a v alid Bitmap, a 304 * @param icon Icon to be displayed in the notification. When this isn't a v alid Bitmap, a
305 * default icon will be generated instead. 305 * default icon will be generated instead.
306 * @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.
307 * durations for which to turn on or off the vibrator in mill iseconds.
306 * @param silent Whether the default sound, vibration and lights should be s uppressed. 308 * @param silent Whether the default sound, vibration and lights should be s uppressed.
307 */ 309 */
308 @CalledByNative 310 @CalledByNative
309 private void displayNotification(long persistentNotificationId, String origi n, String tag, 311 private void displayNotification(long persistentNotificationId, String origi n, String tag,
310 String title, String body, Bitmap icon, boolean silent) { 312 String title, String body, Bitmap icon, long[] vibrate, boolean sile nt) {
311 if (icon == null || icon.getWidth() == 0) { 313 if (icon == null || icon.getWidth() == 0) {
312 icon = getIconGenerator().generateIconForUrl(origin, true); 314 icon = getIconGenerator().generateIconForUrl(origin, true);
313 } 315 }
314 316
315 Resources res = mAppContext.getResources(); 317 Resources res = mAppContext.getResources();
316 318
317 // The data used to make each intent unique according to the rules of In tent#filterEquals. 319 // The data used to make each intent unique according to the rules of In tent#filterEquals.
318 // Without this, the pending intents derived from them may be reused, be cause extras are 320 // Without this, the pending intents derived from them may be reused, be cause extras are
319 // not taken into account for the filterEquals comparison. 321 // not taken into account for the filterEquals comparison.
320 Uri intentData = Uri.parse(origin).buildUpon().fragment( 322 Uri intentData = Uri.parse(origin).buildUpon().fragment(
(...skipping 21 matching lines...) Expand all
342 .setDeleteIntent(getPendingIntent( 344 .setDeleteIntent(getPendingIntent(
343 NotificationConstants.ACTION_CLOSE_NOTIFICATION, 345 NotificationConstants.ACTION_CLOSE_NOTIFICATION,
344 persistentNotificationId, origin, tag, intentData)) 346 persistentNotificationId, origin, tag, intentData))
345 .addAction(R.drawable.settings_cog, 347 .addAction(R.drawable.settings_cog,
346 res.getString(R.string.page_info_site_settings_button ), 348 res.getString(R.string.page_info_site_settings_button ),
347 pendingSettingsIntent) 349 pendingSettingsIntent)
348 .setSubText(origin); 350 .setSubText(origin);
349 351
350 // Use the system's default ringtone, vibration and indicator lights unl ess the notification 352 // Use the system's default ringtone, vibration and indicator lights unl ess the notification
351 // has been marked as being silent, for example because it's low priorit y. 353 // has been marked as being silent, for example because it's low priorit y.
352 if (!silent) notificationBuilder.setDefaults(Notification.DEFAULT_ALL); 354 // 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.
355 // 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.
356 if (!silent) {
357 int defaults = Notification.DEFAULT_ALL;
358 if (vibrate.length > 0) {
359 defaults &= ~Notification.DEFAULT_VIBRATE;
360 notificationBuilder.setVibrate(vibrate);
361 }
362 notificationBuilder.setDefaults(defaults);
363 }
353 364
354 String platformTag = makePlatformTag(persistentNotificationId, origin, t ag); 365 String platformTag = makePlatformTag(persistentNotificationId, origin, t ag);
355 mNotificationManager.notify(platformTag, PLATFORM_ID, notificationBuilde r.build()); 366 mNotificationManager.notify(platformTag, PLATFORM_ID, notificationBuilde r.build());
356 } 367 }
357 368
358 /** 369 /**
359 * Ensures the existance of an icon generator, which is created lazily. 370 * Ensures the existance of an icon generator, which is created lazily.
360 * 371 *
361 * @return The icon generator which can be used. 372 * @return The icon generator which can be used.
362 */ 373 */
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 origin, tag); 447 origin, tag);
437 } 448 }
438 449
439 private static native void nativeInitializeNotificationUIManager(); 450 private static native void nativeInitializeNotificationUIManager();
440 451
441 private native boolean nativeOnNotificationClicked(long nativeNotificationUI ManagerAndroid, 452 private native boolean nativeOnNotificationClicked(long nativeNotificationUI ManagerAndroid,
442 long persistentNotificationId, String origin, String tag); 453 long persistentNotificationId, String origin, String tag);
443 private native boolean nativeOnNotificationClosed(long nativeNotificationUIM anagerAndroid, 454 private native boolean nativeOnNotificationClosed(long nativeNotificationUIM anagerAndroid,
444 long persistentNotificationId, String origin, String tag); 455 long persistentNotificationId, String origin, String tag);
445 } 456 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698