diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt index 23486394a2ca..06a7267adf04 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt @@ -198,6 +198,7 @@ class SyncedFoldersActivity : setTheme(R.style.FallbackThemingTheme) } binding.emptyList.emptyListViewAction.setOnClickListener { showHiddenItems() } + PermissionUtil.requestExternalStoragePermission(this, viewThemeUtils, true) } override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -810,9 +811,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) diff --git a/app/src/main/java/com/owncloud/android/utils/PermissionUtil.kt b/app/src/main/java/com/owncloud/android/utils/PermissionUtil.kt index 1d85050e187f..71c2217d5fde 100644 --- a/app/src/main/java/com/owncloud/android/utils/PermissionUtil.kt +++ b/app/src/main/java/com/owncloud/android/utils/PermissionUtil.kt @@ -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) + } + } } }