Merge pull request #14127 from nextcloud/bugfix/infinite-storage-permission-request

BugFix - Infinite Storage Permission Check
This commit is contained in:
Tobias Kaminsky 2024-12-05 15:01:41 +01:00 committed by GitHub
commit 4a224815cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View file

@ -191,6 +191,7 @@ class SyncedFoldersActivity :
setTheme(R.style.FallbackThemingTheme)
}
binding.emptyList.emptyListViewAction.setOnClickListener { showHiddenItems() }
PermissionUtil.requestExternalStoragePermission(this, viewThemeUtils, true)
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
@ -808,9 +809,6 @@ class SyncedFoldersActivity :
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted
load(getItemsDisplayedPerFolder(), true)
} else {
// permission denied --> request again
PermissionUtil.requestExternalStoragePermission(this, viewThemeUtils, true)
}
}
else -> super.onRequestPermissionsResult(requestCode, permissions, grantResults)

View file

@ -251,10 +251,16 @@ object PermissionUtil {
activity,
listener
)
}
val dialogFragment = StoragePermissionDialogFragment.newInstance(permissionRequired)
dialogFragment.show(activity.supportFragmentManager, PERMISSION_CHOICE_DIALOG_TAG)
// Check if the dialog is already added to the FragmentManager.
val existingDialog = activity.supportFragmentManager.findFragmentByTag(PERMISSION_CHOICE_DIALOG_TAG)
// Only show the dialog if it's not already shown.
if (existingDialog == null) {
val dialogFragment = StoragePermissionDialogFragment.newInstance(permissionRequired)
dialogFragment.show(activity.supportFragmentManager, PERMISSION_CHOICE_DIALOG_TAG)
}
}
}
}