Repository: cordova-plugin-statusbar Updated Branches: refs/heads/master d980145c9 -> 3f552ed73
CB-10879: Enable overlaysWebView on Android API 21+ This closes #77 This patch enables devices running Android API 21+ to have the status bar overlaying the WebView, i.e. `StatusBar.overlaysWebView(true)`. It lets any Android version call `StatusBar.overlaysWebView(false)` to disable the overlay, which is actually the default behavior on that platform. Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/commit/3f552ed7 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/tree/3f552ed7 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/diff/3f552ed7 Branch: refs/heads/master Commit: 3f552ed7343bf5f7982abc187afefe0b097ae7f2 Parents: d980145 Author: Andrea Lazzarotto <[email protected]> Authored: Sun Feb 26 20:11:07 2017 +0100 Committer: Joe Bowser <[email protected]> Committed: Tue Apr 25 12:05:23 2017 -0700 ---------------------------------------------------------------------- src/android/StatusBar.java | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/blob/3f552ed7/src/android/StatusBar.java ---------------------------------------------------------------------- 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); + } + } + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
