Android: fix cutout area rendering on Android 9 and above

Fix rendering to cutout areas so that they are filled both
in portrait and landscape modes.

Fixes: QTBUG-96877
Pick-to: 6.5 6.2
Change-Id: I8a29557236ed1b7084afc902dc1fb42d9535ef32
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
This commit is contained in:
Rami Potinkara 2022-11-23 21:03:41 +02:00 committed by Assam Boudjelthia
parent 588eab99d2
commit 792a5b15c9

View File

@ -133,13 +133,13 @@ public class QtActivityDelegate
return;
m_systemUiVisibility = systemUiVisibility;
setLayoutInDisplayCutoutMode();
int systemUiVisibilityFlags = 0;
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);
systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_VISIBLE;
break;
case SYSTEM_UI_VISIBILITY_FULLSCREEN:
m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
@ -157,7 +157,6 @@ public class QtActivityDelegate
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_VISIBLE;
break;
};
@ -166,6 +165,17 @@ public class QtActivityDelegate
m_layout.requestLayout();
}
private void setLayoutInDisplayCutoutMode()
{
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;
}
}
public void updateFullScreen()
{
if (m_systemUiVisibility == SYSTEM_UI_VISIBILITY_FULLSCREEN) {