Add preference to toggle chapter URL hash for downloads (jobobby04/TachiyomiSY#1533)
(cherry picked from commit 0ffc798e9ae5a201ef2051d48099bf38f467815b) * Or (cherry picked from commit b1e6fa65d6437427b6a3eb03af36b3d9e3e5e645)
This commit is contained in:
parent
64f12cc6a5
commit
1ac96825c4
4 changed files with 43 additions and 2 deletions
|
|
@ -88,6 +88,7 @@ import tachiyomi.core.common.util.lang.withUIContext
|
||||||
import tachiyomi.core.common.util.system.ImageUtil
|
import tachiyomi.core.common.util.system.ImageUtil
|
||||||
import tachiyomi.core.common.util.system.logcat
|
import tachiyomi.core.common.util.system.logcat
|
||||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||||
|
import tachiyomi.domain.download.service.DownloadPreferences
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences
|
import tachiyomi.domain.library.service.LibraryPreferences
|
||||||
import tachiyomi.domain.manga.interactor.GetAllManga
|
import tachiyomi.domain.manga.interactor.GetAllManga
|
||||||
import tachiyomi.domain.manga.interactor.ResetViewerFlags
|
import tachiyomi.domain.manga.interactor.ResetViewerFlags
|
||||||
|
|
@ -120,7 +121,10 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||||
val basePreferences = remember { Injekt.get<BasePreferences>() }
|
val basePreferences = remember { Injekt.get<BasePreferences>() }
|
||||||
val networkPreferences = remember { Injekt.get<NetworkPreferences>() }
|
val networkPreferences = remember { Injekt.get<NetworkPreferences>() }
|
||||||
val libraryPreferences = remember { Injekt.get<LibraryPreferences>() }
|
val libraryPreferences = remember { Injekt.get<LibraryPreferences>() }
|
||||||
|
// SY -->
|
||||||
|
val downloadPreferences = remember { Injekt.get<DownloadPreferences>() }
|
||||||
val exhPreferences = remember { Injekt.get<ExhPreferences>() }
|
val exhPreferences = remember { Injekt.get<ExhPreferences>() }
|
||||||
|
// SY <--
|
||||||
|
|
||||||
return listOf(
|
return listOf(
|
||||||
Preference.PreferenceItem.TextPreference(
|
Preference.PreferenceItem.TextPreference(
|
||||||
|
|
@ -180,6 +184,9 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||||
getDataGroup(),
|
getDataGroup(),
|
||||||
getNetworkGroup(networkPreferences = networkPreferences),
|
getNetworkGroup(networkPreferences = networkPreferences),
|
||||||
getLibraryGroup(libraryPreferences = libraryPreferences),
|
getLibraryGroup(libraryPreferences = libraryPreferences),
|
||||||
|
// SY -->
|
||||||
|
getDownloadsGroup(downloadPreferences = downloadPreferences),
|
||||||
|
// SY <--
|
||||||
getReaderGroup(basePreferences = basePreferences),
|
getReaderGroup(basePreferences = basePreferences),
|
||||||
getExtensionsGroup(basePreferences = basePreferences),
|
getExtensionsGroup(basePreferences = basePreferences),
|
||||||
// SY -->
|
// SY -->
|
||||||
|
|
@ -400,6 +407,24 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SY ->
|
||||||
|
@Composable
|
||||||
|
private fun getDownloadsGroup(
|
||||||
|
downloadPreferences: DownloadPreferences,
|
||||||
|
): Preference.PreferenceGroup {
|
||||||
|
return Preference.PreferenceGroup(
|
||||||
|
title = stringResource(MR.strings.pref_category_downloads),
|
||||||
|
preferenceItems = persistentListOf(
|
||||||
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
|
preference = downloadPreferences.includeChapterUrlHash(),
|
||||||
|
title = stringResource(SYMR.strings.pref_include_chapter_url_hash),
|
||||||
|
subtitle = stringResource(SYMR.strings.pref_include_chapter_url_hash_desc),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// <- SY
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun getReaderGroup(
|
private fun getReaderGroup(
|
||||||
basePreferences: BasePreferences,
|
basePreferences: BasePreferences,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import tachiyomi.core.common.i18n.stringResource
|
||||||
import tachiyomi.core.common.storage.displayablePath
|
import tachiyomi.core.common.storage.displayablePath
|
||||||
import tachiyomi.core.common.util.system.logcat
|
import tachiyomi.core.common.util.system.logcat
|
||||||
import tachiyomi.domain.chapter.model.Chapter
|
import tachiyomi.domain.chapter.model.Chapter
|
||||||
|
import tachiyomi.domain.download.service.DownloadPreferences
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences
|
import tachiyomi.domain.library.service.LibraryPreferences
|
||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import tachiyomi.domain.storage.service.StorageManager
|
import tachiyomi.domain.storage.service.StorageManager
|
||||||
|
|
@ -29,6 +30,9 @@ class DownloadProvider(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val storageManager: StorageManager = Injekt.get(),
|
private val storageManager: StorageManager = Injekt.get(),
|
||||||
private val libraryPreferences: LibraryPreferences = Injekt.get(),
|
private val libraryPreferences: LibraryPreferences = Injekt.get(),
|
||||||
|
// SY -->
|
||||||
|
private val downloadPreferences: DownloadPreferences = Injekt.get(),
|
||||||
|
// SY <--
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val downloadsDir: UniFile?
|
private val downloadsDir: UniFile?
|
||||||
|
|
@ -209,6 +213,9 @@ class DownloadProvider(
|
||||||
chapterScanlator: String?,
|
chapterScanlator: String?,
|
||||||
chapterUrl: String,
|
chapterUrl: String,
|
||||||
disallowNonAsciiFilenames: Boolean = libraryPreferences.disallowNonAsciiFilenames().get(),
|
disallowNonAsciiFilenames: Boolean = libraryPreferences.disallowNonAsciiFilenames().get(),
|
||||||
|
// SY -->
|
||||||
|
includeChapterUrlHash: Boolean = downloadPreferences.includeChapterUrlHash().get(),
|
||||||
|
// SY <--
|
||||||
): String {
|
): String {
|
||||||
var dirName = sanitizeChapterName(chapterName)
|
var dirName = sanitizeChapterName(chapterName)
|
||||||
if (!chapterScanlator.isNullOrBlank()) {
|
if (!chapterScanlator.isNullOrBlank()) {
|
||||||
|
|
@ -216,7 +223,7 @@ class DownloadProvider(
|
||||||
}
|
}
|
||||||
// Subtract 7 bytes for hash and underscore, 4 bytes for .cbz
|
// Subtract 7 bytes for hash and underscore, 4 bytes for .cbz
|
||||||
dirName = DiskUtil.buildValidFilename(dirName, DiskUtil.MAX_FILE_NAME_BYTES - 11, disallowNonAsciiFilenames)
|
dirName = DiskUtil.buildValidFilename(dirName, DiskUtil.MAX_FILE_NAME_BYTES - 11, disallowNonAsciiFilenames)
|
||||||
dirName += "_" + md5(chapterUrl).take(6)
|
/* SY --> */ if (includeChapterUrlHash) /* SY <-- */ dirName += "_" + md5(chapterUrl).take(6)
|
||||||
return dirName
|
return dirName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -243,7 +250,7 @@ class DownloadProvider(
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get the filename that would be generated if the user were
|
// Get the filename that would be generated if the user were
|
||||||
// using the other value for the disallow non-ASCII
|
// using the other value for the disallow non-ASCII or non-hash
|
||||||
// filenames setting. This ensures that chapters downloaded
|
// filenames setting. This ensures that chapters downloaded
|
||||||
// before the user changed the setting can still be found.
|
// before the user changed the setting can still be found.
|
||||||
val otherChapterDirName =
|
val otherChapterDirName =
|
||||||
|
|
@ -252,6 +259,9 @@ class DownloadProvider(
|
||||||
chapterScanlator,
|
chapterScanlator,
|
||||||
chapterUrl,
|
chapterUrl,
|
||||||
!libraryPreferences.disallowNonAsciiFilenames().get(),
|
!libraryPreferences.disallowNonAsciiFilenames().get(),
|
||||||
|
// SY -->
|
||||||
|
!downloadPreferences.includeChapterUrlHash().get(),
|
||||||
|
// SY <--
|
||||||
)
|
)
|
||||||
|
|
||||||
return buildList(2) {
|
return buildList(2) {
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,10 @@ class DownloadPreferences(
|
||||||
|
|
||||||
fun parallelPageLimit() = preferenceStore.getInt("download_parallel_page_limit", 5)
|
fun parallelPageLimit() = preferenceStore.getInt("download_parallel_page_limit", 5)
|
||||||
|
|
||||||
|
// SY -->
|
||||||
|
fun includeChapterUrlHash() = preferenceStore.getBoolean("download_include_chapter_url_hash", true)
|
||||||
|
// SY <--
|
||||||
|
|
||||||
// KMK -->
|
// KMK -->
|
||||||
fun downloadCacheRenewInterval() = preferenceStore.getInt("download_cache_renew_interval", 1)
|
fun downloadCacheRenewInterval() = preferenceStore.getInt("download_cache_renew_interval", 1)
|
||||||
// KMK <--
|
// KMK <--
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,8 @@
|
||||||
<string name="bandwidth_data_saver_server">Bandwidth Hero Proxy Server</string>
|
<string name="bandwidth_data_saver_server">Bandwidth Hero Proxy Server</string>
|
||||||
<string name="data_saver_server_summary">Put Bandwidth Hero Proxy server url here</string>
|
<string name="data_saver_server_summary">Put Bandwidth Hero Proxy server url here</string>
|
||||||
<string name="clear_db_exclude_read">Keep entries with read chapters</string>
|
<string name="clear_db_exclude_read">Keep entries with read chapters</string>
|
||||||
|
<string name="pref_include_chapter_url_hash">Include chapter URL hash</string>
|
||||||
|
<string name="pref_include_chapter_url_hash_desc">Append the first six characters of the chapter URL's MD5 hash to the chapter file or folder name.</string>
|
||||||
|
|
||||||
<!-- Log Level -->
|
<!-- Log Level -->
|
||||||
<string name="log_minimal">Minimal</string>
|
<string name="log_minimal">Minimal</string>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue