mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 08:45:20 +00:00
make notifications optional (#349)
This commit is contained in:
@@ -65,7 +65,16 @@ class OnboardingCoordinator(
|
|||||||
fun requestPermissions() {
|
fun requestPermissions() {
|
||||||
Log.d(TAG, "User accepted permission explanation, requesting permissions")
|
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()) {
|
if (missingPermissions.isEmpty()) {
|
||||||
completeOnboarding()
|
completeOnboarding()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ class PermissionManager(private val context: Context) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all permissions required by the app
|
* 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> {
|
fun getRequiredPermissions(): List<String> {
|
||||||
val permissions = mutableListOf<String>()
|
val permissions = mutableListOf<String>()
|
||||||
@@ -65,14 +67,23 @@ class PermissionManager(private val context: Context) {
|
|||||||
Manifest.permission.ACCESS_FINE_LOCATION
|
Manifest.permission.ACCESS_FINE_LOCATION
|
||||||
))
|
))
|
||||||
|
|
||||||
// Notification permission (Android 13+)
|
// Notification permission intentionally excluded to keep it optional
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
||||||
permissions.add(Manifest.permission.POST_NOTIFICATIONS)
|
|
||||||
}
|
|
||||||
|
|
||||||
return permissions
|
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
|
* Check if a specific permission is granted
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user