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
6c919c8d
Commit
6c919c8d
authored
Nov 07, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix app state not showing up correctly when tapping on notification [#477]
parent
3eb95003
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
24 deletions
+28
-24
ClickReceiver.java
src/android/ClickReceiver.java
+2
-2
LocalNotification.java
src/android/LocalNotification.java
+26
-22
No files found.
src/android/ClickReceiver.java
View file @
6c919c8d
...
@@ -48,8 +48,8 @@ public class ClickReceiver extends AbstractClickReceiver {
...
@@ -48,8 +48,8 @@ public class ClickReceiver extends AbstractClickReceiver {
*/
*/
@Override
@Override
public
void
onClick
(
Notification
notification
,
Bundle
bundle
)
{
public
void
onClick
(
Notification
notification
,
Bundle
bundle
)
{
String
action
=
getAction
();
String
action
=
getAction
();
JSONObject
data
=
new
JSONObject
();
JSONObject
data
=
new
JSONObject
();
setTextInput
(
action
,
data
);
setTextInput
(
action
,
data
);
launchAppIf
();
launchAppIf
();
...
...
src/android/LocalNotification.java
View file @
6c919c8d
...
@@ -23,7 +23,10 @@ package de.appplant.cordova.plugin.localnotification;
...
@@ -23,7 +23,10 @@ package de.appplant.cordova.plugin.localnotification;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.app.KeyguardManager
;
import
android.content.Context
;
import
android.util.Pair
;
import
android.util.Pair
;
import
android.view.View
;
import
org.apache.cordova.CallbackContext
;
import
org.apache.cordova.CallbackContext
;
import
org.apache.cordova.CordovaInterface
;
import
org.apache.cordova.CordovaInterface
;
...
@@ -34,6 +37,7 @@ import org.json.JSONArray;
...
@@ -34,6 +37,7 @@ import org.json.JSONArray;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
java.lang.ref.WeakReference
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -60,9 +64,6 @@ public class LocalNotification extends CordovaPlugin {
...
@@ -60,9 +64,6 @@ public class LocalNotification extends CordovaPlugin {
// Indicates if the device is ready (to receive events)
// Indicates if the device is ready (to receive events)
private
static
Boolean
deviceready
=
false
;
private
static
Boolean
deviceready
=
false
;
// To inform the user about the state of the app in callbacks
private
static
Boolean
isInBackground
=
true
;
// Queues all events before deviceready
// Queues all events before deviceready
private
static
ArrayList
<
String
>
eventQueue
=
new
ArrayList
<
String
>();
private
static
ArrayList
<
String
>
eventQueue
=
new
ArrayList
<
String
>();
...
@@ -80,26 +81,13 @@ public class LocalNotification extends CordovaPlugin {
...
@@ -80,26 +81,13 @@ public class LocalNotification extends CordovaPlugin {
}
}
/**
/**
* Called when the system is about to start resuming a previous activity.
*
* @param multitasking Flag indicating if multitasking is turned on for app.
*/
@Override
public
void
onPause
(
boolean
multitasking
)
{
super
.
onPause
(
multitasking
);
isInBackground
=
true
;
}
/**
* Called when the activity will start interacting with the user.
* Called when the activity will start interacting with the user.
*
*
* @param multitasking
* @param multitasking Flag indicating if multitasking is turned on for app.
* Flag indicating if multitasking is turned on for app
*/
*/
@Override
@Override
public
void
onResume
(
boolean
multitasking
)
{
public
void
onResume
(
boolean
multitasking
)
{
super
.
onResume
(
multitasking
);
super
.
onResume
(
multitasking
);
isInBackground
=
false
;
deviceready
();
deviceready
();
}
}
...
@@ -108,8 +96,7 @@ public class LocalNotification extends CordovaPlugin {
...
@@ -108,8 +96,7 @@ public class LocalNotification extends CordovaPlugin {
*/
*/
@Override
@Override
public
void
onDestroy
()
{
public
void
onDestroy
()
{
deviceready
=
false
;
deviceready
=
false
;
isInBackground
=
true
;
}
}
/**
/**
...
@@ -487,7 +474,6 @@ public class LocalNotification extends CordovaPlugin {
...
@@ -487,7 +474,6 @@ public class LocalNotification extends CordovaPlugin {
* Call all pending callbacks after the deviceready event has been fired.
* Call all pending callbacks after the deviceready event has been fired.
*/
*/
private
static
synchronized
void
deviceready
()
{
private
static
synchronized
void
deviceready
()
{
isInBackground
=
false
;
deviceready
=
true
;
deviceready
=
true
;
for
(
String
js
:
eventQueue
)
{
for
(
String
js
:
eventQueue
)
{
...
@@ -528,7 +514,7 @@ public class LocalNotification extends CordovaPlugin {
...
@@ -528,7 +514,7 @@ public class LocalNotification extends CordovaPlugin {
try
{
try
{
data
.
put
(
"event"
,
event
);
data
.
put
(
"event"
,
event
);
data
.
put
(
"foreground"
,
!
isInBackground
);
data
.
put
(
"foreground"
,
isInForeground
()
);
data
.
put
(
"queued"
,
!
deviceready
);
data
.
put
(
"queued"
,
!
deviceready
);
if
(
toast
!=
null
)
{
if
(
toast
!=
null
)
{
...
@@ -574,6 +560,24 @@ public class LocalNotification extends CordovaPlugin {
...
@@ -574,6 +560,24 @@ public class LocalNotification extends CordovaPlugin {
}
}
/**
/**
* If the app is running in foreground.
*/
private
static
boolean
isInForeground
()
{
if
(!
deviceready
)
return
false
;
KeyguardManager
km
=
(
KeyguardManager
)
webView
.
getContext
()
.
getSystemService
(
Context
.
KEYGUARD_SERVICE
);
//noinspection SimplifiableIfStatement
if
(
km
.
isKeyguardLocked
())
return
false
;
return
webView
.
getView
().
getWindowVisibility
()
==
View
.
VISIBLE
;
}
/**
* Convert JSON array of integers to List.
* Convert JSON array of integers to List.
*
*
* @param ary Array of integers.
* @param ary Array of integers.
...
...
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