mirror of
https://github.com/skyline-emu/skyline.git
synced 2025-01-07 09:38:17 +01:00
Fix and make foldable screen support optional
This commit is contained in:
parent
4c7fd0447d
commit
9742014f9b
@ -504,27 +504,26 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
||||
* Updating the layout depending on type and state of device
|
||||
*/
|
||||
private fun updateCurrentLayout(newLayoutInfo: WindowLayoutInfo) {
|
||||
val displayMetrics = DisplayMetrics()
|
||||
windowManager.defaultDisplay.getMetrics(displayMetrics)
|
||||
binding.onScreenGameView.minimumHeight = displayMetrics.heightPixels
|
||||
requestedOrientation =
|
||||
if (emulationSettings.orientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
|
||||
emulationSettings.orientation
|
||||
if (!emulationSettings.supportFoldableScreen) return
|
||||
binding.onScreenGameView.minimumHeight = with (windowManager) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
maximumWindowMetrics.bounds.height()
|
||||
} else {
|
||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
||||
val displayMetrics = DisplayMetrics()
|
||||
@Suppress("DEPRECATION")
|
||||
defaultDisplay.getMetrics(displayMetrics)
|
||||
displayMetrics.heightPixels
|
||||
}
|
||||
for (displayFeature in newLayoutInfo.displayFeatures) {
|
||||
val foldFeature = displayFeature as? FoldingFeature
|
||||
foldFeature?.let {
|
||||
//Folding feature separates the display area into two distinct sections
|
||||
if (it.isSeparating) {
|
||||
if (emulationSettings.orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED){
|
||||
requestedOrientation = emulationSettings.orientation
|
||||
}
|
||||
if (it.orientation == FoldingFeature.Orientation.HORIZONTAL) {
|
||||
binding.onScreenGameView.minimumHeight = displayFeature.bounds.top
|
||||
}
|
||||
}
|
||||
}
|
||||
requestedOrientation = emulationSettings.orientation
|
||||
val foldingFeature = newLayoutInfo.displayFeatures.find { it is FoldingFeature }
|
||||
(foldingFeature as? FoldingFeature)?.let {
|
||||
if (it.isSeparating) {
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||
if (it.orientation == FoldingFeature.Orientation.HORIZONTAL)
|
||||
binding.onScreenGameView.minimumHeight = it.bounds.top
|
||||
else
|
||||
requestedOrientation = emulationSettings.orientation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ class EmulationSettings private constructor(context : Context, prefName : String
|
||||
var orientation by sharedPreferences(context, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, prefName = prefName)
|
||||
var aspectRatio by sharedPreferences(context, 0, prefName = prefName)
|
||||
var respectDisplayCutout by sharedPreferences(context, false, prefName = prefName)
|
||||
var supportFoldableScreen by sharedPreferences(context, false, prefName = prefName)
|
||||
|
||||
// GPU
|
||||
var gpuDriver by sharedPreferences(context, SYSTEM_GPU_DRIVER, prefName = prefName)
|
||||
|
@ -85,14 +85,12 @@
|
||||
<item>Device Aspect Ratio (Stretch to fit)</item>
|
||||
</string-array>
|
||||
<string-array name="orientation_entries">
|
||||
<item>Landscape (auto)</item>
|
||||
<item>Auto</item>
|
||||
<item>Landscape</item>
|
||||
<item>Landscape (reverse)</item>
|
||||
</string-array>
|
||||
<integer-array name="orientation_values">
|
||||
<item>6</item>
|
||||
<item>-1</item>
|
||||
<item>0</item>
|
||||
<item>8</item>
|
||||
</integer-array>
|
||||
|
@ -91,6 +91,9 @@
|
||||
<string name="respect_display_cutout">Respect Display Cutout</string>
|
||||
<string name="respect_display_cutout_enabled">Do not draw UI elements in the cutout area</string>
|
||||
<string name="respect_display_cutout_disabled">Allow UI elements to be drawn in the cutout area</string>
|
||||
<string name="support_foldable_screen">Support Foldable Screens</string>
|
||||
<string name="support_foldable_screen_enabled">Folded devices will display game and controller separately</string>
|
||||
<string name="support_foldable_screen_disabled">Display controller over games even when device is folded</string>
|
||||
<!-- Settings - Audio -->
|
||||
<string name="audio">Audio</string>
|
||||
<string name="disable_audio_output">Disable Audio Output</string>
|
||||
|
@ -67,6 +67,12 @@
|
||||
android:summaryOn="@string/respect_display_cutout_enabled"
|
||||
app:key="respect_display_cutout"
|
||||
app:title="@string/respect_display_cutout" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:summaryOff="@string/support_foldable_screen_disabled"
|
||||
android:summaryOn="@string/support_foldable_screen_enabled"
|
||||
app:key="support_foldable_screen"
|
||||
app:title="@string/support_foldable_screen" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="category_audio"
|
||||
|
Loading…
Reference in New Issue
Block a user