mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 20:31:51 +01:00
Change catalogue hiding dialog to accommodate more options in the future
This commit is contained in:
parent
5276e25b22
commit
849cb4208f
@ -10,6 +10,9 @@ import android.view.MenuItem
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
|
import com.afollestad.materialdialogs.list.listItems
|
||||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
@ -60,8 +63,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
|||||||
CatalogueAdapter.OnBrowseClickListener,
|
CatalogueAdapter.OnBrowseClickListener,
|
||||||
RootSearchInterface,
|
RootSearchInterface,
|
||||||
BottomSheetController,
|
BottomSheetController,
|
||||||
CatalogueAdapter.OnLatestClickListener,
|
CatalogueAdapter.OnLatestClickListener {
|
||||||
HideCatalogueDialog.Listener {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application preferences.
|
* Application preferences.
|
||||||
@ -254,15 +256,22 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemLongClick(position: Int) {
|
override fun onItemLongClick(position: Int) {
|
||||||
|
val activity = activity ?: return
|
||||||
val item = adapter?.getItem(position) as? SourceItem ?: return
|
val item = adapter?.getItem(position) as? SourceItem ?: return
|
||||||
val source = item.source
|
|
||||||
|
|
||||||
val dialog = HideCatalogueDialog(source)
|
MaterialDialog(activity)
|
||||||
dialog.targetController = this@CatalogueController
|
.title(text = item.source.name)
|
||||||
dialog.showDialog(router)
|
.listItems(items = listOf(activity.getString(R.string.hide)),
|
||||||
|
waitForPositiveButton = false, selection = { _, index, _ ->
|
||||||
|
when (index) {
|
||||||
|
0 -> {
|
||||||
|
hideCatalogue(item.source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hideCatalogueDialogClosed(source: Source) {
|
private fun hideCatalogue(source: Source) {
|
||||||
val current = preferences.hiddenCatalogues().getOrDefault()
|
val current = preferences.hiddenCatalogues().getOrDefault()
|
||||||
preferences.hiddenCatalogues().set(current + source.id.toString())
|
preferences.hiddenCatalogues().set(current + source.id.toString())
|
||||||
|
|
||||||
|
@ -1,31 +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(activity!!)
|
|
||||||
.title(text = activity!!.getString(R.string.hide_question, source.name))
|
|
||||||
.positiveButton(android.R.string.ok) {
|
|
||||||
(targetController as? Listener)?.hideCatalogueDialogClosed(source)
|
|
||||||
}
|
|
||||||
.negativeButton(android.R.string.cancel)
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Listener {
|
|
||||||
fun hideCatalogueDialogClosed(source: Source)
|
|
||||||
}
|
|
||||||
}
|
|
@ -630,7 +630,7 @@
|
|||||||
<string name="filter">Filter</string>
|
<string name="filter">Filter</string>
|
||||||
<string name="forward">Forward</string>
|
<string name="forward">Forward</string>
|
||||||
<string name="free">Free</string>
|
<string name="free">Free</string>
|
||||||
<string name="hide_question">Hide %1$s?</string>
|
<string name="hide">Hide</string>
|
||||||
<string name="ignore">Ignore</string>
|
<string name="ignore">Ignore</string>
|
||||||
<string name="install">Install</string>
|
<string name="install">Install</string>
|
||||||
<string name="left">Left</string>
|
<string name="left">Left</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user