mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-22 05:20:36 +01:00
Added notification support
This commit is contained in:
parent
db91946114
commit
ff47102b92
@ -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"
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user