|
16 | 16 | import android.os.Handler; |
17 | 17 | import android.os.Looper; |
18 | 18 | import android.provider.Settings; |
19 | | -import android.text.util.Linkify; |
20 | 19 | import android.util.DisplayMetrics; |
21 | 20 | import android.util.Log; |
22 | 21 | import android.view.LayoutInflater; |
|
101 | 100 | import org.schabi.newpipe.util.NavigationHelper; |
102 | 101 | import org.schabi.newpipe.util.PermissionHelper; |
103 | 102 | import org.schabi.newpipe.util.ShareUtils; |
| 103 | +import org.schabi.newpipe.util.TextLinkifier; |
104 | 104 | import org.schabi.newpipe.util.ThemeHelper; |
105 | 105 | import org.schabi.newpipe.views.AnimatedProgressBar; |
106 | 106 | import org.schabi.newpipe.views.LargeTextMovementMethod; |
|
112 | 112 | import java.util.concurrent.TimeUnit; |
113 | 113 |
|
114 | 114 | import icepick.State; |
115 | | -import io.noties.markwon.Markwon; |
116 | | -import io.noties.markwon.linkify.LinkifyPlugin; |
117 | 115 | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; |
118 | | -import io.reactivex.rxjava3.core.Single; |
119 | 116 | import io.reactivex.rxjava3.disposables.CompositeDisposable; |
120 | 117 | import io.reactivex.rxjava3.disposables.Disposable; |
121 | 118 | import io.reactivex.rxjava3.schedulers.Schedulers; |
@@ -1232,28 +1229,20 @@ private void prepareDescription(final Description description) { |
1232 | 1229 | return; |
1233 | 1230 | } |
1234 | 1231 |
|
1235 | | - if (description.getType() == Description.HTML) { |
1236 | | - disposables.add(Single.just(description.getContent()) |
1237 | | - .map(descriptionText -> |
1238 | | - HtmlCompat.fromHtml(descriptionText, |
1239 | | - HtmlCompat.FROM_HTML_MODE_LEGACY)) |
1240 | | - .subscribeOn(Schedulers.computation()) |
1241 | | - .observeOn(AndroidSchedulers.mainThread()) |
1242 | | - .subscribe(spanned -> { |
1243 | | - videoDescriptionView.setText(spanned); |
1244 | | - videoDescriptionView.setVisibility(View.VISIBLE); |
1245 | | - })); |
1246 | | - } else if (description.getType() == Description.MARKDOWN) { |
1247 | | - final Markwon markwon = Markwon.builder(requireContext()) |
1248 | | - .usePlugin(LinkifyPlugin.create()) |
1249 | | - .build(); |
1250 | | - markwon.setMarkdown(videoDescriptionView, description.getContent()); |
1251 | | - videoDescriptionView.setVisibility(View.VISIBLE); |
1252 | | - } else { |
1253 | | - //== Description.PLAIN_TEXT |
1254 | | - videoDescriptionView.setAutoLinkMask(Linkify.WEB_URLS); |
1255 | | - videoDescriptionView.setText(description.getContent(), TextView.BufferType.SPANNABLE); |
1256 | | - videoDescriptionView.setVisibility(View.VISIBLE); |
| 1232 | + switch (description.getType()) { |
| 1233 | + case Description.HTML: |
| 1234 | + disposables.add(TextLinkifier.createLinksFromHtmlBlock(requireContext(), |
| 1235 | + description.getContent(), videoDescriptionView, |
| 1236 | + HtmlCompat.FROM_HTML_MODE_LEGACY)); |
| 1237 | + break; |
| 1238 | + case Description.MARKDOWN: |
| 1239 | + disposables.add(TextLinkifier.createLinksFromMarkdownText(requireContext(), |
| 1240 | + description.getContent(), videoDescriptionView)); |
| 1241 | + break; |
| 1242 | + case Description.PLAIN_TEXT: default: |
| 1243 | + disposables.add(TextLinkifier.createLinksFromPlainText(requireContext(), |
| 1244 | + description.getContent(), videoDescriptionView)); |
| 1245 | + break; |
1257 | 1246 | } |
1258 | 1247 | } |
1259 | 1248 |
|
@@ -1569,8 +1558,8 @@ public void handleResult(@NonNull final StreamInfo info) { |
1569 | 1558 | prepareDescription(info.getDescription()); |
1570 | 1559 | updateProgressInfo(info); |
1571 | 1560 | initThumbnailViews(info); |
1572 | | - showMetaInfoInTextView(info.getMetaInfo(), detailMetaInfoTextView, detailMetaInfoSeparator); |
1573 | | - |
| 1561 | + disposables.add(showMetaInfoInTextView(info.getMetaInfo(), detailMetaInfoTextView, |
| 1562 | + detailMetaInfoSeparator)); |
1574 | 1563 |
|
1575 | 1564 | if (player == null || player.isStopped()) { |
1576 | 1565 | updateOverlayData(info.getName(), info.getUploaderName(), info.getThumbnailUrl()); |
|
0 commit comments