Always save pages/covers in subfolders
Ensures that pages and covers are grouped together.
This commit is contained in:
parent
7ed99fbbd6
commit
8568d5d6c3
6 changed files with 6 additions and 24 deletions
|
@ -342,11 +342,6 @@ object SettingsReaderScreen : SearchableSettings {
|
|||
pref = readerPreferences.readWithLongTap(),
|
||||
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 {
|
||||
data class Pictures private constructor(val relativePath: String) : Location {
|
||||
companion object {
|
||||
fun create(relativePath: String = ""): Pictures {
|
||||
return Pictures(relativePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
data class Pictures(val relativePath: String) : Location
|
||||
|
||||
data object Cache : Location
|
||||
|
||||
fun directory(context: Context): File {
|
||||
return when (this) {
|
||||
Cache -> context.cacheImageDir
|
||||
is Pictures -> {
|
||||
val file = File(
|
||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
|
||||
|
@ -192,6 +185,7 @@ sealed interface Location {
|
|||
}
|
||||
file
|
||||
}
|
||||
Cache -> context.cacheImageDir
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,8 +102,8 @@ class MangaCoverScreenModel(
|
|||
imageSaver.save(
|
||||
Image.Cover(
|
||||
bitmap = bitmap,
|
||||
name = manga.title,
|
||||
location = if (temp) Location.Cache else Location.Pictures.create(),
|
||||
name = "cover",
|
||||
location = if (temp) Location.Cache else Location.Pictures(manga.title),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -740,17 +740,14 @@ class ReaderViewModel @JvmOverloads constructor(
|
|||
|
||||
val filename = generateFilename(manga, page)
|
||||
|
||||
// Pictures directory.
|
||||
val relativePath = if (readerPreferences.folderPerManga().get()) DiskUtil.buildValidFilename(manga.title) else ""
|
||||
|
||||
// Copy file in background.
|
||||
// Copy file in background
|
||||
viewModelScope.launchNonCancellable {
|
||||
try {
|
||||
val uri = imageSaver.save(
|
||||
image = Image.Page(
|
||||
inputStream = page.stream!!,
|
||||
name = filename,
|
||||
location = Location.Pictures.create(relativePath),
|
||||
location = Location.Pictures(DiskUtil.buildValidFilename(manga.title)),
|
||||
),
|
||||
)
|
||||
withUIContext {
|
||||
|
|
|
@ -54,8 +54,6 @@ class ReaderPreferences(
|
|||
|
||||
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 skipFiltered() = preferenceStore.getBoolean("skip_filtered", true)
|
||||
|
|
|
@ -363,8 +363,6 @@
|
|||
<string name="tapping_inverted_both">Both</string>
|
||||
<string name="pref_reader_actions">Actions</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="white_background">White</string>
|
||||
<string name="gray_background">Gray</string>
|
||||
|
|
Reference in a new issue