Skip to content

Commit

Permalink
Use HTML in the podcast description
Browse files Browse the repository at this point in the history
  • Loading branch information
geekygecko committed Dec 5, 2024
1 parent c58fc59 commit e448212
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.text.Html
import android.text.Spannable
import android.text.SpannableString
import android.text.style.ForegroundColorSpan
Expand Down Expand Up @@ -64,6 +65,8 @@ import au.com.shiftyjelly.pocketcasts.ui.extensions.themed
import au.com.shiftyjelly.pocketcasts.ui.theme.Theme
import au.com.shiftyjelly.pocketcasts.ui.theme.ThemeColor
import au.com.shiftyjelly.pocketcasts.utils.extensions.dpToPx
import au.com.shiftyjelly.pocketcasts.utils.featureflag.Feature
import au.com.shiftyjelly.pocketcasts.utils.featureflag.FeatureFlag
import au.com.shiftyjelly.pocketcasts.views.extensions.hide
import au.com.shiftyjelly.pocketcasts.views.extensions.show
import au.com.shiftyjelly.pocketcasts.views.extensions.toggleVisibility
Expand Down Expand Up @@ -302,7 +305,11 @@ class PodcastAdapter(
with(holder.binding.bottom.nextText) {
text = podcast.displayableNextEpisodeDate(context)
}
holder.binding.bottom.description.text = podcast.podcastDescription
holder.binding.bottom.description.text = if (FeatureFlag.isEnabled(Feature.PODCAST_HTML_DESCRIPTION)) {
Html.fromHtml(podcast.podcastDescription, Html.FROM_HTML_MODE_COMPACT)
} else {
podcast.podcastDescription
}
holder.binding.bottom.description.setLinkTextColor(tintColor)
holder.binding.bottom.description.readMore(3)
holder.binding.bottom.authorText.text = podcast.author
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import au.com.shiftyjelly.pocketcasts.models.entity.Podcast
import au.com.shiftyjelly.pocketcasts.models.entity.PodcastEpisode
import au.com.shiftyjelly.pocketcasts.models.type.EpisodesSortType
import au.com.shiftyjelly.pocketcasts.utils.extensions.parseIsoDate
import au.com.shiftyjelly.pocketcasts.utils.featureflag.Feature
import au.com.shiftyjelly.pocketcasts.utils.featureflag.FeatureFlag
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import java.util.Date
Expand Down Expand Up @@ -39,6 +41,7 @@ data class PodcastInfo(
@field:Json(name = "title") val title: String?,
@field:Json(name = "author") val author: String?,
@field:Json(name = "description") val description: String?,
@field:Json(name = "descriptionHtml") val descriptionHtml: String?,
@field:Json(name = "show_type") val showType: String?,
@field:Json(name = "category") val category: String?,
@field:Json(name = "audio") val audio: Boolean?,
Expand All @@ -52,7 +55,11 @@ data class PodcastInfo(
podcast.title = title ?: ""
podcast.author = author ?: ""
podcast.podcastCategory = category ?: ""
podcast.podcastDescription = description ?: ""
if (FeatureFlag.isEnabled(Feature.PODCAST_HTML_DESCRIPTION)) {
podcast.podcastDescription = descriptionHtml.takeUnless { it.isNullOrBlank() } ?: description ?: ""
} else {
podcast.podcastDescription = description ?: ""
}
podcast.episodesSortType = if (showType == "serial") EpisodesSortType.EPISODES_SORT_BY_DATE_ASC else EpisodesSortType.EPISODES_SORT_BY_DATE_DESC
episodes?.mapNotNull { it.toEpisode(uuid) }?.let { episodes ->
podcast.episodes.addAll(episodes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ enum class Feature(
hasFirebaseRemoteFlag = true,
hasDevToggle = true,
),
PODCAST_HTML_DESCRIPTION(
key = "podcast_html_description",
title = "Use HTML in the podcast description",
defaultValue = true,
tier = FeatureTier.Free,
hasFirebaseRemoteFlag = true,
hasDevToggle = true,
),
;

companion object {
Expand Down

0 comments on commit e448212

Please sign in to comment.