mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-13 12:38:58 +01:00
[feature] add ability to set global filter/sort/display for Manga chapters (#3622)
* - [feature] add ability to set global filter/sort/display for Manga chapters * - move default chapter settings functionality to overflow menu - code clean up * - show confirmation dialog when user selects "Set as Default" option in Chapter Settings * - hide overflow menu in LibrarySettingsSheet * - apply default chapter settings if manga is added to Library from a Source's browsing screen Co-authored-by: arkon <arkon@users.noreply.github.com>
This commit is contained in:
@@ -28,6 +28,7 @@ import eu.kanade.tachiyomi.ui.browse.source.filter.TextItem
|
||||
import eu.kanade.tachiyomi.ui.browse.source.filter.TextSectionItem
|
||||
import eu.kanade.tachiyomi.ui.browse.source.filter.TriStateItem
|
||||
import eu.kanade.tachiyomi.ui.browse.source.filter.TriStateSectionItem
|
||||
import eu.kanade.tachiyomi.util.chapter.ChapterSettingsHelper
|
||||
import eu.kanade.tachiyomi.util.removeCovers
|
||||
import kotlinx.coroutines.flow.subscribe
|
||||
import rx.Observable
|
||||
@@ -268,6 +269,8 @@ open class BrowseSourcePresenter(
|
||||
|
||||
if (!manga.favorite) {
|
||||
manga.removeCovers(coverCache)
|
||||
} else {
|
||||
ChapterSettingsHelper.applySettingDefaultsFromPreferences(manga)
|
||||
}
|
||||
|
||||
db.insertManga(manga).executeAsBlocking()
|
||||
|
||||
@@ -18,6 +18,7 @@ import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.ui.manga.chapter.ChapterItem
|
||||
import eu.kanade.tachiyomi.util.chapter.ChapterSettingsHelper
|
||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||
import eu.kanade.tachiyomi.util.isLocal
|
||||
import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed
|
||||
@@ -82,6 +83,10 @@ class MangaPresenter(
|
||||
override fun onCreate(savedState: Bundle?) {
|
||||
super.onCreate(savedState)
|
||||
|
||||
if (!manga.favorite) {
|
||||
ChapterSettingsHelper.applySettingDefaultsFromPreferences(manga)
|
||||
}
|
||||
|
||||
// Manga info - start
|
||||
|
||||
getMangaObservable()
|
||||
|
||||
@@ -14,7 +14,7 @@ class ChaptersSettingsSheet(
|
||||
activity: Activity,
|
||||
private val presenter: MangaPresenter,
|
||||
onGroupClickListener: (ExtendedNavigationView.Group) -> Unit
|
||||
) : TabbedBottomSheetDialog(activity) {
|
||||
) : TabbedBottomSheetDialog(activity, presenter.manga) {
|
||||
|
||||
val filters: Filter
|
||||
private val sort: Sort
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package eu.kanade.tachiyomi.ui.manga.chapter
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.util.chapter.ChapterSettingsHelper
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.widget.DialogCheckboxView
|
||||
|
||||
class SetChapterSettingsDialog(val context: Context, val manga: Manga) {
|
||||
private var dialog: Dialog
|
||||
|
||||
init {
|
||||
this.dialog = buildDialog()
|
||||
}
|
||||
|
||||
private fun buildDialog(): Dialog {
|
||||
val view = DialogCheckboxView(context).apply {
|
||||
setDescription(R.string.confirm_set_chapter_settings)
|
||||
setOptionDescription(R.string.also_set_chapter_settings_for_library)
|
||||
}
|
||||
|
||||
return MaterialDialog(context)
|
||||
.title(R.string.action_chapter_settings)
|
||||
.customView(
|
||||
view = view,
|
||||
horizontalPadding = true
|
||||
)
|
||||
.positiveButton(android.R.string.ok) {
|
||||
ChapterSettingsHelper.setNewSettingDefaults(manga)
|
||||
if (view.isChecked()) {
|
||||
ChapterSettingsHelper.updateAllMangasWithDefaultsFromPreferences()
|
||||
}
|
||||
|
||||
context.toast(context.getString(R.string.chapter_settings_updated))
|
||||
}
|
||||
.negativeButton(android.R.string.cancel)
|
||||
}
|
||||
|
||||
fun showDialog() = dialog.show()
|
||||
|
||||
fun dismissDialog() = dialog.dismiss()
|
||||
}
|
||||
Reference in New Issue
Block a user