diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 4f0bae074..1b94c07b2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index ef3d285e6..eb646b38d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 4a0eb5350..a667537bc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -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 {