Skip to content

Commit

Permalink
Merge pull request #173 from TeamAmaze/bugfix/permissions-activity
Browse files Browse the repository at this point in the history
Fix permission activity not found issue on few devices
  • Loading branch information
VishalNehra authored Jul 14, 2024
2 parents 13a7b02 + 0d95e29 commit 1eaf9c2
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 42 deletions.
49 changes: 27 additions & 22 deletions app/src/main/java/com/amaze/fileutilities/PermissionsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,30 +161,35 @@ open class PermissionsActivity :

private fun checkStoragePermission(): Boolean {
// Verify that all required contact permissions have been granted.
var isFound = false
if (VERSION.SDK_INT >= Build.VERSION_CODES.R) {
try {
isFound = (
ActivityCompat.checkSelfPermission(
this, Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
)
== PackageManager.PERMISSION_GRANTED
) || (
ActivityCompat.checkSelfPermission(
this, Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION
)

// Verify that all required contact permissions have been granted.
return if (VERSION.SDK_INT >= Build.VERSION_CODES.R) {
(
ActivityCompat.checkSelfPermission(
this, Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
)
== PackageManager.PERMISSION_GRANTED
) || (
ActivityCompat.checkSelfPermission(
this, Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION
)

== PackageManager.PERMISSION_GRANTED
) || Environment.isExternalStorageManager()
} else {
(
ActivityCompat.checkSelfPermission(
this,
Manifest.permission.WRITE_EXTERNAL_STORAGE
)
== PackageManager.PERMISSION_GRANTED
)
== PackageManager.PERMISSION_GRANTED
) || Environment.isExternalStorageManager()
} catch (anfe: ActivityNotFoundException) {
log.warn("all files access permission activity missing, fallback to default",anfe)
}
}
if (!isFound) {
isFound = (
ActivityCompat.checkSelfPermission(
this,
Manifest.permission.WRITE_EXTERNAL_STORAGE
)
== PackageManager.PERMISSION_GRANTED
)
}
return isFound
}

fun isLocationEnabled(onPermissionGranted: OnPermissionGranted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,27 +147,35 @@ abstract class WelcomePermissionScreen :

fun checkStoragePermission(): Boolean {
// Verify that all required contact permissions have been granted.
return if (VERSION.SDK_INT >= Build.VERSION_CODES.R) {
(
ActivityCompat.checkSelfPermission(
this, Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
)
== PackageManager.PERMISSION_GRANTED
) || (
ActivityCompat.checkSelfPermission(
this, Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION
)
== PackageManager.PERMISSION_GRANTED
) || Environment.isExternalStorageManager()
} else {
(
ActivityCompat.checkSelfPermission(
this,
Manifest.permission.WRITE_EXTERNAL_STORAGE
)
== PackageManager.PERMISSION_GRANTED
)
var isFound = false
if (VERSION.SDK_INT >= Build.VERSION_CODES.R) {
try {
isFound = (
ActivityCompat.checkSelfPermission(
this, Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
)
== PackageManager.PERMISSION_GRANTED
) || (
ActivityCompat.checkSelfPermission(
this, Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION
)

== PackageManager.PERMISSION_GRANTED
) || Environment.isExternalStorageManager()
} catch (anfe: ActivityNotFoundException) {
log.warn("all files access permission activity missing, fallback to default",anfe)
}
}
if (!isFound) {
isFound = (
ActivityCompat.checkSelfPermission(
this,
Manifest.permission.WRITE_EXTERNAL_STORAGE
)
== PackageManager.PERMISSION_GRANTED
)
}
return isFound
}

fun isLocationEnabled(onPermissionGranted: OnPermissionGranted) {
Expand Down

0 comments on commit 1eaf9c2

Please sign in to comment.