diff --git a/sbapp/main.py b/sbapp/main.py index 9348760..942e0a1 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -3,10 +3,12 @@ import LXMF import time import sys import os +import plyer from kivy.logger import Logger, LOG_LEVELS -# Logger.setLevel(LOG_LEVELS["debug"]) -Logger.setLevel(LOG_LEVELS["error"]) +# TODO: Reset +Logger.setLevel(LOG_LEVELS["debug"]) +# Logger.setLevel(LOG_LEVELS["error"]) if RNS.vendor.platformutils.get_platform() != "android": local = os.path.dirname(__file__) @@ -27,6 +29,8 @@ if RNS.vendor.platformutils.get_platform() == "android": from ui.messages import Messages, ts_format from ui.helpers import ContentNavigationDrawer, DrawerList, IconListItem + from android.permissions import request_permissions, check_permission + else: from .sideband.core import SidebandCore @@ -62,19 +66,47 @@ class SidebandApp(MDApp): self.lxmf_sync_dialog_open = False self.sync_dialog = None - Window.softinput_mode = "below_target" - self.icon = self.sideband.asset_dir+"/images/icon.png" + self.icon = self.sideband.asset_dir+"/icon.png" + self.notification_icon = self.sideband.asset_dir+"/notification_icon.png" def start_core(self, dt): self.sideband.start() self.open_conversations() Clock.schedule_interval(self.jobs, 1) + def dismiss_splash(dt): + from android import loadingscreen + loadingscreen.hide_loading_screen() + + if RNS.vendor.platformutils.get_platform() == "android": + Clock.schedule_once(dismiss_splash, 0) + + ################################################# # General helpers # ################################################# + def notify(self, title, content): + notifications_enabled = True + + if notifications_enabled: + if RNS.vendor.platformutils.get_platform() == "android": + notifications_permitted = False + if check_permission("android.permission.POST_NOTIFICATIONS"): + notifications_permitted = True + else: + RNS.log("Requesting notification permission") + request_permissions(["android.permission.POST_NOTIFICATIONS"]) + else: + notifications_permitted = True + + if notifications_permitted: + if RNS.vendor.platformutils.get_platform() == "android": + plyer.notification.notify(title, content, notification_icon=self.notification_icon) + else: + plyer.notification.notify(title, content) + def build(self): FONT_PATH = self.sideband.asset_dir+"/fonts" self.theme_cls.theme_style = "Dark" diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index 2406266..2abe789 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -58,7 +58,7 @@ class SidebandCore(): CONV_GROUP = 0x02 CONV_BROADCAST = 0x03 - MAX_ANNOUNCES = 64 + MAX_ANNOUNCES = 48 aspect_filter = "lxmf.delivery" def received_announce(self, destination_hash, announced_identity, app_data): @@ -80,8 +80,7 @@ class SidebandCore(): if not os.path.isdir(self.app_dir+"/app_storage"): os.makedirs(self.app_dir+"/app_storage") - self.asset_dir = self.app_dir+"/assets" - self.kv_dir = self.app_dir+"/views/kv" + self.asset_dir = self.app_dir+"/app/assets" self.config_path = self.app_dir+"/app_storage/sideband_config" self.identity_path = self.app_dir+"/app_storage/primary_identity" self.db_path = self.app_dir+"/app_storage/sideband.db"