make use of some new .nomedia checking extensions
This commit is contained in:
parent
3fd1981679
commit
fd0014cbe6
8 changed files with 9 additions and 30 deletions
|
@ -61,7 +61,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.15.1'
|
implementation 'com.simplemobiletools:commons:5.15.9'
|
||||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||||
|
|
|
@ -207,7 +207,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.menu_media, menu)
|
menuInflater.inflate(R.menu.menu_media, menu)
|
||||||
|
|
||||||
val isFolderHidden = File(mPath).containsNoMedia()
|
val isFolderHidden = mPath.containsNoMedia()
|
||||||
menu.apply {
|
menu.apply {
|
||||||
findItem(R.id.group).isVisible = !config.scrollHorizontally
|
findItem(R.id.group).isVisible = !config.scrollHorizontally
|
||||||
|
|
||||||
|
|
|
@ -145,8 +145,8 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkHideBtnVisibility(menu: Menu, selectedPaths: ArrayList<String>) {
|
private fun checkHideBtnVisibility(menu: Menu, selectedPaths: ArrayList<String>) {
|
||||||
menu.findItem(R.id.cab_hide).isVisible = selectedPaths.any { !File(it).doesThisOrParentHaveNoMedia() }
|
menu.findItem(R.id.cab_hide).isVisible = selectedPaths.any { !it.doesThisOrParentHaveNoMedia() }
|
||||||
menu.findItem(R.id.cab_unhide).isVisible = selectedPaths.any { File(it).doesThisOrParentHaveNoMedia() }
|
menu.findItem(R.id.cab_unhide).isVisible = selectedPaths.any { it.doesThisOrParentHaveNoMedia() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkPinBtnVisibility(menu: Menu, selectedPaths: ArrayList<String>) {
|
private fun checkPinBtnVisibility(menu: Menu, selectedPaths: ArrayList<String>) {
|
||||||
|
@ -308,7 +308,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
val affectedPositions = ArrayList<Int>()
|
val affectedPositions = ArrayList<Int>()
|
||||||
val includedFolders = activity.config.includedFolders
|
val includedFolders = activity.config.includedFolders
|
||||||
val newDirs = dirs.filterIndexed { index, directory ->
|
val newDirs = dirs.filterIndexed { index, directory ->
|
||||||
val removeDir = File(directory.path).doesThisOrParentHaveNoMedia() && !includedFolders.contains(directory.path)
|
val removeDir = directory.path.doesThisOrParentHaveNoMedia() && !includedFolders.contains(directory.path)
|
||||||
if (removeDir) {
|
if (removeDir) {
|
||||||
affectedPositions.add(index)
|
affectedPositions.add(index)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import com.simplemobiletools.gallery.pro.BuildConfig
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.activities.SimpleActivity
|
import com.simplemobiletools.gallery.pro.activities.SimpleActivity
|
||||||
import com.simplemobiletools.gallery.pro.dialogs.PickDirectoryDialog
|
import com.simplemobiletools.gallery.pro.dialogs.PickDirectoryDialog
|
||||||
import com.simplemobiletools.gallery.pro.helpers.NOMEDIA
|
|
||||||
import com.simplemobiletools.gallery.pro.helpers.RECYCLE_BIN
|
import com.simplemobiletools.gallery.pro.helpers.RECYCLE_BIN
|
||||||
import com.simplemobiletools.gallery.pro.interfaces.MediumDao
|
import com.simplemobiletools.gallery.pro.interfaces.MediumDao
|
||||||
import com.squareup.picasso.Picasso
|
import com.squareup.picasso.Picasso
|
||||||
|
|
|
@ -424,7 +424,7 @@ fun Context.storeDirectoryItems(items: ArrayList<Directory>, directoryDao: Direc
|
||||||
|
|
||||||
fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders: MutableSet<String>): String {
|
fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders: MutableSet<String>): String {
|
||||||
val dirName = getFolderNameFromPath(path)
|
val dirName = getFolderNameFromPath(path)
|
||||||
return if (File(path).doesThisOrParentHaveNoMedia() && !path.isThisOrParentIncluded(includedFolders)) {
|
return if (path.doesThisOrParentHaveNoMedia() && !path.isThisOrParentIncluded(includedFolders)) {
|
||||||
"$dirName $hidden"
|
"$dirName $hidden"
|
||||||
} else {
|
} else {
|
||||||
dirName
|
dirName
|
||||||
|
@ -587,7 +587,7 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly:
|
||||||
|
|
||||||
val hiddenString = resources.getString(R.string.hidden)
|
val hiddenString = resources.getString(R.string.hidden)
|
||||||
filteredDirectories.forEach {
|
filteredDirectories.forEach {
|
||||||
it.name = if (File(it.path).doesThisOrParentHaveNoMedia() && !it.path.isThisOrParentIncluded(includedPaths)) {
|
it.name = if (it.path.doesThisOrParentHaveNoMedia() && !it.path.isThisOrParentIncluded(includedPaths)) {
|
||||||
"${it.name.removeSuffix(hiddenString).trim()} $hiddenString"
|
"${it.name.removeSuffix(hiddenString).trim()} $hiddenString"
|
||||||
} else {
|
} else {
|
||||||
it.name
|
it.name
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
package com.simplemobiletools.gallery.pro.extensions
|
|
||||||
|
|
||||||
import com.simplemobiletools.gallery.pro.helpers.NOMEDIA
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
fun File.containsNoMedia() = isDirectory && File(this, NOMEDIA).exists()
|
|
||||||
|
|
||||||
fun File.doesThisOrParentHaveNoMedia(): Boolean {
|
|
||||||
var curFile = this
|
|
||||||
while (true) {
|
|
||||||
if (curFile.containsNoMedia()) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
curFile = curFile.parentFile ?: break
|
|
||||||
if (curFile.absolutePath == "/") {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
|
@ -1,7 +1,8 @@
|
||||||
package com.simplemobiletools.gallery.pro.extensions
|
package com.simplemobiletools.gallery.pro.extensions
|
||||||
|
|
||||||
import android.media.MediaMetadataRetriever
|
import android.media.MediaMetadataRetriever
|
||||||
import com.simplemobiletools.gallery.pro.helpers.NOMEDIA
|
import com.simplemobiletools.commons.extensions.doesThisOrParentHaveNoMedia
|
||||||
|
import com.simplemobiletools.commons.helpers.NOMEDIA
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,6 @@ const val SLIDESHOW_ANIMATION_NONE = 0
|
||||||
const val SLIDESHOW_ANIMATION_SLIDE = 1
|
const val SLIDESHOW_ANIMATION_SLIDE = 1
|
||||||
const val SLIDESHOW_ANIMATION_FADE = 2
|
const val SLIDESHOW_ANIMATION_FADE = 2
|
||||||
|
|
||||||
const val NOMEDIA = ".nomedia"
|
|
||||||
const val FAVORITES = "favorites"
|
const val FAVORITES = "favorites"
|
||||||
const val RECYCLE_BIN = "recycle_bin"
|
const val RECYCLE_BIN = "recycle_bin"
|
||||||
const val SHOW_FAVORITES = "show_favorites"
|
const val SHOW_FAVORITES = "show_favorites"
|
||||||
|
|
Loading…
Reference in a new issue