| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 9 import android.app.Notification; | 9 import android.app.Notification; |
| 10 import android.app.PendingIntent; | 10 import android.app.PendingIntent; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 protected int mSmallIconId; | 115 protected int mSmallIconId; |
| 116 protected Bitmap mSmallIconBitmap; | 116 protected Bitmap mSmallIconBitmap; |
| 117 protected PendingIntent mContentIntent; | 117 protected PendingIntent mContentIntent; |
| 118 protected PendingIntent mDeleteIntent; | 118 protected PendingIntent mDeleteIntent; |
| 119 protected List<Action> mActions = new ArrayList<>(MAX_AUTHOR_PROVIDED_ACTION
_BUTTONS); | 119 protected List<Action> mActions = new ArrayList<>(MAX_AUTHOR_PROVIDED_ACTION
_BUTTONS); |
| 120 protected Action mSettingsAction; | 120 protected Action mSettingsAction; |
| 121 protected int mDefaults = Notification.DEFAULT_ALL; | 121 protected int mDefaults = Notification.DEFAULT_ALL; |
| 122 protected long[] mVibratePattern; | 122 protected long[] mVibratePattern; |
| 123 protected long mTimestamp; | 123 protected long mTimestamp; |
| 124 protected boolean mRenotify; | 124 protected boolean mRenotify; |
| 125 | 125 protected int mVisibility; |
| 126 private Bitmap mLargeIcon; | 126 private Bitmap mLargeIcon; |
| 127 | 127 |
| 128 public NotificationBuilderBase(Resources resources) { | 128 public NotificationBuilderBase(Resources resources) { |
| 129 mLargeIconWidthPx = | 129 mLargeIconWidthPx = |
| 130 resources.getDimensionPixelSize(android.R.dimen.notification_lar
ge_icon_width); | 130 resources.getDimensionPixelSize(android.R.dimen.notification_lar
ge_icon_width); |
| 131 mLargeIconHeightPx = | 131 mLargeIconHeightPx = |
| 132 resources.getDimensionPixelSize(android.R.dimen.notification_lar
ge_icon_height); | 132 resources.getDimensionPixelSize(android.R.dimen.notification_lar
ge_icon_height); |
| 133 mIconGenerator = createIconGenerator(resources); | 133 mIconGenerator = createIconGenerator(resources); |
| 134 } | 134 } |
| 135 | 135 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 292 |
| 293 /** | 293 /** |
| 294 * Sets the vibration pattern to use. | 294 * Sets the vibration pattern to use. |
| 295 */ | 295 */ |
| 296 public NotificationBuilderBase setVibrate(long[] pattern) { | 296 public NotificationBuilderBase setVibrate(long[] pattern) { |
| 297 mVibratePattern = Arrays.copyOf(pattern, pattern.length); | 297 mVibratePattern = Arrays.copyOf(pattern, pattern.length); |
| 298 return this; | 298 return this; |
| 299 } | 299 } |
| 300 | 300 |
| 301 /** | 301 /** |
| 302 * Sets the visibility of the notification (if set to private, overrides \se
tDefaults| and |
| 303 * |setVibrate|) |
| 304 */ |
| 305 public NotificationBuilderBase setVisibility(int visibility) { |
| 306 mVisibility = visibility; |
| 307 return this; |
| 308 } |
| 309 |
| 310 /** |
| 302 * Sets the timestamp at which the event of the notification took place. | 311 * Sets the timestamp at which the event of the notification took place. |
| 303 */ | 312 */ |
| 304 public NotificationBuilderBase setTimestamp(long timestamp) { | 313 public NotificationBuilderBase setTimestamp(long timestamp) { |
| 305 mTimestamp = timestamp; | 314 mTimestamp = timestamp; |
| 306 return this; | 315 return this; |
| 307 } | 316 } |
| 308 | 317 |
| 309 /** | 318 /** |
| 310 * Sets the behavior for when the notification is replaced. | 319 * Sets the behavior for when the notification is replaced. |
| 311 */ | 320 */ |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 int largeIconWidthPx = | 491 int largeIconWidthPx = |
| 483 resources.getDimensionPixelSize(android.R.dimen.notification_lar
ge_icon_width); | 492 resources.getDimensionPixelSize(android.R.dimen.notification_lar
ge_icon_width); |
| 484 int largeIconHeightPx = | 493 int largeIconHeightPx = |
| 485 resources.getDimensionPixelSize(android.R.dimen.notification_lar
ge_icon_height); | 494 resources.getDimensionPixelSize(android.R.dimen.notification_lar
ge_icon_height); |
| 486 float density = resources.getDisplayMetrics().density; | 495 float density = resources.getDisplayMetrics().density; |
| 487 int cornerRadiusPx = Math.min(largeIconWidthPx, largeIconHeightPx) / 2; | 496 int cornerRadiusPx = Math.min(largeIconWidthPx, largeIconHeightPx) / 2; |
| 488 return new RoundedIconGenerator(largeIconWidthPx, largeIconHeightPx, cor
nerRadiusPx, | 497 return new RoundedIconGenerator(largeIconWidthPx, largeIconHeightPx, cor
nerRadiusPx, |
| 489 NOTIFICATION_ICON_BG_COLOR, NOTIFICATION_ICON_TEXT_SIZE_DP * den
sity); | 498 NOTIFICATION_ICON_BG_COLOR, NOTIFICATION_ICON_TEXT_SIZE_DP * den
sity); |
| 490 } | 499 } |
| 491 } | 500 } |
| OLD | NEW |