Chromium Code Reviews| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 protected int mSmallIconId; | 116 protected int mSmallIconId; |
| 117 protected Bitmap mSmallIconBitmap; | 117 protected Bitmap mSmallIconBitmap; |
| 118 protected PendingIntent mContentIntent; | 118 protected PendingIntent mContentIntent; |
| 119 protected PendingIntent mDeleteIntent; | 119 protected PendingIntent mDeleteIntent; |
| 120 protected List<Action> mActions = new ArrayList<>(MAX_AUTHOR_PROVIDED_ACTION _BUTTONS); | 120 protected List<Action> mActions = new ArrayList<>(MAX_AUTHOR_PROVIDED_ACTION _BUTTONS); |
| 121 protected Action mSettingsAction; | 121 protected Action mSettingsAction; |
| 122 protected int mDefaults = Notification.DEFAULT_ALL; | 122 protected int mDefaults = Notification.DEFAULT_ALL; |
| 123 protected long[] mVibratePattern; | 123 protected long[] mVibratePattern; |
| 124 protected long mTimestamp; | 124 protected long mTimestamp; |
| 125 protected boolean mRenotify; | 125 protected boolean mRenotify; |
| 126 protected int mPriority; | |
| 127 private Bitmap mLargeIcon; | |
| 128 protected final String mChannelId; | |
| 126 | 129 |
| 127 private Bitmap mLargeIcon; | 130 public NotificationBuilderBase( |
| 128 | 131 Resources resources, @ChannelDefinitions.ChannelId String channelId) { |
| 129 public NotificationBuilderBase(Resources resources) { | |
| 130 mLargeIconWidthPx = | 132 mLargeIconWidthPx = |
| 131 resources.getDimensionPixelSize(android.R.dimen.notification_lar ge_icon_width); | 133 resources.getDimensionPixelSize(android.R.dimen.notification_lar ge_icon_width); |
| 132 mLargeIconHeightPx = | 134 mLargeIconHeightPx = |
| 133 resources.getDimensionPixelSize(android.R.dimen.notification_lar ge_icon_height); | 135 resources.getDimensionPixelSize(android.R.dimen.notification_lar ge_icon_height); |
| 134 mIconGenerator = createIconGenerator(resources); | 136 mIconGenerator = createIconGenerator(resources); |
| 137 mChannelId = channelId; | |
| 135 } | 138 } |
| 136 | 139 |
| 137 /** | 140 /** |
| 138 * Combines all of the options that have been set and returns a new Notifica tion object. | 141 * Combines all of the options that have been set and returns a new Notifica tion object. |
| 139 */ | 142 */ |
| 140 public abstract Notification build(); | 143 public abstract Notification build(); |
| 141 | 144 |
| 142 /** | 145 /** |
| 143 * Sets the title text of the notification. | 146 * Sets the title text of the notification. |
| 144 */ | 147 */ |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 | 296 |
| 294 /** | 297 /** |
| 295 * Sets the vibration pattern to use. | 298 * Sets the vibration pattern to use. |
| 296 */ | 299 */ |
| 297 public NotificationBuilderBase setVibrate(long[] pattern) { | 300 public NotificationBuilderBase setVibrate(long[] pattern) { |
| 298 mVibratePattern = Arrays.copyOf(pattern, pattern.length); | 301 mVibratePattern = Arrays.copyOf(pattern, pattern.length); |
| 299 return this; | 302 return this; |
| 300 } | 303 } |
| 301 | 304 |
| 302 /** | 305 /** |
| 306 * Sets the priority of the notification (if set to private, overrides \setD efaults| and | |
|
Yaron
2017/05/24 18:08:29
will fix comment
| |
| 307 * |setVibrate|) | |
| 308 */ | |
| 309 public NotificationBuilderBase setPriority(int priority) { | |
| 310 mPriority = priority; | |
| 311 return this; | |
| 312 } | |
| 313 | |
| 314 /** | |
| 303 * Sets the timestamp at which the event of the notification took place. | 315 * Sets the timestamp at which the event of the notification took place. |
| 304 */ | 316 */ |
| 305 public NotificationBuilderBase setTimestamp(long timestamp) { | 317 public NotificationBuilderBase setTimestamp(long timestamp) { |
| 306 mTimestamp = timestamp; | 318 mTimestamp = timestamp; |
| 307 return this; | 319 return this; |
| 308 } | 320 } |
| 309 | 321 |
| 310 /** | 322 /** |
| 311 * Sets the behavior for when the notification is replaced. | 323 * Sets the behavior for when the notification is replaced. |
| 312 */ | 324 */ |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 485 int largeIconWidthPx = | 497 int largeIconWidthPx = |
| 486 resources.getDimensionPixelSize(android.R.dimen.notification_lar ge_icon_width); | 498 resources.getDimensionPixelSize(android.R.dimen.notification_lar ge_icon_width); |
| 487 int largeIconHeightPx = | 499 int largeIconHeightPx = |
| 488 resources.getDimensionPixelSize(android.R.dimen.notification_lar ge_icon_height); | 500 resources.getDimensionPixelSize(android.R.dimen.notification_lar ge_icon_height); |
| 489 float density = resources.getDisplayMetrics().density; | 501 float density = resources.getDisplayMetrics().density; |
| 490 int cornerRadiusPx = Math.min(largeIconWidthPx, largeIconHeightPx) / 2; | 502 int cornerRadiusPx = Math.min(largeIconWidthPx, largeIconHeightPx) / 2; |
| 491 return new RoundedIconGenerator(largeIconWidthPx, largeIconHeightPx, cor nerRadiusPx, | 503 return new RoundedIconGenerator(largeIconWidthPx, largeIconHeightPx, cor nerRadiusPx, |
| 492 NOTIFICATION_ICON_BG_COLOR, NOTIFICATION_ICON_TEXT_SIZE_DP * den sity); | 504 NOTIFICATION_ICON_BG_COLOR, NOTIFICATION_ICON_TEXT_SIZE_DP * den sity); |
| 493 } | 505 } |
| 494 } | 506 } |
| OLD | NEW |