From 3238d1aa3587b8b0b357aa35362a3302a9ddcef5 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Tue, 14 Apr 2020 22:06:48 -0600 Subject: [PATCH] Hopefully fix battery status detection --- www/assets/js/platform.js | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/www/assets/js/platform.js b/www/assets/js/platform.js index 0868fd2..29a1856 100644 --- a/www/assets/js/platform.js +++ b/www/assets/js/platform.js @@ -173,28 +173,6 @@ function initCordova() { } ); }; - - window.addEventListener("batterylow", function (status) { - auto_disable_animations = true; - if (getStorage("animation") == "auto") { - toggleAnimations(false); - } - batterylevel = status.level; - }, false); - - window.addEventListener("batterystatus", function (status) { - if (status.isPlugged && getStorage("animation") == "auto") { - // Plugged in, enable animations - auto_disable_animations = false; - toggleAnimations(true); - } - if (typeof batterylevel !== 'undefined' && status.level > batterylevel && getStorage("animation") == "auto") { - // The battery level has gone up from when it was low, so we're probably not low anymore - auto_disable_animations = false; - toggleAnimations(true); - } - }, false); - } else { setupHTML5BarcodeScanner(); } @@ -204,6 +182,19 @@ function initCordova() { window.open($(this).attr("href"), "_system"); evt.preventDefault(); }); + + window.addEventListener("batterystatus", function (status) { + if (getStorage("animation") == "auto") { + if (status.isPlugged || status.level > 20) { + // Plugged in or above 20%, enable animations + auto_disable_animations = false; + toggleAnimations(true); + } else { + auto_disable_animations = false; + toggleAnimations(true); + } + } + }, false); } function initNW() {