From 8c2f4b7e17dfe152bc2432257a604af20dc1dac9 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Thu, 7 Mar 2024 14:45:21 -0700 Subject: [PATCH] Improve synopsis/description display on phone and emulator Instead of using a BottomSheetDialog, which can be buggy (#816) and modifies the UI more then we need to, which is just a little bit of poor UI, this way it just expands the description/synopsis if it is clicked, which is nicer UI. It only only this for phone and emulator layouts though, on TV having the same popup is nicer so it puts the text in a bit bigger view also. This method is also nice, because if there is nothing to expand it doesn't created an unneeded dialog or do anything at all, and if you accidentally click it it doesn't end up getting in your way. showBottomDialogText in SingleSelectionHelper could probably be removed after this if you want as it is now unused again, however I decided to leave it as I figured maybe it would be useful in the future but not sure if you want to or not... --- .../cloudstream3/ui/result/EpisodeAdapter.kt | 14 ++++- .../ui/result/ResultFragmentPhone.kt | 28 +++++----- .../ui/result/ResultFragmentTv.kt | 54 ++++++++++++------- 3 files changed, 61 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt index 6b63e623..fa81aa16 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt @@ -246,8 +246,20 @@ class EpisodeAdapter( episodeDescript.apply { text = card.description.html() isGone = text.isNullOrBlank() + + var isExpanded = false 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 + } + } } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt index 76066c2e..1dfb62c4 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt @@ -11,6 +11,7 @@ import android.graphics.Rect import android.os.Build import android.os.Bundle import android.text.Editable +import android.text.InputFilter import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -688,14 +689,17 @@ open class ResultFragmentPhone : FullScreenPlayer() { resultNextAiringTime.setText(d.nextAiringDate) resultPoster.setImage(d.posterImage) resultPosterBackground.setImage(d.posterBackgroundImage) - resultDescription.setTextHtml(d.plotText) - resultDescription.setOnClickListener { - activity?.let { activity -> - activity.showBottomDialogText( - d.titleText.asString(activity), - d.plotText.asString(activity).html(), - {} - ) + + var isExpanded = false + resultDescription.apply { + setTextHtml(d.plotText) + setOnClickListener { + isExpanded = !isExpanded + filters = if (isExpanded) { + arrayOf(InputFilter.LengthFilter(Integer.MAX_VALUE)) + } else { + arrayOf(InputFilter.LengthFilter(1000)) + } } } @@ -901,14 +905,6 @@ open class ResultFragmentPhone : FullScreenPlayer() { observe(viewModel.recommendations) { recommendations -> setRecommendations(recommendations, null) } - observe(viewModel.episodeSynopsis) { description -> - activity?.let { activity -> - activity.showBottomDialogText( - activity.getString(R.string.synopsis), - description.html() - ) { viewModel.releaseEpisodeSynopsis() } - } - } context?.let { ctx -> val arrayAdapter = ArrayAdapter(ctx, R.layout.sort_bottom_single_choice) /* diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt index 427e9cb3..0cafcf42 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt @@ -4,6 +4,7 @@ import android.animation.Animator import android.annotation.SuppressLint import android.app.Dialog import android.os.Bundle +import android.text.InputFilter import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -39,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.SearchHelper import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isEmulatorSettings +import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings import com.lagradost.cloudstream3.utils.AppUtils.getNameFull import com.lagradost.cloudstream3.utils.AppUtils.html import com.lagradost.cloudstream3.utils.AppUtils.isRtl @@ -720,16 +722,19 @@ class ResultFragmentTv : Fragment() { observe(viewModel.recommendations) { recommendations -> setRecommendations(recommendations, null) } - observe(viewModel.episodeSynopsis) { description -> - view.context?.let { ctx -> - val builder: AlertDialog.Builder = - AlertDialog.Builder(ctx, R.style.AlertDialogCustom) - builder.setMessage(description.html()) - .setTitle(R.string.synopsis) - .setOnDismissListener { - viewModel.releaseEpisodeSynopsis() - } - .show() + + if (isTrueTvSettings()) { + observe(viewModel.episodeSynopsis) { description -> + view.context?.let { ctx -> + val builder: AlertDialog.Builder = + AlertDialog.Builder(ctx, R.style.AlertDialogCustom) + builder.setMessage(description.html()) + .setTitle(R.string.synopsis) + .setOnDismissListener { + viewModel.releaseEpisodeSynopsis() + } + .show() + } } } @@ -831,14 +836,27 @@ class ResultFragmentTv : Fragment() { resultNextAiring.setText(d.nextAiringEpisode) resultNextAiringTime.setText(d.nextAiringDate) resultPoster.setImage(d.posterImage) - resultDescription.setTextHtml(d.plotText) - resultDescription.setOnClickListener { view -> - 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() + + var isExpanded = false + resultDescription.apply { + setTextHtml(d.plotText) + setOnClickListener { + if (context.isEmulatorSettings()) { + isExpanded = !isExpanded + filters = if (isExpanded) { + arrayOf(InputFilter.LengthFilter(Integer.MAX_VALUE)) + } else { + arrayOf(InputFilter.LengthFilter(1000)) + } + } 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() + } + } } }