mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-25 14:50:37 +01:00
Disable notifications on Android API levels less than 26
This commit is contained in:
parent
c3ac63db6d
commit
41774a5629
@ -55,6 +55,7 @@ if RNS.vendor.platformutils.get_platform() == "android":
|
|||||||
from android.permissions import request_permissions, check_permission
|
from android.permissions import request_permissions, check_permission
|
||||||
|
|
||||||
from kivymd.utils.set_bars_colors import set_bars_colors
|
from kivymd.utils.set_bars_colors import set_bars_colors
|
||||||
|
android_api_version = autoclass('android.os.Build$VERSION').SDK_INT
|
||||||
|
|
||||||
else:
|
else:
|
||||||
from .sideband.core import SidebandCore
|
from .sideband.core import SidebandCore
|
||||||
@ -151,6 +152,9 @@ class SidebandApp(MDApp):
|
|||||||
self.sideband.setstate("app.foreground", True)
|
self.sideband.setstate("app.foreground", True)
|
||||||
|
|
||||||
def start_service(self):
|
def start_service(self):
|
||||||
|
if RNS.vendor.platformutils.is_android():
|
||||||
|
RNS.log("Running on Android API level "+str(android_api_version))
|
||||||
|
|
||||||
RNS.log("Launching platform-specific service for RNS and LXMF")
|
RNS.log("Launching platform-specific service for RNS and LXMF")
|
||||||
if RNS.vendor.platformutils.get_platform() == "android":
|
if RNS.vendor.platformutils.get_platform() == "android":
|
||||||
self.android_service = autoclass('io.unsigned.sideband.ServiceSidebandservice')
|
self.android_service = autoclass('io.unsigned.sideband.ServiceSidebandservice')
|
||||||
@ -217,10 +221,8 @@ class SidebandApp(MDApp):
|
|||||||
|
|
||||||
self.update_ui_colors()
|
self.update_ui_colors()
|
||||||
|
|
||||||
st = time.time()
|
# for wid in self.root.ids:
|
||||||
RNS.log("Recursing widgets...")
|
# RNS.log("Found: "+str(wid)+str(self.root.ids[wid]))
|
||||||
for wid in self.root.ids:
|
|
||||||
RNS.log("Found: "+str(wid)+str(self.root.ids[wid]))
|
|
||||||
|
|
||||||
def set_bars_colors(self):
|
def set_bars_colors(self):
|
||||||
if RNS.vendor.platformutils.get_platform() == "android":
|
if RNS.vendor.platformutils.get_platform() == "android":
|
||||||
@ -868,13 +870,13 @@ class SidebandApp(MDApp):
|
|||||||
### Settings screen
|
### Settings screen
|
||||||
######################################
|
######################################
|
||||||
def settings_action(self, sender=None):
|
def settings_action(self, sender=None):
|
||||||
self.root.ids.screen_manager.transition.direction = "left"
|
|
||||||
|
|
||||||
self.settings_init()
|
|
||||||
|
|
||||||
self.root.ids.screen_manager.current = "settings_screen"
|
|
||||||
self.root.ids.nav_drawer.set_state("closed")
|
self.root.ids.nav_drawer.set_state("closed")
|
||||||
|
def cb(dt):
|
||||||
|
self.root.ids.screen_manager.transition.direction = "left"
|
||||||
|
self.settings_init()
|
||||||
|
self.root.ids.screen_manager.current = "settings_screen"
|
||||||
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
|
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
|
||||||
|
Clock.schedule_once(cb, 0.2)
|
||||||
|
|
||||||
def settings_init(self, sender=None):
|
def settings_init(self, sender=None):
|
||||||
if not self.settings_ready:
|
if not self.settings_ready:
|
||||||
@ -969,8 +971,12 @@ class SidebandApp(MDApp):
|
|||||||
self.root.ids.settings_propagation_node_address.bind(on_text_validate=save_prop_addr)
|
self.root.ids.settings_propagation_node_address.bind(on_text_validate=save_prop_addr)
|
||||||
self.root.ids.settings_propagation_node_address.bind(focus=save_prop_addr)
|
self.root.ids.settings_propagation_node_address.bind(focus=save_prop_addr)
|
||||||
|
|
||||||
|
if android_api_version >= 26:
|
||||||
self.root.ids.settings_notifications_on.active = self.sideband.config["notifications_on"]
|
self.root.ids.settings_notifications_on.active = self.sideband.config["notifications_on"]
|
||||||
self.root.ids.settings_notifications_on.bind(active=save_notifications_on)
|
self.root.ids.settings_notifications_on.bind(active=save_notifications_on)
|
||||||
|
else:
|
||||||
|
self.root.ids.settings_notifications_on.active = False
|
||||||
|
self.root.ids.settings_notifications_on.disabled = True
|
||||||
|
|
||||||
self.root.ids.settings_dark_ui.active = self.sideband.config["dark_ui"]
|
self.root.ids.settings_dark_ui.active = self.sideband.config["dark_ui"]
|
||||||
self.root.ids.settings_dark_ui.bind(active=save_dark_ui)
|
self.root.ids.settings_dark_ui.bind(active=save_dark_ui)
|
||||||
|
@ -14,6 +14,8 @@ else:
|
|||||||
if RNS.vendor.platformutils.get_platform() == "android":
|
if RNS.vendor.platformutils.get_platform() == "android":
|
||||||
from jnius import autoclass, cast
|
from jnius import autoclass, cast
|
||||||
from android import python_act
|
from android import python_act
|
||||||
|
android_api_version = autoclass('android.os.Build$VERSION').SDK_INT
|
||||||
|
|
||||||
Context = autoclass('android.content.Context')
|
Context = autoclass('android.content.Context')
|
||||||
Intent = autoclass('android.content.Intent')
|
Intent = autoclass('android.content.Intent')
|
||||||
BitmapFactory = autoclass('android.graphics.BitmapFactory')
|
BitmapFactory = autoclass('android.graphics.BitmapFactory')
|
||||||
@ -22,6 +24,8 @@ if RNS.vendor.platformutils.get_platform() == "android":
|
|||||||
AndroidString = autoclass('java.lang.String')
|
AndroidString = autoclass('java.lang.String')
|
||||||
NotificationManager = autoclass('android.app.NotificationManager')
|
NotificationManager = autoclass('android.app.NotificationManager')
|
||||||
Context = autoclass('android.content.Context')
|
Context = autoclass('android.content.Context')
|
||||||
|
|
||||||
|
if android_api_version >= 26:
|
||||||
NotificationBuilder = autoclass('android.app.Notification$Builder')
|
NotificationBuilder = autoclass('android.app.Notification$Builder')
|
||||||
NotificationChannel = autoclass('android.app.NotificationChannel')
|
NotificationChannel = autoclass('android.app.NotificationChannel')
|
||||||
|
|
||||||
@ -34,6 +38,9 @@ else:
|
|||||||
|
|
||||||
class SidebandService():
|
class SidebandService():
|
||||||
def android_notification(self, title="", content="", ticker="", group=None, context_id=None):
|
def android_notification(self, title="", content="", ticker="", group=None, context_id=None):
|
||||||
|
if android_api_version < 26:
|
||||||
|
return
|
||||||
|
else:
|
||||||
package_name = "io.unsigned.sideband"
|
package_name = "io.unsigned.sideband"
|
||||||
|
|
||||||
if not self.notification_service:
|
if not self.notification_service:
|
||||||
|
Loading…
Reference in New Issue
Block a user