Skip to content

Broken support for the orientation when natural orientation is not portrait #285

@NeverwinterMoon

Description

@NeverwinterMoon

Currently, the app has something like this in the code:

internal fun applyDeviceRotation(deviceRotation: DeviceRotation, useCaseGroup: UseCaseGroup) {
    val targetRotation = deviceRotation.toUiSurfaceRotation()
    useCaseGroup.useCases.forEach {
        when (it) {
            is Preview -> {
                // Preview's target rotation should not be updated with device rotation.
                // Instead, preview rotation should match the display rotation.
                // When Preview is created, it is initialized with the display rotation.
                // This will need to be updated separately if the display rotation is not
                // locked. Currently the app is locked to portrait orientation.
            }

But this statement - "Currently the app is locked to portrait orientation" - is not true. The activity is set up with android:screenOrientation="nosensor" (which is, by the way, officially advised against starting with Android 12). This does not mean that the app is locked to portrait. This means that it's locked to "natural" orientation. For a tablet or even for a foldable, this could be landscape. I've tested this app on a Pixel Tablet and it is indeed broken. The information from the sensor will be cropped in device's natural orientation (will be cropped from 4:3 to 3:4).

I would be really interested in seeing this project show how to handle this kind of thing. And handling of multi-window as well. I am trying to refactor legacy app code in my own app and was using this project as an example. Really appreciate the existence of this and would like to see the support for all these different orientations.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions