mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 19:31:48 +01:00
Trim line breaks in manga info only when collapsed (#5818)
* don't trim newlines if summary expanded * move description trim logic to separate function * logic error oops * let's try something * fix bug on first load makes it so that, description text is trimmed when entering manga from library Co-authored-by: Andreas <andreas.everos@gmail.com> Co-authored-by: Andreas <andreas.everos@gmail.com>
This commit is contained in:
parent
bd033db84c
commit
f683f21ee2
@ -292,14 +292,7 @@ class MangaInfoHeaderAdapter(
|
|||||||
showMangaInfo(hasInfoContent)
|
showMangaInfo(hasInfoContent)
|
||||||
if (hasInfoContent) {
|
if (hasInfoContent) {
|
||||||
// Update description TextView.
|
// Update description TextView.
|
||||||
binding.mangaSummaryText.text = if (manga.description.isNullOrBlank()) {
|
binding.mangaSummaryText.text = updateDescription(manga.description, (fromSource || isTablet).not())
|
||||||
view.context.getString(R.string.unknown)
|
|
||||||
} else {
|
|
||||||
// Max lines of 3 with a blank line looks whack so we remove
|
|
||||||
// any line breaks that is 2 or more and replace it with 1
|
|
||||||
manga.description!!
|
|
||||||
.replace(Regex("[\\r\\n]{2,}", setOf(RegexOption.MULTILINE)), "\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update genres list
|
// Update genres list
|
||||||
if (!manga.genre.isNullOrBlank()) {
|
if (!manga.genre.isNullOrBlank()) {
|
||||||
@ -357,6 +350,8 @@ class MangaInfoHeaderAdapter(
|
|||||||
binding.mangaSummarySection.transitionToEnd()
|
binding.mangaSummarySection.transitionToEnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.mangaSummaryText.text = updateDescription(manga.description, isCurrentlyExpanded)
|
||||||
|
|
||||||
binding.mangaSummaryText.maxLines = if (isCurrentlyExpanded) {
|
binding.mangaSummaryText.maxLines = if (isCurrentlyExpanded) {
|
||||||
maxLines
|
maxLines
|
||||||
} else {
|
} else {
|
||||||
@ -364,6 +359,22 @@ class MangaInfoHeaderAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateDescription(description: String?, isCurrentlyExpanded: Boolean): CharSequence? {
|
||||||
|
return if (description.isNullOrBlank()) {
|
||||||
|
view.context.getString(R.string.unknown)
|
||||||
|
} else {
|
||||||
|
// Max lines of 3 with a blank line looks whack so we remove
|
||||||
|
// any line breaks that is 2 or more and replace it with 1
|
||||||
|
// however, don't do this if already expanded because we need those blank lines
|
||||||
|
if (!isCurrentlyExpanded) {
|
||||||
|
description
|
||||||
|
} else {
|
||||||
|
description
|
||||||
|
.replace(Regex("[\\r\\n]{2,}", setOf(RegexOption.MULTILINE)), "\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update favorite button with correct drawable and text.
|
* Update favorite button with correct drawable and text.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user