buildozer icon indicating copy to clipboard operation
buildozer copied to clipboard

Changing the screen orientation depending on the auto-rotate setting

Open bl1nch opened this issue 2 years ago • 7 comments
trafficstars

Description

Hello. At the moment, based on the documentation, Buildozer supports portrait and landscape orientations, but the application changes the screen orientation regardless of the state of the sensor on the user’s device. Thus, the orientation changes even if auto-rotation of the screen is disabled in the device settings. I've seen examples of fixing this using pyjnius but I would like to know if Buildozer supports this?

bl1nch avatar Sep 12 '23 09:09 bl1nch

Buildozer app rotation is enabled in buildozer.spec using orientation options. https://github.com/Android-for-Python/Android-for-Python-Users#orientation

Android has a global 'auto-rotate' enable/disable option as part of Accessibility options.

Yes, I can confirm that Buildozer builds apps that ignore Android's global 'auto-rotate' disable.

In fact, I expect Buildozer apps ignore all the Android Accessibility options.

RobertFlatt avatar Sep 13 '23 04:09 RobertFlatt

Hi @bl1nch,

Can you please post your buildozer.spec file and confirm that the build has been performed with the latest version of buildozer from scratch?

misl6 avatar Sep 16 '23 12:09 misl6

Hi @misl6, sorry for such a late reply

buildozer-arm64-v8a.spec.txt

If it suddenly matters I have a custom build method with Github Actions, so I clone p4a and make some changes every time, so don't mind this line:

p4a.source_dir = .python/python-for-android

I constantly use the latest version of the builldozer

The solution with pyjnius that I found on the internet, but I’m not sure if it works since I haven’t had time to check it yet:

from jnius import autoclass
PythonActivity = autoclass("org.kivy.android.PythonActivity")
ActivityInfo = autoclass("android.content.pm.ActivityInfo")
activity = PythonActivity.mActivity
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER)

bl1nch avatar Sep 20 '23 18:09 bl1nch

Hi @misl6, sorry for such a late reply

buildozer-arm64-v8a.spec.txt

If it suddenly matters I have a custom build method with Github Actions, so I clone p4a and make some changes every time, so don't mind this line:

p4a.source_dir = .python/python-for-android

I constantly use the latest version of the builldozer

The solution with pyjnius that I found on the internet, but I’m not sure if it works since I haven’t had time to check it yet:

from jnius import autoclass
PythonActivity = autoclass("org.kivy.android.PythonActivity")
ActivityInfo = autoclass("android.content.pm.ActivityInfo")
activity = PythonActivity.mActivity
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER)

I recently tested this solution and it works perfect

bl1nch avatar Oct 11 '23 05:10 bl1nch

have a custom build method with Github Actions

Which version of buildozer uses?

misl6 avatar Oct 12 '23 18:10 misl6

Last build with version 1.5.0 build

bl1nch avatar Oct 13 '23 08:10 bl1nch

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have the means to take action. Please reach out if you have or find the answers we need so that we can investigate further.

github-actions[bot] avatar Nov 23 '23 18:11 github-actions[bot]