From a4a1065c4f47243f835f195c8359f33c2379922a Mon Sep 17 00:00:00 2001 From: Vladimir Kotikov Date: Tue, 29 Dec 2015 10:27:43 +0300 Subject: [PATCH] CB-9513 Allow to show/hide status bar in fullscreen mode. This closes #42 --- src/android/StatusBar.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/android/StatusBar.java b/src/android/StatusBar.java index 21a6602..0b7d67c 100644 --- a/src/android/StatusBar.java +++ b/src/android/StatusBar.java @@ -23,6 +23,7 @@ import android.app.Activity; import android.graphics.Color; import android.os.Build; import android.util.Log; +import android.view.View; import android.view.Window; import android.view.WindowManager; @@ -76,6 +77,7 @@ public class StatusBar extends CordovaPlugin { Log.v(TAG, "Executing action: " + action); final Activity activity = this.cordova.getActivity(); final Window window = activity.getWindow(); + if ("_ready".equals(action)) { boolean statusBarVisible = (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0; callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible)); @@ -86,6 +88,17 @@ public class StatusBar extends CordovaPlugin { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { + // SYSTEM_UI_FLAG_FULLSCREEN is available since JellyBean, but we + // use KitKat here to be aligned with "Fullscreen" preference + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + int uiOptions = window.getDecorView().getSystemUiVisibility(); + uiOptions &= ~View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; + uiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN; + + window.getDecorView().setSystemUiVisibility(uiOptions); + return; + } + window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } }); @@ -96,6 +109,17 @@ public class StatusBar extends CordovaPlugin { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { + // SYSTEM_UI_FLAG_FULLSCREEN is available since JellyBean, but we + // use KitKat here to be aligned with "Fullscreen" preference + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + int uiOptions = window.getDecorView().getSystemUiVisibility() + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_FULLSCREEN; + + window.getDecorView().setSystemUiVisibility(uiOptions); + return; + } + window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } });