mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Change catalogue hiding dialog to accommodate more options in the future
This commit is contained in:
parent
f3d69599aa
commit
4c10b9844b
3 changed files with 15 additions and 41 deletions
|
@ -9,6 +9,7 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||
import com.bluelinelabs.conductor.ControllerChangeType
|
||||
import com.bluelinelabs.conductor.RouterTransaction
|
||||
|
@ -42,8 +43,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
|||
FlexibleAdapter.OnItemClickListener,
|
||||
FlexibleAdapter.OnItemLongClickListener,
|
||||
CatalogueAdapter.OnBrowseClickListener,
|
||||
CatalogueAdapter.OnLatestClickListener,
|
||||
HideCatalogueDialog.Listener {
|
||||
CatalogueAdapter.OnLatestClickListener {
|
||||
|
||||
/**
|
||||
* Application preferences.
|
||||
|
@ -130,15 +130,22 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
|||
}
|
||||
|
||||
override fun onItemLongClick(position: Int) {
|
||||
val activity = activity ?: return
|
||||
val item = adapter?.getItem(position) as? SourceItem ?: return
|
||||
val source = item.source
|
||||
|
||||
val dialog = HideCatalogueDialog(source)
|
||||
dialog.targetController = this@CatalogueController
|
||||
dialog.showDialog(router)
|
||||
MaterialDialog.Builder(activity)
|
||||
.title(item.source.name)
|
||||
.items(activity.getString(R.string.action_hide))
|
||||
.itemsCallback { _, _, which, _ ->
|
||||
when (which) {
|
||||
0 -> {
|
||||
hideCatalogue(item.source)
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
|
||||
override fun hideCatalogueDialogClosed(source: Source) {
|
||||
private fun hideCatalogue(source: Source) {
|
||||
val current = preferences.hiddenCatalogues().getOrDefault()
|
||||
preferences.hiddenCatalogues().set(current + source.id.toString())
|
||||
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
package eu.kanade.tachiyomi.ui.catalogue
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class HideCatalogueDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
|
||||
private val source = Injekt.get<SourceManager>().get(args.getLong("key"))!!
|
||||
|
||||
constructor(source: Source) : this(Bundle().apply { putLong("key", source.id) })
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.title(activity!!.getString(R.string.hide_catalogue, source.name))
|
||||
.positiveText(android.R.string.ok)
|
||||
.onPositive { _, _ ->
|
||||
(targetController as? Listener)?.hideCatalogueDialogClosed(source)
|
||||
}
|
||||
.negativeText(android.R.string.cancel)
|
||||
.build()
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
fun hideCatalogueDialogClosed(source: Source)
|
||||
}
|
||||
}
|
|
@ -83,6 +83,7 @@
|
|||
<string name="action_display_grid">Grid</string>
|
||||
<string name="action_display_list">List</string>
|
||||
<string name="action_display_download_badge">Download badges</string>
|
||||
<string name="action_hide">Hide</string>
|
||||
<string name="action_set_filter">Set filter</string>
|
||||
<string name="action_cancel">Cancel</string>
|
||||
<string name="action_cancel_all">Cancel all</string>
|
||||
|
@ -368,7 +369,6 @@
|
|||
<string name="action_global_search_hint">Global search…</string>
|
||||
<string name="latest">Latest</string>
|
||||
<string name="browse">Browse</string>
|
||||
<string name="hide_catalogue">Hide %1$s?</string>
|
||||
|
||||
<!-- Manga activity -->
|
||||
<string name="manga_not_in_db">This manga has been removed from the database.</string>
|
||||
|
|
Loading…
Reference in a new issue