mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 14:50: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.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import android.text.Html
|
|
||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import android.util.Log
|
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.AddToPlaylistDialog
|
||||||
import com.github.libretube.ui.dialogs.DownloadDialog
|
import com.github.libretube.ui.dialogs.DownloadDialog
|
||||||
import com.github.libretube.ui.dialogs.ShareDialog
|
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.setInvisible
|
||||||
import com.github.libretube.ui.extensions.setupSubscriptionButton
|
import com.github.libretube.ui.extensions.setupSubscriptionButton
|
||||||
import com.github.libretube.ui.interfaces.OnlinePlayerOptions
|
import com.github.libretube.ui.interfaces.OnlinePlayerOptions
|
||||||
@ -940,19 +940,13 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
initializeRelatedVideos(response.relatedStreams)
|
initializeRelatedVideos(response.relatedStreams)
|
||||||
// set video description
|
// set video description
|
||||||
val description = response.description!!
|
val description = response.description!!
|
||||||
binding.playerDescription.text =
|
|
||||||
// detect whether the description is html formatted
|
// detect whether the description is html formatted
|
||||||
if (description.contains("<") && description.contains(">")) {
|
if (description.contains("<") && description.contains(">")) {
|
||||||
if (SDK_INT >= Build.VERSION_CODES.N) {
|
binding.playerDescription.setFormattedHtml(description)
|
||||||
Html.fromHtml(description, Html.FROM_HTML_MODE_COMPACT)
|
} else {
|
||||||
.trim()
|
binding.playerDescription.text = description
|
||||||
} else {
|
}
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
Html.fromHtml(description).trim()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
description
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.playerChannel.setOnClickListener {
|
binding.playerChannel.setOnClickListener {
|
||||||
val activity = view?.context as MainActivity
|
val activity = view?.context as MainActivity
|
||||||
|
@ -53,7 +53,7 @@ class PlaylistFragment : BaseFragment() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
arguments?.let {
|
arguments?.let {
|
||||||
playlistId = it.getString(IntentData.playlistId)
|
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:id="@+id/player_description"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:autoLink="web"
|
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:textIsSelectable="true"
|
android:textIsSelectable="true"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
Loading…
Reference in New Issue
Block a user