Add wakelock feature
This commit is contained in:
parent
1e0b435064
commit
a429277009
@ -15,7 +15,8 @@
|
|||||||
"cordova": {
|
"cordova": {
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"cordova-plugin-geolocation": {},
|
"cordova-plugin-geolocation": {},
|
||||||
"cordova-plugin-whitelist": {}
|
"cordova-plugin-whitelist": {},
|
||||||
|
"at.gofg.sportscomputer.powermanagement": {}
|
||||||
},
|
},
|
||||||
"platforms": [
|
"platforms": [
|
||||||
"android"
|
"android"
|
||||||
@ -23,6 +24,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cordova-android": "^8.0.0",
|
"cordova-android": "^8.0.0",
|
||||||
|
"cordova-plugin-powermanagement-orig": "git+https://github.com/boltex/cordova-plugin-powermanagement.git",
|
||||||
"cordova-plugin-whitelist": "^1.3.4"
|
"cordova-plugin-whitelist": "^1.3.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -73,7 +73,19 @@ function initCordova() {
|
|||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
document.addEventListener("deviceready", function () {
|
document.addEventListener("deviceready", function () {
|
||||||
|
if (localStorage.getItem("wakelock") == "true") {
|
||||||
|
window.powerManagement.dim(function () {
|
||||||
|
console.log('Partial wakelock acquired');
|
||||||
|
}, function () {
|
||||||
|
console.log('Failed to acquire partial wakelock');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
window.powerManagement.release(function () {
|
||||||
|
console.log('Wakelock released');
|
||||||
|
}, function () {
|
||||||
|
console.log('Failed to release wakelock');
|
||||||
|
});
|
||||||
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
openBrowser = function (url) {
|
openBrowser = function (url) {
|
||||||
|
@ -17,6 +17,35 @@ $('.item-content[data-setting=darktheme] .toggle input').on("change", function (
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.item-content[data-setting=wakelock] .toggle input').on("change", function () {
|
||||||
|
var checked = $(this).prop('checked');
|
||||||
|
console.log(checked);
|
||||||
|
localStorage.setItem("wakelock", checked);
|
||||||
|
|
||||||
|
if (platform_type == "cordova") {
|
||||||
|
if (localStorage.getItem("wakelock") == "true") {
|
||||||
|
window.powerManagement.dim(function () {
|
||||||
|
console.log('Partial wakelock acquired');
|
||||||
|
}, function () {
|
||||||
|
console.log('Failed to acquire partial wakelock');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
window.powerManagement.release(function () {
|
||||||
|
console.log('Wakelock released');
|
||||||
|
}, function () {
|
||||||
|
console.log('Failed to release wakelock');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
app.toast.show({
|
||||||
|
text: "This setting won't do anything on your device.",
|
||||||
|
position: "bottom",
|
||||||
|
destroyOnClose: true,
|
||||||
|
closeTimeout: 1000 * 10
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function pickAlertSound() {
|
function pickAlertSound() {
|
||||||
var currentalertsound = localStorage.getItem("alertsound");
|
var currentalertsound = localStorage.getItem("alertsound");
|
||||||
app.dialog.create({
|
app.dialog.create({
|
||||||
|
@ -81,10 +81,18 @@ var routes = [
|
|||||||
text: "Select which sound to play when a package is nearby.",
|
text: "Select which sound to play when a package is nearby.",
|
||||||
onclick: "pickAlertSound()"
|
onclick: "pickAlertSound()"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
setting: "wakelock",
|
||||||
|
title: "Keep screen on",
|
||||||
|
text: "Improves GPS accuracy and alert sound reliability, but uses more battery.",
|
||||||
|
toggle: true,
|
||||||
|
checked: localStorage.getItem("wakelock") == "true",
|
||||||
|
onclick: ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
setting: "darktheme",
|
setting: "darktheme",
|
||||||
title: "Use dark theme",
|
title: "Use dark theme",
|
||||||
text: "",
|
text: "Saves power on phones with OLED screens.",
|
||||||
toggle: true,
|
toggle: true,
|
||||||
checked: localStorage.getItem("darktheme") == "true",
|
checked: localStorage.getItem("darktheme") == "true",
|
||||||
onclick: ""
|
onclick: ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user