Albirew/tachiyomi
Archivé
1
0
Bifurcation 0

Basic implementation of hiding catalogue by long pressing

Cette révision appartient à :
arkon 2020-03-02 22:49:48 -05:00
Parent 9eb441ac44
révision a29f33020d
3 fichiers modifiés avec 55 ajouts et 4 suppressions

Voir le fichier

@ -18,7 +18,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.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.base.controller.requestPermissionsSafe
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
@ -38,8 +40,10 @@ import uy.kohesive.injekt.api.get
*/
class CatalogueController : NucleusController<CataloguePresenter>(),
FlexibleAdapter.OnItemClickListener,
FlexibleAdapter.OnItemLongClickListener,
CatalogueAdapter.OnBrowseClickListener,
CatalogueAdapter.OnLatestClickListener {
CatalogueAdapter.OnLatestClickListener,
HideCatalogueDialog.Listener {
/**
* Application preferences.
@ -118,9 +122,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
@ -128,6 +129,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]
*/

Voir le fichier

@ -0,0 +1,33 @@
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)
}
}

Voir le fichier

@ -367,6 +367,7 @@
<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>