1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-26 12:10:09 +01: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.ui.components.metadata.ImageMetadataItem
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.util.Localization
import org.schabi.newpipe.util.NO_SERVICE_ID
import org.schabi.newpipe.util.image.ImageStrategy
@Composable
fun AboutChannelSection(channelInfo: ChannelInfo) {
@ -41,12 +41,12 @@ fun AboutChannelSection(channelInfo: ChannelInfo) {
)
}
ImageStrategy.choosePreferredImage(channelInfo.avatars)?.let {
ImageMetadataItem(R.string.metadata_avatars, channelInfo.avatars, it)
if (channelInfo.avatars.isNotEmpty()) {
ImageMetadataItem(R.string.metadata_avatars, channelInfo.avatars)
}
ImageStrategy.choosePreferredImage(channelInfo.banners)?.let {
ImageMetadataItem(R.string.metadata_banners, channelInfo.banners, it)
if (channelInfo.banners.isNotEmpty()) {
ImageMetadataItem(R.string.metadata_banners, channelInfo.banners)
}
if (channelInfo.tags.isNotEmpty()) {

View File

@ -26,22 +26,16 @@ import org.schabi.newpipe.util.image.ImageStrategy
import org.schabi.newpipe.util.image.PreferredImageQuality
@Composable
fun ImageMetadataItem(
@StringRes title: Int,
images: List<Image>,
preferredUrl: String? = ImageStrategy.choosePreferredImage(images)
) {
fun ImageMetadataItem(@StringRes title: Int, images: List<Image>) {
val context = LocalContext.current
val imageLinks = remember { convertImagesToLinks(context, images, preferredUrl) }
val imageLinks = remember(images) { convertImagesToLinks(context, images) }
MetadataItem(title = title, value = imageLinks)
}
private fun convertImagesToLinks(
context: Context,
images: List<Image>,
preferredUrl: String?
): AnnotatedString {
private fun convertImagesToLinks(context: Context, images: List<Image>): AnnotatedString {
val preferredUrl = ImageStrategy.choosePreferredImage(images)
fun imageSizeToText(size: Int): String {
return if (size == Image.HEIGHT_UNKNOWN) context.getString(R.string.question_mark)
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.util.Localization
import org.schabi.newpipe.util.NO_SERVICE_ID
import org.schabi.newpipe.util.image.ImageStrategy
import java.time.OffsetDateTime
@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 {
MetadataItem(
title = R.string.metadata_age_limit,
value = streamInfo.ageLimit.toString()
)
MetadataItem(title = R.string.metadata_age_limit, value = 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>) {
ImageStrategy.choosePreferredImage(images)?.let {
if (images.isNotEmpty()) {
item {
ImageMetadataItem(title, images, it)
ImageMetadataItem(title, images)
}
}
}