Android: let fullscreen use entire screen

API level 19 (Android 4.4) introduces "immersive" mode which lets
the app use the entire screen.

Change-Id: I12f6aebaf1303cdc5b6bfb51944e895351fa2406
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
bb10
Paul Olav Tvete 2013-12-11 16:49:59 +01:00 committed by The Qt Project
parent 58326e8585
commit c6b285a79d
1 changed files with 38 additions and 0 deletions

View File

@ -139,9 +139,41 @@ public class QtActivityDelegate
if (m_fullScreen = enterFullScreen) {
m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
if (Build.VERSION.SDK_INT >= 19) {
try {
int ui_flag_immersive_sticky = View.class.getDeclaredField("SYSTEM_UI_FLAG_IMMERSIVE_STICKY").getInt(null);
int ui_flag_layout_stable = View.class.getDeclaredField("SYSTEM_UI_FLAG_LAYOUT_STABLE").getInt(null);
int ui_flag_layout_hide_navigation = View.class.getDeclaredField("SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION").getInt(null);
int ui_flag_layout_fullscreen = View.class.getDeclaredField("SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN").getInt(null);
int ui_flag_hide_navigation = View.class.getDeclaredField("SYSTEM_UI_FLAG_HIDE_NAVIGATION").getInt(null);
int ui_flag_fullscreen = View.class.getDeclaredField("SYSTEM_UI_FLAG_FULLSCREEN").getInt(null);
Method m = View.class.getMethod("setSystemUiVisibility", int.class);
m.invoke(m_activity.getWindow().getDecorView(),
ui_flag_layout_stable
| ui_flag_layout_hide_navigation
| ui_flag_layout_fullscreen
| ui_flag_hide_navigation
| ui_flag_fullscreen
| ui_flag_immersive_sticky
| View.INVISIBLE);
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
if (Build.VERSION.SDK_INT >= 19) {
try {
int ui_flag_visible = View.class.getDeclaredField("SYSTEM_UI_FLAG_VISIBLE").getInt(null);
Method m = View.class.getMethod("setSystemUiVisibility", int.class);
m.invoke(m_activity.getWindow().getDecorView(),
ui_flag_visible);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
@ -696,6 +728,12 @@ public class QtActivityDelegate
QtNative.updateApplicationState(ApplicationActive);
QtNative.clearLostActions();
QtNative.updateWindow();
if (m_fullScreen) {
// Suspending the app clears the immersive mode, so we need to set it again.
m_fullScreen = false; // Force the setFullScreen() call below to actually do something
setFullScreen(true);
}
}
}
}