mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-15 18:48:52 +01:00
Request notification permission on Android 13
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
package com.moez.QKSMS.manager
|
||||
|
||||
import android.Manifest
|
||||
import android.app.NotificationManager
|
||||
import android.app.role.RoleManager
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
@@ -29,6 +30,8 @@ import javax.inject.Inject
|
||||
|
||||
class PermissionManagerImpl @Inject constructor(private val context: Context) : PermissionManager {
|
||||
|
||||
private val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
|
||||
override fun isDefaultSms(): Boolean {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
context.getSystemService(RoleManager::class.java)?.isRoleHeld(RoleManager.ROLE_SMS) == true
|
||||
@@ -49,6 +52,13 @@ class PermissionManagerImpl @Inject constructor(private val context: Context) :
|
||||
return hasPermission(Manifest.permission.READ_CONTACTS)
|
||||
}
|
||||
|
||||
override fun hasNotifications(): Boolean {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
|
||||
return true
|
||||
}
|
||||
return notificationManager.areNotificationsEnabled()
|
||||
}
|
||||
|
||||
override fun hasPhone(): Boolean {
|
||||
return hasPermission(Manifest.permission.READ_PHONE_STATE)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user