Skip to content

Commit

Permalink
add support for setWhen on Android notifications
Browse files Browse the repository at this point in the history
Closes MaikuB#596.
  • Loading branch information
nioncode committed Apr 24, 2020
1 parent 60072d6 commit d0d698e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ private static Notification createNotification(Context context, NotificationDeta
builder.setShowWhen(BooleanUtils.getValue(notificationDetails.showWhen));
}

if (notificationDetails.when != null) {
builder.setWhen(notificationDetails.when);
}

setVisibility(notificationDetails, builder);
applyGrouping(notificationDetails, builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public class NotificationDetails {
private static final String CATEGORY = "category";
private static final String TIMEOUT_AFTER = "timeoutAfter";
private static final String SHOW_WHEN = "showWhen";
private static final String WHEN = "when";


public Integer id;
Expand Down Expand Up @@ -151,6 +152,7 @@ public class NotificationDetails {
public Long timeoutAfter;
public String category;
public Boolean showWhen;
public Long when;



Expand Down Expand Up @@ -200,6 +202,7 @@ private static void readPlatformSpecifics(Map<String, Object> arguments, Notific
readGroupingInformation(notificationDetails, platformChannelSpecifics);
notificationDetails.onlyAlertOnce = (Boolean) platformChannelSpecifics.get(ONLY_ALERT_ONCE);
notificationDetails.showWhen = (Boolean) platformChannelSpecifics.get(SHOW_WHEN);
notificationDetails.when = (Long) platformChannelSpecifics.get(WHEN);
readProgressInformation(notificationDetails, platformChannelSpecifics);
readColor(notificationDetails, platformChannelSpecifics);
readChannelInformation(notificationDetails, platformChannelSpecifics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class AndroidNotificationDetails {
this.largeIcon,
this.onlyAlertOnce,
this.showWhen = true,
this.when,
this.channelShowBadge = true,
this.showProgress = false,
this.maxProgress = 0,
Expand Down Expand Up @@ -141,8 +142,19 @@ class AndroidNotificationDetails {
final bool onlyAlertOnce;

/// Specifies if the notification should display the timestamp of when it occurred.
///
/// To control the actual timestamp of the notification, use [when].
final bool showWhen;

/// Specifies the timestamp of the notification.
///
/// If not specified, this will be set to the current time when the
/// notification gets created.
///
/// To control whether the timestamp is shown in the notification, use
/// [showWhen].
final int when;

/// Specifies if the notification will be used to show progress.
final bool showProgress;

Expand Down Expand Up @@ -216,6 +228,7 @@ class AndroidNotificationDetails {
'colorBlue': color?.blue,
'onlyAlertOnce': onlyAlertOnce,
'showWhen': showWhen,
'when': when,
'showProgress': showProgress,
'maxProgress': maxProgress,
'progress': progress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -188,6 +189,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -266,6 +268,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -342,6 +345,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -420,6 +424,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -513,6 +518,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -600,6 +606,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -693,6 +700,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -778,6 +786,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -867,6 +876,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -947,6 +957,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -1024,6 +1035,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -1108,6 +1120,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -1221,6 +1234,7 @@ void main() {
'colorBlue': null,
'onlyAlertOnce': null,
'showWhen': true,
'when': null,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down

0 comments on commit d0d698e

Please sign in to comment.