Skip to content

Commit

Permalink
Merge pull request #3626 from kiwix/Issue#3625
Browse files Browse the repository at this point in the history
Fixed: Extracted the website link from the string file for the Play Store restriction dialog.
  • Loading branch information
kelson42 authored Dec 29, 2023
2 parents fff9991 + 9b14868 commit 61c6f96
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() =
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
13 changes: 10 additions & 3 deletions core/src/main/java/org/kiwix/kiwixmobile/core/help/HelpFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,23 @@ abstract class HelpFragment : BaseFragment() {
@Inject
lateinit var sharedPreferenceUtil: SharedPreferenceUtil
private var fragmentHelpBinding: FragmentHelpBinding? = null
protected open fun rawTitleDescriptionMap(): List<Pair<Int, Int>> = emptyList()
protected open fun rawTitleDescriptionMap(): List<Pair<Int, Any>> = emptyList()
override val fragmentToolbar: Toolbar? by lazy {
fragmentHelpBinding?.root?.findViewById(R.id.toolbar)
}
override val fragmentTitle: String? by lazy { getString(R.string.menu_help) }

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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Any>) :
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<Any>, val customIcon: Int?) :
KiwixDialog(
Expand Down
5 changes: 1 addition & 4 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@
<item>@string/help_10</item>
<item>@string/help_11</item>
</string-array>
<string-array name="description_help_6">
<item>@string/zim_files_not_showing_description</item>
</string-array>
<string name="bookmarks_from_current_book">View Bookmarks From All Books</string>
<string name="search_bookmarks">Search bookmarks</string>
<string name="switch_tabs">Switch tabs</string>
Expand Down Expand Up @@ -305,7 +302,7 @@
<string name="open_drawer">Open Drawer</string>
<string name="close_drawer">Close Drawer</string>
<string name="zim_files_not_showing">Zim files not showing?</string>
<string name="zim_files_not_showing_description">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 <a href="https://download.kiwix.org/release/kiwix-android/">https://download.kiwix.org/release/kiwix-android/</a></string>
<string name="zim_files_not_showing_description">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</string>
<string name="understood">Understood</string>
<string name="how_to_update_content">How to update content?</string>
<string name="update_content_description">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.</string>
Expand Down

0 comments on commit 61c6f96

Please sign in to comment.