Browse Source

Always save pages/covers in subfolders

Ensures that pages and covers are grouped together.
arkon 1 year ago
parent
commit
8568d5d6c3

+ 0 - 5
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),
-                ),
             ),
         )
     }

+ 2 - 8
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
         }
     }
 }

+ 2 - 2
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),
                 ),
             )
         }

+ 2 - 5
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 {

+ 0 - 2
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)

+ 0 - 2
i18n/src/main/res/values/strings.xml

@@ -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>