diff --git a/sbapp/main.py b/sbapp/main.py index acbc174..4c3176a 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -108,7 +108,9 @@ class SidebandApp(MDApp): if self.sideband.first_run: self.guide_action() - self.request_permissions() + def fp(delta_time): + self.request_permissions() + Clock.schedule_once(fp, 3) else: self.open_conversations() @@ -199,12 +201,20 @@ class SidebandApp(MDApp): def check_permissions(self): if RNS.vendor.platformutils.get_platform() == "android": - if check_permission("android.permission.POST_NOTIFICATIONS"): - RNS.log("Have notification permissions") + mActivity = autoclass('org.kivy.android.PythonActivity').mActivity + Context = autoclass('android.content.Context') + NotificationManager = autoclass('android.app.NotificationManager') + notification_service = cast(NotificationManager, mActivity.getSystemService(Context.NOTIFICATION_SERVICE)) + + if notification_service.areNotificationsEnabled(): self.sideband.setpersistent("permissions.notifications", True) else: - RNS.log("Do not have notification permissions") - self.sideband.setpersistent("permissions.notifications", False) + if check_permission("android.permission.POST_NOTIFICATIONS"): + RNS.log("Have notification permissions", RNS.LOG_DEBUG) + self.sideband.setpersistent("permissions.notifications", True) + else: + RNS.log("Do not have notification permissions") + self.sideband.setpersistent("permissions.notifications", False) else: self.sideband.setpersistent("permissions.notifications", True) @@ -214,7 +224,7 @@ class SidebandApp(MDApp): def request_notifications_permission(self): if RNS.vendor.platformutils.get_platform() == "android": if not check_permission("android.permission.POST_NOTIFICATIONS"): - RNS.log("Requesting notification permission") + RNS.log("Requesting notification permission", RNS.LOG_DEBUG) request_permissions(["android.permission.POST_NOTIFICATIONS"]) self.check_permissions() diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index ba88ce3..5cd2eff 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -436,8 +436,6 @@ class SidebandCore(): pass def __db_init(self): - # TODO: Remove - print("------------------ DB INIT") db = sqlite3.connect(self.db_path) dbc = db.cursor() @@ -458,8 +456,6 @@ class SidebandCore(): db.commit() db.close() - # TODO: Remove - print("------------------ DB INIT DONE") def _db_initstate(self): db = sqlite3.connect(self.db_path)