Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements --manifest-orientation and changes how --orientation works so we can now pass the setting to the SDL orientation hint #2739

Merged
merged 1 commit into from
Jan 22, 2023

Conversation

misl6
Copy link
Member

@misl6 misl6 commented Jan 21, 2023

As discussed on issue #2724 , when targeting API 31 and above, on Android 12 and above, the attribute android:screenOrientation is ignored, as the activity will run in multi-window mode.

This PR takes advantage of changes made on SDL side which have been applied as a patch to python-for-android SDL build: #2730.

After these changes, orientation can be controlled in two ways:

--orientation will control the allowed orientations (portrait, landscape, portrait-reverse, landscape-reverse). The allowed orientations list is then set to KIVY_ORIENTATION, which is used during window setup time to populate the SDL_HINT_ORIENTATIONS value, as we're doing for other platforms.

--manifest-orientation has been added to keep the android:screenOrientation personalisation functionality, even if Android will be likely deprecate this attribute in future. Valid values can be find here.

If --manifest-orientation is not set, and only (one of multiple) --orientation options are passed, the value for android:screenOrientation is guessed and synthesised from the --orientation option. Since android:screenOrientation accepts only 1 value, if multiple --orientation are given, android:screenOrientation will be set to unspecified.

A buildozer PR will follow.

P.S. : I'm slowly changing pythonforandroid/bootstraps/common/build/build.py in order to make it deeply testable, so some changes may seem to be unrelated, but are needed in order to actually test the code.

⚠️ The changes applied in this PR will likely break existing third party examples and automated builds, if a now unsupported orientation setting is used, so the user will need to migrate, if needed. Specifically, --orientation sensor or --orientation user are not valid anymore, and an error will be raised, and the user will be forced to migrate.

… so we can now pass the setting to SDL orientation hint
Copy link
Member

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat, thanks! 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants