Fix ignore user orientation setting

The default Auto entry is now called Landscape (Auto), which better describes the SCREEN_ORIENTATION_SENSOR_LANDSCAPE property. For devices like the Surface Duo, Oppo Find X, and Flip, to use the folding feature, the user must select the new Auto entry in the settings.
This commit is contained in:
skriand 2023-04-22 13:53:05 +03:00
parent 37d162a9aa
commit 4c7fd0447d
2 changed files with 13 additions and 4 deletions

View File

@ -507,14 +507,21 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
val displayMetrics = DisplayMetrics()
windowManager.defaultDisplay.getMetrics(displayMetrics)
binding.onScreenGameView.minimumHeight = displayMetrics.heightPixels
requestedOrientation = emulationSettings.orientation
requestedOrientation =
if (emulationSettings.orientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
emulationSettings.orientation
} else {
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
}
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) {
//Folding feature separates the display area into two distinct sections
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
if (foldFeature.orientation == FoldingFeature.Orientation.HORIZONTAL) {
if (emulationSettings.orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED){
requestedOrientation = emulationSettings.orientation
}
if (it.orientation == FoldingFeature.Orientation.HORIZONTAL) {
binding.onScreenGameView.minimumHeight = displayFeature.bounds.top
}
}

View File

@ -85,12 +85,14 @@
<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>