mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 09:25:19 +00:00
make notifications optional (#349)
This commit is contained in:
@@ -65,7 +65,16 @@ class OnboardingCoordinator(
|
||||
fun requestPermissions() {
|
||||
Log.d(TAG, "User accepted permission explanation, requesting permissions")
|
||||
|
||||
val missingPermissions = permissionManager.getMissingPermissions()
|
||||
// Required permissions
|
||||
val missingRequired = permissionManager.getMissingPermissions()
|
||||
|
||||
// Optional permissions (ask, but do not block if denied)
|
||||
val optionalToRequest = permissionManager
|
||||
.getOptionalPermissions()
|
||||
.filter { !permissionManager.isPermissionGranted(it) }
|
||||
|
||||
val missingPermissions = (missingRequired + optionalToRequest).distinct()
|
||||
|
||||
if (missingPermissions.isEmpty()) {
|
||||
completeOnboarding()
|
||||
return
|
||||
|
||||
@@ -41,6 +41,8 @@ class PermissionManager(private val context: Context) {
|
||||
|
||||
/**
|
||||
* Get all permissions required by the app
|
||||
* Note: Notification permission is optional and not included here,
|
||||
* so the app works without notification access.
|
||||
*/
|
||||
fun getRequiredPermissions(): List<String> {
|
||||
val permissions = mutableListOf<String>()
|
||||
@@ -65,14 +67,23 @@ class PermissionManager(private val context: Context) {
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
))
|
||||
|
||||
// Notification permission (Android 13+)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
permissions.add(Manifest.permission.POST_NOTIFICATIONS)
|
||||
}
|
||||
// Notification permission intentionally excluded to keep it optional
|
||||
|
||||
return permissions
|
||||
}
|
||||
|
||||
/**
|
||||
* Get optional permissions that improve the experience but aren't required.
|
||||
* Currently includes POST_NOTIFICATIONS on Android 13+.
|
||||
*/
|
||||
fun getOptionalPermissions(): List<String> {
|
||||
val optional = mutableListOf<String>()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
optional.add(Manifest.permission.POST_NOTIFICATIONS)
|
||||
}
|
||||
return optional
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a specific permission is granted
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user