mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-21 20:45:29 +03:00
implement permission check for notifications on Android 13
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
46322b2b63
commit
2df415b36e
3 changed files with 23 additions and 0 deletions
|
@ -27,6 +27,7 @@
|
||||||
*/
|
*/
|
||||||
package com.nextcloud.talk.conversationlist
|
package com.nextcloud.talk.conversationlist
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
import android.animation.AnimatorInflater
|
import android.animation.AnimatorInflater
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.SearchManager
|
import android.app.SearchManager
|
||||||
|
@ -217,6 +218,19 @@ class ConversationsListActivity :
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onPostCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// handle notification permission on API level >= 33
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
|
||||||
|
&& !platformPermissionUtil.isPostNotificationsPermissionGranted()) {
|
||||||
|
requestPermissions(
|
||||||
|
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
|
||||||
|
REQUEST_POST_NOTIFICATIONS_PERMISSION
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
|
||||||
|
@ -1506,5 +1520,6 @@ class ConversationsListActivity :
|
||||||
const val CLIENT_UPGRADE_GPLAY_LINK = "https://play.google.com/store/apps/details?id="
|
const val CLIENT_UPGRADE_GPLAY_LINK = "https://play.google.com/store/apps/details?id="
|
||||||
const val HTTP_SERVICE_UNAVAILABLE = 503
|
const val HTTP_SERVICE_UNAVAILABLE = 503
|
||||||
const val MAINTENANCE_MODE_HEADER_KEY = "X-Nextcloud-Maintenance-Mode"
|
const val MAINTENANCE_MODE_HEADER_KEY = "X-Nextcloud-Maintenance-Mode"
|
||||||
|
const val REQUEST_POST_NOTIFICATIONS_PERMISSION = 111
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,4 +27,5 @@ interface PlatformPermissionUtil {
|
||||||
fun isMicrophonePermissionGranted(): Boolean
|
fun isMicrophonePermissionGranted(): Boolean
|
||||||
fun isBluetoothPermissionGranted(): Boolean
|
fun isBluetoothPermissionGranted(): Boolean
|
||||||
fun isFilesPermissionGranted(): Boolean
|
fun isFilesPermissionGranted(): Boolean
|
||||||
|
fun isPostNotificationsPermissionGranted(): Boolean
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,13 @@ class PlatformPermissionUtilImpl(private val context: Context) : PlatformPermiss
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun isPostNotificationsPermissionGranted(): Boolean {
|
||||||
|
return PermissionChecker.checkSelfPermission(
|
||||||
|
context,
|
||||||
|
Manifest.permission.POST_NOTIFICATIONS
|
||||||
|
) == PermissionChecker.PERMISSION_GRANTED
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val TAG = PlatformPermissionUtilImpl::class.simpleName
|
private val TAG = PlatformPermissionUtilImpl::class.simpleName
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue