mirror of
https://github.com/markqvist/Sideband.git
synced 2024-10-01 03:15:37 -04:00
Permission check flow
This commit is contained in:
parent
b06db067e6
commit
8aeb643b81
@ -8,8 +8,8 @@ import base64
|
||||
import threading
|
||||
|
||||
from kivy.logger import Logger, LOG_LEVELS
|
||||
# Logger.setLevel(LOG_LEVELS["debug"])
|
||||
Logger.setLevel(LOG_LEVELS["error"])
|
||||
Logger.setLevel(LOG_LEVELS["debug"])
|
||||
# Logger.setLevel(LOG_LEVELS["error"])
|
||||
|
||||
if RNS.vendor.platformutils.get_platform() != "android":
|
||||
local = os.path.dirname(__file__)
|
||||
@ -36,6 +36,8 @@ if RNS.vendor.platformutils.get_platform() == "android":
|
||||
from android import mActivity
|
||||
from android.permissions import request_permissions, check_permission
|
||||
|
||||
from kivymd.utils.set_bars_colors import set_bars_colors
|
||||
|
||||
else:
|
||||
from .sideband.core import SidebandCore
|
||||
|
||||
@ -86,9 +88,9 @@ class SidebandApp(MDApp):
|
||||
Window.softinput_mode = "below_target"
|
||||
self.icon = self.sideband.asset_dir+"/icon.png"
|
||||
self.notification_icon = self.sideband.asset_dir+"/notification_icon.png"
|
||||
self.check_permissions()
|
||||
|
||||
def start_core(self, dt):
|
||||
self.check_permissions()
|
||||
self.start_service()
|
||||
|
||||
Clock.schedule_interval(self.jobs, 1)
|
||||
@ -110,6 +112,8 @@ class SidebandApp(MDApp):
|
||||
else:
|
||||
self.open_conversations()
|
||||
|
||||
self.set_bars_colors()
|
||||
|
||||
self.app_state = SidebandApp.ACTIVE
|
||||
|
||||
def start_service(self):
|
||||
@ -149,6 +153,14 @@ class SidebandApp(MDApp):
|
||||
else:
|
||||
self.theme_cls.theme_style = "Light"
|
||||
|
||||
def set_bars_colors(self):
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
set_bars_colors(
|
||||
self.theme_cls.primary_color, # status bar color
|
||||
[0,0,0,0], # navigation bar color
|
||||
"Light", # icons color of status bar
|
||||
)
|
||||
|
||||
def share_text(self, text):
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
Intent = autoclass('android.content.Intent')
|
||||
@ -350,7 +362,7 @@ class SidebandApp(MDApp):
|
||||
dialog = MDDialog(
|
||||
text="An announce for your LXMF destination was sent on all available interfaces",
|
||||
buttons=[ yes_button ],
|
||||
elevation=0,
|
||||
# elevation=0,
|
||||
)
|
||||
def dl_yes(s):
|
||||
dialog.dismiss()
|
||||
|
@ -3,8 +3,8 @@ import RNS
|
||||
from os import environ
|
||||
|
||||
from kivy.logger import Logger, LOG_LEVELS
|
||||
# Logger.setLevel(LOG_LEVELS["debug"])
|
||||
Logger.setLevel(LOG_LEVELS["error"])
|
||||
Logger.setLevel(LOG_LEVELS["debug"])
|
||||
# Logger.setLevel(LOG_LEVELS["error"])
|
||||
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
from jnius import autoclass, cast
|
||||
|
@ -118,7 +118,6 @@ class SidebandCore():
|
||||
except Exception as e:
|
||||
RNS.log("Error while configuring Sideband: "+str(e), RNS.LOG_ERROR)
|
||||
|
||||
|
||||
# Initialise Reticulum configuration
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
try:
|
||||
@ -180,10 +179,13 @@ class SidebandCore():
|
||||
self.config["connect_i2p_ifac_netname"] = ""
|
||||
self.config["connect_i2p_ifac_passphrase"] = ""
|
||||
|
||||
self.__save_config()
|
||||
|
||||
if not os.path.isfile(self.db_path):
|
||||
self.__db_init()
|
||||
else:
|
||||
self._db_initstate()
|
||||
self._db_initpersistent()
|
||||
|
||||
self.__save_config()
|
||||
|
||||
def should_persist_data(self):
|
||||
if self.reticulum != None:
|
||||
@ -434,6 +436,8 @@ class SidebandCore():
|
||||
pass
|
||||
|
||||
def __db_init(self):
|
||||
# TODO: Remove
|
||||
print("------------------ DB INIT")
|
||||
db = sqlite3.connect(self.db_path)
|
||||
dbc = db.cursor()
|
||||
|
||||
@ -454,6 +458,8 @@ class SidebandCore():
|
||||
|
||||
db.commit()
|
||||
db.close()
|
||||
# TODO: Remove
|
||||
print("------------------ DB INIT DONE")
|
||||
|
||||
def _db_initstate(self):
|
||||
db = sqlite3.connect(self.db_path)
|
||||
@ -906,7 +912,7 @@ class SidebandCore():
|
||||
self.service_thread.start()
|
||||
|
||||
def __start_jobs_immediate(self):
|
||||
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=3)
|
||||
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=7)
|
||||
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
if not self.reticulum.is_connected_to_shared_instance:
|
||||
|
@ -3,6 +3,8 @@ root_layout = """
|
||||
#: import SlideTransition kivy.uix.screenmanager.SlideTransition
|
||||
|
||||
MDNavigationLayout:
|
||||
md_bg_color: app.theme_cls.bg_darkest
|
||||
|
||||
ScreenManager:
|
||||
id: screen_manager
|
||||
transition: SlideTransition()
|
||||
|
Loading…
Reference in New Issue
Block a user