add nomedia adding/removing at directory view
This commit is contained in:
parent
23a13b397e
commit
f27afeb674
2 changed files with 46 additions and 5 deletions
|
@ -23,9 +23,7 @@ import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
import com.simplemobiletools.gallery.dialogs.CopyDialog
|
import com.simplemobiletools.gallery.dialogs.CopyDialog
|
||||||
import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog
|
import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.*
|
||||||
import com.simplemobiletools.gallery.extensions.containsNoMedia
|
|
||||||
import com.simplemobiletools.gallery.extensions.createSelector
|
|
||||||
import com.simplemobiletools.gallery.models.Directory
|
import com.simplemobiletools.gallery.models.Directory
|
||||||
import kotlinx.android.synthetic.main.directory_item.view.*
|
import kotlinx.android.synthetic.main.directory_item.view.*
|
||||||
import kotlinx.android.synthetic.main.directory_tmb.view.*
|
import kotlinx.android.synthetic.main.directory_tmb.view.*
|
||||||
|
@ -172,6 +170,15 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleFoldersVisibility(hide: Boolean) {
|
private fun toggleFoldersVisibility(hide: Boolean) {
|
||||||
|
val paths = getSelectedPaths()
|
||||||
|
for (path in paths) {
|
||||||
|
if (hide) {
|
||||||
|
activity.addNoMedia(path)
|
||||||
|
} else {
|
||||||
|
activity.removeNoMedia(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
actMode?.finish()
|
actMode?.finish()
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@ import android.view.KeyCharacterMap
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewConfiguration
|
import android.view.ViewConfiguration
|
||||||
import com.simplemobiletools.commons.extensions.getMimeType
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.gallery.BuildConfig
|
import com.simplemobiletools.gallery.BuildConfig
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.gallery.helpers.NOMEDIA
|
||||||
import com.simplemobiletools.gallery.helpers.REQUEST_EDIT_IMAGE
|
import com.simplemobiletools.gallery.helpers.REQUEST_EDIT_IMAGE
|
||||||
import com.simplemobiletools.gallery.helpers.REQUEST_SET_WALLPAPER
|
import com.simplemobiletools.gallery.helpers.REQUEST_SET_WALLPAPER
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
|
@ -142,3 +142,37 @@ fun AppCompatActivity.hideSystemUI() {
|
||||||
View.SYSTEM_UI_FLAG_FULLSCREEN or
|
View.SYSTEM_UI_FLAG_FULLSCREEN or
|
||||||
View.SYSTEM_UI_FLAG_IMMERSIVE
|
View.SYSTEM_UI_FLAG_IMMERSIVE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun SimpleActivity.addNoMedia(path: String) {
|
||||||
|
val file = File(path, NOMEDIA)
|
||||||
|
if (file.exists())
|
||||||
|
return
|
||||||
|
|
||||||
|
if (needsStupidWritePermissions(path)) {
|
||||||
|
if (!isShowingPermDialog(file)) {
|
||||||
|
getFileDocument(path, config.treeUri)?.createFile("", NOMEDIA)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
file.createNewFile()
|
||||||
|
}
|
||||||
|
scanFile(file) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun SimpleActivity.removeNoMedia(path: String) {
|
||||||
|
val file = File(path, NOMEDIA)
|
||||||
|
if (!file.exists())
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!file.delete() && !tryFastDocumentDelete(file)) {
|
||||||
|
if (needsStupidWritePermissions(path)) {
|
||||||
|
if (!isShowingPermDialog(file)) {
|
||||||
|
getFileDocument(path, config.treeUri)?.apply {
|
||||||
|
if (isFile) {
|
||||||
|
delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scanFile(file) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue