mirror of
https://github.com/liberatedsystems/Sideband_CE.git
synced 2024-09-03 04:13:27 +02: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()
|
||||||
|
def fp(delta_time):
|
||||||
self.request_permissions()
|
self.request_permissions()
|
||||||
|
Clock.schedule_once(fp, 3)
|
||||||
else:
|
else:
|
||||||
self.open_conversations()
|
self.open_conversations()
|
||||||
|
|
||||||
@ -199,8 +201,16 @@ 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":
|
||||||
|
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"):
|
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)
|
self.sideband.setpersistent("permissions.notifications", True)
|
||||||
else:
|
else:
|
||||||
RNS.log("Do not have notification permissions")
|
RNS.log("Do not have notification permissions")
|
||||||
@ -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