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()
|
adapter?.removeAllScrollableHeaders()
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
adapter?.addScrollableHeader(item)
|
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 {
|
override fun isSwipeable(): Boolean {
|
||||||
return source.id != LocalSource.ID
|
return source.id != LocalSource.ID && header != null
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,14 +87,16 @@ class SourcePresenter(
|
|||||||
|
|
||||||
// Emit the first item immediately but delay subsequent emissions by 500ms.
|
// Emit the first item immediately but delay subsequent emissions by 500ms.
|
||||||
lastUsedSubscription = Observable.merge(
|
lastUsedSubscription = Observable.merge(
|
||||||
sharedObs.take(1),
|
sharedObs.take(1),
|
||||||
sharedObs.skip(1).delay(500, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()))
|
sharedObs.skip(1).delay(500, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
|
||||||
.distinctUntilChanged()
|
).distinctUntilChanged().map {
|
||||||
.map { (sourceManager.get(it) as? CatalogueSource)?.let { source ->
|
(sourceManager.get(it) as? CatalogueSource)?.let { source ->
|
||||||
val pinnedCatalogues = preferences.pinnedCatalogues().getOrDefault()
|
val pinnedCatalogues = preferences.pinnedCatalogues().getOrDefault()
|
||||||
val isPinned = source.id.toString() in pinnedCatalogues
|
val isPinned = source.id.toString() in pinnedCatalogues
|
||||||
SourceItem(source, null, isPinned) } }
|
if (isPinned) null
|
||||||
.subscribeLatestCache(SourceController::setLastUsedSource)
|
else SourceItem(source, null, isPinned)
|
||||||
|
}
|
||||||
|
}.subscribeLatestCache(SourceController::setLastUsedSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateSources() {
|
fun updateSources() {
|
||||||
@ -121,5 +123,6 @@ class SourcePresenter(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val PINNED_KEY = "pinned"
|
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.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.source.SourcePresenter
|
import eu.kanade.tachiyomi.ui.source.SourcePresenter
|
||||||
import java.util.Locale
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class to change the application's language in runtime.
|
* Utility class to change the application's language in runtime.
|
||||||
@ -58,6 +58,7 @@ object LocaleHelper {
|
|||||||
null -> ""
|
null -> ""
|
||||||
"" -> context.getString(R.string.other)
|
"" -> context.getString(R.string.other)
|
||||||
SourcePresenter.PINNED_KEY -> context.getString(R.string.pinned)
|
SourcePresenter.PINNED_KEY -> context.getString(R.string.pinned)
|
||||||
|
SourcePresenter.LAST_USED_KEY -> context.getString(R.string.last_used)
|
||||||
"all" -> context.getString(R.string.all)
|
"all" -> context.getString(R.string.all)
|
||||||
else -> {
|
else -> {
|
||||||
val locale = getLocale(lang)
|
val locale = getLocale(lang)
|
||||||
|
@ -215,6 +215,7 @@
|
|||||||
<string name="all_sources">All sources</string>
|
<string name="all_sources">All sources</string>
|
||||||
<string name="sources">Sources</string>
|
<string name="sources">Sources</string>
|
||||||
<string name="source_hidden">Source hidden</string>
|
<string name="source_hidden">Source hidden</string>
|
||||||
|
<string name="last_used">Last Used</string>
|
||||||
|
|
||||||
<!-- Other Screens -->
|
<!-- Other Screens -->
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user