diff --git a/src/android/StatusBar.java b/src/android/StatusBar.java index 6c99d78..7b4d946 100644 --- a/src/android/StatusBar.java +++ b/src/android/StatusBar.java @@ -142,6 +142,23 @@ public class StatusBar extends CordovaPlugin { return true; } + if ("overlaysWebView".equals(action)) { + if (Build.VERSION.SDK_INT >= 21) { + this.cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + try { + setStatusBarTransparent(args.getBoolean(0)); + } catch (JSONException ignore) { + LOG.e(TAG, "Invalid boolean argument"); + } + } + }); + return true; + } + else return args.getBoolean(0) == false; + } + return false; } @@ -164,4 +181,21 @@ public class StatusBar extends CordovaPlugin { } } } + + private void setStatusBarTransparent(final boolean transparent) { + if (Build.VERSION.SDK_INT >= 21) { + final Window window = cordova.getActivity().getWindow(); + if (transparent) { + window.getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + window.setStatusBarColor(Color.TRANSPARENT); + } + else { + window.getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_VISIBLE); + } + } + } }