mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
url decode the document file uri before deleting, should fix SD delete issues
This commit is contained in:
parent
099e13ea0c
commit
58ace8e59f
3 changed files with 11 additions and 3 deletions
|
@ -29,6 +29,7 @@ import com.simplemobiletools.gallery.models.Directory
|
|||
import com.simplemobiletools.gallery.views.MyScalableRecyclerView
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import java.io.File
|
||||
import java.net.URLDecoder
|
||||
import java.util.*
|
||||
|
||||
class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||
|
@ -193,7 +194,8 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
val document = getFileDocument(file.absolutePath, config.treeUri)
|
||||
|
||||
// double check we have the uri to the proper file path, not some parent folder
|
||||
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath())) {
|
||||
val uri = URLDecoder.decode(document.uri.toString(), "UTF-8")
|
||||
if (uri.endsWith(file.absolutePath.getFilenameFromPath())) {
|
||||
Thread({
|
||||
document.delete()
|
||||
}).start()
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.simplemobiletools.gallery.views.MyScalableRecyclerView
|
|||
import kotlinx.android.synthetic.main.activity_media.*
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.net.URLDecoder
|
||||
import java.util.*
|
||||
|
||||
class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||
|
@ -222,7 +223,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
val document = getFileDocument(it.absolutePath, config.treeUri)
|
||||
|
||||
// double check we have the uri to the proper file path, not some parent folder
|
||||
if (document.uri.toString().endsWith(it.absolutePath.getFilenameFromPath()) && !document.isDirectory) {
|
||||
val uri = URLDecoder.decode(document.uri.toString(), "UTF-8")
|
||||
if (uri.endsWith(it.absolutePath.getFilenameFromPath()) && !document.isDirectory) {
|
||||
Thread({
|
||||
document.delete()
|
||||
}).start()
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.simplemobiletools.gallery.helpers.REQUEST_SET_WALLPAPER
|
|||
import com.simplemobiletools.gallery.models.Medium
|
||||
import kotlinx.android.synthetic.main.activity_medium.*
|
||||
import java.io.File
|
||||
import java.net.URLDecoder
|
||||
import java.util.*
|
||||
|
||||
class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, ViewPagerFragment.FragmentListener {
|
||||
|
@ -237,7 +238,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
if (needsStupidWritePermissions(mPath)) {
|
||||
if (!isShowingPermDialog(file)) {
|
||||
val document = getFileDocument(mPath, config.treeUri)
|
||||
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory)
|
||||
|
||||
// double check we have the uri to the proper file path, not some parent folder
|
||||
val uri = URLDecoder.decode(document.uri.toString(), "UTF-8")
|
||||
if (uri.endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory)
|
||||
document.delete()
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue