From a9840d6b4ac1ba39343a34f71b7620736426c825 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Sun, 5 Nov 2023 00:50:47 -0700 Subject: [PATCH] Revert "Always save pages/covers in subfolders" This reverts commit 7733c46ffc88591a059fa3de6197079876275329. --- .../data/preference/PreferencesHelper.kt | 2 ++ .../tachiyomi/ui/manga/MangaDetailsPresenter.kt | 17 ++++++++++++----- .../tachiyomi/ui/reader/ReaderViewModel.kt | 10 ++++++++-- .../ui/setting/SettingsReaderController.kt | 5 +++++ app/src/main/res/values/strings.xml | 2 ++ 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 2738d479dff1..cefcb4ba83f8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -237,6 +237,8 @@ class PreferencesHelper(val context: Context) { fun downloadOnlyOverWifi() = prefs.getBoolean(Keys.downloadOnlyOverWifi, true) + fun folderPerManga() = flowPrefs.getBoolean("create_folder_per_manga", false) + fun librarySearchSuggestion() = flowPrefs.getString(Keys.librarySearchSuggestion, "") fun showLibrarySearchSuggestions() = flowPrefs.getBoolean(Keys.showLibrarySearchSuggestions, false) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt index fd37a8e2d2d6..e30afb78d5d0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt @@ -853,12 +853,19 @@ class MangaDetailsPresenter( fun saveCover(): Boolean { return try { - val baseDir = Environment.getExternalStorageDirectory().absolutePath + - File.separator + Environment.DIRECTORY_PICTURES + - File.separator + preferences.context.getString(R.string.app_name) - val directory = - File(baseDir + File.separator + DiskUtil.buildValidFilename(manga.title)) + val directory = if (preferences.folderPerManga().get()) { + val baseDir = Environment.getExternalStorageDirectory().absolutePath + + File.separator + Environment.DIRECTORY_PICTURES + + File.separator + preferences.context.getString(R.string.app_name) + File(baseDir + File.separator + DiskUtil.buildValidFilename(manga.title)) + } else { + File( + Environment.getExternalStorageDirectory().absolutePath + + File.separator + Environment.DIRECTORY_PICTURES + + File.separator + preferences.context.getString(R.string.app_name), + ) + } val file = saveCover(directory) DiskUtil.scanMedia(preferences.context, file) true 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 ccb216638f66..510f792ddcf4 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 @@ -817,8 +817,11 @@ class ReaderViewModel( val baseDir = Environment.getExternalStorageDirectory().absolutePath + File.separator + Environment.DIRECTORY_PICTURES + File.separator + context.getString(R.string.app_name) - val destDir = + val destDir = if (preferences.folderPerManga().get()) { File(baseDir + File.separator + DiskUtil.buildValidFilename(manga.title)) + } else { + File(baseDir) + } // Copy file in background. viewModelScope.launchNonCancellable { @@ -848,8 +851,11 @@ class ReaderViewModel( val baseDir = Environment.getExternalStorageDirectory().absolutePath + File.separator + Environment.DIRECTORY_PICTURES + File.separator + context.getString(R.string.app_name) - val destDir = + val destDir = if (preferences.folderPerManga().get()) { File(baseDir + File.separator + DiskUtil.buildValidFilename(manga.title)) + } else { + File(baseDir) + } try { val file = saveImages(firstPage, secondPage, isLTR, bg, destDir, manga) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt index 688fa34d0113..4a75bf8ab190 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt @@ -395,6 +395,11 @@ class SettingsReaderController : SettingsController() { titleRes = R.string.show_on_long_press defaultValue = true } + switchPreference { + bindTo(preferences.folderPerManga()) + titleRes = R.string.save_pages_separately + summaryRes = R.string.create_folders_by_manga_title + } } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 77227b40efbc..d43bc785ddcb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -502,6 +502,8 @@ Automatic (based on orientation) Actions Show on long press + Save pages in separate folders + Creates folders according to manga title Sensitivity for hiding menu on scroll Highest High