public class WonderPushChannel
extends java.lang.Object
implements java.lang.Cloneable
BETA - This API is marked beta and may change without prior notice to reflect any changes made to the Android O APIs.
This class mimicks the android.app.android.app.NotificationChannel
class to permit
exposing its benefits to devices prior to Android O.
Contrary to the latter, this class permits to override only a few aspects of the notification.
It also contains some additions that may no longer be available under Android O where the user
is in full control of these settings, such as preventing a notification that usually makes a
sound or vibrates to vibrate while the device is in silent mode.
Some feature like the color should remain configurable using this class under Android O.
android.app.android.app.NotificationChannel
Constructor and Description |
---|
WonderPushChannel(java.lang.String id,
java.lang.String groupId)
Create a notification channel.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone() |
boolean |
equals(java.lang.Object o) |
java.lang.Integer |
getColor()
Returns the color to impose on all notifications posted to this channel.
|
java.lang.String |
getDescription()
Returns the user visible description of this channel.
|
java.lang.String |
getGroupId()
Returns what group this channel belongs to.
|
java.lang.String |
getId()
Returns the id of this channel.
|
java.lang.Integer |
getImportance()
Returns the user specified importance for notifications posted to this channel.
|
java.lang.Integer |
getLightColor()
Sets the notification light color for notifications posted to this channel,
if lights are enabled on this channel and the device supports that feature.
|
java.lang.Boolean |
getLights()
Returns whether notifications posted to this channel trigger notification lights.
|
java.lang.Boolean |
getLocalOnly()
Returns whether notifications posted to this channel should be local to this device.
|
java.lang.Integer |
getLockscreenVisibility()
Returns whether or not notifications posted to this channel are shown on the lockscreen in full or redacted form.
|
java.lang.String |
getName()
Returns the user visible name of this channel.
|
java.lang.Boolean |
getSound()
Returns whether a sound should be played for notifications posted to this channel.
|
android.net.Uri |
getSoundUri()
Returns the notification sound for this channel.
|
java.lang.Boolean |
getVibrate()
Returns whether notifications posted to this channel always vibrate.
|
java.lang.Boolean |
getVibrateInSilentMode()
Returns whether notifications posted to this channel vibrate if the device is in silent mode.
|
long[] |
getVibrationPattern()
Returns the vibration pattern for notifications posted to this channel.
|
int |
hashCode() |
WonderPushChannel |
setColor(java.lang.Integer color)
Sets the color to impose on all notifications posted to this channel.
|
WonderPushChannel |
setDescription(java.lang.String description)
Sets the user visible description of this channel.
|
WonderPushChannel |
setImportance(java.lang.Integer importance)
Sets the level of interruption of this notification channel.
|
WonderPushChannel |
setLightColor(java.lang.Integer lightColor)
Returns the notification light color for notifications posted to this channel.
|
WonderPushChannel |
setLights(java.lang.Boolean lights)
Sets whether notifications posted to this channel should display notification lights, on devices that support that feature.
|
WonderPushChannel |
setLocalOnly(java.lang.Boolean localOnly)
Sets whether notifications posted to this channel should be local to this device.
|
WonderPushChannel |
setLockscreenVisibility(java.lang.Integer lockscreenVisibility)
Sets whether notifications posted to this channel appear on the lockscreen or not, and if so, whether they appear in a redacted form.
|
WonderPushChannel |
setName(java.lang.String name)
Sets the user visible name of this channel.
|
WonderPushChannel |
setSound(java.lang.Boolean sound)
Sets whether a sound should be played for notifications posted to this channel.
|
WonderPushChannel |
setSoundUri(android.net.Uri soundUri)
Sets the sound that should be played for notifications posted to this channel and its audio attributes.
|
WonderPushChannel |
setVibrate(java.lang.Boolean vibrate)
Sets whether notification posted to this channel should vibrate.
|
WonderPushChannel |
setVibrateInSilentMode(java.lang.Boolean vibrateInSilentMode)
Sets whether notifications posted to this channel vibrate if the device is in silent mode.
|
WonderPushChannel |
setVibrationPattern(long[] vibrationPattern)
Sets the vibration pattern for notifications posted to this channel.
|
java.lang.String |
toString() |
public WonderPushChannel(@NonNull java.lang.String id, java.lang.String groupId)
id
- The id of the channel. Must be unique per package. The value may be truncated if it is too long.groupId
- The id of a channel group. You should create the group prior to creating this channel.android.app.NotificationChannel#NotificationChannel(java.lang.String, java.lang.CharSequence, int)
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getId()
android.app.NotificationChannel#getId()
public java.lang.String getGroupId()
null
.android.app.NotificationChannel#setGroup(String)
public java.lang.String getName()
android.app.NotificationChannel#getName()
public WonderPushChannel setName(java.lang.String name)
name
- The user visible name of this channel.android.app.NotificationChannel#setName(CharSequence)
public java.lang.String getDescription()
android.app.NotificationChannel#getDescription()
public WonderPushChannel setDescription(java.lang.String description)
description
- The user visible description of this channel.android.app.NotificationChannel#setDescription(String)
public java.lang.Integer getImportance()
NotificationManager.IMPORTANCE_DEFAULT
null
if this setting does not override the received notifications setting.android.app.NotificationChannel#getImportance()
public WonderPushChannel setImportance(java.lang.Integer importance)
NotificationManager.IMPORTANCE_DEFAULT
importance
- The level of interruption of this notification channel.
Use null
to not override the received notifications setting.android.app.NotificationChannel#setImportance(int)
public java.lang.Boolean getLights()
null
if this setting does not override the received notifications setting.android.app.NotificationChannel#shouldShowLights()
public WonderPushChannel setLights(java.lang.Boolean lights)
lights
- Whether notifications posted to this channel should display notification lights
Use null
to not override the received notifications setting.android.app.NotificationChannel#enableLights(boolean)
public java.lang.Boolean getVibrate()
null
if this setting does not override the received notifications setting.android.app.NotificationChannel#shouldVibrate()
public WonderPushChannel setVibrate(java.lang.Boolean vibrate)
setVibrationPattern(long[])
.vibrate
- Whether notification posted to this channel should vibrate.
Use null
to not override the received notifications setting.android.app.NotificationChannel#enableVibration(boolean)
public long[] getVibrationPattern()
null
if this setting does not override the received notifications setting.android.app.NotificationChannel#getVibrationPattern()
public WonderPushChannel setVibrationPattern(long[] vibrationPattern)
vibrationPattern
- The vibration pattern for notifications posted to this channel.
Use null
to not override the received notifications setting.android.app.NotificationChannel#setVibrationPattern(long[])
public java.lang.Integer getLightColor()
null
if this setting does not override the received notifications setting.android.app.NotificationChannel#getLightColor()
public WonderPushChannel setLightColor(java.lang.Integer lightColor)
lightColor
- The notification light color for notifications posted to this channel.
Use null
to not override the received notifications setting.android.app.NotificationChannel#setLightColor(int)
public java.lang.Integer getLockscreenVisibility()
null
if this setting does not override the received notifications setting.android.app.NotificationChannel#getLockscreenVisibility()
public WonderPushChannel setLockscreenVisibility(java.lang.Integer lockscreenVisibility)
Notification.VISIBILITY_PUBLIC
.lockscreenVisibility
- Whether notifications posted to this channel appear on the lockscreen or not, and if so, whether they appear in a redacted form.
Use null
to not override the received notifications setting.android.app.NotificationChannel#setLockscreenVisibility(int)
public java.lang.Boolean getSound()
null
if this setting does not override the received notifications setting.android.app.NotificationChannel#getSound()
public WonderPushChannel setSound(java.lang.Boolean sound)
sound
- Whether a sound should be played for notifications posted to this channel.
Use null
to not override the received notifications setting.android.app.NotificationChannel#setSound(android.net.Uri, android.media.AudioAttributes)
public android.net.Uri getSoundUri()
null
if this setting does not override the received notifications setting.android.app.NotificationChannel#getSound()
public WonderPushChannel setSoundUri(android.net.Uri soundUri)
NotificationManager.IMPORTANCE_DEFAULT
should have a sound.soundUri
- The sound that should be played for notifications posted to this channel.
You can use Settings.System.DEFAULT_NOTIFICATION_URI
to use the default notification sound.
Use null
to not override the received notifications setting.android.app.NotificationChannel#setSound(android.net.Uri, android.media.AudioAttributes)
public java.lang.Boolean getVibrateInSilentMode()
This is a WonderPush addition.
The primary use of this flag is to permit notifications with sound and vibration in normal mode but prevent it from vibrating in all cases in silent mode.
null
if this setting does not override the received notifications setting.public WonderPushChannel setVibrateInSilentMode(java.lang.Boolean vibrateInSilentMode)
This is a WonderPush addition.
The primary use of this flag is to permit notifications with sound and vibration in normal mode but prevent it from vibrating in all cases in silent mode.
Note: You can control this setting irrespective of the fact that a given notification should vibrate a make a sound in normal mode.
vibrateInSilentMode
- Whether notifications posted to this channel vibrate if the device is in silent mode.
Use null
to not override the received notifications setting.public java.lang.Integer getColor()
This is independent of Android O notification channels and should continue to work under Android O.
null
if this setting does not override the received notifications setting.Notification.Builder.setColor(int)
public WonderPushChannel setColor(java.lang.Integer color)
This is independent of Android O notification channels and should continue to work under Android O.
color
- The color to impose on all notifications posted to this channel.
Use null
to not override the received notifications setting.Notification.Builder.setColor(int)
public java.lang.Boolean getLocalOnly()
This is independent of Android O notification channels and should continue to work under Android O.
null
if this setting does not override the received notifications setting.Notification.Builder.setLocalOnly(boolean)
public WonderPushChannel setLocalOnly(java.lang.Boolean localOnly)
This is independent of Android O notification channels and should continue to work under Android O.
localOnly
- Whether notifications posted to this channel should be local to this device.
Use null
to not override the received notifications setting.Notification.Builder.setLocalOnly(boolean)