Android: fix display cut mode being short edges always
Fixed _SHORT_EDGES and _DEFAULT conflict. Mapping from Qt API's to Android's is following: -QWindow::FullScreen -> _DEFAULT -Qt::MaximizeUsingFullscreenGeometryHint -> _TRANSLUCENT -Others -> _NEVER -Not supported -> _SHORT_EDGES (Use Java as workaround) For example in QML: -visibility: Window.FullScreen -flags: Qt.MaximizeUsingFullscreenGeometryHint Fixes: QTBUG-114437 Task-number: QTBUG-96877 Pick-to: 6.6 6.5 6.2 Change-Id: I730b3e3f76401b52548ece05dee60526d0be8207 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
This commit is contained in:
parent
7c2167d3b8
commit
adb7e2525e
@ -88,6 +88,7 @@ public class QtActivityDelegate
|
||||
private static final String APPLICATION_PARAMETERS_KEY = "application.parameters";
|
||||
private static final String STATIC_INIT_CLASSES_KEY = "static.init.classes";
|
||||
|
||||
// Keep in sync with QtAndroid::SystemUiVisibility in androidjnimain.h
|
||||
public static final int SYSTEM_UI_VISIBILITY_NORMAL = 0;
|
||||
public static final int SYSTEM_UI_VISIBILITY_FULLSCREEN = 1;
|
||||
public static final int SYSTEM_UI_VISIBILITY_TRANSLUCENT = 2;
|
||||
@ -133,13 +134,13 @@ public class QtActivityDelegate
|
||||
return;
|
||||
|
||||
m_systemUiVisibility = systemUiVisibility;
|
||||
setLayoutInDisplayCutoutMode();
|
||||
|
||||
int systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_VISIBLE;
|
||||
switch (m_systemUiVisibility) {
|
||||
case SYSTEM_UI_VISIBILITY_NORMAL:
|
||||
m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||
m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setDisplayCutoutLayout(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER);
|
||||
break;
|
||||
case SYSTEM_UI_VISIBILITY_FULLSCREEN:
|
||||
m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
@ -151,12 +152,14 @@ public class QtActivityDelegate
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||
| View.INVISIBLE;
|
||||
setDisplayCutoutLayout(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT);
|
||||
break;
|
||||
case SYSTEM_UI_VISIBILITY_TRANSLUCENT:
|
||||
m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
|
||||
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
|
||||
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setDisplayCutoutLayout(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS);
|
||||
break;
|
||||
};
|
||||
|
||||
@ -165,15 +168,10 @@ public class QtActivityDelegate
|
||||
m_layout.requestLayout();
|
||||
}
|
||||
|
||||
private void setLayoutInDisplayCutoutMode()
|
||||
private void setDisplayCutoutLayout(int cutoutLayout)
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
int cutOutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
|
||||
if (SYSTEM_UI_VISIBILITY_FULLSCREEN == m_systemUiVisibility)
|
||||
cutOutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
||||
|
||||
m_activity.getWindow().getAttributes().layoutInDisplayCutoutMode = cutOutMode;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
|
||||
m_activity.getWindow().getAttributes().layoutInDisplayCutoutMode = cutoutLayout;
|
||||
}
|
||||
|
||||
public void updateFullScreen()
|
||||
|
Loading…
Reference in New Issue
Block a user