mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-25 23:00: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:
|
||||
self.guide_action()
|
||||
def fp(delta_time):
|
||||
self.request_permissions()
|
||||
Clock.schedule_once(fp, 3)
|
||||
else:
|
||||
self.open_conversations()
|
||||
|
||||
@ -199,8 +201,16 @@ class SidebandApp(MDApp):
|
||||
|
||||
def check_permissions(self):
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
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:
|
||||
if check_permission("android.permission.POST_NOTIFICATIONS"):
|
||||
RNS.log("Have notification permissions")
|
||||
RNS.log("Have notification permissions", RNS.LOG_DEBUG)
|
||||
self.sideband.setpersistent("permissions.notifications", True)
|
||||
else:
|
||||
RNS.log("Do not have notification permissions")
|
||||
@ -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()
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user