fix CQ for kivy main file
This commit is contained in:
parent
14c5984a1b
commit
6755f9f392
|
@ -9,7 +9,7 @@ Bitmessage android(mobile) interface
|
||||||
from sys import platform as _sys_platform
|
from sys import platform as _sys_platform
|
||||||
from os import environ
|
from os import environ
|
||||||
|
|
||||||
'''
|
"""
|
||||||
We need to check platform and set environ for KIVY_CAMERA, if requires, before importing kivy.
|
We need to check platform and set environ for KIVY_CAMERA, if requires, before importing kivy.
|
||||||
|
|
||||||
We cannot use sys.platform directly because it returns 'linux' on android devices as well.
|
We cannot use sys.platform directly because it returns 'linux' on android devices as well.
|
||||||
|
@ -17,57 +17,60 @@ We cannot use kivy.util.platform beacuse it imports kivy beforehand and thus set
|
||||||
after that doesn't make any sense.
|
after that doesn't make any sense.
|
||||||
|
|
||||||
So we needed to copy the `_get_platform` function from kivy.utils
|
So we needed to copy the `_get_platform` function from kivy.utils
|
||||||
'''
|
"""
|
||||||
|
|
||||||
|
|
||||||
def _get_platform():
|
def _get_platform():
|
||||||
# On Android sys.platform returns 'linux2', so prefer to check the
|
# On Android sys.platform returns 'linux2', so prefer to check the
|
||||||
# existence of environ variables set during Python initialization
|
# existence of environ variables set during Python initialization
|
||||||
kivy_build = environ.get('KIVY_BUILD', '')
|
kivy_build = environ.get("KIVY_BUILD", "")
|
||||||
if kivy_build in {'android', 'ios'}:
|
if kivy_build in {"android", "ios"}:
|
||||||
return kivy_build
|
return kivy_build
|
||||||
elif 'P4A_BOOTSTRAP' in environ:
|
elif "P4A_BOOTSTRAP" in environ:
|
||||||
return 'android'
|
return "android"
|
||||||
elif 'ANDROID_ARGUMENT' in environ:
|
elif "ANDROID_ARGUMENT" in environ:
|
||||||
# We used to use this method to detect android platform,
|
# We used to use this method to detect android platform,
|
||||||
# leaving it here to be backwards compatible with `pydroid3`
|
# leaving it here to be backwards compatible with `pydroid3`
|
||||||
# and similar tools outside kivy's ecosystem
|
# and similar tools outside kivy's ecosystem
|
||||||
return 'android'
|
return "android"
|
||||||
elif _sys_platform in ('win32', 'cygwin'):
|
elif _sys_platform in ("win32", "cygwin"):
|
||||||
return 'win'
|
return "win"
|
||||||
elif _sys_platform == 'darwin':
|
elif _sys_platform == "darwin":
|
||||||
return 'macosx'
|
return "macosx"
|
||||||
elif _sys_platform.startswith('linux'):
|
elif _sys_platform.startswith("linux"):
|
||||||
return 'linux'
|
return "linux"
|
||||||
elif _sys_platform.startswith('freebsd'):
|
elif _sys_platform.startswith("freebsd"):
|
||||||
return 'linux'
|
return "linux"
|
||||||
return 'unknown'
|
return "unknown"
|
||||||
|
|
||||||
platform= _get_platform()
|
|
||||||
|
|
||||||
if platform=='android':
|
platform = _get_platform()
|
||||||
|
|
||||||
|
if platform == "android":
|
||||||
from jnius import autoclass, cast
|
from jnius import autoclass, cast
|
||||||
from android.runnable import run_on_ui_thread
|
from android.runnable import run_on_ui_thread
|
||||||
from android import python_act as PythonActivity
|
from android import python_act as PythonActivity
|
||||||
|
|
||||||
Toast= autoclass('android.widget.Toast')
|
Toast = autoclass("android.widget.Toast")
|
||||||
String = autoclass('java.lang.String')
|
String = autoclass("java.lang.String")
|
||||||
CharSequence= autoclass('java.lang.CharSequence')
|
CharSequence = autoclass("java.lang.CharSequence")
|
||||||
context= PythonActivity.mActivity
|
context = PythonActivity.mActivity
|
||||||
|
|
||||||
@run_on_ui_thread
|
@run_on_ui_thread
|
||||||
def show_toast(text, length):
|
def show_toast(text, length):
|
||||||
t= Toast.makeText(context, text, length)
|
t = Toast.makeText(context, text, length)
|
||||||
t.show()
|
t.show()
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
'''
|
"""
|
||||||
After tweaking a little bit with opencv camera, it's possible to make camera
|
After tweaking a little bit with opencv camera, it's possible to make camera
|
||||||
go on and off as required while the app is still running.
|
go on and off as required while the app is still running.
|
||||||
|
|
||||||
Other camera provider such as `gi` has some issue upon closing the camera.
|
Other camera provider such as `gi` has some issue upon closing the camera.
|
||||||
by setting KIVY_CAMERA environment variable before importing kivy, we are forcing it to use opencv camera provider.
|
by setting KIVY_CAMERA environment variable before importing kivy, we are forcing it to use opencv camera provider.
|
||||||
'''
|
"""
|
||||||
environ['KIVY_CAMERA']='opencv'
|
environ["KIVY_CAMERA"] = "opencv"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
@ -117,17 +120,14 @@ from kivymd.uix.list import (
|
||||||
OneLineAvatarIconListItem,
|
OneLineAvatarIconListItem,
|
||||||
OneLineListItem
|
OneLineListItem
|
||||||
)
|
)
|
||||||
|
|
||||||
# from kivymd.uix.navigationdrawer import (
|
# from kivymd.uix.navigationdrawer import (
|
||||||
# MDNavigationDrawer,
|
# MDNavigationDrawer,
|
||||||
# NavigationDrawerHeaderBase
|
# NavigationDrawerHeaderBase
|
||||||
# )
|
# )
|
||||||
from kivymd.uix.selectioncontrol import MDCheckbox, MDSwitch
|
from kivymd.uix.selectioncontrol import MDCheckbox, MDSwitch
|
||||||
from kivymd.uix.chip import MDChip
|
from kivymd.uix.chip import MDChip
|
||||||
from kivy.uix.screenmanager import (
|
from kivy.uix.screenmanager import RiseInTransition, SlideTransition, FallOutTransition
|
||||||
RiseInTransition,
|
|
||||||
SlideTransition,
|
|
||||||
FallOutTransition
|
|
||||||
)
|
|
||||||
|
|
||||||
import queues
|
import queues
|
||||||
from semaphores import kivyuisignaler
|
from semaphores import kivyuisignaler
|
||||||
|
@ -142,17 +142,31 @@ from kivy.effects.dampedscroll import DampedScrollEffect
|
||||||
from kivy_garden.zbarcam import ZBarCam
|
from kivy_garden.zbarcam import ZBarCam
|
||||||
from pyzbar.pyzbar import ZBarSymbol
|
from pyzbar.pyzbar import ZBarSymbol
|
||||||
|
|
||||||
if platform != 'android':
|
if platform != "android":
|
||||||
from kivy.config import Config
|
from kivy.config import Config
|
||||||
Config.set('input', 'mouse', 'mouse,multitouch_on_demand')
|
|
||||||
|
Config.set("input", "mouse", "mouse, multitouch_on_demand")
|
||||||
# pylint: disable=too-few-public-methods,too-many-arguments,attribute-defined-outside-init
|
# pylint: disable=too-few-public-methods,too-many-arguments,attribute-defined-outside-init
|
||||||
|
|
||||||
KVFILES = [
|
KVFILES = [
|
||||||
'settings', 'popup', 'allmails', 'draft',
|
"settings",
|
||||||
'maildetail', 'common_widgets', 'addressbook',
|
"popup",
|
||||||
'myaddress', 'composer', 'payment', 'sent',
|
"allmails",
|
||||||
'network', 'login', 'credits', 'trash', 'inbox',
|
"draft",
|
||||||
'chat_room', 'chat_list'
|
"maildetail",
|
||||||
|
"common_widgets",
|
||||||
|
"addressbook",
|
||||||
|
"myaddress",
|
||||||
|
"composer",
|
||||||
|
"payment",
|
||||||
|
"sent",
|
||||||
|
"network",
|
||||||
|
"login",
|
||||||
|
"credits",
|
||||||
|
"trash",
|
||||||
|
"inbox",
|
||||||
|
"chat_room",
|
||||||
|
"chat_list"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,6 +174,7 @@ def toast(text):
|
||||||
"""Method will display the toast message"""
|
"""Method will display the toast message"""
|
||||||
# pylint: disable=redefined-outer-name
|
# pylint: disable=redefined-outer-name
|
||||||
from kivymd.toast.kivytoast import toast
|
from kivymd.toast.kivytoast import toast
|
||||||
|
|
||||||
toast(text)
|
toast(text)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -175,9 +190,11 @@ def ShowTimeHistoy(act_time):
|
||||||
crnt_date = datetime.now()
|
crnt_date = datetime.now()
|
||||||
duration = crnt_date - action_time
|
duration = crnt_date - action_time
|
||||||
display_data = (
|
display_data = (
|
||||||
action_time.strftime('%d/%m/%Y')
|
action_time.strftime("%d/%m/%Y")
|
||||||
if duration.days >= 365 else action_time.strftime('%I:%M %p').lstrip('0')
|
if duration.days >= 365
|
||||||
if duration.days == 0 and crnt_date.strftime('%d/%m/%Y') == action_time.strftime('%d/%m/%Y')
|
else action_time.strftime("%I:%M %p").lstrip("0")
|
||||||
|
if duration.days == 0
|
||||||
|
and crnt_date.strftime("%d/%m/%Y") == action_time.strftime("%d/%m/%Y")
|
||||||
else action_time.strftime("%d %b")
|
else action_time.strftime("%d %b")
|
||||||
)
|
)
|
||||||
return display_data
|
return display_data
|
||||||
|
@ -187,9 +204,10 @@ def AddTimeWidget(time): # pylint: disable=redefined-outer-name
|
||||||
"""This method is used to create TimeWidget"""
|
"""This method is used to create TimeWidget"""
|
||||||
action_time = TimeTagRightSampleWidget(
|
action_time = TimeTagRightSampleWidget(
|
||||||
text=str(ShowTimeHistoy(time)),
|
text=str(ShowTimeHistoy(time)),
|
||||||
font_style='Caption',
|
font_style="Caption",
|
||||||
size=[120, 140] if platform == 'android' else [64, 80])
|
size=[120, 140] if platform == "android" else [64, 80],
|
||||||
action_time.font_size = '11sp'
|
)
|
||||||
|
action_time.font_size = "11sp"
|
||||||
return action_time
|
return action_time
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user