From 99feed5bb82537d0c7fef49494ccf5eca592658b Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Wed, 27 Nov 2024 16:43:08 +0530 Subject: [PATCH] Fixed: D&D description is not displayed correctly. * The issue was caused by an HTML entity in the description of the "D&D" ZIM file. The description was displayed as "D&D Wiki" because it was not properly decoded before being set in the TextView. * We have now implemented proper decoding of any HTML entities present in the title or description before setting them to the TextView, ensuring the description is displayed correctly. --- .../zimManager/libraryView/adapter/LibraryViewHolder.kt | 4 ++-- .../kiwix/kiwixmobile/core/extensions/TextViewExtensions.kt | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zimManager/libraryView/adapter/LibraryViewHolder.kt b/app/src/main/java/org/kiwix/kiwixmobile/zimManager/libraryView/adapter/LibraryViewHolder.kt index ddb442b37..214b6d787 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zimManager/libraryView/adapter/LibraryViewHolder.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/zimManager/libraryView/adapter/LibraryViewHolder.kt @@ -103,8 +103,8 @@ sealed class LibraryViewHolder(containerView: View) : @Suppress("MagicNumber") override fun bind(item: LibraryDownloadItem) { itemDownloadBinding.libraryDownloadFavicon.setBitmap(item.favIcon) - itemDownloadBinding.libraryDownloadTitle.text = item.title - itemDownloadBinding.libraryDownloadDescription.text = item.description + itemDownloadBinding.libraryDownloadTitle.setTextAndVisibility(item.title) + itemDownloadBinding.libraryDownloadDescription.setTextAndVisibility(item.description) itemDownloadBinding.downloadProgress.progress = item.progress itemDownloadBinding.stop.apply { setToolTipWithContentDescription(itemDownloadBinding.root.context.getString(string.stop)) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/TextViewExtensions.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/TextViewExtensions.kt index 132bfeb59..93dc8744e 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/TextViewExtensions.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/extensions/TextViewExtensions.kt @@ -20,10 +20,11 @@ package org.kiwix.kiwixmobile.core.extensions import android.view.View import android.widget.TextView +import org.kiwix.kiwixmobile.core.utils.StyleUtils.fromHtml fun TextView.setTextAndVisibility(nullableText: String?) = - if (nullableText != null && nullableText.isNotEmpty()) { - text = nullableText + if (!nullableText.isNullOrEmpty()) { + text = nullableText.fromHtml().toString() visibility = View.VISIBLE } else { visibility = View.GONE