From aeca8d2e1aa46f1fb20b737c681b19138044898f Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Thu, 21 Dec 2023 19:50:32 +0530 Subject: [PATCH 1/2] Fixed: Extracted the website link from the string file for the Play Store restriction dialog. * Removed the link from `zim_files_not_showing_description`. * Modified the dialog for displaying the link in `PlayStoreRestrictionPopup`. * Refactored the `rawTitleDescriptionMap`() method in `HelpFragment` to accommodate both strings and arrays for showing links inside the HelpFragment. --- .../kiwixmobile/help/KiwixHelpFragment.kt | 6 +++++- .../library/LocalLibraryFragment.kt | 2 +- .../kiwixmobile/core/help/HelpFragment.kt | 13 +++++++++--- .../core/utils/dialog/KiwixDialog.kt | 20 ++++++++++++------- core/src/main/res/values/strings.xml | 5 +---- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/help/KiwixHelpFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/help/KiwixHelpFragment.kt index 60f003439a..916e140429 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/help/KiwixHelpFragment.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/help/KiwixHelpFragment.kt @@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.help import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.core.help.HelpFragment +import org.kiwix.kiwixmobile.core.main.KIWIX_APK_WEBSITE_URL class KiwixHelpFragment : HelpFragment() { override fun rawTitleDescriptionMap() = @@ -28,7 +29,10 @@ class KiwixHelpFragment : HelpFragment() { R.string.help_2 to R.array.description_help_2, R.string.help_5 to R.array.description_help_5, R.string.how_to_update_content to R.array.update_content_description, - R.string.zim_files_not_showing to R.array.description_help_6 + R.string.zim_files_not_showing to getString( + R.string.zim_files_not_showing_description, + KIWIX_APK_WEBSITE_URL + ) ) } else { listOf( diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LocalLibraryFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LocalLibraryFragment.kt index 8e22466209..4909f9d4c1 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LocalLibraryFragment.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LocalLibraryFragment.kt @@ -391,7 +391,7 @@ class LocalLibraryFragment : BaseFragment() { sharedPreferenceUtil.playStoreRestrictionPermissionDialog = false // Show Dialog to the user to inform about the play store restriction dialogShower.show( - KiwixDialog.PlayStoreRestrictionPopup, + KiwixDialog.PlayStoreRestrictionPopup(KIWIX_APK_WEBSITE_URL), {}, ::openKiwixWebsiteForDownloadingApk ) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/help/HelpFragment.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/help/HelpFragment.kt index 0bcf66930a..d751f0a1c5 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/help/HelpFragment.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/help/HelpFragment.kt @@ -47,7 +47,7 @@ abstract class HelpFragment : BaseFragment() { @Inject lateinit var sharedPreferenceUtil: SharedPreferenceUtil private var fragmentHelpBinding: FragmentHelpBinding? = null - protected open fun rawTitleDescriptionMap(): List> = emptyList() + protected open fun rawTitleDescriptionMap(): List> = emptyList() override val fragmentToolbar: Toolbar? by lazy { fragmentHelpBinding?.root?.findViewById(R.id.toolbar) } @@ -55,8 +55,15 @@ abstract class HelpFragment : BaseFragment() { private val titleDescriptionMap by lazy { rawTitleDescriptionMap().associate { (title, description) -> - getString(title) to resources.getStringArray(description) - .joinToString(separator = "\n") + val descriptionValue = when (description) { + is String -> description + is Int -> resources.getStringArray(description).joinToString(separator = "\n") + else -> { + throw IllegalArgumentException("Invalid description resource type for title: $title") + } + } + + getString(title) to descriptionValue } } diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/KiwixDialog.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/KiwixDialog.kt index 6482ebec37..2b7e0bfe21 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/KiwixDialog.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/KiwixDialog.kt @@ -170,13 +170,19 @@ sealed class KiwixDialog( neutralMessage = R.string.do_not_ask_anymore ) - object PlayStoreRestrictionPopup : KiwixDialog( - null, - R.string.zim_files_not_showing_description, - R.string.understood, - R.string.download, - cancelable = false - ) + data class PlayStoreRestrictionPopup(override val args: List) : + KiwixDialog( + null, + R.string.zim_files_not_showing_description, + R.string.understood, + R.string.download, + cancelable = false + ), + HasBodyFormatArgs { + constructor(websiteUrl: String) : this( + listOf(websiteUrl) + ) + } data class ShowRate(override val args: List, val customIcon: Int?) : KiwixDialog( diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 2084cb4d7d..58d59070c6 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -210,9 +210,6 @@ @string/help_10 @string/help_11 - - @string/zim_files_not_showing_description - View Bookmarks From All Books Search bookmarks Switch tabs @@ -305,7 +302,7 @@ Open Drawer Close Drawer Zim files not showing? - Due to Google Play policies on Android 11 and above, this Google Store app can\’t open sideloaded ZIM files. You can either download them through the app or, instead, install the full version of kiwix app from our official website https://download.kiwix.org/release/kiwix-android/ + Due to Google Play policies on Android 11 and above, this Google Store app can\’t open sideloaded ZIM files. You can either download them through the app or, instead, install the full version of kiwix app from our official website %s Understood How to update content? To update content (a zim file) you need to download the full latest version of this very same content. You can do that via the download section. From 9b148682f4b8098dab61c8c8daeaef024d478d43 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Fri, 22 Dec 2023 11:51:30 +0530 Subject: [PATCH 2/2] Fixed `HelpFragmentTest` that is failing on API level 30,33. --- .../java/org/kiwix/kiwixmobile/help/HelpRobot.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpRobot.kt index cc5bdc8c4d..90bcf8bb93 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpRobot.kt @@ -26,6 +26,7 @@ import org.kiwix.kiwixmobile.Findable.Text import org.kiwix.kiwixmobile.Findable.ViewId import org.kiwix.kiwixmobile.core.R.id import org.kiwix.kiwixmobile.core.R.string +import org.kiwix.kiwixmobile.core.main.KIWIX_APK_WEBSITE_URL fun help(func: HelpRobot.() -> Unit) = HelpRobot().apply(func) @@ -86,7 +87,14 @@ class HelpRobot : BaseRobot() { } fun assertZimFileNotShowingIsExpanded() { - isVisible(TextId(string.zim_files_not_showing_description)) + isVisible( + Text( + context.getString( + string.zim_files_not_showing_description, + KIWIX_APK_WEBSITE_URL + ) + ) + ) } fun assertZimFileNotShowingIsNotVisible() {