From 1a2d8ddd0b97a4623e8c1e0e98a0842b9e8e8a3b Mon Sep 17 00:00:00 2001 From: Faisal Khan Date: Fri, 28 Apr 2023 16:14:39 +0530 Subject: [PATCH] Improvement of links in description and comment texts. --- .../github/libretube/ui/adapters/CommentsAdapter.kt | 4 +--- .../github/libretube/ui/fragments/PlayerFragment.kt | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt index 35d52c5dc..964400279 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt @@ -1,8 +1,6 @@ package com.github.libretube.ui.adapters import android.annotation.SuppressLint -import android.os.Handler -import android.os.Looper import android.text.method.LinkMovementMethod import android.view.* import android.view.ViewGroup.MarginLayoutParams @@ -78,7 +76,7 @@ class CommentsAdapter( commentInfos.text = comment.author + TextUtils.SEPARATOR + comment.commentedTime commentText.movementMethod = LinkMovementMethod.getInstance() - commentText.text = comment.commentText + commentText.text = comment.commentText?.replace("", " ") ?.parseAsHtml(tagHandler = HtmlParser(LinkHandler(handleLink ?: {}))) commentText.setOnClickListener { diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 8638eaab9..885ca734d 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -110,10 +110,6 @@ import com.google.android.exoplayer2.trackselection.DefaultTrackSelector import com.google.android.exoplayer2.upstream.DefaultDataSource import com.google.android.exoplayer2.util.MimeTypes import com.google.android.material.dialog.MaterialAlertDialogBuilder -import java.io.IOException -import java.util.* -import java.util.concurrent.Executors -import kotlin.math.abs import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -122,6 +118,10 @@ import kotlinx.coroutines.withContext import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import retrofit2.HttpException +import java.io.IOException +import java.util.* +import java.util.concurrent.Executors +import kotlin.math.abs class PlayerFragment : Fragment(), OnlinePlayerOptions { private var _binding: FragmentPlayerBinding? = null @@ -1087,7 +1087,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { // detect whether the description is html formatted if (description.contains("<") && description.contains(">")) { descTextView.movementMethod = LinkMovementMethod.getInstance() - descTextView.text = description + descTextView.text = description.replace("", " ") .parseAsHtml(tagHandler = HtmlParser(LinkHandler(this::handleLink))) } else { // Links can be present as plain text