Skip to content

Commit

Permalink
Improved the permissions handling system and moved some stuff in the …
Browse files Browse the repository at this point in the history
…view models
  • Loading branch information
Mihai-Cristian Condrea committed Jun 29, 2024
1 parent f1f7641 commit 993d2fa
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 186 deletions.
15 changes: 8 additions & 7 deletions app/src/main/kotlin/com/d4rk/cleaner/ui/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,26 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
Manifest.permission.WRITE_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED

Build.VERSION.SDK_INT <= Build.VERSION_CODES.S ->
Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2 ->
ContextCompat.checkSelfPermission(
getApplication(),
Manifest.permission.READ_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED &&
ContextCompat.checkSelfPermission(
getApplication(),
Manifest.permission.WRITE_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED
) == PackageManager.PERMISSION_GRANTED

else -> true
}

val hasManageStoragePermission = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Environment.isExternalStorageManager()
} else {
true
}

val hasUsageStatsPermission = isAccessGranted()
val hasUsageStatsPermission = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
isAccessGranted()
} else {
true
}

val hasMediaPermissions = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
ContextCompat.checkSelfPermission(
Expand Down
Loading

0 comments on commit 993d2fa

Please sign in to comment.