Skip to content

Commit ba7dba2

Browse files
[Android] Fix window flags;
1 parent 952d0ab commit ba7dba2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Engine/Staple.Player.Android/StapleActivity.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,35 @@ protected override void Main()
261261
}
262262
}
263263

264+
public override void OnWindowFocusChanged(bool hasFocus)
265+
{
266+
base.OnWindowFocusChanged(hasFocus);
267+
268+
if (hasFocus)
269+
{
270+
if (OperatingSystem.IsAndroidVersionAtLeast(35))
271+
{
272+
Window.InsetsController.Hide(WindowInsets.Type.SystemBars());
273+
Window.InsetsController.SystemBarsBehavior = (int)WindowInsetsControllerBehavior.ShowTransientBarsBySwipe;
274+
}
275+
else if (OperatingSystem.IsAndroidVersionAtLeast(30))
276+
{
277+
Window.SetDecorFitsSystemWindows(false);
278+
Window.InsetsController.Hide(WindowInsets.Type.SystemBars());
279+
Window.InsetsController.SystemBarsBehavior = (int)WindowInsetsControllerBehavior.ShowTransientBarsBySwipe;
280+
}
281+
else if (OperatingSystem.IsAndroidVersionAtLeast(19))
282+
{
283+
Window.DecorView.SystemUiFlags = SystemUiFlags.LayoutStable |
284+
SystemUiFlags.LayoutHideNavigation |
285+
SystemUiFlags.LayoutFullscreen |
286+
SystemUiFlags.HideNavigation |
287+
SystemUiFlags.Fullscreen |
288+
SystemUiFlags.ImmersiveSticky;
289+
}
290+
}
291+
}
292+
264293
protected override void OnCreate(Bundle savedInstanceState)
265294
{
266295
if (OperatingSystem.IsAndroidVersionAtLeast(23))
@@ -288,6 +317,15 @@ protected override void OnCreate(Bundle savedInstanceState)
288317
Window.Attributes = p;
289318
}
290319

320+
RequestWindowFeature(WindowFeatures.NoTitle);
321+
322+
Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
323+
324+
if (OperatingSystem.IsAndroidVersionAtLeast(30))
325+
{
326+
Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.Always;
327+
}
328+
291329
base.OnCreate(savedInstanceState);
292330

293331
foreach (var library in AdditionalLibraries())

0 commit comments

Comments
 (0)