Commit 45b5d887 by Sebastián Katzer

Added new Android specific options clock: and timeout:

parent 7622df53
...@@ -97,10 +97,11 @@ A notification does have a set of configurable properties. Not all of them are s ...@@ -97,10 +97,11 @@ A notification does have a set of configurable properties. Not all of them are s
| Property | Property | Property | Property | Property | Property | Property | Property | | Property | Property | Property | Property | Property | Property | Property | Property |
| :------------ | :------------ | :------------ | :------------ | :------------ | :------------ | :------------ | :------------ | | :------------ | :------------ | :------------ | :------------ | :------------ | :------------ | :------------ | :------------ |
| id | data | actionGroupId | summary | led | showWhen | channel | actions | | id | data | actionGroupId | summary | led | clock | channel | actions |
| text | icon | attachments | smallIcon | color | defaults | launch | groupSummary | | text | icon | attachments | smallIcon | color | defaults | launch | groupSummary |
| title | silent | progressBar | sticky | vibrate | priority | mediaSession | foreground | | title | silent | progressBar | sticky | vibrate | priority | mediaSession | foreground |
| sound | trigger | group | autoClear | lockscreen | number | badge | wakeup | | sound | trigger | group | autoClear | lockscreen | number | badge | wakeup |
| timeout |
For their default values see: For their default values see:
......
...@@ -137,10 +137,11 @@ public final class Builder { ...@@ -137,10 +137,11 @@ public final class Builder {
.setColor(options.getColor()) .setColor(options.getColor())
.setVisibility(options.getVisibility()) .setVisibility(options.getVisibility())
.setPriority(options.getPriority()) .setPriority(options.getPriority())
.setShowWhen(options.getShowWhen()) .setShowWhen(options.showClock())
.setUsesChronometer(options.isWithProgressBar()) .setUsesChronometer(options.showChronometer())
.setGroup(options.getGroup()) .setGroup(options.getGroup())
.setGroupSummary(options.getGroupSummary()) .setGroupSummary(options.getGroupSummary())
.setTimeoutAfter(options.getTimeout())
.setLights(options.getLedColor(), options.getLedOn(), options.getLedOff()); .setLights(options.getLedColor(), options.getLedOn(), options.getLedOff());
if (sound != Uri.EMPTY && !isUpdate()) { if (sound != Uri.EMPTY && !isUpdate()) {
......
...@@ -308,7 +308,7 @@ public final class Notification { ...@@ -308,7 +308,7 @@ public final class Notification {
public void show() { public void show() {
if (builder == null) return; if (builder == null) return;
if (options.isWithProgressBar()) { if (options.showChronometer()) {
cacheBuilder(); cacheBuilder();
} }
...@@ -427,7 +427,7 @@ public final class Notification { ...@@ -427,7 +427,7 @@ public final class Notification {
/** /**
* Caches the builder instance so it can be used later. * Caches the builder instance so it can be used later.
*/ */
private void cacheBuilder () { private void cacheBuilder() {
if (cache == null) { if (cache == null) {
cache = new SparseArray<NotificationCompat.Builder>(); cache = new SparseArray<NotificationCompat.Builder>();
......
...@@ -200,6 +200,13 @@ public final class Options { ...@@ -200,6 +200,13 @@ public final class Options {
} }
/** /**
* Gets the value for the timeout flag.
*/
long getTimeout() {
return options.optLong("timeout");
}
/**
* The channel id of that notification. * The channel id of that notification.
*/ */
String getChannel() { String getChannel() {
...@@ -481,8 +488,19 @@ public final class Options { ...@@ -481,8 +488,19 @@ public final class Options {
/** /**
* If the notification shall show the when date. * If the notification shall show the when date.
*/ */
boolean getShowWhen() { boolean showClock() {
return options.optBoolean("showWhen", true); Object clock = options.opt("clock");
return (clock instanceof Boolean) ? (Boolean) clock : true;
}
/**
* If the notification shall show the when date.
*/
boolean showChronometer() {
Object clock = options.opt("clock");
return (clock instanceof String) && clock.equals("chronometer");
} }
/** /**
......
...@@ -30,6 +30,7 @@ exports._defaults = { ...@@ -30,6 +30,7 @@ exports._defaults = {
autoClear : true, autoClear : true,
badge : null, badge : null,
channel : null, channel : null,
clock : true,
color : null, color : null,
data : null, data : null,
defaults : 0, defaults : 0,
...@@ -45,13 +46,13 @@ exports._defaults = { ...@@ -45,13 +46,13 @@ exports._defaults = {
number : 0, number : 0,
priority : 0, priority : 0,
progressBar : false, progressBar : false,
showWhen : true,
silent : false, silent : false,
smallIcon : 'res://icon', smallIcon : 'res://icon',
sound : true, sound : true,
sticky : false, sticky : false,
summary : null, summary : null,
text : '', text : '',
timeout : false,
title : '', title : '',
trigger : { type : 'calendar' }, trigger : { type : 'calendar' },
vibrate : false, vibrate : false,
...@@ -606,6 +607,14 @@ exports._convertProperties = function (options) { ...@@ -606,6 +607,14 @@ exports._convertProperties = function (options) {
console.warn('Property "smallIcon" must be of kind res://...'); console.warn('Property "smallIcon" must be of kind res://...');
} }
if (typeof options.timeout === 'boolean') {
options.timeout = options.timeout ? 3600000 : null;
}
if (options.timeout) {
options.timeout = parseToInt('timeout', options);
}
options.data = JSON.stringify(options.data); options.data = JSON.stringify(options.data);
this._convertTrigger(options); this._convertTrigger(options);
...@@ -761,6 +770,10 @@ exports._convertProgressBar = function (options) { ...@@ -761,6 +770,10 @@ exports._convertProgressBar = function (options) {
cfg.enabled = !!cfg.enabled; cfg.enabled = !!cfg.enabled;
if (cfg.enabled && options.clock === true) {
options.clock = 'chronometer';
}
return options; return options;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment