Show "fetched x time ago" in grouped/all recents

+ show "fetched" when sorting by fetched in updates mode in recents
This commit is contained in:
Jays2Kings 2022-06-29 16:51:18 -04:00
parent fd89ca13e7
commit ebbb6a2129
2 changed files with 26 additions and 4 deletions

View file

@ -4,6 +4,7 @@ import androidx.recyclerview.widget.ItemTouchHelper
import com.fredporciuncula.flow.preferences.Preference
import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterAdapter
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.drop
@ -24,6 +25,7 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
var showUpdatedTime = preferences.showUpdatedTime().get()
var uniformCovers = preferences.uniformGrid().get()
var showOutline = preferences.outlineOnCovers().get()
var sortByFetched = preferences.sortFetchedTime().get()
val viewType: Int
get() = delegate.getViewType()
@ -48,6 +50,7 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
preferences.showTitleFirstInRecents().register { showTitleFirst = it }
preferences.showUpdatedTime().register { showUpdatedTime = it }
preferences.uniformGrid().register { uniformCovers = it }
preferences.sortFetchedTime().asImmediateFlowIn(delegate.scope()) { sortByFetched = it }
preferences.outlineOnCovers().register(false) {
showOutline = it
(0 until itemCount).forEach { i ->

View file

@ -124,10 +124,29 @@ class RecentMangaHolder(
item.mch.manga.date_added.timeSpanFromNow(itemView.context),
)
isSmallUpdates -> ""
item.mch.history.id == null -> binding.body.context.getString(
item.mch.history.id == null -> {
if (adapter.viewType == RecentsPresenter.VIEW_TYPE_ONLY_UPDATES) {
if (adapter.sortByFetched) {
binding.body.context.getString(
R.string.fetched_,
item.chapter.date_fetch.timeSpanFromNow(itemView.context),
)
} else {
binding.body.context.getString(
R.string.updated_,
item.chapter.date_upload.timeSpanFromNow(itemView.context),
)
}
} else {
binding.body.context.getString(
R.string.fetched_,
item.chapter.date_fetch.timeSpanFromNow(itemView.context),
) + "\n" + binding.body.context.getString(
R.string.updated_,
item.chapter.date_upload.timeSpanFromNow(itemView.context),
)
}
}
item.chapter.id != item.mch.chapter.id ->
binding.body.context.getString(
R.string.read_,