diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt index 8b9f3bea4..9b06f99c6 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt @@ -27,6 +27,7 @@ */ package com.nextcloud.talk.conversationlist +import android.Manifest import android.animation.AnimatorInflater import android.annotation.SuppressLint import android.app.SearchManager @@ -217,6 +218,19 @@ class ConversationsListActivity : 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() { super.onResume() @@ -1506,5 +1520,6 @@ class ConversationsListActivity : const val CLIENT_UPGRADE_GPLAY_LINK = "https://play.google.com/store/apps/details?id=" const val HTTP_SERVICE_UNAVAILABLE = 503 const val MAINTENANCE_MODE_HEADER_KEY = "X-Nextcloud-Maintenance-Mode" + const val REQUEST_POST_NOTIFICATIONS_PERMISSION = 111 } } diff --git a/app/src/main/java/com/nextcloud/talk/utils/permissions/PlatformPermissionUtil.kt b/app/src/main/java/com/nextcloud/talk/utils/permissions/PlatformPermissionUtil.kt index a288de610..51085108a 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/permissions/PlatformPermissionUtil.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/permissions/PlatformPermissionUtil.kt @@ -27,4 +27,5 @@ interface PlatformPermissionUtil { fun isMicrophonePermissionGranted(): Boolean fun isBluetoothPermissionGranted(): Boolean fun isFilesPermissionGranted(): Boolean + fun isPostNotificationsPermissionGranted(): Boolean } diff --git a/app/src/main/java/com/nextcloud/talk/utils/permissions/PlatformPermissionUtilImpl.kt b/app/src/main/java/com/nextcloud/talk/utils/permissions/PlatformPermissionUtilImpl.kt index cdfb232d1..ba59ad7cd 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/permissions/PlatformPermissionUtilImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/permissions/PlatformPermissionUtilImpl.kt @@ -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 { private val TAG = PlatformPermissionUtilImpl::class.simpleName }