Added!: Support for delete intent for Notification.Builder in NotificationUtils

This commit is contained in:
agnostic-apollo
2021-08-20 22:12:01 +05:00
parent 35ea19dd75
commit baacabdfbf
5 changed files with 29 additions and 16 deletions

View File

@@ -53,20 +53,25 @@ public class NotificationUtils {
* @param title The title for the notification.
* @param notificationText The second line text of the notification.
* @param notificationBigText The full text of the notification that may optionally be styled.
* @param pendingIntent The {@link PendingIntent} which should be sent when notification is clicked.
* @param contentIntent The {@link PendingIntent} which should be sent when notification is clicked.
* @param deleteIntent The {@link PendingIntent} which should be sent when notification is deleted.
* @param notificationMode The notification mode. It must be one of {@code NotificationUtils.NOTIFICATION_MODE_*}.
* The builder returned will be {@code null} if {@link #NOTIFICATION_MODE_NONE}
* is passed. That case should ideally be handled before calling this function.
* @return Returns the {@link Notification.Builder}.
*/
@Nullable
public static Notification.Builder geNotificationBuilder(final Context context, final String channelId, final int priority, final CharSequence title, final CharSequence notificationText, final CharSequence notificationBigText, final PendingIntent pendingIntent, final int notificationMode) {
public static Notification.Builder geNotificationBuilder(
final Context context, final String channelId, final int priority, final CharSequence title,
final CharSequence notificationText, final CharSequence notificationBigText,
final PendingIntent contentIntent, final PendingIntent deleteIntent, final int notificationMode) {
if (context == null) return null;
Notification.Builder builder = new Notification.Builder(context);
builder.setContentTitle(title);
builder.setContentText(notificationText);
builder.setStyle(new Notification.BigTextStyle().bigText(notificationBigText));
builder.setContentIntent(pendingIntent);
builder.setContentIntent(contentIntent);
builder.setDeleteIntent(deleteIntent);
builder.setPriority(priority);