Handle toolbar title in manga details on tablets similar to on phones

(cherry picked from commit 47f865aa720c47faa7853f4be3065e3ba718f1ba)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt
This commit is contained in:
arkon 2021-05-24 16:28:50 -04:00 committed by Jobobby04
parent 9c2eadd8ca
commit 6b771b4a70
2 changed files with 16 additions and 15 deletions

View File

@ -353,6 +353,15 @@ class MangaController :
mangaInfoButtonsAdapter mangaInfoButtonsAdapter
) )
) )
it.scrollEvents()
.onEach { updateToolbarTitleAlpha() }
.launchIn(viewScope)
// Delayed in case we need to jump to chapters
it.post {
updateToolbarTitleAlpha()
}
} }
binding.chaptersRecycler?.let { binding.chaptersRecycler?.let {
it.adapter = ConcatAdapter(chaptersHeaderAdapter, chaptersAdapter) it.adapter = ConcatAdapter(chaptersHeaderAdapter, chaptersAdapter)
@ -392,19 +401,17 @@ class MangaController :
} }
private fun updateToolbarTitleAlpha(alpha: Int? = null) { private fun updateToolbarTitleAlpha(alpha: Int? = null) {
if (binding.fullRecycler == null) { val scrolledList = binding.fullRecycler ?: binding.infoRecycler!!
return
}
val calculatedAlpha = when { val calculatedAlpha = when {
// Specific alpha provided // Specific alpha provided
alpha != null -> alpha alpha != null -> alpha
// First item isn't in view, full opacity // First item isn't in view, full opacity
((binding.fullRecycler!!.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() > 0) -> 255 ((scrolledList.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() > 0) -> 255
// Based on scroll amount when first item is in view // Based on scroll amount when first item is in view
else -> min(binding.fullRecycler!!.computeVerticalScrollOffset(), 255) else -> min(scrolledList.computeVerticalScrollOffset(), 255)
} }
(activity as? MainActivity)?.binding?.toolbar?.setTitleTextColor( (activity as? MainActivity)?.binding?.toolbar?.setTitleTextColor(

View File

@ -224,16 +224,10 @@ class MangaInfoHeaderAdapter(
*/ */
private fun setMangaInfo(manga: Manga, source: Source?) { private fun setMangaInfo(manga: Manga, source: Source?) {
// Update full title TextView. // Update full title TextView.
with(binding.mangaFullTitle) { binding.mangaFullTitle.text = if (manga.title.isBlank()) {
if (isTablet) { view.context.getString(R.string.unknown)
isVisible = false } else {
} else { manga.title
text = if (manga.title.isBlank()) {
view.context.getString(R.string.unknown)
} else {
manga.title
}
}
} }
// Update author TextView. // Update author TextView.