description formatting fix

This commit is contained in:
Bnyro 2022-05-29 12:33:10 +02:00
parent 6bef5587b7
commit b05f396704
3 changed files with 19 additions and 7 deletions

View File

@ -19,6 +19,7 @@ import com.github.libretube.adapters.ChannelAdapter
import com.github.libretube.obj.Subscribe import com.github.libretube.obj.Subscribe
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import org.chromium.base.ThreadUtils.runOnUiThread
import java.io.IOException import java.io.IOException
import retrofit2.HttpException import retrofit2.HttpException
@ -206,10 +207,11 @@ class ChannelFragment : Fragment() {
response.subscriberCount.formatShort() response.subscriberCount.formatShort()
) )
val channelDescription = view.findViewById<TextView>(R.id.channel_description) val channelDescription = view.findViewById<TextView>(R.id.channel_description)
if (response.description?.trim() == "") if (response.description?.trim() == "") {
channelDescription.visibility = View.GONE channelDescription.visibility = View.GONE
else } else {
channelDescription.text = response.description?.trim() channelDescription.text = response.description?.trim()
}
val bannerImage = view.findViewById<ImageView>(R.id.channel_banner) val bannerImage = view.findViewById<ImageView>(R.id.channel_banner)
val channelImage = view.findViewById<ImageView>(R.id.channel_image) val channelImage = view.findViewById<ImageView>(R.id.channel_image)
Picasso.get().load(response.bannerUrl).into(bannerImage) Picasso.get().load(response.bannerUrl).into(bannerImage)

View File

@ -69,6 +69,7 @@ import com.google.android.exoplayer2.util.RepeatModeUtil
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import org.chromium.base.ThreadUtils.runOnUiThread
import java.io.IOException import java.io.IOException
import java.net.URLEncoder import java.net.URLEncoder
import java.util.concurrent.Executors import java.util.concurrent.Executors
@ -654,13 +655,21 @@ class PlayerFragment : Fragment() {
response.relatedStreams!!, response.relatedStreams!!,
childFragmentManager childFragmentManager
) )
val description = response.description!!
view.findViewById<TextView>(R.id.player_description).text = view.findViewById<TextView>(R.id.player_description).text =
// detect whether the description is html formatted
if (description.contains("<") && description.contains(">")) {
if (SDK_INT >= Build.VERSION_CODES.N) { if (SDK_INT >= Build.VERSION_CODES.N) {
Html.fromHtml(response.description, Html.FROM_HTML_MODE_COMPACT).trim() Html.fromHtml(description, Html.FROM_HTML_MODE_COMPACT)
.trim()
} else { } else {
Html.fromHtml(response.description).trim() Html.fromHtml(description).trim()
} }
}
else {
description
}
view.findViewById<TextView>(R.id.player_views_info).text = view.findViewById<TextView>(R.id.player_views_info).text =
response.views.formatShort() + " views • " + response.uploadDate response.views.formatShort() + " views • " + response.uploadDate
view.findViewById<TextView>(R.id.textLike).text = response.likes.formatShort() view.findViewById<TextView>(R.id.textLike).text = response.likes.formatShort()

View File

@ -96,6 +96,7 @@
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:layout_marginBottom="15dp" android:layout_marginBottom="15dp"
android:autoLink="web"
android:text="" /> android:text="" />
<RelativeLayout <RelativeLayout