Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cordova-plugin-background-geolocation
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Aksimaya
cordova-plugin-background-geolocation
Commits
bda025f2
Commit
bda025f2
authored
Mar 13, 2014
by
Chris Scott
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'android'
parents
ba81579e
569a6e81
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
259 additions
and
153 deletions
+259
-153
BackgroundGpsPlugin.java
src/android/BackgroundGpsPlugin.java
+8
-3
LocationUpdateService.java
src/android/LocationUpdateService.java
+216
-136
Location.java
src/android/data/Location.java
+17
-1
LocationOpenHelper.java
src/android/data/sqlite/LocationOpenHelper.java
+14
-12
SQLiteLocationDAO.java
src/android/data/sqlite/SQLiteLocationDAO.java
+4
-1
No files found.
src/android/BackgroundGpsPlugin.java
View file @
bda025f2
...
@@ -21,6 +21,8 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
...
@@ -21,6 +21,8 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
private
Intent
updateServiceIntent
;
private
Intent
updateServiceIntent
;
private
Boolean
isEnabled
=
false
;
private
String
authToken
;
private
String
authToken
;
private
String
url
;
private
String
url
;
private
String
stationaryRadius
=
"30"
;
private
String
stationaryRadius
=
"30"
;
...
@@ -33,7 +35,8 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
...
@@ -33,7 +35,8 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
Activity
activity
=
this
.
cordova
.
getActivity
();
Activity
activity
=
this
.
cordova
.
getActivity
();
Boolean
result
=
false
;
Boolean
result
=
false
;
updateServiceIntent
=
new
Intent
(
activity
,
LocationUpdateService
.
class
);
updateServiceIntent
=
new
Intent
(
activity
,
LocationUpdateService
.
class
);
if
(
ACTION_START
.
equalsIgnoreCase
(
action
))
{
if
(
ACTION_START
.
equalsIgnoreCase
(
action
)
&&
!
isEnabled
)
{
result
=
true
;
result
=
true
;
if
(
authToken
==
null
||
url
==
null
)
{
if
(
authToken
==
null
||
url
==
null
)
{
callbackContext
.
error
(
"Call configure before calling start"
);
callbackContext
.
error
(
"Call configure before calling start"
);
...
@@ -49,8 +52,10 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
...
@@ -49,8 +52,10 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
updateServiceIntent
.
putExtra
(
"isDebugging"
,
isDebugging
);
updateServiceIntent
.
putExtra
(
"isDebugging"
,
isDebugging
);
activity
.
startService
(
updateServiceIntent
);
activity
.
startService
(
updateServiceIntent
);
isEnabled
=
true
;
}
}
}
else
if
(
ACTION_STOP
.
equalsIgnoreCase
(
action
))
{
}
else
if
(
ACTION_STOP
.
equalsIgnoreCase
(
action
))
{
isEnabled
=
false
;
result
=
true
;
result
=
true
;
activity
.
stopService
(
updateServiceIntent
);
activity
.
stopService
(
updateServiceIntent
);
callbackContext
.
success
();
callbackContext
.
success
();
...
...
src/android/LocationUpdateService.java
View file @
bda025f2
This diff is collapsed.
Click to expand it.
src/android/data/Location.java
View file @
bda025f2
...
@@ -9,6 +9,9 @@ public class Location {
...
@@ -9,6 +9,9 @@ public class Location {
private
String
latitude
;
private
String
latitude
;
private
String
longitude
;
private
String
longitude
;
private
Date
recordedAt
;
private
Date
recordedAt
;
private
String
accuracy
;
private
String
speed
;
private
Long
id
;
private
Long
id
;
public
Long
getId
()
{
public
Long
getId
()
{
...
@@ -17,7 +20,6 @@ public class Location {
...
@@ -17,7 +20,6 @@ public class Location {
public
void
setId
(
Long
id
)
{
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
String
getLatitude
()
{
public
String
getLatitude
()
{
return
latitude
;
return
latitude
;
}
}
...
@@ -36,12 +38,26 @@ public class Location {
...
@@ -36,12 +38,26 @@ public class Location {
public
void
setRecordedAt
(
Date
recordedAt
)
{
public
void
setRecordedAt
(
Date
recordedAt
)
{
this
.
recordedAt
=
recordedAt
;
this
.
recordedAt
=
recordedAt
;
}
}
public
String
getAccuracy
()
{
return
accuracy
;
}
public
void
setAccuracy
(
String
accuracy
)
{
this
.
accuracy
=
accuracy
;
}
public
String
getSpeed
()
{
return
speed
;
}
public
void
setSpeed
(
String
speed
)
{
this
.
speed
=
speed
;
}
public
static
Location
fromAndroidLocation
(
android
.
location
.
Location
originalLocation
)
{
public
static
Location
fromAndroidLocation
(
android
.
location
.
Location
originalLocation
)
{
Location
location
=
new
Location
();
Location
location
=
new
Location
();
location
.
setRecordedAt
(
new
Date
(
originalLocation
.
getTime
()));
location
.
setRecordedAt
(
new
Date
(
originalLocation
.
getTime
()));
location
.
setLongitude
(
String
.
valueOf
(
originalLocation
.
getLongitude
()));
location
.
setLongitude
(
String
.
valueOf
(
originalLocation
.
getLongitude
()));
location
.
setLatitude
(
String
.
valueOf
(
originalLocation
.
getLatitude
()));
location
.
setLatitude
(
String
.
valueOf
(
originalLocation
.
getLatitude
()));
location
.
setAccuracy
(
String
.
valueOf
(
originalLocation
.
getAccuracy
()));
location
.
setSpeed
(
String
.
valueOf
(
originalLocation
.
getSpeed
()));
return
location
;
return
location
;
}
}
...
...
src/android/data/sqlite/LocationOpenHelper.java
View file @
bda025f2
...
@@ -13,6 +13,8 @@ public class LocationOpenHelper extends SQLiteOpenHelper {
...
@@ -13,6 +13,8 @@ public class LocationOpenHelper extends SQLiteOpenHelper {
private
static
final
String
LOCATION_TABLE_COLUMNS
=
private
static
final
String
LOCATION_TABLE_COLUMNS
=
" id INTEGER PRIMARY KEY AUTOINCREMENT,"
+
" id INTEGER PRIMARY KEY AUTOINCREMENT,"
+
" recordedAt TEXT,"
+
" recordedAt TEXT,"
+
" accuracy TEXT,"
+
" speed TEXT,"
+
" latitude TEXT,"
+
" latitude TEXT,"
+
" longitude TEXT"
;
" longitude TEXT"
;
private
static
final
String
LOCATION_TABLE_CREATE
=
private
static
final
String
LOCATION_TABLE_CREATE
=
...
...
src/android/data/sqlite/SQLiteLocationDAO.java
View file @
bda025f2
...
@@ -78,6 +78,8 @@ public class SQLiteLocationDAO implements LocationDAO {
...
@@ -78,6 +78,8 @@ public class SQLiteLocationDAO implements LocationDAO {
l
.
setRecordedAt
(
stringToDate
(
c
.
getString
(
c
.
getColumnIndex
(
"recordedAt"
))));
l
.
setRecordedAt
(
stringToDate
(
c
.
getString
(
c
.
getColumnIndex
(
"recordedAt"
))));
l
.
setLatitude
(
c
.
getString
(
c
.
getColumnIndex
(
"latitude"
)));
l
.
setLatitude
(
c
.
getString
(
c
.
getColumnIndex
(
"latitude"
)));
l
.
setLongitude
(
c
.
getString
(
c
.
getColumnIndex
(
"longitude"
)));
l
.
setLongitude
(
c
.
getString
(
c
.
getColumnIndex
(
"longitude"
)));
l
.
setAccuracy
(
c
.
getString
(
c
.
getColumnIndex
(
"accuracy"
)));
l
.
setSpeed
(
c
.
getString
(
c
.
getColumnIndex
(
"speed"
)));
return
l
;
return
l
;
}
}
...
@@ -87,7 +89,8 @@ public class SQLiteLocationDAO implements LocationDAO {
...
@@ -87,7 +89,8 @@ public class SQLiteLocationDAO implements LocationDAO {
values
.
put
(
"latitude"
,
location
.
getLatitude
());
values
.
put
(
"latitude"
,
location
.
getLatitude
());
values
.
put
(
"longitude"
,
location
.
getLongitude
());
values
.
put
(
"longitude"
,
location
.
getLongitude
());
values
.
put
(
"recordedAt"
,
dateToString
(
location
.
getRecordedAt
()));
values
.
put
(
"recordedAt"
,
dateToString
(
location
.
getRecordedAt
()));
values
.
put
(
"accuracy"
,
location
.
getAccuracy
());
values
.
put
(
"speed"
,
location
.
getSpeed
());
return
values
;
return
values
;
}
}
...
...
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