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:*" />
|
<access launch-external="yes" origin="geo:*" />
|
||||||
<platform name="android">
|
<platform name="android">
|
||||||
<allow-intent href="market:*" />
|
<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_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/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" />
|
<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
|
Apache License
|
||||||
Version 2.0, January 2004
|
Version 2.0, January 2004
|
||||||
|
@ -27,7 +27,9 @@
|
|||||||
"cordova-plugin-whitelist": {},
|
"cordova-plugin-whitelist": {},
|
||||||
"phonegap-plugin-barcodescanner": {},
|
"phonegap-plugin-barcodescanner": {},
|
||||||
"cordova-plugin-device": {},
|
"cordova-plugin-device": {},
|
||||||
"cordova-plugin-battery-status": {}
|
"cordova-plugin-battery-status": {},
|
||||||
|
"cordova-plugin-statusbar": {},
|
||||||
|
"cordova-plugin-headercolor": {}
|
||||||
},
|
},
|
||||||
"platforms": [
|
"platforms": [
|
||||||
"android",
|
"android",
|
||||||
@ -39,8 +41,10 @@
|
|||||||
"cordova-browser": "^6.0.0",
|
"cordova-browser": "^6.0.0",
|
||||||
"cordova-plugin-battery-status": "^2.0.3",
|
"cordova-plugin-battery-status": "^2.0.3",
|
||||||
"cordova-plugin-device": "^2.0.3",
|
"cordova-plugin-device": "^2.0.3",
|
||||||
|
"cordova-plugin-headercolor": "^1.0.0",
|
||||||
"cordova-plugin-inappbrowser": "^3.1.0",
|
"cordova-plugin-inappbrowser": "^3.1.0",
|
||||||
"cordova-plugin-powermanagement-netsyms": "git+https://source.netsyms.com/Netsyms/cordova-plugin-powermanagement",
|
"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"
|
"cordova-plugin-whitelist": "^1.3.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {}
|
"devDependencies": {}
|
||||||
|
@ -101,19 +101,33 @@ if (getStorage("alertvolume") == null) {
|
|||||||
setStorage("alertvolume", 100);
|
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() {
|
function applyColorTheme() {
|
||||||
if (getStorage("apptheme") == "dark") {
|
if (getStorage("apptheme") == "dark") {
|
||||||
// dark theme
|
setAppTheme("dark");
|
||||||
$("#app").addClass("theme-dark");
|
|
||||||
} else if (getStorage("apptheme") == "light") {
|
} else if (getStorage("apptheme") == "light") {
|
||||||
// light theme
|
setAppTheme("light");
|
||||||
$("#app").removeClass("theme-dark");
|
|
||||||
} else {
|
} else {
|
||||||
// automatic theme, default light
|
// automatic theme, default light
|
||||||
if (typeof Framework7.device.prefersColorScheme() !== 'undefined' && Framework7.device.prefersColorScheme() == "dark") {
|
if (typeof Framework7.device.prefersColorScheme() !== 'undefined' && Framework7.device.prefersColorScheme() == "dark") {
|
||||||
$("#app").addClass("theme-dark");
|
setAppTheme("dark");
|
||||||
} else {
|
} else {
|
||||||
$("#app").removeClass("theme-dark");
|
setAppTheme("light");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,7 @@ function setupHTML5BarcodeScanner() {
|
|||||||
|
|
||||||
function initCordova() {
|
function initCordova() {
|
||||||
platform_type = "cordova";
|
platform_type = "cordova";
|
||||||
|
|
||||||
// Handle back button to close things
|
// Handle back button to close things
|
||||||
document.addEventListener("backbutton", handleBackButton, false);
|
document.addEventListener("backbutton", handleBackButton, false);
|
||||||
document.addEventListener("deviceready", function () {
|
document.addEventListener("deviceready", function () {
|
||||||
@ -138,6 +139,9 @@ function initCordova() {
|
|||||||
console.log("Warn", 'Failed to release wakelock');
|
console.log("Warn", 'Failed to release wakelock');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure the status bar color is set properly
|
||||||
|
applyColorTheme();
|
||||||
}, false);
|
}, false);
|
||||||
openBrowser = function (url) {
|
openBrowser = function (url) {
|
||||||
cordova.InAppBrowser.open(url, '_blank', 'location=yes');
|
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
|
Apache License
|
||||||
Version 2.0, January 2004
|
Version 2.0, January 2004
|
||||||
|
@ -485,8 +485,8 @@ var routes = [
|
|||||||
text: "Log out",
|
text: "Log out",
|
||||||
link: true,
|
link: true,
|
||||||
onclick: "logout()"
|
onclick: "logout()"
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
settings.push(
|
settings.push(
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user