public class Notifications
extends java.lang.Object
Notification
objectsModifier and Type | Class and Description |
---|---|
static class |
Notifications.NotificationReceiver
BroadcastReceiver to handle notification actions |
Modifier and Type | Field and Description |
---|---|
private static int |
ID_CLIPBOARD_SERVICE |
private static int |
ID_COPY |
private static int |
ID_DEVICE |
private static int |
ID_ERROR |
private boolean |
mChannelsInit
Flag for channel initialization
|
private int |
mClipItemCt
Count of number of clipboard messages received.
|
private android.content.Context |
mContext
Global Application Context
|
private static Notifications |
sInstance |
Modifier | Constructor and Description |
---|---|
private |
Notifications(android.content.Context context) |
Modifier and Type | Method and Description |
---|---|
private void |
createChannel(java.lang.String id,
int importance,
java.lang.String name,
java.lang.String desc,
java.lang.Boolean badge)
Create a
NotificationChannel |
private androidx.core.app.NotificationCompat.Builder |
getBuilder(android.app.PendingIntent pInt,
java.lang.String channelId,
int largeIcon,
java.lang.String titleText)
Get a builder with the common settings for a notification
|
private android.graphics.Bitmap |
getLargeIcon(int id)
Get large icon
|
private android.app.NotificationManager |
getManager()
Get the NotificationManager
|
private android.app.PendingIntent |
getPIntent(android.content.Context context,
java.lang.Class aClass,
android.content.Intent intent)
Get a pending intent with a synthetic back stack
|
void |
initChannels(android.content.Context context)
Initialize the
NotificationChannel for Android O |
static Notifications |
INST(android.content.Context context)
Lazily create our instance
|
void |
removeAll()
Remove all Notifications
|
void |
removeClips()
Remove
Clip notifications |
void |
removeDevices()
Remove
Device notifications |
void |
removeErrors()
Remove
LastError notifications |
private void |
resetCount()
Reset message count
|
void |
show(Clip clip)
Display notification on a clipboard change
|
void |
show(LastError lastError)
Display notification on an app error or exception
|
void |
show(java.lang.String action,
java.lang.CharSequence device)
Display notification on remote device added or removed
|
void |
showNotificationSettings(android.content.Context context)
Display the Notification settings for Android O
|
void |
startAndShow(ClipboardWatcherService service)
Start and show the
ClipboardWatcherService |
private static final int ID_COPY
private static final int ID_DEVICE
private static final int ID_CLIPBOARD_SERVICE
private static final int ID_ERROR
private static Notifications sInstance
private final android.content.Context mContext
private boolean mChannelsInit
private int mClipItemCt
public static Notifications INST(@NonNull android.content.Context context)
context
- any old contextpublic void initChannels(android.content.Context context)
NotificationChannel
for Android Ocontext
- A Contextpublic void startAndShow(ClipboardWatcherService service)
ClipboardWatcherService
service
- the foreground service to monitor the clipboardpublic void show(Clip clip)
clip
- the Clip
to display notification forpublic void show(java.lang.String action, java.lang.CharSequence device)
action
- Added or removeddevice
- remote devicepublic void show(LastError lastError)
lastError
- error messagepublic void removeClips()
Clip
notificationspublic void removeDevices()
Device
notificationspublic void removeErrors()
LastError
notificationspublic void removeAll()
public void showNotificationSettings(android.content.Context context)
context
- A contextprivate void resetCount()
private android.graphics.Bitmap getLargeIcon(int id)
id
- Resource idprivate android.app.NotificationManager getManager()
private android.app.PendingIntent getPIntent(android.content.Context context, java.lang.Class aClass, android.content.Intent intent)
context
- a contextaClass
- an Activity
classintent
- an intent for the top of the stackprivate androidx.core.app.NotificationCompat.Builder getBuilder(android.app.PendingIntent pInt, java.lang.String channelId, int largeIcon, java.lang.String titleText)
pInt
- Content intentlargeIcon
- display icontitleText
- display titleprivate void createChannel(java.lang.String id, int importance, java.lang.String name, java.lang.String desc, java.lang.Boolean badge)
NotificationChannel
id
- unique channel IDimportance
- channel importancename
- channel namedesc
- channel descriptionbadge
- true if a badge should be shown on app icon