From 0827cdc64a412a68c8bc6dfcc39dafecc9bd1f83 Mon Sep 17 00:00:00 2001 From: Sujal-Gupta-SG Date: Tue, 28 Jan 2025 22:43:13 +0530 Subject: [PATCH 1/3] corrected --- .../java/fr/free/nrw/commons/media/MediaDetailFragment.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt index 4c993fb803..6f252f2bd5 100644 --- a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt +++ b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt @@ -650,10 +650,8 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C } private fun onDepictionsLoaded(idAndCaptions: List) { - binding.depictsLayout.visibility = - if (idAndCaptions.isEmpty()) View.GONE else View.VISIBLE - binding.depictionsEditButton.visibility = - if (idAndCaptions.isEmpty()) View.GONE else View.VISIBLE + binding.depictsLayout.visibility = View.VISIBLE + binding.depictionsEditButton.visibility = View.VISIBLE buildDepictionList(idAndCaptions) } From 4e261fc21950ce3614bd3d67ccbc21c88b44f856 Mon Sep 17 00:00:00 2001 From: Sujal-Gupta-SG Date: Tue, 28 Jan 2025 23:48:31 +0530 Subject: [PATCH 2/3] corrected --- .../nrw/commons/media/MediaDetailFragment.kt | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt index 6f252f2bd5..06debb2283 100644 --- a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt +++ b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt @@ -201,7 +201,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C /** * Depicts is a feature part of Structured data. * Multiple Depictions can be added for an image just like categories. - * However unlike categories depictions is multi-lingual + * However unlike categories depictions is multi-lingualmedia * Ex: key: en value: monument */ private var imageInfoCache: ImageInfo? = null @@ -861,8 +861,22 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C */ private fun buildDepictionList(idAndCaptions: List) { binding.mediaDetailDepictionContainer.removeAllViews() + + // Create a mutable list from the original list + val mutableIdAndCaptions = idAndCaptions.toMutableList() + + if (mutableIdAndCaptions.isEmpty()) { + // Create a placeholder IdAndCaptions object and add it to the list + mutableIdAndCaptions.add( + IdAndCaptions( + id = media?.pageId ?: "", // Use an empty string if media?.pageId is null + captions = mapOf(Locale.getDefault().language to getString(R.string.detail_panel_cats_none)) // Create a Map with the language as the key and the message as the value + ) + ) + } + val locale: String = Locale.getDefault().language - for (idAndCaption: IdAndCaptions in idAndCaptions) { + for (idAndCaption: IdAndCaptions in mutableIdAndCaptions) { binding.mediaDetailDepictionContainer.addView( buildDepictLabel( getDepictionCaption(idAndCaption, locale), @@ -873,6 +887,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C } } + private fun getDepictionCaption(idAndCaption: IdAndCaptions, locale: String): String? { // Check if the Depiction Caption is available in user's locale // if not then check for english, else show any available. From 49086b7475c797c50c6d46000c7f9edc8d08643c Mon Sep 17 00:00:00 2001 From: Sujal Date: Wed, 29 Jan 2025 00:32:22 +0530 Subject: [PATCH 3/3] Update MediaDetailFragment.kt Spelling correction --- .../main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt index 06debb2283..d714b094a6 100644 --- a/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt +++ b/app/src/main/java/fr/free/nrw/commons/media/MediaDetailFragment.kt @@ -201,7 +201,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C /** * Depicts is a feature part of Structured data. * Multiple Depictions can be added for an image just like categories. - * However unlike categories depictions is multi-lingualmedia + * However unlike categories depictions is multi-lingual * Ex: key: en value: monument */ private var imageInfoCache: ImageInfo? = null