avoid deleting Downloads folder
This commit is contained in:
parent
0960897225
commit
e54cadfbdc
3 changed files with 5 additions and 2 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue