mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 05:41:51 +01:00
Always save pages/covers in subfolders
Ensures that pages and covers are grouped together.
This commit is contained in:
parent
7ed99fbbd6
commit
8568d5d6c3
@ -342,11 +342,6 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
pref = readerPreferences.readWithLongTap(),
|
pref = readerPreferences.readWithLongTap(),
|
||||||
title = stringResource(R.string.pref_read_with_long_tap),
|
title = stringResource(R.string.pref_read_with_long_tap),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
|
||||||
pref = readerPreferences.folderPerManga(),
|
|
||||||
title = stringResource(R.string.pref_create_folder_per_manga),
|
|
||||||
subtitle = stringResource(R.string.pref_create_folder_per_manga_summary),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -166,19 +166,12 @@ sealed class Image(
|
|||||||
}
|
}
|
||||||
|
|
||||||
sealed interface Location {
|
sealed interface Location {
|
||||||
data class Pictures private constructor(val relativePath: String) : Location {
|
data class Pictures(val relativePath: String) : Location
|
||||||
companion object {
|
|
||||||
fun create(relativePath: String = ""): Pictures {
|
|
||||||
return Pictures(relativePath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data object Cache : Location
|
data object Cache : Location
|
||||||
|
|
||||||
fun directory(context: Context): File {
|
fun directory(context: Context): File {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
Cache -> context.cacheImageDir
|
|
||||||
is Pictures -> {
|
is Pictures -> {
|
||||||
val file = File(
|
val file = File(
|
||||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
|
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
|
||||||
@ -192,6 +185,7 @@ sealed interface Location {
|
|||||||
}
|
}
|
||||||
file
|
file
|
||||||
}
|
}
|
||||||
|
Cache -> context.cacheImageDir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,8 @@ class MangaCoverScreenModel(
|
|||||||
imageSaver.save(
|
imageSaver.save(
|
||||||
Image.Cover(
|
Image.Cover(
|
||||||
bitmap = bitmap,
|
bitmap = bitmap,
|
||||||
name = manga.title,
|
name = "cover",
|
||||||
location = if (temp) Location.Cache else Location.Pictures.create(),
|
location = if (temp) Location.Cache else Location.Pictures(manga.title),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -740,17 +740,14 @@ class ReaderViewModel @JvmOverloads constructor(
|
|||||||
|
|
||||||
val filename = generateFilename(manga, page)
|
val filename = generateFilename(manga, page)
|
||||||
|
|
||||||
// Pictures directory.
|
// Copy file in background
|
||||||
val relativePath = if (readerPreferences.folderPerManga().get()) DiskUtil.buildValidFilename(manga.title) else ""
|
|
||||||
|
|
||||||
// Copy file in background.
|
|
||||||
viewModelScope.launchNonCancellable {
|
viewModelScope.launchNonCancellable {
|
||||||
try {
|
try {
|
||||||
val uri = imageSaver.save(
|
val uri = imageSaver.save(
|
||||||
image = Image.Page(
|
image = Image.Page(
|
||||||
inputStream = page.stream!!,
|
inputStream = page.stream!!,
|
||||||
name = filename,
|
name = filename,
|
||||||
location = Location.Pictures.create(relativePath),
|
location = Location.Pictures(DiskUtil.buildValidFilename(manga.title)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
withUIContext {
|
withUIContext {
|
||||||
|
@ -54,8 +54,6 @@ class ReaderPreferences(
|
|||||||
|
|
||||||
fun readerHideThreshold() = preferenceStore.getEnum("reader_hide_threshold", ReaderHideThreshold.LOW)
|
fun readerHideThreshold() = preferenceStore.getEnum("reader_hide_threshold", ReaderHideThreshold.LOW)
|
||||||
|
|
||||||
fun folderPerManga() = preferenceStore.getBoolean("create_folder_per_manga", false)
|
|
||||||
|
|
||||||
fun skipRead() = preferenceStore.getBoolean("skip_read", false)
|
fun skipRead() = preferenceStore.getBoolean("skip_read", false)
|
||||||
|
|
||||||
fun skipFiltered() = preferenceStore.getBoolean("skip_filtered", true)
|
fun skipFiltered() = preferenceStore.getBoolean("skip_filtered", true)
|
||||||
|
@ -363,8 +363,6 @@
|
|||||||
<string name="tapping_inverted_both">Both</string>
|
<string name="tapping_inverted_both">Both</string>
|
||||||
<string name="pref_reader_actions">Actions</string>
|
<string name="pref_reader_actions">Actions</string>
|
||||||
<string name="pref_read_with_long_tap">Show actions on long tap</string>
|
<string name="pref_read_with_long_tap">Show actions on long tap</string>
|
||||||
<string name="pref_create_folder_per_manga">Save pages into separate folders</string>
|
|
||||||
<string name="pref_create_folder_per_manga_summary">Creates folders according to entries\' title</string>
|
|
||||||
<string name="pref_reader_theme">Background color</string>
|
<string name="pref_reader_theme">Background color</string>
|
||||||
<string name="white_background">White</string>
|
<string name="white_background">White</string>
|
||||||
<string name="gray_background">Gray</string>
|
<string name="gray_background">Gray</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user