Skip to content

Commit

Permalink
Revert "Always save pages/covers in subfolders"
Browse files Browse the repository at this point in the history
This reverts commit 7733c46.
  • Loading branch information
Jays2Kings committed Nov 5, 2023
1 parent fed555d commit a9840d6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@
<string name="automatic_orientation">Automatic (based on orientation)</string>
<string name="actions">Actions</string>
<string name="show_on_long_press">Show on long press</string>
<string name="save_pages_separately">Save pages in separate folders</string>
<string name="create_folders_by_manga_title">Creates folders according to manga title</string>
<string name="pref_hide_threshold">Sensitivity for hiding menu on scroll</string>
<string name="pref_highest">Highest</string>
<string name="pref_high">High</string>
Expand Down

0 comments on commit a9840d6

Please sign in to comment.