This commit is contained in:
yumoqing 2022-01-13 11:11:53 +08:00
parent 804027cfb6
commit 07bea7bb61

View File

@ -1,6 +1,12 @@
import os import os
import sys import sys
from kivy.resources import resource_add_path
resource_add_path(os.path.join(os.path.dirname(__file__),'./ttf'))
Config.set('kivy', 'default_font', [
'msgothic',
'DroidSansFallback.ttf'])
import signal import signal
import codecs import codecs
import json import json
@ -8,6 +14,7 @@ import json
from appPublic.jsonConfig import getConfig from appPublic.jsonConfig import getConfig
from appPublic.folderUtils import ProgramPath from appPublic.folderUtils import ProgramPath
from appPublic.uniqueID import getID from appPublic.uniqueID import getID
from appPublic.rsa import RSA
from kivy.factory import Factory from kivy.factory import Factory
from kivy.config import Config from kivy.config import Config
@ -16,55 +23,20 @@ from kivy.core.window import WindowBase, Window
from kivy.clock import Clock from kivy.clock import Clock
from kivy.logger import Logger from kivy.logger import Logger
from kivy.utils import platform from kivy.utils import platform
from kivy.app import App
import kivy
import plyer import plyer
from kivy.resources import resource_add_path from .register import *
resource_add_path(os.path.join(os.path.dirname(__file__),'./ttf'))
Config.set('kivy', 'default_font', [
'msgothic',
'DroidSansFallback.ttf'])
from kivy.app import App
from kivy.utils import platform
from .threadcall import HttpClient,Workers from .threadcall import HttpClient,Workers
from .utils import * from .utils import *
from .pagescontainer import PageContainer
from .blocks import Blocks
from .theming import ThemeManager
from .widget_css import register_css from .widget_css import register_css
from appPublic.rsa import RSA
if platform == 'android': if platform == 'android':
from jnius import autoclass from jnius import autoclass
from .android_rotation import get_rotation from .android_rotation import get_rotation
class ServerInfo:
def __init__(self):
self.rsaEngine = RSA()
self.publickey = None
self.authCode = None
def getServerPK(self):
config = getConfig()
url = '%s%s' % (config.uihome, config.publickey_url)
hc = App.get_running_app().hc
d = hc.get(url)
self.publickey = self.rsaEngine. publickeyFromText(d)
def encode(self,uinfo):
if self.publickey is None:
self.getServerPK()
if uinfo['authmethod'] == 'password':
authinfo = '%s::%s::%s' % (uinfo['authmethod'], uinfo['userid'], uinfo['passwd'])
x = self.rsaEngine.encode(self.publickey, authinfo)
self.authCode = x
return x
return None
def signal_handler(signal, frame): def signal_handler(signal, frame):
app = App.get_running_app() app = App.get_running_app()
app.workers.running = False app.workers.running = False
@ -73,19 +45,6 @@ def signal_handler(signal, frame):
signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGINT, signal_handler)
def getAuthHeader():
app = App.get_running_app()
if not hasattr(app,'serverinfo'):
print('app serverinfo not found')
return {}
serverinfo = app.serverinfo
if hasattr(serverinfo,'authCode'):
return {
'authorization':serverinfo.authCode
}
print('serverinfo authCode not found')
return {}
class BlocksApp(App): class BlocksApp(App):
def get_rotation(self): def get_rotation(self):
return get_rotation() return get_rotation()
@ -118,21 +77,9 @@ class BlocksApp(App):
self.platform = platform self.platform = platform
self.is_desktop = platform in ['win', 'linux', 'macosx'] self.is_desktop = platform in ['win', 'linux', 'macosx']
config = getConfig() config = getConfig()
self.csses = { self.public_headers = {
"default":{ "platform":self.platform
"bgcolor":[0.35,0.35,0.35,1],
"fgcolor":[0.85,0.85,0.85,1]
},
"input":{
"bgcolor":[0.35,0.35,0.35,1],
"fgcolor":[0.85,0.85,0.85,1]
},
"input_focus":{
"bgcolor":[0.25,0.25,0.25,1],
"fgcolor":[0.8,0.8,0.8,1]
}
} }
self.public_headers = {}
Window.bind(on_request_close=self.on_close) Window.bind(on_request_close=self.on_close)
Window.bind(on_rotate=self.on_rotate) Window.bind(on_rotate=self.on_rotate)
Window.bind(size=self.device_info) Window.bind(size=self.device_info)
@ -141,7 +88,7 @@ class BlocksApp(App):
self.load_csses() self.load_csses()
self.running = True self.running = True
if config.root: if config.root:
blocks = Blocks() blocks = Factory.Blocks()
x = blocks.widgetBuild(config.root) x = blocks.widgetBuild(config.root)
if x is None: if x is None:
alert('buildError,Exit', title='Error') alert('buildError,Exit', title='Error')