1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-01-09 17:00:32 +00:00

Show image tags even if image loading is disabled

This commit is contained in:
Isira Seneviratne 2024-09-01 17:43:06 +05:30
parent 2653787fe1
commit 507b3b4108
3 changed files with 15 additions and 24 deletions

View File

@ -16,10 +16,10 @@ import org.schabi.newpipe.R
import org.schabi.newpipe.extractor.channel.ChannelInfo import org.schabi.newpipe.extractor.channel.ChannelInfo
import org.schabi.newpipe.ui.components.metadata.ImageMetadataItem import org.schabi.newpipe.ui.components.metadata.ImageMetadataItem
import org.schabi.newpipe.ui.components.metadata.MetadataItem import org.schabi.newpipe.ui.components.metadata.MetadataItem
import org.schabi.newpipe.ui.components.metadata.TagsSection
import org.schabi.newpipe.ui.theme.AppTheme import org.schabi.newpipe.ui.theme.AppTheme
import org.schabi.newpipe.util.Localization import org.schabi.newpipe.util.Localization
import org.schabi.newpipe.util.NO_SERVICE_ID import org.schabi.newpipe.util.NO_SERVICE_ID
import org.schabi.newpipe.util.image.ImageStrategy
@Composable @Composable
fun AboutChannelSection(channelInfo: ChannelInfo) { fun AboutChannelSection(channelInfo: ChannelInfo) {
@ -41,12 +41,12 @@ fun AboutChannelSection(channelInfo: ChannelInfo) {
) )
} }
ImageStrategy.choosePreferredImage(channelInfo.avatars)?.let { if (channelInfo.avatars.isNotEmpty()) {
ImageMetadataItem(R.string.metadata_avatars, channelInfo.avatars, it) ImageMetadataItem(R.string.metadata_avatars, channelInfo.avatars)
} }
ImageStrategy.choosePreferredImage(channelInfo.banners)?.let { if (channelInfo.banners.isNotEmpty()) {
ImageMetadataItem(R.string.metadata_banners, channelInfo.banners, it) ImageMetadataItem(R.string.metadata_banners, channelInfo.banners)
} }
if (channelInfo.tags.isNotEmpty()) { if (channelInfo.tags.isNotEmpty()) {

View File

@ -26,22 +26,16 @@ import org.schabi.newpipe.util.image.ImageStrategy
import org.schabi.newpipe.util.image.PreferredImageQuality import org.schabi.newpipe.util.image.PreferredImageQuality
@Composable @Composable
fun ImageMetadataItem( fun ImageMetadataItem(@StringRes title: Int, images: List<Image>) {
@StringRes title: Int,
images: List<Image>,
preferredUrl: String? = ImageStrategy.choosePreferredImage(images)
) {
val context = LocalContext.current val context = LocalContext.current
val imageLinks = remember { convertImagesToLinks(context, images, preferredUrl) } val imageLinks = remember(images) { convertImagesToLinks(context, images) }
MetadataItem(title = title, value = imageLinks) MetadataItem(title = title, value = imageLinks)
} }
private fun convertImagesToLinks( private fun convertImagesToLinks(context: Context, images: List<Image>): AnnotatedString {
context: Context, val preferredUrl = ImageStrategy.choosePreferredImage(images)
images: List<Image>,
preferredUrl: String?
): AnnotatedString {
fun imageSizeToText(size: Int): String { fun imageSizeToText(size: Int): String {
return if (size == Image.HEIGHT_UNKNOWN) context.getString(R.string.question_mark) return if (size == Image.HEIGHT_UNKNOWN) context.getString(R.string.question_mark)
else size.toString() else size.toString()

View File

@ -58,7 +58,6 @@ import org.schabi.newpipe.ui.components.metadata.TagsSection
import org.schabi.newpipe.ui.theme.AppTheme import org.schabi.newpipe.ui.theme.AppTheme
import org.schabi.newpipe.util.Localization import org.schabi.newpipe.util.Localization
import org.schabi.newpipe.util.NO_SERVICE_ID import org.schabi.newpipe.util.NO_SERVICE_ID
import org.schabi.newpipe.util.image.ImageStrategy
import java.time.OffsetDateTime import java.time.OffsetDateTime
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@ -161,12 +160,10 @@ fun VideoDescriptionSection(streamInfo: StreamInfo) {
} }
} }
if (streamInfo.ageLimit != StreamExtractor.NO_AGE_LIMIT) { val ageLimit = streamInfo.ageLimit
if (ageLimit != StreamExtractor.NO_AGE_LIMIT) {
item { item {
MetadataItem( MetadataItem(title = R.string.metadata_age_limit, value = ageLimit.toString())
title = R.string.metadata_age_limit,
value = streamInfo.ageLimit.toString()
)
} }
} }
@ -214,9 +211,9 @@ private fun LazyListScope.metadataItem(@StringRes title: Int, value: String) {
} }
private fun LazyListScope.imageMetadataItem(@StringRes title: Int, images: List<Image>) { private fun LazyListScope.imageMetadataItem(@StringRes title: Int, images: List<Image>) {
ImageStrategy.choosePreferredImage(images)?.let { if (images.isNotEmpty()) {
item { item {
ImageMetadataItem(title, images, it) ImageMetadataItem(title, images)
} }
} }
} }