Skip to content

Commit bf527a4

Browse files
Merge pull request #14133 from nextcloud/backport/14127/stable-3.30
[stable-3.30] BugFix - Infinite Storage Permission Check
2 parents aa29235 + a9109b4 commit bf527a4

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class SyncedFoldersActivity :
198198
setTheme(R.style.FallbackThemingTheme)
199199
}
200200
binding.emptyList.emptyListViewAction.setOnClickListener { showHiddenItems() }
201+
PermissionUtil.requestExternalStoragePermission(this, viewThemeUtils, true)
201202
}
202203

203204
override fun onCreateOptionsMenu(menu: Menu): Boolean {
@@ -810,9 +811,6 @@ class SyncedFoldersActivity :
810811
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
811812
// permission was granted
812813
load(getItemsDisplayedPerFolder(), true)
813-
} else {
814-
// permission denied --> request again
815-
PermissionUtil.requestExternalStoragePermission(this, viewThemeUtils, true)
816814
}
817815
}
818816
else -> super.onRequestPermissionsResult(requestCode, permissions, grantResults)

app/src/main/java/com/owncloud/android/utils/PermissionUtil.kt

+9-3
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,16 @@ object PermissionUtil {
251251
activity,
252252
listener
253253
)
254-
}
255254

256-
val dialogFragment = StoragePermissionDialogFragment.newInstance(permissionRequired)
257-
dialogFragment.show(activity.supportFragmentManager, PERMISSION_CHOICE_DIALOG_TAG)
255+
// Check if the dialog is already added to the FragmentManager.
256+
val existingDialog = activity.supportFragmentManager.findFragmentByTag(PERMISSION_CHOICE_DIALOG_TAG)
257+
258+
// Only show the dialog if it's not already shown.
259+
if (existingDialog == null) {
260+
val dialogFragment = StoragePermissionDialogFragment.newInstance(permissionRequired)
261+
dialogFragment.show(activity.supportFragmentManager, PERMISSION_CHOICE_DIALOG_TAG)
262+
}
263+
}
258264
}
259265
}
260266

0 commit comments

Comments
 (0)