Android: Set "immersive" mode on earlier android versions.

Most of "immersive" flags are available on earlier Android versions.

Change-Id: Ic4f03a3c9491570bc5f8c5afbb61669644b20d8e
Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
This commit is contained in:
BogDan Vatra 2015-05-28 10:55:12 +03:00 committed by BogDan Vatra
parent 5632375b86
commit c63f4c5d01

View File

@ -133,37 +133,32 @@ 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);
try {
if (Build.VERSION.SDK_INT >= 14) {
int flags = View.class.getDeclaredField("SYSTEM_UI_FLAG_HIDE_NAVIGATION").getInt(null);
if (Build.VERSION.SDK_INT >= 16) {
flags |= View.class.getDeclaredField("SYSTEM_UI_FLAG_LAYOUT_STABLE").getInt(null);
flags |= View.class.getDeclaredField("SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION").getInt(null);
flags |= View.class.getDeclaredField("SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN").getInt(null);
flags |= View.class.getDeclaredField("SYSTEM_UI_FLAG_FULLSCREEN").getInt(null);
if (Build.VERSION.SDK_INT >= 19)
flags |= View.class.getDeclaredField("SYSTEM_UI_FLAG_IMMERSIVE_STICKY").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();
m.invoke(m_activity.getWindow().getDecorView(), flags | 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) {
if (Build.VERSION.SDK_INT >= 14) {
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);
m.invoke(m_activity.getWindow().getDecorView(), ui_flag_visible);
} catch (Exception e) {
e.printStackTrace();
}