mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
a/android: hide display cutout to use full screen
This commit is contained in:
parent
b18202e5d0
commit
a2f5e5f1b9
|
@ -11,6 +11,7 @@ package org.freedesktop.monado.auxiliary;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
|
@ -47,12 +48,16 @@ public class MonadoView extends SurfaceView implements SurfaceHolder.Callback, S
|
|||
@Nullable
|
||||
private SurfaceHolder currentSurfaceHolder = null;
|
||||
|
||||
private SystemUiController systemUiController = null;
|
||||
|
||||
public MonadoView(Context context) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
Activity activity;
|
||||
if (context instanceof Activity) {
|
||||
activity = (Activity) context;
|
||||
systemUiController = new SystemUiController(activity);
|
||||
systemUiController.hide();
|
||||
} else {
|
||||
activity = null;
|
||||
}
|
||||
|
@ -63,6 +68,8 @@ public class MonadoView extends SurfaceView implements SurfaceHolder.Callback, S
|
|||
super(activity);
|
||||
this.context = activity;
|
||||
this.activity = activity;
|
||||
systemUiController = new SystemUiController(activity);
|
||||
systemUiController.hide();
|
||||
}
|
||||
|
||||
private MonadoView(Activity activity, long nativePointer) {
|
||||
|
@ -142,6 +149,10 @@ public class MonadoView extends SurfaceView implements SurfaceHolder.Callback, S
|
|||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
|
||||
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
lp.layoutInDisplayCutoutMode =
|
||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
||||
}
|
||||
windowManager.addView(this, lp);
|
||||
if (focusable) {
|
||||
requestFocus();
|
||||
|
|
|
@ -75,7 +75,9 @@ class SystemUiController(activity: Activity) {
|
|||
override fun hide() {
|
||||
activity.runOnUiThread {
|
||||
val controller = activity.window.insetsController
|
||||
controller!!.hide(WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars())
|
||||
controller!!.hide(WindowInsets.Type.displayCutout()
|
||||
or WindowInsets.Type.statusBars()
|
||||
or WindowInsets.Type.navigationBars())
|
||||
controller.systemBarsBehavior =
|
||||
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
}
|
||||
|
@ -84,7 +86,10 @@ class SystemUiController(activity: Activity) {
|
|||
init {
|
||||
runOnUiThread {
|
||||
activity.window.insetsController!!.addOnControllableInsetsChangedListener { _: WindowInsetsController?, typeMask: Int ->
|
||||
if (typeMask and WindowInsets.Type.statusBars() == 1 || typeMask and WindowInsets.Type.navigationBars() == 1) {
|
||||
if (typeMask and WindowInsets.Type.displayCutout() == 1
|
||||
|| typeMask and WindowInsets.Type.statusBars() == 1
|
||||
|| typeMask and WindowInsets.Type.navigationBars() == 1
|
||||
) {
|
||||
hide()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ package org.freedesktop.monado.ipc
|
|||
|
||||
import android.content.Context
|
||||
import android.hardware.display.DisplayManager
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.provider.Settings
|
||||
|
@ -183,6 +184,10 @@ class SurfaceManager(context: Context) : SurfaceHolder.Callback {
|
|||
val lp = WindowManager.LayoutParams()
|
||||
lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
|
||||
lp.flags = if (focusable) VIEW_FLAG_FOCUSABLE else VIEW_FLAG_NOT_FOCUSABLE
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
lp.layoutInDisplayCutoutMode =
|
||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
||||
}
|
||||
|
||||
val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
||||
wm.addView(v, lp)
|
||||
|
|
Loading…
Reference in a new issue