mirror of
https://github.com/skyline-emu/skyline.git
synced 2025-01-07 09:38:17 +01:00
Extract display height and only set for foldables
This commit is contained in:
parent
9742014f9b
commit
88f56d814d
@ -128,6 +128,19 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
||||
|
||||
private var gameSurface : Surface? = null
|
||||
|
||||
private val displayHeight by lazy {
|
||||
with (windowManager) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
maximumWindowMetrics.bounds.height()
|
||||
} else {
|
||||
val displayMetrics = DisplayMetrics()
|
||||
@Suppress("DEPRECATION")
|
||||
defaultDisplay.getMetrics(displayMetrics)
|
||||
displayMetrics.heightPixels
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the entry point into the emulation code for libskyline
|
||||
*
|
||||
@ -319,9 +332,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
||||
lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
WindowInfoTracker.getOrCreate(this@EmulationActivity)
|
||||
.windowLayoutInfo(this@EmulationActivity)
|
||||
.collect { newLayoutInfo ->
|
||||
updateCurrentLayout(newLayoutInfo)
|
||||
}
|
||||
.collect { updateCurrentLayout(it) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -505,19 +516,10 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
||||
*/
|
||||
private fun updateCurrentLayout(newLayoutInfo: WindowLayoutInfo) {
|
||||
if (!emulationSettings.supportFoldableScreen) return
|
||||
binding.onScreenGameView.minimumHeight = with (windowManager) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
maximumWindowMetrics.bounds.height()
|
||||
} else {
|
||||
val displayMetrics = DisplayMetrics()
|
||||
@Suppress("DEPRECATION")
|
||||
defaultDisplay.getMetrics(displayMetrics)
|
||||
displayMetrics.heightPixels
|
||||
}
|
||||
}
|
||||
requestedOrientation = emulationSettings.orientation
|
||||
val foldingFeature = newLayoutInfo.displayFeatures.find { it is FoldingFeature }
|
||||
(foldingFeature as? FoldingFeature)?.let {
|
||||
binding.onScreenGameView.minimumHeight = displayHeight
|
||||
requestedOrientation = emulationSettings.orientation
|
||||
if (it.isSeparating) {
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||
if (it.orientation == FoldingFeature.Orientation.HORIZONTAL)
|
||||
|
Loading…
Reference in New Issue
Block a user