Improve synopsis/description display on phone and emulator (#967)

This commit is contained in:
Luna712 2024-03-14 01:29:12 +08:00 committed by GitHub
parent 81df68e137
commit adc653943b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 53 additions and 38 deletions

View file

@ -246,8 +246,17 @@ class EpisodeAdapter(
episodeDescript.apply { episodeDescript.apply {
text = card.description.html() text = card.description.html()
isGone = text.isNullOrBlank() isGone = text.isNullOrBlank()
var isExpanded = false
setOnClickListener { setOnClickListener {
clickCallback.invoke(EpisodeClickEvent(ACTION_SHOW_DESCRIPTION, card)) if (isTrueTv) {
clickCallback.invoke(EpisodeClickEvent(ACTION_SHOW_DESCRIPTION, card))
} else {
isExpanded = !isExpanded
maxLines = if (isExpanded) {
Integer.MAX_VALUE
} else 4
}
} }
} }

View file

@ -62,14 +62,12 @@ import com.lagradost.cloudstream3.ui.result.ResultFragment.updateUIEvent
import com.lagradost.cloudstream3.ui.search.SearchAdapter import com.lagradost.cloudstream3.ui.search.SearchAdapter
import com.lagradost.cloudstream3.ui.search.SearchHelper import com.lagradost.cloudstream3.ui.search.SearchHelper
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
import com.lagradost.cloudstream3.utils.AppUtils.html
import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable
import com.lagradost.cloudstream3.utils.AppUtils.loadCache import com.lagradost.cloudstream3.utils.AppUtils.loadCache
import com.lagradost.cloudstream3.utils.AppUtils.openBrowser import com.lagradost.cloudstream3.utils.AppUtils.openBrowser
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialogInstant import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialogInstant
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialogText
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog
import com.lagradost.cloudstream3.utils.UIHelper import com.lagradost.cloudstream3.utils.UIHelper
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
@ -688,14 +686,15 @@ open class ResultFragmentPhone : FullScreenPlayer() {
resultNextAiringTime.setText(d.nextAiringDate) resultNextAiringTime.setText(d.nextAiringDate)
resultPoster.setImage(d.posterImage) resultPoster.setImage(d.posterImage)
resultPosterBackground.setImage(d.posterBackgroundImage) resultPosterBackground.setImage(d.posterBackgroundImage)
resultDescription.setTextHtml(d.plotText)
resultDescription.setOnClickListener { var isExpanded = false
activity?.let { activity -> resultDescription.apply {
activity.showBottomDialogText( setTextHtml(d.plotText)
d.titleText.asString(activity), setOnClickListener {
d.plotText.asString(activity).html(), isExpanded = !isExpanded
{} maxLines = if (isExpanded) {
) Integer.MAX_VALUE
} else 10
} }
} }
@ -901,14 +900,6 @@ open class ResultFragmentPhone : FullScreenPlayer() {
observe(viewModel.recommendations) { recommendations -> observe(viewModel.recommendations) { recommendations ->
setRecommendations(recommendations, null) setRecommendations(recommendations, null)
} }
observe(viewModel.episodeSynopsis) { description ->
activity?.let { activity ->
activity.showBottomDialogText(
activity.getString(R.string.synopsis),
description.html()
) { viewModel.releaseEpisodeSynopsis() }
}
}
context?.let { ctx -> context?.let { ctx ->
val arrayAdapter = ArrayAdapter<String>(ctx, R.layout.sort_bottom_single_choice) val arrayAdapter = ArrayAdapter<String>(ctx, R.layout.sort_bottom_single_choice)
/* /*

View file

@ -40,6 +40,7 @@ import com.lagradost.cloudstream3.ui.search.SEARCH_ACTION_FOCUSED
import com.lagradost.cloudstream3.ui.search.SearchAdapter import com.lagradost.cloudstream3.ui.search.SearchAdapter
import com.lagradost.cloudstream3.ui.search.SearchHelper import com.lagradost.cloudstream3.ui.search.SearchHelper
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isEmulatorSettings import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isEmulatorSettings
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
import com.lagradost.cloudstream3.utils.AppUtils.html import com.lagradost.cloudstream3.utils.AppUtils.html
import com.lagradost.cloudstream3.utils.AppUtils.isRtl import com.lagradost.cloudstream3.utils.AppUtils.isRtl
import com.lagradost.cloudstream3.utils.AppUtils.loadCache import com.lagradost.cloudstream3.utils.AppUtils.loadCache
@ -754,16 +755,19 @@ class ResultFragmentTv : Fragment() {
observe(viewModel.recommendations) { recommendations -> observe(viewModel.recommendations) { recommendations ->
setRecommendations(recommendations, null) setRecommendations(recommendations, null)
} }
observe(viewModel.episodeSynopsis) { description ->
view.context?.let { ctx -> if (isTrueTvSettings()) {
val builder: AlertDialog.Builder = observe(viewModel.episodeSynopsis) { description ->
AlertDialog.Builder(ctx, R.style.AlertDialogCustom) view.context?.let { ctx ->
builder.setMessage(description.html()) val builder: AlertDialog.Builder =
.setTitle(R.string.synopsis) AlertDialog.Builder(ctx, R.style.AlertDialogCustom)
.setOnDismissListener { builder.setMessage(description.html())
viewModel.releaseEpisodeSynopsis() .setTitle(R.string.synopsis)
} .setOnDismissListener {
.show() viewModel.releaseEpisodeSynopsis()
}
.show()
}
} }
} }
@ -874,14 +878,25 @@ class ResultFragmentTv : Fragment() {
resultNextAiring.setText(d.nextAiringEpisode) resultNextAiring.setText(d.nextAiringEpisode)
resultNextAiringTime.setText(d.nextAiringDate) resultNextAiringTime.setText(d.nextAiringDate)
resultPoster.setImage(d.posterImage) resultPoster.setImage(d.posterImage)
resultDescription.setTextHtml(d.plotText)
resultDescription.setOnClickListener { view -> var isExpanded = false
view.context?.let { ctx -> resultDescription.apply {
val builder: AlertDialog.Builder = setTextHtml(d.plotText)
AlertDialog.Builder(ctx, R.style.AlertDialogCustom) setOnClickListener {
builder.setMessage(d.plotText.asString(ctx).html()) if (context.isEmulatorSettings()) {
.setTitle(d.plotHeaderText.asString(ctx)) isExpanded = !isExpanded
.show() maxLines = if (isExpanded) {
Integer.MAX_VALUE
} else 10
} else {
view.context?.let { ctx ->
val builder: AlertDialog.Builder =
AlertDialog.Builder(ctx, R.style.AlertDialogCustom)
builder.setMessage(d.plotText.asString(ctx).html())
.setTitle(d.plotHeaderText.asString(ctx))
.show()
}
}
} }
} }

View file

@ -409,8 +409,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="10"
android:foreground="@drawable/outline_drawable" android:foreground="@drawable/outline_drawable"
android:maxLength="1000"
android:nextFocusUp="@id/result_back" android:nextFocusUp="@id/result_back"
android:nextFocusDown="@id/result_bookmark_Button" android:nextFocusDown="@id/result_bookmark_Button"
android:paddingTop="5dp" android:paddingTop="5dp"