From 8568d5d6c3ceae0084a350906b330f23dab571e1 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 8 Oct 2023 17:04:02 -0400 Subject: [PATCH] Always save pages/covers in subfolders Ensures that pages and covers are grouped together. --- .../more/settings/screen/SettingsReaderScreen.kt | 5 ----- .../java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt | 10 ++-------- .../kanade/tachiyomi/ui/manga/MangaCoverScreenModel.kt | 4 ++-- .../eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt | 7 ++----- .../tachiyomi/ui/reader/setting/ReaderPreferences.kt | 2 -- i18n/src/main/res/values/strings.xml | 2 -- 6 files changed, 6 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt index ef35ea38b6..e4ac76681d 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt @@ -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), - ), ), ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt index 7086f10239..783d8bdaee 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt @@ -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 } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaCoverScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaCoverScreenModel.kt index ffb6553c45..784a99aa2d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaCoverScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaCoverScreenModel.kt @@ -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), ), ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt index ff098b92ea..55be5fd61d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt @@ -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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt index a58cd90969..faf75d0ba9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt @@ -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) diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index bb2918baa5..41d216db55 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -363,8 +363,6 @@ Both Actions Show actions on long tap - Save pages into separate folders - Creates folders according to entries\' title Background color White Gray