Add persistent notification for background GPS

Skylar Ittner 4 years ago
parent 0203720cd1
commit b2f0d00795

8
package-lock.json generated

@ -1,6 +1,6 @@
{ {
"name": "com.netsyms.packagehelper", "name": "com.netsyms.packagehelper",
"version": "1.6.0", "version": "1.6.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -423,6 +423,12 @@
"resolved": "https://registry.npmjs.org/cordova-plugin-device/-/cordova-plugin-device-2.0.3.tgz", "resolved": "https://registry.npmjs.org/cordova-plugin-device/-/cordova-plugin-device-2.0.3.tgz",
"integrity": "sha1-wrQbfv0EVd0Jf4k1bYW/3V2t6w8=" "integrity": "sha1-wrQbfv0EVd0Jf4k1bYW/3V2t6w8="
}, },
"cordova-plugin-foreground-service": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/cordova-plugin-foreground-service/-/cordova-plugin-foreground-service-1.1.3.tgz",
"integrity": "sha512-/C2Z8w9JIfAaLeXP290msQP9jcHR+CAJYbp6/x+mS21VtvS2Ug0upKsgjEzzSzRnt08Mr8kuwCV7juUd6eCWcw==",
"dev": true
},
"cordova-plugin-headercolor": { "cordova-plugin-headercolor": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/cordova-plugin-headercolor/-/cordova-plugin-headercolor-1.0.0.tgz", "resolved": "https://registry.npmjs.org/cordova-plugin-headercolor/-/cordova-plugin-headercolor-1.0.0.tgz",

@ -29,7 +29,8 @@
"cordova-plugin-device": {}, "cordova-plugin-device": {},
"cordova-plugin-battery-status": {}, "cordova-plugin-battery-status": {},
"cordova-plugin-statusbar": {}, "cordova-plugin-statusbar": {},
"cordova-plugin-headercolor": {} "cordova-plugin-headercolor": {},
"cordova-plugin-foreground-service": {}
}, },
"platforms": [ "platforms": [
"browser", "browser",
@ -47,5 +48,7 @@
"cordova-plugin-statusbar": "^2.4.3", "cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-whitelist": "^1.3.4" "cordova-plugin-whitelist": "^1.3.4"
}, },
"devDependencies": {} "devDependencies": {
"cordova-plugin-foreground-service": "^1.1.3"
}
} }

@ -169,6 +169,10 @@ function initCordova() {
}); });
} }
if (getStorage("runinbackground") == "true") {
cordova.plugins.foregroundService.start('PackageHelper', 'GPS active');
}
// Make sure the status bar color is set properly // Make sure the status bar color is set properly
applyColorTheme(); applyColorTheme();
}, false); }, false);

@ -98,6 +98,22 @@ $('.item-content[data-setting=wakelock] .toggle input').on("change", function ()
} }
}); });
$('.item-content[data-setting=runinbackground] .toggle input').on("change", function () {
var checked = $(this).prop('checked');
setStorage("runinbackground", checked);
if (platform_type == "cordova") {
loadSettings();
} else {
app.toast.show({
text: "This setting won't do anything on your device.",
position: "bottom",
destroyOnClose: true,
closeTimeout: 1000 * 10
});
}
});
$('.item-content[data-setting=hardwarescanner] .toggle input').on("change", function () { $('.item-content[data-setting=hardwarescanner] .toggle input').on("change", function () {
var checked = $(this).prop('checked'); var checked = $(this).prop('checked');
setStorage("hardwarescanner", checked); setStorage("hardwarescanner", checked);

@ -100,6 +100,12 @@ function loadSettings() {
console.log("Warn", 'Failed to release wakelock'); console.log("Warn", 'Failed to release wakelock');
}); });
} }
if (getStorage("runinbackground") == "true") {
cordova.plugins.foregroundService.start('PackageHelper', 'GPS active');
} else {
cordova.plugins.foregroundService.stop();
}
} }
} }

@ -531,11 +531,11 @@ var routes = [
}); });
if (platform_type == "cordova" && cordova.platformId != "browser") { if (platform_type == "cordova" && cordova.platformId != "browser") {
settings.push({ settings.push({
setting: "wakelock", setting: "runinbackground",
title: "Keep screen on", title: "Run in background",
text: "Improves GPS accuracy and alert sound reliability, but uses more battery.", text: "Get package alerts when the screen is off or a different app is open.",
toggle: true, toggle: true,
checked: getStorage("wakelock") == "true", checked: getStorage("runinbackground") == "true",
onclick: "" onclick: ""
}); });
} }
@ -798,8 +798,19 @@ var routes = [
selected: getStorage("animation") == "off" selected: getStorage("animation") == "off"
} }
] ]
}, }
{ ];
if (platform_type == "cordova" && cordova.platformId != "browser") {
settings.push({
setting: "wakelock",
title: "Keep screen on",
text: "",
toggle: true,
checked: getStorage("wakelock") == "true",
onclick: ""
});
}
settings.push([{
setting: "showhelp", setting: "showhelp",
title: "Show help", title: "Show help",
text: "Show the <span class=material-icons-intext><i class=material-icons>help</i></span> icons", text: "Show the <span class=material-icons-intext><i class=material-icons>help</i></span> icons",
@ -815,7 +826,7 @@ var routes = [
checked: getStorage("oldhomeui") == "true", checked: getStorage("oldhomeui") == "true",
onclick: "" onclick: ""
} }
]; ]);
resolve({ resolve({
templateUrl: './pages/settings.html' templateUrl: './pages/settings.html'
}, { }, {

Loading…
Cancel
Save