From 81b8caa077ba99e1ad35a6f1ab7d17838edffc4e Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 7 Aug 2023 18:02:42 +0200 Subject: [PATCH] feat: support for video meta info --- .../java/com/github/libretube/api/obj/MetaInfo.kt | 11 +++++++++++ .../java/com/github/libretube/api/obj/Streams.kt | 1 + .../github/libretube/ui/fragments/PlayerFragment.kt | 12 ++++++++++++ app/src/main/res/layout/fragment_player.xml | 10 +++++++++- 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/github/libretube/api/obj/MetaInfo.kt diff --git a/app/src/main/java/com/github/libretube/api/obj/MetaInfo.kt b/app/src/main/java/com/github/libretube/api/obj/MetaInfo.kt new file mode 100644 index 000000000..296784d2a --- /dev/null +++ b/app/src/main/java/com/github/libretube/api/obj/MetaInfo.kt @@ -0,0 +1,11 @@ +package com.github.libretube.api.obj + +import kotlinx.serialization.Serializable + +@Serializable +data class MetaInfo( + val title: String, + val description: String, + val urls: List, + val urlTexts: List +) diff --git a/app/src/main/java/com/github/libretube/api/obj/Streams.kt b/app/src/main/java/com/github/libretube/api/obj/Streams.kt index 700761162..548530f00 100644 --- a/app/src/main/java/com/github/libretube/api/obj/Streams.kt +++ b/app/src/main/java/com/github/libretube/api/obj/Streams.kt @@ -21,6 +21,7 @@ data class Streams( val license: String, val visibility: String, val tags: List, + val metaInfo: List, val hls: String? = null, val dash: String? = null, val lbryId: String? = null, 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 9b245f4f8..115835b58 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 @@ -16,6 +16,7 @@ import android.os.PowerManager import android.text.format.DateUtils import android.text.method.LinkMovementMethod import android.text.util.Linkify +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -861,6 +862,17 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { playerTitle.text = streams.title playerDescription.text = streams.description + metaInfo.isVisible = streams.metaInfo.isNotEmpty() + // generate a meta info text with clickable links using html + val metaInfoText = streams.metaInfo.joinToString("\n\n") { info -> + val text = info.description.takeIf { it.isNotBlank() } ?: info.title + val links = info.urls.mapIndexed { index, url -> + "${info.urlTexts.getOrNull(index).orEmpty()}" + }.joinToString(", ") + "$text $links" + } + metaInfo.text = metaInfoText.parseAsHtml() + playerChannelSubCount.text = context?.getString( R.string.subscribers, streams.uploaderSubscriberCount.formatShort() diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index 4dabb0e1d..c35ce684d 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -107,6 +107,14 @@ android:orientation="vertical" android:visibility="gone"> + + + android:layout_height="wrap_content" />