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
c3520580
Commit
c3520580
authored
Mar 31, 2015
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix get* with single id on Android
parent
b8da2b94
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
22 deletions
+103
-22
LocalNotification.java
src/android/LocalNotification.java
+84
-20
Manager.java
src/android/notification/Manager.java
+6
-0
Notification.java
src/android/notification/Notification.java
+1
-1
local-notification-core.js
www/local-notification-core.js
+12
-1
No files found.
src/android/LocalNotification.java
View file @
c3520580
...
@@ -174,6 +174,15 @@ public class LocalNotification extends CordovaPlugin {
...
@@ -174,6 +174,15 @@ public class LocalNotification extends CordovaPlugin {
else
if
(
action
.
equals
(
"getTriggeredIds"
))
{
else
if
(
action
.
equals
(
"getTriggeredIds"
))
{
getTriggeredIds
(
command
);
getTriggeredIds
(
command
);
}
}
else
if
(
action
.
equals
(
"getSingle"
))
{
getSingle
(
args
,
command
);
}
else
if
(
action
.
equals
(
"getSingleScheduled"
))
{
getSingleScheduled
(
args
,
command
);
}
else
if
(
action
.
equals
(
"getSingleTriggered"
))
{
getSingleTriggered
(
args
,
command
);
}
else
if
(
action
.
equals
(
"getAll"
))
{
else
if
(
action
.
equals
(
"getAll"
))
{
getAll
(
args
,
command
);
getAll
(
args
,
command
);
}
}
...
@@ -369,23 +378,51 @@ public class LocalNotification extends CordovaPlugin {
...
@@ -369,23 +378,51 @@ public class LocalNotification extends CordovaPlugin {
}
}
/**
/**
*
Set of o
ptions from local notification.
*
O
ptions from local notification.
*
*
* @param ids
* @param ids
* Set of local notification IDs
* Set of local notification IDs
* @param command
* @param command
* The callback context used when calling back into JavaScript.
* The callback context used when calling back into JavaScript.
*/
*/
private
void
getAll
(
JSONArray
ids
,
CallbackContext
command
)
{
private
void
getSingle
(
JSONArray
ids
,
CallbackContext
command
)
{
List
<
JSONObject
>
options
;
getOptions
(
ids
.
optString
(
0
),
Notification
.
Type
.
ALL
,
command
);
}
if
(
ids
.
length
()
==
0
)
{
/**
options
=
getNotificationMgr
().
getOptions
();
* Options from scheduled notification.
}
else
{
*
options
=
getNotificationMgr
().
getOptionsById
(
toList
(
ids
));
* @param ids
* Set of local notification IDs
* @param command
* The callback context used when calling back into JavaScript.
*/
private
void
getSingleScheduled
(
JSONArray
ids
,
CallbackContext
command
)
{
getOptions
(
ids
.
optString
(
0
),
Notification
.
Type
.
SCHEDULED
,
command
);
}
}
command
.
success
(
new
JSONArray
(
options
));
/**
* Options from triggered notification.
*
* @param ids
* Set of local notification IDs
* @param command
* The callback context used when calling back into JavaScript.
*/
private
void
getSingleTriggered
(
JSONArray
ids
,
CallbackContext
command
)
{
getOptions
(
ids
.
optString
(
0
),
Notification
.
Type
.
TRIGGERED
,
command
);
}
/**
* Set of options from local notification.
*
* @param ids
* Set of local notification IDs
* @param command
* The callback context used when calling back into JavaScript.
*/
private
void
getAll
(
JSONArray
ids
,
CallbackContext
command
)
{
getOptions
(
ids
,
Notification
.
Type
.
ALL
,
command
);
}
}
/**
/**
...
@@ -397,34 +434,61 @@ public class LocalNotification extends CordovaPlugin {
...
@@ -397,34 +434,61 @@ public class LocalNotification extends CordovaPlugin {
* The callback context used when calling back into JavaScript.
* The callback context used when calling back into JavaScript.
*/
*/
private
void
getScheduled
(
JSONArray
ids
,
CallbackContext
command
)
{
private
void
getScheduled
(
JSONArray
ids
,
CallbackContext
command
)
{
List
<
JSONObject
>
options
;
getOptions
(
ids
,
Notification
.
Type
.
SCHEDULED
,
command
);
}
if
(
ids
.
length
()
==
0
)
{
/**
options
=
getNotificationMgr
().
getOptionsByType
(
Notification
.
Type
.
SCHEDULED
);
* Set of options from triggered notifications.
}
else
{
*
options
=
getNotificationMgr
().
getOptionsBy
(
* @param ids
Notification
.
Type
.
SCHEDULED
,
toList
(
ids
));
* Set of local notification IDs
* @param command
* The callback context used when calling back into JavaScript.
*/
private
void
getTriggered
(
JSONArray
ids
,
CallbackContext
command
)
{
getOptions
(
ids
,
Notification
.
Type
.
TRIGGERED
,
command
);
}
}
command
.
success
(
new
JSONArray
(
options
));
/**
* Options from local notification.
*
* @param id
* Set of local notification IDs
* @param type
* The local notification life cycle type
* @param command
* The callback context used when calling back into JavaScript.
*/
private
void
getOptions
(
String
id
,
Notification
.
Type
type
,
CallbackContext
command
)
{
JSONArray
ids
=
new
JSONArray
().
put
(
id
);
JSONObject
options
=
getNotificationMgr
().
getOptionsBy
(
type
,
toList
(
ids
)).
get
(
0
);
command
.
success
(
options
);
}
}
/**
/**
* Set of options from
triggered
notifications.
* Set of options from
local
notifications.
*
*
* @param ids
* @param ids
* Set of local notification IDs
* Set of local notification IDs
* @param type
* The local notification life cycle type
* @param command
* @param command
* The callback context used when calling back into JavaScript.
* The callback context used when calling back into JavaScript.
*/
*/
private
void
getTriggered
(
JSONArray
ids
,
CallbackContext
command
)
{
private
void
getOptions
(
JSONArray
ids
,
Notification
.
Type
type
,
CallbackContext
command
)
{
List
<
JSONObject
>
options
;
List
<
JSONObject
>
options
;
if
(
ids
.
length
()
==
0
)
{
if
(
ids
.
length
()
==
0
)
{
options
=
getNotificationMgr
().
getOptionsByType
(
Notification
.
Type
.
TRIGGERED
);
options
=
getNotificationMgr
().
getOptionsByType
(
type
);
}
else
{
}
else
{
options
=
getNotificationMgr
().
getOptionsBy
(
options
=
getNotificationMgr
().
getOptionsBy
(
type
,
toList
(
ids
));
Notification
.
Type
.
TRIGGERED
,
toList
(
ids
));
}
}
command
.
success
(
new
JSONArray
(
options
));
command
.
success
(
new
JSONArray
(
options
));
...
...
src/android/notification/Manager.java
View file @
c3520580
...
@@ -256,6 +256,9 @@ public class Manager {
...
@@ -256,6 +256,9 @@ public class Manager {
List
<
Notification
>
notifications
=
getAll
();
List
<
Notification
>
notifications
=
getAll
();
ArrayList
<
Notification
>
list
=
new
ArrayList
<
Notification
>();
ArrayList
<
Notification
>
list
=
new
ArrayList
<
Notification
>();
if
(
type
==
Notification
.
Type
.
ALL
)
return
notifications
;
for
(
Notification
notification
:
notifications
)
{
for
(
Notification
notification
:
notifications
)
{
if
(
notification
.
getType
()
==
type
)
{
if
(
notification
.
getType
()
==
type
)
{
list
.
add
(
notification
);
list
.
add
(
notification
);
...
@@ -368,6 +371,9 @@ public class Manager {
...
@@ -368,6 +371,9 @@ public class Manager {
public
List
<
JSONObject
>
getOptionsBy
(
Notification
.
Type
type
,
public
List
<
JSONObject
>
getOptionsBy
(
Notification
.
Type
type
,
List
<
Integer
>
ids
)
{
List
<
Integer
>
ids
)
{
if
(
type
==
Notification
.
Type
.
ALL
)
return
getOptionsById
(
ids
);
ArrayList
<
JSONObject
>
options
=
new
ArrayList
<
JSONObject
>();
ArrayList
<
JSONObject
>
options
=
new
ArrayList
<
JSONObject
>();
List
<
Notification
>
notifications
=
getByIds
(
ids
);
List
<
Notification
>
notifications
=
getByIds
(
ids
);
...
...
src/android/notification/Notification.java
View file @
c3520580
...
@@ -46,7 +46,7 @@ public class Notification {
...
@@ -46,7 +46,7 @@ public class Notification {
// Used to differ notifications by their life cycle state
// Used to differ notifications by their life cycle state
public
static
enum
Type
{
public
static
enum
Type
{
SCHEDULED
,
TRIGGERED
ALL
,
SCHEDULED
,
TRIGGERED
}
}
// Default receiver to handle the trigger event
// Default receiver to handle the trigger event
...
...
www/local-notification-core.js
View file @
c3520580
...
@@ -275,7 +275,8 @@ exports.get = function () {
...
@@ -275,7 +275,8 @@ exports.get = function () {
scope
=
args
[
2
];
scope
=
args
[
2
];
if
(
!
Array
.
isArray
(
ids
))
{
if
(
!
Array
.
isArray
(
ids
))
{
ids
=
[
ids
];
this
.
exec
(
'getSingle'
,
ids
.
toString
(),
callback
,
scope
);
return
;
}
}
ids
=
this
.
convertIds
(
ids
);
ids
=
this
.
convertIds
(
ids
);
...
@@ -321,6 +322,11 @@ exports.getScheduled = function () {
...
@@ -321,6 +322,11 @@ exports.getScheduled = function () {
ids
=
[
ids
];
ids
=
[
ids
];
}
}
if
(
!
Array
.
isArray
(
ids
))
{
this
.
exec
(
'getSingleScheduled'
,
ids
.
toString
(),
callback
,
scope
);
return
;
}
ids
=
this
.
convertIds
(
ids
);
ids
=
this
.
convertIds
(
ids
);
this
.
exec
(
'getScheduled'
,
ids
,
callback
,
scope
);
this
.
exec
(
'getScheduled'
,
ids
,
callback
,
scope
);
...
@@ -364,6 +370,11 @@ exports.getTriggered = function () {
...
@@ -364,6 +370,11 @@ exports.getTriggered = function () {
ids
=
[
ids
];
ids
=
[
ids
];
}
}
if
(
!
Array
.
isArray
(
ids
))
{
this
.
exec
(
'getSingleTriggered'
,
ids
.
toString
(),
callback
,
scope
);
return
;
}
ids
=
this
.
convertIds
(
ids
);
ids
=
this
.
convertIds
(
ids
);
this
.
exec
(
'getTriggered'
,
ids
,
callback
,
scope
);
this
.
exec
(
'getTriggered'
,
ids
,
callback
,
scope
);
...
...
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