forked from geode-sdk/android-launcher
add screen insets utils
This commit is contained in:
2 files changed
+18
No files matched your search
@@ -472,6 +472,9 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
||||
|
||||
if (displayMode == DisplayMode.FULLSCREEN && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
||||
GeodeUtils.handleSafeArea = true
|
||||
} else {
|
||||
GeodeUtils.handleSafeArea = false
|
||||
}
|
||||
|
||||
hideSystemUi()
|
||||
|
||||
@@ -39,6 +39,8 @@ import kotlin.system.exitProcess
|
||||
@Suppress("unused", "KotlinJniMissingFunction")
|
||||
object GeodeUtils {
|
||||
private lateinit var activity: WeakReference<AppCompatActivity>
|
||||
var handleSafeArea: Boolean = false
|
||||
|
||||
private lateinit var openFileResultLauncher: ActivityResultLauncher<GeodeOpenFileActivityResult.OpenFileParams>
|
||||
private lateinit var openDirectoryResultLauncher: ActivityResultLauncher<Uri?>
|
||||
private lateinit var openFilesResultLauncher: ActivityResultLauncher<GeodeOpenFilesActivityResult.OpenFileParams>
|
||||
@@ -482,6 +484,19 @@ object GeodeUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getScreenInsets(): IntArray? {
|
||||
if (!handleSafeArea || Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||
return null
|
||||
}
|
||||
|
||||
return activity.get()?.run {
|
||||
val displayCutout = window.decorView.rootWindowInsets?.displayCutout ?: return null
|
||||
|
||||
intArrayOf(displayCutout.safeInsetLeft, displayCutout.safeInsetBottom, displayCutout.safeInsetRight, displayCutout.safeInsetTop)
|
||||
}
|
||||
}
|
||||
|
||||
const val ARGUMENT_SAFE_MODE = "--geode:safe-mode"
|
||||
|
||||
private var additionalLaunchArguments = arrayListOf<String>()
|
||||
|
||||
Reference in new issue
Block a user