SDK 30 changes

- handle SAF dialog on ViewPagerActivity before refreshing screen
This commit is contained in:
darthpaul 2022-03-19 20:30:59 +00:00
parent 4a3e502484
commit 399c8e241d

View file

@ -1109,20 +1109,26 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
val fileDirItem = FileDirItem(path, path.getFilenameFromPath()) val fileDirItem = FileDirItem(path, path.getFilenameFromPath())
if (config.useRecycleBin && !getCurrentMedium()!!.getIsInRecycleBin()) { if (config.useRecycleBin && !getCurrentMedium()!!.getIsInRecycleBin()) {
mIgnoredPaths.add(fileDirItem.path) handleSAFDialogSdk30(fileDirItem.path) {
val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList<ThumbnailItem> if (!it) {
runOnUiThread { return@handleSAFDialogSdk30
gotMedia(media, true, false) }
}
movePathsInRecycleBin(arrayListOf(path)) { mIgnoredPaths.add(fileDirItem.path)
if (it) { val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList<ThumbnailItem>
tryDeleteFileDirItem(fileDirItem, false, false) { runOnUiThread {
mIgnoredPaths.remove(fileDirItem.path) gotMedia(media, true, false)
deleteDirectoryIfEmpty() }
movePathsInRecycleBin(arrayListOf(path)) {
if (it) {
tryDeleteFileDirItem(fileDirItem, false, false) {
mIgnoredPaths.remove(fileDirItem.path)
deleteDirectoryIfEmpty()
}
} else {
toast(R.string.unknown_error_occurred)
} }
} else {
toast(R.string.unknown_error_occurred)
} }
} }
} else { } else {
@ -1131,15 +1137,21 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
} }
private fun handleDeletion(fileDirItem: FileDirItem) { private fun handleDeletion(fileDirItem: FileDirItem) {
mIgnoredPaths.add(fileDirItem.path) handleSAFDialogSdk30(fileDirItem.path) {
val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList<ThumbnailItem> if (!it) {
runOnUiThread { return@handleSAFDialogSdk30
gotMedia(media, true, false) }
}
tryDeleteFileDirItem(fileDirItem, false, true) { mIgnoredPaths.add(fileDirItem.path)
mIgnoredPaths.remove(fileDirItem.path) val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList<ThumbnailItem>
deleteDirectoryIfEmpty() runOnUiThread {
gotMedia(media, true, false)
}
tryDeleteFileDirItem(fileDirItem, false, true) {
mIgnoredPaths.remove(fileDirItem.path)
deleteDirectoryIfEmpty()
}
} }
} }