mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-06-05 21:59:19 +02:00
avoid deleting Downloads folder
This commit is contained in:
@ -207,7 +207,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||
|
||||
private fun deleteDirectoryIfEmpty() {
|
||||
val file = File(mPath)
|
||||
if (file.isDirectory && file.listFiles()?.isEmpty() == true) {
|
||||
if (!file.isDownloadsFolder() && file.isDirectory && file.listFiles()?.isEmpty() == true) {
|
||||
file.delete()
|
||||
}
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||
|
||||
private fun deleteDirectoryIfEmpty() {
|
||||
val file = File(mDirectory)
|
||||
if (file.isDirectory && file.listFiles()?.isEmpty() == true) {
|
||||
if (!file.isDownloadsFolder() && file.isDirectory && file.listFiles()?.isEmpty() == true) {
|
||||
file.delete()
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.simplemobiletools.gallery.extensions
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.os.Environment
|
||||
import com.simplemobiletools.gallery.helpers.NOMEDIA
|
||||
import java.io.File
|
||||
|
||||
@ -13,3 +14,5 @@ fun File.getCompressionFormat(): Bitmap.CompressFormat {
|
||||
}
|
||||
|
||||
fun File.containsNoMedia() = isDirectory && File(this, NOMEDIA).exists()
|
||||
|
||||
fun File.isDownloadsFolder() = absolutePath == Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString()
|
||||
|
Reference in New Issue
Block a user