Merge pull request #2384 from KryptKode/feat/handle-saf-on-fullscreen

Handle SAF on pager full screen  - SDK 30 changes
This commit is contained in:
Tibor Kaputa 2022-03-19 22:16:58 +01:00 committed by GitHub
commit f9ce90201b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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