diff --git a/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java b/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java index bd3bbd9ea..53bbe490f 100644 --- a/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java +++ b/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java @@ -284,7 +284,10 @@ protected static Notification createNotification( : notificationDetails.body) .setTicker(notificationDetails.ticker) .setAutoCancel(BooleanUtils.getValue(notificationDetails.autoCancel)) - .setContentIntent(pendingIntent) + .setContentIntent( + BooleanUtils.getValue(notificationDetails.selectable) + ? pendingIntent + : null) .setPriority(notificationDetails.priority) .setOngoing(BooleanUtils.getValue(notificationDetails.ongoing)) .setSilent(BooleanUtils.getValue(notificationDetails.silent)) diff --git a/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/models/NotificationDetails.java b/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/models/NotificationDetails.java index dcb59648a..13da16f81 100644 --- a/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/models/NotificationDetails.java +++ b/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/models/NotificationDetails.java @@ -34,6 +34,7 @@ public class NotificationDetails implements Serializable { private static final String REPEAT_TIME = "repeatTime"; private static final String PLATFORM_SPECIFICS = "platformSpecifics"; private static final String AUTO_CANCEL = "autoCancel"; + private static final String SELECTABLE = "selectable"; private static final String ONGOING = "ongoing"; private static final String SILENT = "silent"; private static final String STYLE = "style"; @@ -155,6 +156,7 @@ public class NotificationDetails implements Serializable { public Boolean setAsGroupSummary; public Integer groupAlertBehavior; public Boolean autoCancel; + public Boolean selectable; public Boolean ongoing; public Boolean silent; public Integer day; @@ -252,6 +254,7 @@ private static void readPlatformSpecifics( (Map) arguments.get(PLATFORM_SPECIFICS); if (platformChannelSpecifics != null) { notificationDetails.autoCancel = (Boolean) platformChannelSpecifics.get(AUTO_CANCEL); + notificationDetails.selectable = (Boolean) platformChannelSpecifics.get(SELECTABLE); notificationDetails.ongoing = (Boolean) platformChannelSpecifics.get(ONGOING); notificationDetails.silent = (Boolean) platformChannelSpecifics.get(SILENT); notificationDetails.style = diff --git a/flutter_local_notifications/lib/src/platform_specifics/android/method_channel_mappers.dart b/flutter_local_notifications/lib/src/platform_specifics/android/method_channel_mappers.dart index cc1fa1994..d8485740f 100644 --- a/flutter_local_notifications/lib/src/platform_specifics/android/method_channel_mappers.dart +++ b/flutter_local_notifications/lib/src/platform_specifics/android/method_channel_mappers.dart @@ -188,6 +188,7 @@ extension AndroidNotificationDetailsMapper on AndroidNotificationDetails { 'setAsGroupSummary': setAsGroupSummary, 'groupAlertBehavior': groupAlertBehavior.index, 'autoCancel': autoCancel, + 'selectable': selectable, 'ongoing': ongoing, 'silent': silent, 'colorAlpha': color?.alpha, diff --git a/flutter_local_notifications/lib/src/platform_specifics/android/notification_details.dart b/flutter_local_notifications/lib/src/platform_specifics/android/notification_details.dart index c3a23f1d2..2f1445283 100644 --- a/flutter_local_notifications/lib/src/platform_specifics/android/notification_details.dart +++ b/flutter_local_notifications/lib/src/platform_specifics/android/notification_details.dart @@ -114,6 +114,7 @@ class AndroidNotificationDetails { this.setAsGroupSummary = false, this.groupAlertBehavior = GroupAlertBehavior.all, this.autoCancel = true, + this.selectable = true, this.ongoing = false, this.silent = false, this.color, @@ -237,6 +238,14 @@ class AndroidNotificationDetails { /// Specifies if the notification should automatically dismissed upon tapping /// on it. final bool autoCancel; + + /// Specifies if the notification is selectable. + /// + /// If `selectable` is `false`, the `contentIntent` will be set to `null`, + /// disabling click actions on the notification. + /// + /// The default value is `true`. + final bool selectable; /// Specifies if the notification will be "ongoing". final bool ongoing; diff --git a/flutter_local_notifications/test/android_flutter_local_notifications_test.dart b/flutter_local_notifications/test/android_flutter_local_notifications_test.dart index 2bc9e30d8..eca845999 100644 --- a/flutter_local_notifications/test/android_flutter_local_notifications_test.dart +++ b/flutter_local_notifications/test/android_flutter_local_notifications_test.dart @@ -141,6 +141,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -263,6 +264,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -347,6 +349,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -432,6 +435,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -518,6 +522,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -608,6 +613,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -697,6 +703,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -784,6 +791,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': true, 'colorAlpha': null, @@ -872,6 +880,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -962,6 +971,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -1067,6 +1077,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -1166,6 +1177,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -1271,6 +1283,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -1368,6 +1381,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -1469,6 +1483,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -1561,6 +1576,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -1650,6 +1666,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -1746,6 +1763,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -1871,6 +1889,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -1985,6 +2004,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -2217,6 +2237,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -2314,6 +2335,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -2412,6 +2434,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': null, @@ -2712,6 +2735,7 @@ void main() { 'setAsGroupSummary': false, 'groupAlertBehavior': GroupAlertBehavior.all.index, 'autoCancel': true, + 'selectable': true, 'ongoing': false, 'silent': false, 'colorAlpha': 255,