Setting: Creates folders according to manga title (#4861)

* cherry-picking my changes

* Update SettingsDownloadController.kt

* Update SettingsDownloadController.kt

* Update ReaderPresenter.kt

Co-authored-by: arkon <arkon@users.noreply.github.com>
This commit is contained in:
OncePunchedMan 2021-04-27 23:38:56 +02:00 committed by GitHub
parent dad3292bdd
commit 9278407b85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 3 deletions

View File

@ -109,6 +109,8 @@ object PreferenceKeys {
const val downloadOnlyOverWifi = "pref_download_only_over_wifi_key" const val downloadOnlyOverWifi = "pref_download_only_over_wifi_key"
const val folderPerManga = "create_folder_per_manga"
const val numberOfBackups = "backup_slots" const val numberOfBackups = "backup_slots"
const val backupInterval = "backup_interval" const val backupInterval = "backup_interval"

View File

@ -203,6 +203,8 @@ class PreferencesHelper(val context: Context) {
fun downloadOnlyOverWifi() = prefs.getBoolean(Keys.downloadOnlyOverWifi, true) fun downloadOnlyOverWifi() = prefs.getBoolean(Keys.downloadOnlyOverWifi, true)
fun folderPerManga() = prefs.getBoolean(Keys.folderPerManga, false)
fun numberOfBackups() = flowPrefs.getInt(Keys.numberOfBackups, 1) fun numberOfBackups() = flowPrefs.getInt(Keys.numberOfBackups, 1)
fun backupInterval() = flowPrefs.getInt(Keys.backupInterval, 0) fun backupInterval() = flowPrefs.getInt(Keys.backupInterval, 0)

View File

@ -556,11 +556,14 @@ class ReaderPresenter(
notifier.onClear() notifier.onClear()
// Pictures directory. // Pictures directory.
val destDir = File( val baseDir = Environment.getExternalStorageDirectory().absolutePath +
Environment.getExternalStorageDirectory().absolutePath +
File.separator + Environment.DIRECTORY_PICTURES + File.separator + Environment.DIRECTORY_PICTURES +
File.separator + context.getString(R.string.app_name) File.separator + context.getString(R.string.app_name)
) val destDir = if (preferences.folderPerManga()) {
File(baseDir + File.separator + manga.title)
} else {
File(baseDir)
}
// Copy file in background. // Copy file in background.
Observable.fromCallable { saveImage(page, destDir, manga) } Observable.fromCallable { saveImage(page, destDir, manga) }

View File

@ -27,6 +27,7 @@ import eu.kanade.tachiyomi.util.preference.preference
import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.preferenceCategory
import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.switchPreference
import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.preference.titleRes
import eu.kanade.tachiyomi.util.preference.summaryRes
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.widget.materialdialogs.QuadStateCheckBox import eu.kanade.tachiyomi.widget.materialdialogs.QuadStateCheckBox
import eu.kanade.tachiyomi.widget.materialdialogs.listItemsQuadStateMultiChoice import eu.kanade.tachiyomi.widget.materialdialogs.listItemsQuadStateMultiChoice
@ -66,6 +67,12 @@ class SettingsDownloadController : SettingsController() {
titleRes = R.string.pref_download_only_over_wifi titleRes = R.string.pref_download_only_over_wifi
defaultValue = true defaultValue = true
} }
switchPreference {
key = Keys.folderPerManga
titleRes = R.string.pref_create_folder_per_manga
summaryRes = R.string.pref_create_folder_per_manga_summary
defaultValue = false
}
preferenceCategory { preferenceCategory {
titleRes = R.string.pref_category_delete_chapters titleRes = R.string.pref_category_delete_chapters

View File

@ -367,6 +367,8 @@
<string name="pref_category_auto_download">Auto-download</string> <string name="pref_category_auto_download">Auto-download</string>
<string name="pref_download_new">Download new chapters</string> <string name="pref_download_new">Download new chapters</string>
<string name="pref_download_new_categories_details">Manga in excluded categories will not be downloaded even if they are also in included categories.</string> <string name="pref_download_new_categories_details">Manga in excluded categories will not be downloaded even if they are also in included categories.</string>
<string name="pref_create_folder_per_manga">Saves pages into separate folders</string>
<string name="pref_create_folder_per_manga_summary">Creates folders according to manga title</string>
<!-- Tracking section --> <!-- Tracking section -->
<string name="pref_auto_update_manga_sync">Update chapter progress after reading</string> <string name="pref_auto_update_manga_sync">Update chapter progress after reading</string>