mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Merge pull request #2080 from Kruna1Pate1/fix/link-open-issue
Fix link opening issues
This commit is contained in:
commit
c6b1338aaa
@ -0,0 +1,10 @@
|
||||
package com.github.libretube.ui.extensions
|
||||
|
||||
import android.text.util.Linkify
|
||||
import android.widget.TextView
|
||||
import androidx.core.text.HtmlCompat
|
||||
|
||||
fun TextView.setFormattedHtml(text: String) {
|
||||
Linkify.addLinks(this, Linkify.WEB_URLS)
|
||||
this.text = HtmlCompat.fromHtml(text, HtmlCompat.FROM_HTML_MODE_LEGACY)
|
||||
}
|
@ -15,7 +15,6 @@ import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.PowerManager
|
||||
import android.text.Html
|
||||
import android.text.format.DateUtils
|
||||
import android.util.Base64
|
||||
import android.util.Log
|
||||
@ -73,6 +72,7 @@ import com.github.libretube.ui.base.BaseFragment
|
||||
import com.github.libretube.ui.dialogs.AddToPlaylistDialog
|
||||
import com.github.libretube.ui.dialogs.DownloadDialog
|
||||
import com.github.libretube.ui.dialogs.ShareDialog
|
||||
import com.github.libretube.ui.extensions.setFormattedHtml
|
||||
import com.github.libretube.ui.extensions.setInvisible
|
||||
import com.github.libretube.ui.extensions.setupSubscriptionButton
|
||||
import com.github.libretube.ui.interfaces.OnlinePlayerOptions
|
||||
@ -940,19 +940,13 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
initializeRelatedVideos(response.relatedStreams)
|
||||
// set video description
|
||||
val description = response.description!!
|
||||
binding.playerDescription.text =
|
||||
// detect whether the description is html formatted
|
||||
if (description.contains("<") && description.contains(">")) {
|
||||
if (SDK_INT >= Build.VERSION_CODES.N) {
|
||||
Html.fromHtml(description, Html.FROM_HTML_MODE_COMPACT)
|
||||
.trim()
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
Html.fromHtml(description).trim()
|
||||
}
|
||||
} else {
|
||||
description
|
||||
}
|
||||
|
||||
// detect whether the description is html formatted
|
||||
if (description.contains("<") && description.contains(">")) {
|
||||
binding.playerDescription.setFormattedHtml(description)
|
||||
} else {
|
||||
binding.playerDescription.text = description
|
||||
}
|
||||
|
||||
binding.playerChannel.setOnClickListener {
|
||||
val activity = view?.context as MainActivity
|
||||
|
@ -53,7 +53,7 @@ class PlaylistFragment : BaseFragment() {
|
||||
super.onCreate(savedInstanceState)
|
||||
arguments?.let {
|
||||
playlistId = it.getString(IntentData.playlistId)
|
||||
playlistType = it.serializable(IntentData.playlistType)!!
|
||||
playlistType = it.serializable(IntentData.playlistType) ?: PlaylistType.PUBLIC
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,6 @@
|
||||
android:id="@+id/player_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="web"
|
||||
android:padding="8dp"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="14sp" />
|
||||
|
Loading…
Reference in New Issue
Block a user