Add a option to allow local source to read hidden folders

This commit is contained in:
Jobobby04 2020-09-05 20:13:44 -04:00
parent b4e73cb1eb
commit d83f938e07
5 changed files with 19 additions and 1 deletions

View File

@ -308,4 +308,6 @@ object PreferenceKeys {
const val saveChaptersAsCBZ = "save_chapter_as_cbz"
const val saveChaptersAsCBZLevel = "save_chapter_as_cbz_level"
const val allowLocalSourceHiddenFolders = "allow_local_source_hidden_folders"
}

View File

@ -413,4 +413,6 @@ class PreferencesHelper(val context: Context) {
fun saveChaptersAsCBZ() = flowPrefs.getBoolean(Keys.saveChaptersAsCBZ, false)
fun saveChaptersAsCBZLevel() = flowPrefs.getInt(Keys.saveChaptersAsCBZLevel, 0)
fun allowLocalSourceHiddenFolders() = flowPrefs.getBoolean(Keys.allowLocalSourceHiddenFolders, false)
}

View File

@ -4,6 +4,7 @@ import android.content.Context
import com.google.gson.GsonBuilder
import com.google.gson.JsonParser
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
@ -26,6 +27,8 @@ import junrar.Archive
import junrar.rarfile.FileHeader
import rx.Observable
import timber.log.Timber
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
class LocalSource(private val context: Context) : CatalogueSource {
companion object {
@ -74,6 +77,9 @@ class LocalSource(private val context: Context) : CatalogueSource {
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
val baseDirs = getBaseDirectories(context)
// SY -->
val allowLocalSourceHiddenFolders = Injekt.get<PreferencesHelper>().allowLocalSourceHiddenFolders().get()
// SY <--
val time = if (filters === LATEST_FILTERS) System.currentTimeMillis() - LATEST_THRESHOLD else 0L
var mangaDirs = baseDirs
@ -81,7 +87,7 @@ class LocalSource(private val context: Context) : CatalogueSource {
.mapNotNull { it.listFiles()?.toList() }
.flatten()
.filter { it.isDirectory }
.filterNot { it.name.startsWith('.') }
.filterNot { it.name.startsWith('.') /* SY --> */ && !allowLocalSourceHiddenFolders /* SY <-- */ }
.filter { if (time == 0L) it.name.contains(query, ignoreCase = true) else it.lastModified() >= time }
.distinctBy { it.name }

View File

@ -40,6 +40,12 @@ class SettingsBrowseController : SettingsController() {
summaryRes = R.string.pref_source_navigation_summery
defaultValue = false
}
switchPreference {
key = Keys.allowLocalSourceHiddenFolders
titleRes = R.string.pref_local_source_hidden_folders
summaryRes = R.string.pref_local_source_hidden_folders_summery
defaultValue = false
}
}
preferenceCategory {

View File

@ -180,6 +180,8 @@
<string name="pref_latest_position_summery">Do you want the latest tab to be the first tab in browse? This will make it the default tab when opening browse, not recommended if your on data or a metered network</string>
<string name="pref_source_navigation">Replace latest button</string>
<string name="pref_source_navigation_summery">Replace latest button with a custom browse view that includes both latest and browse</string>
<string name="pref_local_source_hidden_folders">Local source hidden folders</string>
<string name="pref_local_source_hidden_folders_summery">Allow local source to read hidden folders</string>
<!-- Download settings -->
<string name="save_chapter_as_cbz">Save Chapters as CBZ</string>