This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.py
76 lines (63 loc) · 2.57 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.screenmanager import ScreenManager
from kivy.utils import platform
from android_permissions import AndroidPermissions
from applayout.homescreen0 import HomeScreen0
from applayout.photoscreen1 import PhotoScreen1
from applayout.photoscreen2 import PhotoScreen2
from applayout.screenshot3 import ScreenShot3
from applayout.videoscreen4 import VideoScreen4
from applayout.videoscreen5 import VideoScreen5
from camera4kivy import CameraProviderInfo
if platform == 'android':
from jnius import autoclass
from android.runnable import run_on_ui_thread
from android import mActivity
View = autoclass('android.view.View')
@run_on_ui_thread
def hide_landscape_status_bar(instance, width, height):
# width,height gives false layout events, on pinch/spread
# so use Window.width and Window.height
if Window.width > Window.height:
# Hide status bar
option = View.SYSTEM_UI_FLAG_FULLSCREEN
else:
# Show status bar
option = View.SYSTEM_UI_FLAG_VISIBLE
mActivity.getWindow().getDecorView().setSystemUiVisibility(option)
elif platform != 'ios':
# Dispose of that nasty red dot, required for gestures4kivy.
from kivy.config import Config
Config.set('input', 'mouse', 'mouse, disable_multitouch')
class MyApp(App):
def build(self):
self.enable_swipe = False
self.sm = ScreenManager()
self.screens = [HomeScreen0(name='0'),
PhotoScreen1(name='1'),
PhotoScreen2(name='2'),
ScreenShot3(name='3'),
VideoScreen4(name='4')]
if CameraProviderInfo().get_name() in ['picamera2','opencv']:
self.screens.append(VideoScreen5(name='5'))
for s in self.screens:
self.sm.add_widget(s)
if platform == 'android':
Window.bind(on_resize=hide_landscape_status_bar)
return self.sm
def on_start(self):
self.dont_gc = AndroidPermissions(self.start_app)
def start_app(self):
self.dont_gc = None
self.enable_swipe = True
def swipe_screen(self, right):
if self.enable_swipe:
i = int(self.sm.current)
if right:
self.sm.transition.direction = 'right'
self.sm.current = str((i-1) % len(self.screens))
else:
self.sm.transition.direction = 'left'
self.sm.current = str((i+1) % len(self.screens))
MyApp().run()