Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit 2160173

Browse files
committed
Merge pull request #161 from fujunwei/immersive-mode
Add a preference to disable immersive mode
2 parents 4769998 + 18b6305 commit 2160173

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

framework/src/org/apache/cordova/CordovaActivity.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public void onCreate(Bundle savedInstanceState) {
228228
} else if (preferences.getBoolean("Fullscreen", false)) {
229229
toggleFullscreen(getWindow());
230230

231-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
231+
if (isImmersiveMode()) {
232232
getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
233233
@Override
234234
public void onSystemUiVisibilityChange(int visibility) {
@@ -315,14 +315,19 @@ protected void createViews() {
315315
*/
316316
@SuppressLint("NewApi")
317317
private void toggleFullscreen(Window window) {
318-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
318+
if (isImmersiveMode()) {
319319
setSystemUiVisibilityMode(window);
320320
} else {
321321
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
322322
WindowManager.LayoutParams.FLAG_FULLSCREEN);
323323
}
324324
}
325325

326+
private boolean isImmersiveMode() {
327+
return !preferences.getBoolean("disableImmersive", false) &&
328+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
329+
}
330+
326331
private void setSystemUiVisibilityMode(Window window) {
327332
final int uiOptions =
328333
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
@@ -1042,7 +1047,7 @@ public void run() {
10421047
{
10431048
toggleFullscreen(splashDialog.getWindow());
10441049

1045-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
1050+
if (isImmersiveMode()) {
10461051
splashDialog.getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
10471052
@Override
10481053
public void onSystemUiVisibilityChange(int visibility) {

0 commit comments

Comments
 (0)