mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-22 13:30:36 +01:00
Detect notification status on Android < 13
This commit is contained in:
parent
c4f863d8ca
commit
9ef320f43e
@ -108,7 +108,9 @@ class SidebandApp(MDApp):
|
|||||||
|
|
||||||
if self.sideband.first_run:
|
if self.sideband.first_run:
|
||||||
self.guide_action()
|
self.guide_action()
|
||||||
self.request_permissions()
|
def fp(delta_time):
|
||||||
|
self.request_permissions()
|
||||||
|
Clock.schedule_once(fp, 3)
|
||||||
else:
|
else:
|
||||||
self.open_conversations()
|
self.open_conversations()
|
||||||
|
|
||||||
@ -199,12 +201,20 @@ class SidebandApp(MDApp):
|
|||||||
|
|
||||||
def check_permissions(self):
|
def check_permissions(self):
|
||||||
if RNS.vendor.platformutils.get_platform() == "android":
|
if RNS.vendor.platformutils.get_platform() == "android":
|
||||||
if check_permission("android.permission.POST_NOTIFICATIONS"):
|
mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
|
||||||
RNS.log("Have notification permissions")
|
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)
|
self.sideband.setpersistent("permissions.notifications", True)
|
||||||
else:
|
else:
|
||||||
RNS.log("Do not have notification permissions")
|
if check_permission("android.permission.POST_NOTIFICATIONS"):
|
||||||
self.sideband.setpersistent("permissions.notifications", False)
|
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:
|
else:
|
||||||
self.sideband.setpersistent("permissions.notifications", True)
|
self.sideband.setpersistent("permissions.notifications", True)
|
||||||
|
|
||||||
@ -214,7 +224,7 @@ class SidebandApp(MDApp):
|
|||||||
def request_notifications_permission(self):
|
def request_notifications_permission(self):
|
||||||
if RNS.vendor.platformutils.get_platform() == "android":
|
if RNS.vendor.platformutils.get_platform() == "android":
|
||||||
if not check_permission("android.permission.POST_NOTIFICATIONS"):
|
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"])
|
request_permissions(["android.permission.POST_NOTIFICATIONS"])
|
||||||
|
|
||||||
self.check_permissions()
|
self.check_permissions()
|
||||||
|
@ -436,8 +436,6 @@ class SidebandCore():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def __db_init(self):
|
def __db_init(self):
|
||||||
# TODO: Remove
|
|
||||||
print("------------------ DB INIT")
|
|
||||||
db = sqlite3.connect(self.db_path)
|
db = sqlite3.connect(self.db_path)
|
||||||
dbc = db.cursor()
|
dbc = db.cursor()
|
||||||
|
|
||||||
@ -458,8 +456,6 @@ class SidebandCore():
|
|||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
db.close()
|
db.close()
|
||||||
# TODO: Remove
|
|
||||||
print("------------------ DB INIT DONE")
|
|
||||||
|
|
||||||
def _db_initstate(self):
|
def _db_initstate(self):
|
||||||
db = sqlite3.connect(self.db_path)
|
db = sqlite3.connect(self.db_path)
|
||||||
|
Loading…
Reference in New Issue
Block a user