Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix permission activity not found issue on few devices #173

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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