Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_local_notifications] Fixes #1486 :Adds ability to count down chronometer with chronometerCountDown #1778

Merged
merged 6 commits into from Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -347,6 +347,12 @@ protected static Notification createNotification(
builder.setUsesChronometer(notificationDetails.usesChronometer);
}

if (notificationDetails.chronometerCountDown != null) {
if (VERSION.SDK_INT >= VERSION_CODES.N) {
builder.setChronometerCountDown(notificationDetails.chronometerCountDown);
}
}

if (BooleanUtils.getValue(notificationDetails.fullScreenIntent)) {
builder.setFullScreenIntent(pendingIntent, true);
}
Expand Down
Expand Up @@ -108,6 +108,7 @@ public class NotificationDetails implements Serializable {
private static final String SHOW_WHEN = "showWhen";
private static final String WHEN = "when";
private static final String USES_CHRONOMETER = "usesChronometer";
private static final String CHRONOMETER_COUNT_DOWN = "chronometerCountDown";
private static final String ADDITIONAL_FLAGS = "additionalFlags";

private static final String SCHEDULED_DATE_TIME = "scheduledDateTime";
Expand Down Expand Up @@ -173,6 +174,7 @@ public class NotificationDetails implements Serializable {
public int[] additionalFlags;
public Boolean showWhen;
public Boolean usesChronometer;
public Boolean chronometerCountDown;
public String scheduledDateTime;
public String timeZoneName;
public ScheduledNotificationRepeatFrequency scheduledNotificationRepeatFrequency;
Expand Down Expand Up @@ -255,6 +257,8 @@ private static void readPlatformSpecifics(
notificationDetails.when = LongUtils.parseLong(platformChannelSpecifics.get(WHEN));
notificationDetails.usesChronometer =
(Boolean) platformChannelSpecifics.get(USES_CHRONOMETER);
notificationDetails.chronometerCountDown =
(Boolean) platformChannelSpecifics.get(CHRONOMETER_COUNT_DOWN);
readProgressInformation(notificationDetails, platformChannelSpecifics);
readColor(notificationDetails, platformChannelSpecifics);
readChannelInformation(notificationDetails, platformChannelSpecifics);
Expand Down
1 change: 1 addition & 0 deletions flutter_local_notifications/example/lib/main.dart
Expand Up @@ -2155,6 +2155,7 @@ class _HomePageState extends State<HomePage> {
priority: Priority.high,
when: DateTime.now().millisecondsSinceEpoch - 120 * 1000,
usesChronometer: true,
chronometerCountDown: true,
);
final NotificationDetails notificationDetails =
NotificationDetails(android: androidNotificationDetails);
Expand Down
Expand Up @@ -196,6 +196,7 @@ extension AndroidNotificationDetailsMapper on AndroidNotificationDetails {
'showWhen': showWhen,
'when': when,
'usesChronometer': usesChronometer,
'chronometerCountDown': chronometerCountDown,
'showProgress': showProgress,
'maxProgress': maxProgress,
'progress': progress,
Expand Down
Expand Up @@ -122,6 +122,7 @@ class AndroidNotificationDetails {
this.showWhen = true,
this.when,
this.usesChronometer = false,
this.chronometerCountDown = false,
this.channelShowBadge = true,
this.showProgress = false,
this.maxProgress = 0,
Expand Down Expand Up @@ -274,6 +275,11 @@ class AndroidNotificationDetails {
/// Useful when showing an elapsed time (like an ongoing phone call).
final bool usesChronometer;

/// Sets the chronometer to count down instead of counting up.
///
/// This property is only applicable to Android 7.0 and newer versions.
final bool chronometerCountDown;

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

Expand Down
Expand Up @@ -147,6 +147,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -267,6 +268,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -349,6 +351,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -432,6 +435,7 @@ void main() {
'showWhen': true,
'when': timestamp,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -516,6 +520,7 @@ void main() {
'showWhen': true,
'when': timestamp,
'usesChronometer': true,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -604,6 +609,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -691,6 +697,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -777,6 +784,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -865,6 +873,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -968,6 +977,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -1065,6 +1075,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -1168,6 +1179,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -1263,6 +1275,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -1362,6 +1375,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -1452,6 +1466,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -1539,6 +1554,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -1633,6 +1649,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -1756,6 +1773,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -1867,6 +1885,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -1962,6 +1981,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -2056,6 +2076,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -2151,6 +2172,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down Expand Up @@ -2444,6 +2466,7 @@ void main() {
'showWhen': true,
'when': null,
'usesChronometer': false,
'chronometerCountDown': false,
'showProgress': false,
'maxProgress': 0,
'progress': 0,
Expand Down