Optimize screen orientation (#11875)

This commit is contained in:
焕晨HChen 2024-06-30 04:57:11 +08:00 committed by GitHub
parent 15d532e287
commit 4db4400105
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -122,11 +122,12 @@ class AndroidDisplay(private val activity: AndroidApplication) : PlatformDisplay
override fun setOrientation(orientation: ScreenOrientation) {
val mode = when (orientation) {
ScreenOrientation.Landscape -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
ScreenOrientation.Portrait -> ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
// Automatically adjust landscape based on sensors.
ScreenOrientation.Landscape -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
// Automatically adjust the portrait based on the sensor.
ScreenOrientation.Portrait -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
ScreenOrientation.Auto -> ActivityInfo.SCREEN_ORIENTATION_SENSOR
}
// Ensure ActivityTaskManager.getService().setRequestedOrientation isn't called unless necessary!
if (activity.requestedOrientation != mode)
activity.requestedOrientation = mode