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 Jays2Kings
parent bde4d437eb
commit 3da1efe255
4 changed files with 17 additions and 4 deletions

View File

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

View File

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

View File

@ -685,11 +685,14 @@ class ReaderPresenter(
notifier.onClear()
// Pictures directory.
val destDir = File(
Environment.getExternalStorageDirectory().absolutePath +
val baseDir = Environment.getExternalStorageDirectory().absolutePath +
File.separator + Environment.DIRECTORY_PICTURES +
File.separator + "Tachiyomi"
)
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.
Observable.fromCallable { saveImage(page, destDir, manga) }

View File

@ -54,6 +54,12 @@ class SettingsDownloadController : SettingsController() {
titleRes = R.string.only_download_over_wifi
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 {
titleRes = R.string.remove_after_read