mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 19:55:11 +01:00
Added Last Used header to browse, hides if it is a pinned source
This commit is contained in:
parent
f5cc879a7e
commit
204a784895
@ -366,6 +366,7 @@ class SourceController : NucleusController<SourcePresenter>(),
|
||||
adapter?.removeAllScrollableHeaders()
|
||||
if (item != null) {
|
||||
adapter?.addScrollableHeader(item)
|
||||
adapter?.addScrollableHeader(LangItem(SourcePresenter.LAST_USED_KEY))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class SourceItem(val source: CatalogueSource, header: LangItem? = null, val isPi
|
||||
}
|
||||
|
||||
override fun isSwipeable(): Boolean {
|
||||
return source.id != LocalSource.ID
|
||||
return source.id != LocalSource.ID && header != null
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,13 +88,15 @@ class SourcePresenter(
|
||||
// Emit the first item immediately but delay subsequent emissions by 500ms.
|
||||
lastUsedSubscription = Observable.merge(
|
||||
sharedObs.take(1),
|
||||
sharedObs.skip(1).delay(500, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()))
|
||||
.distinctUntilChanged()
|
||||
.map { (sourceManager.get(it) as? CatalogueSource)?.let { source ->
|
||||
sharedObs.skip(1).delay(500, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
|
||||
).distinctUntilChanged().map {
|
||||
(sourceManager.get(it) as? CatalogueSource)?.let { source ->
|
||||
val pinnedCatalogues = preferences.pinnedCatalogues().getOrDefault()
|
||||
val isPinned = source.id.toString() in pinnedCatalogues
|
||||
SourceItem(source, null, isPinned) } }
|
||||
.subscribeLatestCache(SourceController::setLastUsedSource)
|
||||
if (isPinned) null
|
||||
else SourceItem(source, null, isPinned)
|
||||
}
|
||||
}.subscribeLatestCache(SourceController::setLastUsedSource)
|
||||
}
|
||||
|
||||
fun updateSources() {
|
||||
@ -121,5 +123,6 @@ class SourcePresenter(
|
||||
|
||||
companion object {
|
||||
const val PINNED_KEY = "pinned"
|
||||
const val LAST_USED_KEY = "last_used"
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ import android.view.ContextThemeWrapper
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.source.SourcePresenter
|
||||
import java.util.Locale
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Utility class to change the application's language in runtime.
|
||||
@ -58,6 +58,7 @@ object LocaleHelper {
|
||||
null -> ""
|
||||
"" -> context.getString(R.string.other)
|
||||
SourcePresenter.PINNED_KEY -> context.getString(R.string.pinned)
|
||||
SourcePresenter.LAST_USED_KEY -> context.getString(R.string.last_used)
|
||||
"all" -> context.getString(R.string.all)
|
||||
else -> {
|
||||
val locale = getLocale(lang)
|
||||
|
@ -215,6 +215,7 @@
|
||||
<string name="all_sources">All sources</string>
|
||||
<string name="sources">Sources</string>
|
||||
<string name="source_hidden">Source hidden</string>
|
||||
<string name="last_used">Last Used</string>
|
||||
|
||||
<!-- Other Screens -->
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user