Set statusbar and app switcher header color on Android (close #41)
This commit is contained in:
parent
49bddc1b62
commit
9cc023dd96
@ -19,6 +19,7 @@
|
||||
<access launch-external="yes" origin="geo:*" />
|
||||
<platform name="android">
|
||||
<allow-intent href="market:*" />
|
||||
<preference name="HeaderColor" value="#2196F3" />
|
||||
<resource-file src="/res/android/drawable/ic_launcher_background.xml" target="/app/src/main/res/drawable/ic_launcher_background.xml" />
|
||||
<resource-file src="/res/android/drawable/ic_launcher_foreground.xml" target="/app/src/main/res/drawable/ic_launcher_foreground.xml" />
|
||||
<resource-file src="res/android/mipmap-anydpi-v26/ic_launcher.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" />
|
||||
|
@ -2997,7 +2997,7 @@ The Apache Software Foundation (http://www.apache.org/).
|
||||
|
||||
-----
|
||||
|
||||
The following software may be included in this product: cordova-plugin-battery-status, cordova-plugin-device, cordova-plugin-inappbrowser, cordova-plugin-whitelist. A copy of the source code may be downloaded from https://github.com/apache/cordova-plugin-battery-status (cordova-plugin-battery-status), https://github.com/apache/cordova-plugin-device (cordova-plugin-device), https://github.com/apache/cordova-plugin-inappbrowser (cordova-plugin-inappbrowser), https://github.com/apache/cordova-plugin-whitelist (cordova-plugin-whitelist). This software contains the following license and notice below:
|
||||
The following software may be included in this product: cordova-plugin-battery-status, cordova-plugin-device, cordova-plugin-inappbrowser, cordova-plugin-statusbar, cordova-plugin-whitelist. A copy of the source code may be downloaded from https://github.com/apache/cordova-plugin-battery-status (cordova-plugin-battery-status), https://github.com/apache/cordova-plugin-device (cordova-plugin-device), https://github.com/apache/cordova-plugin-inappbrowser (cordova-plugin-inappbrowser), https://github.com/apache/cordova-plugin-statusbar (cordova-plugin-statusbar), https://github.com/apache/cordova-plugin-whitelist (cordova-plugin-whitelist). This software contains the following license and notice below:
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
|
@ -27,7 +27,9 @@
|
||||
"cordova-plugin-whitelist": {},
|
||||
"phonegap-plugin-barcodescanner": {},
|
||||
"cordova-plugin-device": {},
|
||||
"cordova-plugin-battery-status": {}
|
||||
"cordova-plugin-battery-status": {},
|
||||
"cordova-plugin-statusbar": {},
|
||||
"cordova-plugin-headercolor": {}
|
||||
},
|
||||
"platforms": [
|
||||
"android",
|
||||
@ -39,8 +41,10 @@
|
||||
"cordova-browser": "^6.0.0",
|
||||
"cordova-plugin-battery-status": "^2.0.3",
|
||||
"cordova-plugin-device": "^2.0.3",
|
||||
"cordova-plugin-headercolor": "^1.0.0",
|
||||
"cordova-plugin-inappbrowser": "^3.1.0",
|
||||
"cordova-plugin-powermanagement-netsyms": "git+https://source.netsyms.com/Netsyms/cordova-plugin-powermanagement",
|
||||
"cordova-plugin-statusbar": "^2.4.3",
|
||||
"cordova-plugin-whitelist": "^1.3.4"
|
||||
},
|
||||
"devDependencies": {}
|
||||
|
@ -101,19 +101,33 @@ if (getStorage("alertvolume") == null) {
|
||||
setStorage("alertvolume", 100);
|
||||
}
|
||||
|
||||
function setAppTheme(theme) {
|
||||
if (theme == "light") {
|
||||
$("#app").removeClass("theme-dark");
|
||||
if (platform_type == "cordova" && cordova.platformId == 'android' && typeof StatusBar !== 'undefined') {
|
||||
StatusBar.styleDefault();
|
||||
StatusBar.backgroundColorByHexString("#E0E0E0");
|
||||
}
|
||||
} else if (theme == "dark") {
|
||||
$("#app").addClass("theme-dark");
|
||||
if (platform_type == "cordova" && cordova.platformId == 'android' && typeof StatusBar !== 'undefined') {
|
||||
StatusBar.styleLightContent();
|
||||
StatusBar.backgroundColorByHexString("#000000");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function applyColorTheme() {
|
||||
if (getStorage("apptheme") == "dark") {
|
||||
// dark theme
|
||||
$("#app").addClass("theme-dark");
|
||||
setAppTheme("dark");
|
||||
} else if (getStorage("apptheme") == "light") {
|
||||
// light theme
|
||||
$("#app").removeClass("theme-dark");
|
||||
setAppTheme("light");
|
||||
} else {
|
||||
// automatic theme, default light
|
||||
if (typeof Framework7.device.prefersColorScheme() !== 'undefined' && Framework7.device.prefersColorScheme() == "dark") {
|
||||
$("#app").addClass("theme-dark");
|
||||
setAppTheme("dark");
|
||||
} else {
|
||||
$("#app").removeClass("theme-dark");
|
||||
setAppTheme("light");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,6 +122,7 @@ function setupHTML5BarcodeScanner() {
|
||||
|
||||
function initCordova() {
|
||||
platform_type = "cordova";
|
||||
|
||||
// Handle back button to close things
|
||||
document.addEventListener("backbutton", handleBackButton, false);
|
||||
document.addEventListener("deviceready", function () {
|
||||
@ -138,6 +139,9 @@ function initCordova() {
|
||||
console.log("Warn", 'Failed to release wakelock');
|
||||
});
|
||||
}
|
||||
|
||||
// Make sure the status bar color is set properly
|
||||
applyColorTheme();
|
||||
}, false);
|
||||
openBrowser = function (url) {
|
||||
cordova.InAppBrowser.open(url, '_blank', 'location=yes');
|
||||
|
@ -3102,7 +3102,7 @@ The Apache Software Foundation (http://www.apache.org/).
|
||||
|
||||
-----
|
||||
|
||||
The following software may be included in this product: cordova-plugin-battery-status, cordova-plugin-device, cordova-plugin-inappbrowser, cordova-plugin-whitelist. A copy of the source code may be downloaded from https://github.com/apache/cordova-plugin-battery-status (cordova-plugin-battery-status), https://github.com/apache/cordova-plugin-device (cordova-plugin-device), https://github.com/apache/cordova-plugin-inappbrowser (cordova-plugin-inappbrowser), https://github.com/apache/cordova-plugin-whitelist (cordova-plugin-whitelist). This software contains the following license and notice below:
|
||||
The following software may be included in this product: cordova-plugin-battery-status, cordova-plugin-device, cordova-plugin-inappbrowser, cordova-plugin-statusbar, cordova-plugin-whitelist. A copy of the source code may be downloaded from https://github.com/apache/cordova-plugin-battery-status (cordova-plugin-battery-status), https://github.com/apache/cordova-plugin-device (cordova-plugin-device), https://github.com/apache/cordova-plugin-inappbrowser (cordova-plugin-inappbrowser), https://github.com/apache/cordova-plugin-statusbar (cordova-plugin-statusbar), https://github.com/apache/cordova-plugin-whitelist (cordova-plugin-whitelist). This software contains the following license and notice below:
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
|
@ -485,8 +485,8 @@ var routes = [
|
||||
text: "Log out",
|
||||
link: true,
|
||||
onclick: "logout()"
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
settings.push(
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user