Add preference to toggle chapter URL hash for downloads (#1533)
This commit is contained in:
+21
@@ -89,6 +89,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
|
||||||
@@ -117,6 +118,7 @@ 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>() }
|
||||||
|
val downloadPreferences = remember { Injekt.get<DownloadPreferences>() }
|
||||||
|
|
||||||
return listOf(
|
return listOf(
|
||||||
Preference.PreferenceItem.TextPreference(
|
Preference.PreferenceItem.TextPreference(
|
||||||
@@ -167,6 +169,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
getDataGroup(),
|
getDataGroup(),
|
||||||
getNetworkGroup(networkPreferences = networkPreferences),
|
getNetworkGroup(networkPreferences = networkPreferences),
|
||||||
getLibraryGroup(libraryPreferences = libraryPreferences),
|
getLibraryGroup(libraryPreferences = libraryPreferences),
|
||||||
|
getDownloadsGroup(downloadPreferences = downloadPreferences),
|
||||||
getReaderGroup(basePreferences = basePreferences),
|
getReaderGroup(basePreferences = basePreferences),
|
||||||
getExtensionsGroup(basePreferences = basePreferences),
|
getExtensionsGroup(basePreferences = basePreferences),
|
||||||
// SY -->
|
// SY -->
|
||||||
@@ -378,6 +381,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
|
||||||
@@ -28,6 +29,7 @@ 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(),
|
||||||
|
private val downloadPreferences: DownloadPreferences = Injekt.get(),
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val downloadsDir: UniFile?
|
private val downloadsDir: UniFile?
|
||||||
@@ -190,6 +192,7 @@ class DownloadProvider(
|
|||||||
chapterScanlator: String?,
|
chapterScanlator: String?,
|
||||||
chapterUrl: String,
|
chapterUrl: String,
|
||||||
disallowNonAsciiFilenames: Boolean = libraryPreferences.disallowNonAsciiFilenames().get(),
|
disallowNonAsciiFilenames: Boolean = libraryPreferences.disallowNonAsciiFilenames().get(),
|
||||||
|
includeChapterUrlHash: Boolean = downloadPreferences.includeChapterUrlHash().get(),
|
||||||
): String {
|
): String {
|
||||||
var dirName = sanitizeChapterName(chapterName)
|
var dirName = sanitizeChapterName(chapterName)
|
||||||
if (!chapterScanlator.isNullOrBlank()) {
|
if (!chapterScanlator.isNullOrBlank()) {
|
||||||
@@ -197,7 +200,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)
|
if (includeChapterUrlHash) dirName += "_" + md5(chapterUrl).take(6)
|
||||||
return dirName
|
return dirName
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,6 +236,7 @@ class DownloadProvider(
|
|||||||
chapterScanlator,
|
chapterScanlator,
|
||||||
chapterUrl,
|
chapterUrl,
|
||||||
!libraryPreferences.disallowNonAsciiFilenames().get(),
|
!libraryPreferences.disallowNonAsciiFilenames().get(),
|
||||||
|
!downloadPreferences.includeChapterUrlHash().get(),
|
||||||
)
|
)
|
||||||
|
|
||||||
return buildList(2) {
|
return buildList(2) {
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ class DownloadPreferences(
|
|||||||
|
|
||||||
fun parallelPageLimit() = preferenceStore.getInt("download_parallel_page_limit", 5)
|
fun parallelPageLimit() = preferenceStore.getInt("download_parallel_page_limit", 5)
|
||||||
|
|
||||||
|
fun includeChapterUrlHash() = preferenceStore.getBoolean("download_include_chapter_url_hash", true)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val REMOVE_EXCLUDE_CATEGORIES_PREF_KEY = "remove_exclude_categories"
|
private const val REMOVE_EXCLUDE_CATEGORIES_PREF_KEY = "remove_exclude_categories"
|
||||||
private const val DOWNLOAD_NEW_CATEGORIES_PREF_KEY = "download_new_categories"
|
private const val DOWNLOAD_NEW_CATEGORIES_PREF_KEY = "download_new_categories"
|
||||||
|
|||||||
@@ -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 folder name.</string>
|
||||||
|
|
||||||
<!-- Log Level -->
|
<!-- Log Level -->
|
||||||
<string name="log_minimal">Minimal</string>
|
<string name="log_minimal">Minimal</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user