The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

aux/android: Refactor SystemUiController

authored by

Jarvis Huang and committed by
Ryan Pavlik
d60db292 255a74a8

+19 -18
+2 -2
src/xrt/auxiliary/android/src/main/java/org/freedesktop/monado/auxiliary/MonadoView.java
··· 51 51 Activity activity; 52 52 if (context instanceof Activity) { 53 53 activity = (Activity) context; 54 - systemUiController = new SystemUiController(activity); 54 + systemUiController = new SystemUiController(activity.getWindow().getDecorView()); 55 55 systemUiController.hide(); 56 56 } else { 57 57 activity = null; ··· 63 63 super(activity); 64 64 this.context = activity; 65 65 this.activity = activity; 66 - systemUiController = new SystemUiController(activity); 66 + systemUiController = new SystemUiController(activity.getWindow().getDecorView()); 67 67 systemUiController.hide(); 68 68 } 69 69
+15 -15
src/xrt/auxiliary/android/src/main/java/org/freedesktop/monado/auxiliary/SystemUiController.kt
··· 8 8 */ 9 9 package org.freedesktop.monado.auxiliary 10 10 11 - import android.app.Activity 12 11 import android.os.Build 12 + import android.os.Handler 13 + import android.os.Looper 13 14 import android.view.View 14 15 import android.view.WindowInsets 15 16 import android.view.WindowInsetsController 16 17 import androidx.annotation.RequiresApi 17 18 18 19 /** Helper class that handles system ui visibility. */ 19 - class SystemUiController(activity: Activity) { 20 + class SystemUiController(view: View) { 20 21 private val impl: Impl = 21 22 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { 22 - WindowInsetsControllerImpl(activity) 23 + WindowInsetsControllerImpl(view) 23 24 } else { 24 - SystemUiVisibilityImpl(activity) 25 + SystemUiVisibilityImpl(view) 25 26 } 26 27 27 28 /** Hide system ui and make fullscreen. */ ··· 29 30 impl.hide() 30 31 } 31 32 32 - private abstract class Impl(var activity: Activity) { 33 + private abstract class Impl(var view: View) { 34 + private val uiHandler: Handler = Handler(Looper.getMainLooper()) 33 35 abstract fun hide() 34 36 fun runOnUiThread(runnable: Runnable) { 35 - activity.runOnUiThread(runnable) 37 + uiHandler.post(runnable) 36 38 } 37 39 } 38 40 39 41 @Suppress("DEPRECATION") 40 - private class SystemUiVisibilityImpl(activity: Activity) : Impl(activity) { 42 + private class SystemUiVisibilityImpl(view: View) : Impl(view) { 41 43 override fun hide() { 42 - activity.runOnUiThread { 43 - activity.window.decorView.systemUiVisibility = FLAG_FULL_SCREEN_IMMERSIVE_STICKY 44 - } 44 + runOnUiThread { view.systemUiVisibility = FLAG_FULL_SCREEN_IMMERSIVE_STICKY } 45 45 } 46 46 47 47 companion object { ··· 59 59 60 60 init { 61 61 runOnUiThread { 62 - activity.window.decorView.setOnSystemUiVisibilityChangeListener { visibility: Int -> 62 + view.setOnSystemUiVisibilityChangeListener { visibility: Int -> 63 63 // If not fullscreen, fix it. 64 64 if (0 == visibility and View.SYSTEM_UI_FLAG_FULLSCREEN) { 65 65 hide() ··· 70 70 } 71 71 72 72 @RequiresApi(api = Build.VERSION_CODES.R) 73 - private class WindowInsetsControllerImpl(activity: Activity) : Impl(activity) { 73 + private class WindowInsetsControllerImpl(view: View) : Impl(view) { 74 74 override fun hide() { 75 - activity.runOnUiThread { 76 - val controller = activity.window.insetsController 75 + runOnUiThread { 76 + val controller = view.windowInsetsController 77 77 controller!!.hide( 78 78 WindowInsets.Type.displayCutout() or 79 79 WindowInsets.Type.statusBars() or ··· 86 86 87 87 init { 88 88 runOnUiThread { 89 - activity.window.insetsController!!.addOnControllableInsetsChangedListener { 89 + view.windowInsetsController?.addOnControllableInsetsChangedListener { 90 90 _: WindowInsetsController?, 91 91 typeMask: Int -> 92 92 if (
+2 -1
src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/Client.java
··· 191 191 } 192 192 193 193 if (activity != null) { 194 - systemUiController = new SystemUiController(activity); 194 + systemUiController = 195 + new SystemUiController(activity.getWindow().getDecorView()); 195 196 systemUiController.hide(); 196 197 } 197 198 })