This commit is contained in:
yumoqing 2021-06-30 13:16:16 +08:00
parent a85bed50dc
commit 335c17bd56
2 changed files with 10 additions and 5 deletions

View File

@ -1,11 +1,12 @@
from kivy.utils import platform from kivy.utils import platform
import plyer import plyer
try: try:
from android import activity #
# from plyer.platforms.android import activity # from android import activity
# return rotation is 0 forever # get_rotation() failed module 'android.activity' has no attribute 'getWindowManager'
from plyer.platforms.android import activity
except: except:
print('android_rotation.py:from android import activity ERROR') print('android_rotation.py:mport ERROR')
activity = None activity = None
def get_rotation(): def get_rotation():

View File

@ -100,6 +100,9 @@ class TwoSides(WidgetReady, BoxLayout):
def on_size(self,*args): def on_size(self,*args):
if self.width >= self.height: if self.width >= self.height:
print('twosides.py:W-Window.rotation=',
self.app.get_rotation(),
Window.size)
if not self.landscape_widget in self.children: if not self.landscape_widget in self.children:
self.dispatch('on_beforeswitch_landscape') self.dispatch('on_beforeswitch_landscape')
self.clear_widgets() self.clear_widgets()
@ -110,7 +113,8 @@ class TwoSides(WidgetReady, BoxLayout):
self.dispatch('on_afterswitch_landscape') self.dispatch('on_afterswitch_landscape')
self.panel_shape = 'landscape' self.panel_shape = 'landscape'
else: else:
print('twosides.py:Window.rotation=', self.app.get_rotation(), print('twosides.py:H-Window.rotation=',
self.app.get_rotation(),
Window.size) Window.size)
if not self.portrait_widget in self.children: if not self.portrait_widget in self.children:
self.dispatch('on_beforeswitch_landscape') self.dispatch('on_beforeswitch_landscape')