mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-22 21:19:31 +01:00
Merge pull request #3210 from nextcloud/fixNotificationPermissions
Implement permission check for notifications on Android 13
This commit is contained in:
commit
8bef585cfa
@ -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,20 @@ 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 +1521,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 New Issue
Block a user