Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cordova-plugin-local-notifications
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nabil Sadki
cordova-plugin-local-notifications
Commits
45b5d887
Commit
45b5d887
authored
Jan 30, 2018
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new Android specific options clock: and timeout:
parent
7622df53
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
8 deletions
+41
-8
README.md
README.md
+2
-1
Builder.java
src/android/notification/Builder.java
+3
-2
Notification.java
src/android/notification/Notification.java
+2
-2
Options.java
src/android/notification/Options.java
+20
-2
local-notification.js
www/local-notification.js
+14
-1
No files found.
README.md
View file @
45b5d887
...
...
@@ -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 |
| :------------ | :------------ | :------------ | :------------ | :------------ | :------------ | :------------ | :------------ |
| id | data | actionGroupId | summary | led |
showWhen
| channel | actions |
| id | data | actionGroupId | summary | led |
clock
| channel | actions |
| text | icon | attachments | smallIcon | color | defaults | launch | groupSummary |
| title | silent | progressBar | sticky | vibrate | priority | mediaSession | foreground |
| sound | trigger | group | autoClear | lockscreen | number | badge | wakeup |
| timeout |
For their default values see:
...
...
src/android/notification/Builder.java
View file @
45b5d887
...
...
@@ -137,10 +137,11 @@ public final class Builder {
.
setColor
(
options
.
getColor
())
.
setVisibility
(
options
.
getVisibility
())
.
setPriority
(
options
.
getPriority
())
.
setShowWhen
(
options
.
getShowWhen
())
.
setUsesChronometer
(
options
.
isWithProgressBa
r
())
.
setShowWhen
(
options
.
showClock
())
.
setUsesChronometer
(
options
.
showChronomete
r
())
.
setGroup
(
options
.
getGroup
())
.
setGroupSummary
(
options
.
getGroupSummary
())
.
setTimeoutAfter
(
options
.
getTimeout
())
.
setLights
(
options
.
getLedColor
(),
options
.
getLedOn
(),
options
.
getLedOff
());
if
(
sound
!=
Uri
.
EMPTY
&&
!
isUpdate
())
{
...
...
src/android/notification/Notification.java
View file @
45b5d887
...
...
@@ -308,7 +308,7 @@ public final class Notification {
public
void
show
()
{
if
(
builder
==
null
)
return
;
if
(
options
.
isWithProgressBa
r
())
{
if
(
options
.
showChronomete
r
())
{
cacheBuilder
();
}
...
...
@@ -427,7 +427,7 @@ public final class Notification {
/**
* Caches the builder instance so it can be used later.
*/
private
void
cacheBuilder
()
{
private
void
cacheBuilder
()
{
if
(
cache
==
null
)
{
cache
=
new
SparseArray
<
NotificationCompat
.
Builder
>();
...
...
src/android/notification/Options.java
View file @
45b5d887
...
...
@@ -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.
*/
String
getChannel
()
{
...
...
@@ -481,8 +488,19 @@ public final class Options {
/**
* If the notification shall show the when date.
*/
boolean
getShowWhen
()
{
return
options
.
optBoolean
(
"showWhen"
,
true
);
boolean
showClock
()
{
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"
);
}
/**
...
...
www/local-notification.js
View file @
45b5d887
...
...
@@ -30,6 +30,7 @@ exports._defaults = {
autoClear
:
true
,
badge
:
null
,
channel
:
null
,
clock
:
true
,
color
:
null
,
data
:
null
,
defaults
:
0
,
...
...
@@ -45,13 +46,13 @@ exports._defaults = {
number
:
0
,
priority
:
0
,
progressBar
:
false
,
showWhen
:
true
,
silent
:
false
,
smallIcon
:
'res://icon'
,
sound
:
true
,
sticky
:
false
,
summary
:
null
,
text
:
''
,
timeout
:
false
,
title
:
''
,
trigger
:
{
type
:
'calendar'
},
vibrate
:
false
,
...
...
@@ -606,6 +607,14 @@ exports._convertProperties = function (options) {
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
);
this
.
_convertTrigger
(
options
);
...
...
@@ -761,6 +770,10 @@ exports._convertProgressBar = function (options) {
cfg
.
enabled
=
!!
cfg
.
enabled
;
if
(
cfg
.
enabled
&&
options
.
clock
===
true
)
{
options
.
clock
=
'chronometer'
;
}
return
options
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment