MOBILE-4331 app: Remove status bar color from local plugin
parent
7c97b6aedb
commit
701c71c6cb
|
@ -32,11 +32,7 @@ public class SystemUI extends CordovaPlugin {
|
|||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
|
||||
try {
|
||||
switch (action) {
|
||||
case "setNavigationBarColor":
|
||||
this.setNavigationBarColor(args.getString(0));
|
||||
callbackContext.success();
|
||||
|
||||
return true;
|
||||
// No actions yet.
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Log.e(TAG, "Failed executing action: " + action, e);
|
||||
|
@ -45,41 +41,5 @@ public class SystemUI extends CordovaPlugin {
|
|||
return false;
|
||||
}
|
||||
|
||||
private void setNavigationBarColor(String color) {
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (color == null || color.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d(TAG, "Setting navigation bar color to " + color);
|
||||
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final int FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000;
|
||||
final int SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR = 0x00000010;
|
||||
final Window window = cordova.getActivity().getWindow();
|
||||
int uiOptions = window.getDecorView().getSystemUiVisibility();
|
||||
|
||||
uiOptions = uiOptions | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
|
||||
uiOptions = uiOptions & ~SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
||||
|
||||
window.getDecorView().setSystemUiVisibility(uiOptions);
|
||||
|
||||
try {
|
||||
// Using reflection makes sure any 5.0+ device will work without having to compile with SDK level 21
|
||||
window.getClass().getDeclaredMethod("setNavigationBarColor", int.class).invoke(window, Color.parseColor(color));
|
||||
} catch (IllegalArgumentException ignore) {
|
||||
Log.e(TAG, "Invalid hexString argument, use f.i. '#999999'");
|
||||
} catch (Exception ignore) {
|
||||
// this should not happen, only in case Android removes this method in a version > 21
|
||||
Log.w(TAG, "Method window.setNavigationBarColor not found for SDK level " + Build.VERSION.SDK_INT);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue