mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 00:19:10 +01:00
Basic implementation of hiding catalogue by long pressing
This commit is contained in:
parent
0629bf982c
commit
5276e25b22
@ -19,7 +19,9 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.items.IFlexible
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.online.LoginSource
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.requestPermissionsSafe
|
||||
@ -54,10 +56,12 @@ import kotlin.math.max
|
||||
class CatalogueController : NucleusController<CataloguePresenter>(),
|
||||
SourceLoginDialog.Listener,
|
||||
FlexibleAdapter.OnItemClickListener,
|
||||
FlexibleAdapter.OnItemLongClickListener,
|
||||
CatalogueAdapter.OnBrowseClickListener,
|
||||
RootSearchInterface,
|
||||
BottomSheetController,
|
||||
CatalogueAdapter.OnLatestClickListener {
|
||||
CatalogueAdapter.OnLatestClickListener,
|
||||
HideCatalogueDialog.Listener {
|
||||
|
||||
/**
|
||||
* Application preferences.
|
||||
@ -235,9 +239,6 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when item is clicked
|
||||
*/
|
||||
override fun onItemClick(view: View, position: Int): Boolean {
|
||||
val item = adapter?.getItem(position) as? SourceItem ?: return false
|
||||
val source = item.source
|
||||
@ -252,6 +253,22 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onItemLongClick(position: Int) {
|
||||
val item = adapter?.getItem(position) as? SourceItem ?: return
|
||||
val source = item.source
|
||||
|
||||
val dialog = HideCatalogueDialog(source)
|
||||
dialog.targetController = this@CatalogueController
|
||||
dialog.showDialog(router)
|
||||
}
|
||||
|
||||
override fun hideCatalogueDialogClosed(source: Source) {
|
||||
val current = preferences.hiddenCatalogues().getOrDefault()
|
||||
preferences.hiddenCatalogues().set(current + source.id.toString())
|
||||
|
||||
presenter.updateSources()
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when browse is clicked in [CatalogueAdapter]
|
||||
*/
|
||||
|
@ -0,0 +1,31 @@
|
||||
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,6 +630,7 @@
|
||||
<string name="filter">Filter</string>
|
||||
<string name="forward">Forward</string>
|
||||
<string name="free">Free</string>
|
||||
<string name="hide_question">Hide %1$s?</string>
|
||||
<string name="ignore">Ignore</string>
|
||||
<string name="install">Install</string>
|
||||
<string name="left">Left</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user