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...
This commit is contained in:
Luna712 2024-03-07 14:45:21 -07:00 committed by GitHub
parent 809a38507b
commit 8c2f4b7e17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 61 additions and 35 deletions

View file

@ -246,8 +246,20 @@ 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 {
if (isTrueTv) {
clickCallback.invoke(EpisodeClickEvent(ACTION_SHOW_DESCRIPTION, card)) clickCallback.invoke(EpisodeClickEvent(ACTION_SHOW_DESCRIPTION, card))
} else {
isExpanded = !isExpanded
maxLines = if (isExpanded) {
Integer.MAX_VALUE
} else {
4
}
}
} }
} }

View file

@ -11,6 +11,7 @@ import android.graphics.Rect
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.text.Editable import android.text.Editable
import android.text.InputFilter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -688,14 +689,17 @@ 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
{} 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 -> 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

@ -4,6 +4,7 @@ import android.animation.Animator
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.text.InputFilter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup 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.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.getNameFull import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
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
@ -720,6 +722,8 @@ class ResultFragmentTv : Fragment() {
observe(viewModel.recommendations) { recommendations -> observe(viewModel.recommendations) { recommendations ->
setRecommendations(recommendations, null) setRecommendations(recommendations, null)
} }
if (isTrueTvSettings()) {
observe(viewModel.episodeSynopsis) { description -> observe(viewModel.episodeSynopsis) { description ->
view.context?.let { ctx -> view.context?.let { ctx ->
val builder: AlertDialog.Builder = val builder: AlertDialog.Builder =
@ -732,6 +736,7 @@ class ResultFragmentTv : Fragment() {
.show() .show()
} }
} }
}
// Used to request focus the first time the episodes are loaded. // Used to request focus the first time the episodes are loaded.
var hasLoadedEpisodesOnce = false var hasLoadedEpisodesOnce = false
@ -831,8 +836,19 @@ 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
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 -> view.context?.let { ctx ->
val builder: AlertDialog.Builder = val builder: AlertDialog.Builder =
AlertDialog.Builder(ctx, R.style.AlertDialogCustom) AlertDialog.Builder(ctx, R.style.AlertDialogCustom)
@ -841,6 +857,8 @@ class ResultFragmentTv : Fragment() {
.show() .show()
} }
} }
}
}
val error = listOf( val error = listOf(
R.drawable.profile_bg_dark_blue, R.drawable.profile_bg_dark_blue,