diff options
author | Struan Donald <struan@exo.org.uk> | 2013-07-22 12:48:20 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-07-22 12:48:20 +0100 |
commit | f0b29924c62849b6547530bb16bc5309d29f598b (patch) | |
tree | 2236ff5f66111bee5d0bd2011e22770e7d930065 /src | |
parent | db2b27eeb442241dc5f6b7e7ba122daeb8a9e78a (diff) |
Pause and restart position updating on app pause and resume to stop backgroud GPS tracking on Android. Fixes #61
Diffstat (limited to 'src')
-rw-r--r-- | src/js/app.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/js/app.js b/src/js/app.js index af02b0a..8d28084 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -171,8 +171,8 @@ var tpl = { FMS.currentUser = new FMS.User({id: 1}); } - document.addEventListener('pause', function() { FMS.saveCurrentDraft(); }, false); - document.addEventListener('resume', function() { FMS.checkOnlineStatus(); FMS.loadCurrentDraft(); }, false); + document.addEventListener('pause', function() { FMS.locator.stopTracking(); FMS.saveCurrentDraft(); }, false); + document.addEventListener('resume', onResume, false); document.addEventListener('backbutton', function() { FMS.router.back(); }, true); document.addEventListener('offline', function() { FMS.offline(); }, true); document.addEventListener('online', function() { FMS.online(); }, true); @@ -191,6 +191,14 @@ var tpl = { }); } }); + + function onResume() { + FMS.checkOnlineStatus(); + FMS.loadCurrentDraft(); + if ( ( FMS.router.currentView.id == 'front-page' || FMS.router.currentView.id == 'around-page' ) && FMS.currentPosition !== null ) { + FMS.locator.trackPosition(); + } + } })(FMS, Backbone, _, $); var androidStartUp = function() { |