mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
More recents updates
*Add option to expand/collapse grouped chapters separately from updates *Show "more chapters" in body text when collapsed in updates section *Only take last set of recentsitems to check if theres an existing *Shrink the size of sub chapters text
This commit is contained in:
parent
d109819c3a
commit
597a37f1c2
8 changed files with 60 additions and 17 deletions
|
@ -377,6 +377,8 @@ class PreferencesHelper(val context: Context) {
|
|||
|
||||
fun groupChaptersHistory() = flowPrefs.getBoolean(Keys.groupChaptersHistory, true)
|
||||
|
||||
fun collapseGroupedHistory() = flowPrefs.getBoolean("collapse_group_history", false)
|
||||
|
||||
fun showTitleFirstInRecents() = flowPrefs.getBoolean(Keys.showTitleFirstInRecents, false)
|
||||
|
||||
fun lastExtCheck() = flowPrefs.getLong("last_ext_check", 0)
|
||||
|
|
|
@ -28,7 +28,14 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
|
|||
var uniformCovers = preferences.uniformGrid().get()
|
||||
var showOutline = preferences.outlineOnCovers().get()
|
||||
var sortByFetched = preferences.sortFetchedTime().get()
|
||||
var collapseGroupedUpdates = preferences.collapseGroupedUpdates().get()
|
||||
private var collapseGroupedUpdates = preferences.collapseGroupedUpdates().get()
|
||||
private var collapseGroupedHistory = preferences.collapseGroupedHistory().get()
|
||||
val collapseGrouped: Boolean
|
||||
get() = if (viewType == RecentsPresenter.VIEW_TYPE_ONLY_HISTORY) {
|
||||
collapseGroupedHistory
|
||||
} else {
|
||||
collapseGroupedUpdates
|
||||
}
|
||||
|
||||
val viewType: Int
|
||||
get() = delegate.getViewType()
|
||||
|
@ -50,6 +57,7 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
|
|||
preferences.showUpdatedTime().register { showUpdatedTime = it }
|
||||
preferences.uniformGrid().register { uniformCovers = it }
|
||||
preferences.collapseGroupedUpdates().register { collapseGroupedUpdates = it }
|
||||
preferences.collapseGroupedHistory().register { collapseGroupedHistory = it }
|
||||
preferences.sortFetchedTime().asImmediateFlowIn(delegate.scope()) { sortByFetched = it }
|
||||
preferences.outlineOnCovers().register(false) {
|
||||
showOutline = it
|
||||
|
|
|
@ -10,7 +10,6 @@ import android.view.ViewGroup
|
|||
import android.widget.ImageView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.children
|
||||
import androidx.core.view.forEach
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.core.view.updatePaddingRelative
|
||||
|
@ -69,6 +68,8 @@ class RecentMangaHolder(
|
|||
}
|
||||
) {
|
||||
showScanlatorInBody(moreVisible)
|
||||
} else {
|
||||
addMoreUpdatesText(!moreVisible)
|
||||
}
|
||||
binding.endView.updateLayoutParams<ViewGroup.LayoutParams> {
|
||||
height = binding.mainView.height
|
||||
|
@ -237,6 +238,8 @@ class RecentMangaHolder(
|
|||
}
|
||||
) {
|
||||
showScanlatorInBody(moreVisible, item)
|
||||
} else {
|
||||
addMoreUpdatesText(!moreVisible, item)
|
||||
}
|
||||
} else {
|
||||
binding.moreChaptersLayout.removeAllViews()
|
||||
|
@ -261,6 +264,7 @@ class RecentMangaHolder(
|
|||
}
|
||||
}
|
||||
}
|
||||
addMoreUpdatesText(!moreVisible, item)
|
||||
} else {
|
||||
chapterId = null
|
||||
}
|
||||
|
@ -282,9 +286,27 @@ class RecentMangaHolder(
|
|||
}
|
||||
}
|
||||
|
||||
private fun addMoreUpdatesText(add: Boolean, originalItem: RecentMangaItem? = null) {
|
||||
val item = originalItem ?: adapter.getItem(bindingAdapterPosition) as? RecentMangaItem ?: return
|
||||
val originalText = binding.body.text.toString()
|
||||
val andMoreText = itemView.context.resources.getQuantityString(
|
||||
R.plurals.notification_and_n_more,
|
||||
(item.mch.extraChapters.size),
|
||||
(item.mch.extraChapters.size),
|
||||
)
|
||||
if (add && item.mch.extraChapters.isNotEmpty() && isUpdates &&
|
||||
!isSmallUpdates && !originalText.contains(andMoreText)
|
||||
) {
|
||||
val text = "${originalText.substringBefore("\n")}\n$andMoreText"
|
||||
binding.body.text = text
|
||||
} else if (!add && originalText.contains(andMoreText)) {
|
||||
binding.body.text = originalText.removeSuffix("\n$andMoreText")
|
||||
}
|
||||
}
|
||||
|
||||
private fun showScanlatorInBody(add: Boolean, originalItem: RecentMangaItem? = null) {
|
||||
val item = originalItem ?: adapter.getItem(bindingAdapterPosition) as? RecentMangaItem ?: return
|
||||
val originalText = binding.body.text
|
||||
val originalText = binding.body.text.toString()
|
||||
binding.body.maxLines = 2
|
||||
val scanlator = item.chapter.scanlator ?: return
|
||||
if (add) {
|
||||
|
@ -293,7 +315,7 @@ class RecentMangaHolder(
|
|||
binding.body.text = item.chapter.scanlator
|
||||
binding.body.isVisible = true
|
||||
} else if (!originalText.contains(scanlator)) {
|
||||
val text = "$originalText\n$scanlator"
|
||||
val text = "${originalText.substringBefore("\n")}\n$scanlator"
|
||||
binding.body.text = text
|
||||
}
|
||||
} else {
|
||||
|
@ -301,6 +323,7 @@ class RecentMangaHolder(
|
|||
binding.body.isVisible = false
|
||||
} else {
|
||||
binding.body.text = originalText.removeSuffix("\n$scanlator")
|
||||
addMoreUpdatesText(true, item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -311,10 +334,10 @@ class RecentMangaHolder(
|
|||
val showDLs = adapter.showDownloads
|
||||
title.text = chapter.preferredChapterName(context, item.mch.manga, adapter.preferences)
|
||||
title.setTextColor(ChapterUtil.readColor(context, chapter))
|
||||
chapter.dateRead?.let { dateRead ->
|
||||
subtitle.text = context.timeSpanFromNow(R.string.read_, dateRead)
|
||||
subtitle.isVisible = true
|
||||
}
|
||||
subtitle.isVisible = chapter.dateRead != null
|
||||
subtitle.text = chapter.dateRead?.let { dateRead ->
|
||||
context.timeSpanFromNow(R.string.read_, dateRead)
|
||||
} ?: ""
|
||||
root.setOnClickListener {
|
||||
adapter.delegate.onSubChapterClicked(
|
||||
bindingAdapterPosition,
|
||||
|
|
|
@ -653,7 +653,7 @@ class RecentsController(bundle: Bundle? = null) :
|
|||
override fun areExtraChaptersExpanded(position: Int): Boolean {
|
||||
val item = (adapter.getItem(position) as? RecentMangaItem) ?: return false
|
||||
val date = presenter.dateFormat.format(item.chapter.dateRead ?: item.chapter.date_fetch)
|
||||
val invertDefault = !adapter.collapseGroupedUpdates
|
||||
val invertDefault = !adapter.collapseGrouped
|
||||
return presenter.expandedSectionsMap["${item.mch.manga} - $date"]?.xor(invertDefault)
|
||||
?: invertDefault
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ class RecentsController(bundle: Bundle? = null) :
|
|||
override fun updateExpandedExtraChapters(position: Int, expanded: Boolean) {
|
||||
val item = (adapter.getItem(position) as? RecentMangaItem) ?: return
|
||||
val date = presenter.dateFormat.format(item.chapter.dateRead ?: item.chapter.date_fetch)
|
||||
val invertDefault = !adapter.collapseGroupedUpdates
|
||||
val invertDefault = !adapter.collapseGrouped
|
||||
presenter.expandedSectionsMap["${item.mch.manga} - $date"] = expanded.xor(invertDefault)
|
||||
}
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ class RecentsPresenter(
|
|||
}.filterChaptersByScanlators(manga)
|
||||
extraCount += mchs.size - chapters.size
|
||||
if (chapters.isEmpty()) return@mapNotNull null
|
||||
val existingItem = recentItems.find {
|
||||
val existingItem = recentItems.takeLast(ENDLESS_LIMIT).find {
|
||||
val date = Date(it.mch.history.last_read)
|
||||
key == it.manga_id to dateFormat.format(date)
|
||||
}?.takeIf { updatePageCount }
|
||||
|
@ -220,7 +220,7 @@ class RecentsPresenter(
|
|||
val chapters = mcs.map { it.chapter }.filterChaptersByScanlators(manga)
|
||||
extraCount += mcs.size - chapters.size
|
||||
if (chapters.isEmpty()) return@mapNotNull null
|
||||
val existingItem = recentItems.find {
|
||||
val existingItem = recentItems.takeLast(ENDLESS_LIMIT).find {
|
||||
val date = Date(it.chapter.date_fetch)
|
||||
key == it.manga_id to dateFormat.format(date)
|
||||
}?.takeIf { updatePageCount }
|
||||
|
@ -279,9 +279,9 @@ class RecentsPresenter(
|
|||
if (viewType == VIEW_TYPE_ONLY_HISTORY && nextChapter != null) {
|
||||
val unreadChapterIsAlreadyInList =
|
||||
recentItems.any { item -> item.mch.manga.id == it.manga.id } ||
|
||||
mangaList.indexOfFirst { item ->
|
||||
item.manga.id == it.manga.id
|
||||
} > mangaList.indexOf(it)
|
||||
mangaList.indexOfFirst { item ->
|
||||
item.manga.id == it.manga.id
|
||||
} > mangaList.indexOf(it)
|
||||
if (unreadChapterIsAlreadyInList) {
|
||||
return@result it.chapter
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@ class RecentsHistoryView @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
override fun inflateBinding() = RecentsHistoryViewBinding.bind(this)
|
||||
override fun initGeneralPreferences() {
|
||||
binding.groupChapters.bindToPreference(preferences.groupChaptersHistory())
|
||||
binding.collapseGroupedChapters.bindToPreference(preferences.collapseGroupedHistory()) {
|
||||
controller?.presenter?.expandedSectionsMap?.clear()
|
||||
}
|
||||
binding.clearHistory.setOnClickListener {
|
||||
val activity = controller?.activity ?: return@setOnClickListener
|
||||
activity.materialAlertDialog()
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
style="?textAppearanceTitleMedium"
|
||||
style="?textAppearanceTitleSmall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
|
|
|
@ -21,12 +21,19 @@
|
|||
android:text="@string/group_chapters_together"
|
||||
android:textColor="?attr/colorOnBackground" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/collapse_grouped_chapters"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/collapse_grouped_chapters"
|
||||
android:textColor="?attr/colorOnBackground" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/clear_history"
|
||||
style="@style/Theme.Widget.Button.TextButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/clear_history" />
|
||||
|
||||
</LinearLayout>
|
||||
</eu.kanade.tachiyomi.ui.recents.options.RecentsHistoryView>
|
Loading…
Add table
Add a link
Reference in a new issue