From 7d276658d4e7989442d7cc2f471534117a2b4a75 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Fri, 8 Dec 2023 19:06:02 +0530 Subject: [PATCH 1/7] Fixed Start-up message to inform about the restrictions on the Google Store app to open sideloaded ZIM files. * Showing play store restriction to the users in the help screen in play store variant. --- .../kiwixmobile/help/KiwixHelpFragment.kt | 22 ++++++++++++++----- core/src/main/res/values/strings.xml | 5 +++++ 2 files changed, 22 insertions(+), 5 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 9dedd6bd8..571693f9c 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/help/KiwixHelpFragment.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/help/KiwixHelpFragment.kt @@ -18,13 +18,25 @@ package org.kiwix.kiwixmobile.help +import android.os.Build +import org.kiwix.kiwixmobile.BuildConfig.IS_PLAYSTORE import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.core.help.HelpFragment class KiwixHelpFragment : HelpFragment() { - override fun rawTitleDescriptionMap() = listOf( - 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 - ) + override fun rawTitleDescriptionMap() = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && IS_PLAYSTORE) { + listOf( + 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 + ) + } else { + listOf( + 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 + ) + } } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index a5e756b18..643cdcf18 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -209,6 +209,9 @@ @string/help_10 @string/help_11 + + @string/zim_files_not_showing_description + View Bookmarks From All Books Search bookmarks Switch tabs @@ -300,6 +303,8 @@ Tabs restored 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 from our official website 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. All Files Permission Needed From a736a7bdea8dcf1c4f5aa3ca6069ee2030f4c5c6 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Fri, 8 Dec 2023 19:26:59 +0530 Subject: [PATCH 2/7] Fixed the URL shown in the help option and made it clickable to directly open our official website for downloading the APK. --- .../java/org/kiwix/kiwixmobile/core/help/HelpAdapter.kt | 6 +++++- core/src/main/res/layout/item_help.xml | 1 + core/src/main/res/values/strings.xml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/help/HelpAdapter.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/help/HelpAdapter.kt index 904688a44..dadc3e034 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/help/HelpAdapter.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/help/HelpAdapter.kt @@ -18,6 +18,7 @@ package org.kiwix.kiwixmobile.core.help import android.animation.ObjectAnimator +import android.text.method.LinkMovementMethod import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -62,7 +63,10 @@ internal class HelpAdapter(titleDescriptionMap: Map) : override fun bind(item: HelpItem) { itemHelpBinding.itemHelpTitle.setOnClickListener { toggleDescriptionVisibility() } itemHelpBinding.itemHelpToggleExpand.setOnClickListener { toggleDescriptionVisibility() } - itemHelpBinding.itemHelpDescription.text = item.description + itemHelpBinding.itemHelpDescription.apply { + text = item.description + movementMethod = LinkMovementMethod.getInstance() + } itemHelpBinding.itemHelpTitle.text = item.title } } diff --git a/core/src/main/res/layout/item_help.xml b/core/src/main/res/layout/item_help.xml index a6a56cc28..4426a612d 100644 --- a/core/src/main/res/layout/item_help.xml +++ b/core/src/main/res/layout/item_help.xml @@ -35,6 +35,7 @@ android:paddingTop="@dimen/activity_vertical_margin" android:textColor="?textSecondary" android:visibility="gone" + android:autoLink="web" app:layout_constraintTop_toBottomOf="@id/item_help_title" tools:text="@string/help_3" tools:visibility="visible" /> diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 643cdcf18..a5f25281a 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -304,7 +304,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 from our official website + 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/ 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. All Files Permission Needed From 4d47198b909628f25ae8f29db88c825a963d2db4 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Fri, 8 Dec 2023 19:56:20 +0530 Subject: [PATCH 3/7] Introducing the startup message dialog that shows the restrictions of the Play Store to the user. --- .../kiwix/kiwixmobile/core/utils/SharedPreferenceUtil.kt | 7 +++++++ .../org/kiwix/kiwixmobile/core/utils/dialog/KiwixDialog.kt | 7 +++++++ core/src/main/res/values/strings.xml | 1 + 3 files changed, 15 insertions(+) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/SharedPreferenceUtil.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/SharedPreferenceUtil.kt index 741e423be..212233689 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/SharedPreferenceUtil.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/SharedPreferenceUtil.kt @@ -206,6 +206,12 @@ class SharedPreferenceUtil @Inject constructor(val context: Context) { manageExternalFilesPermissionDialogOnRefresh ) } + var playStoreRestrictionPermissionDialog: Boolean + get() = sharedPreferences.getBoolean(PREF_PLAY_STORE_RESTRICTION, true) + set(playStoreRestrictionPermissionDialog) = + sharedPreferences.edit { + putBoolean(PREF_PLAY_STORE_RESTRICTION, playStoreRestrictionPermissionDialog) + } var hostedBooks: Set get() = sharedPreferences.getStringSet(PREF_HOSTED_BOOKS, null)?.toHashSet() ?: HashSet() @@ -266,5 +272,6 @@ class SharedPreferenceUtil @Inject constructor(val context: Context) { const val PREF_MANAGE_EXTERNAL_FILES = "pref_manage_external_files" const val PREF_SHOW_MANAGE_PERMISSION_DIALOG_ON_REFRESH = "pref_show_manage_external_files" const val IS_PLAY_STORE_BUILD = "is_play_store_build" + const val PREF_PLAY_STORE_RESTRICTION = "pref_play_store_restriction" } } 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 b9cb22a67..6c400c669 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,6 +170,13 @@ sealed class KiwixDialog( neutralMessage = R.string.do_not_ask_anymore ) + object PlayStoreRestrictionPopup : KiwixDialog( + null, + R.string.zim_files_not_showing_description, + R.string.understood, + null + ) + data class ShowRate(override val args: List, val customIcon: Int?) : KiwixDialog( R.string.rate_dialog_title, diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index a5f25281a..dfe288cdd 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -305,6 +305,7 @@ 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/ + 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. All Files Permission Needed From c3a6a52255fbf522c63e2f6b90b6bbac22f6dcf9 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Fri, 8 Dec 2023 22:58:15 +0530 Subject: [PATCH 4/7] Added play store restriction dialog --- .../nav/destination/library/LocalLibraryFragment.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 8b1ed5f8f..1514d59f6 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 @@ -363,7 +363,11 @@ class LocalLibraryFragment : BaseFragment() { override fun onResume() { super.onResume() - if (!sharedPreferenceUtil.isPlayStoreBuildWithAndroid11OrAbove() && + if (sharedPreferenceUtil.isPlayStoreBuildWithAndroid11OrAbove() && + sharedPreferenceUtil.playStoreRestrictionPermissionDialog + ) { + showPlayStoreRestrictionInformationToUser() + } else if (!sharedPreferenceUtil.isPlayStoreBuildWithAndroid11OrAbove() && !sharedPreferenceUtil.prefIsTest && !permissionDeniedLayoutShowing ) { checkPermissions() @@ -372,6 +376,13 @@ class LocalLibraryFragment : BaseFragment() { } } + private fun showPlayStoreRestrictionInformationToUser() { + // We should only ask for first time + sharedPreferenceUtil.playStoreRestrictionPermissionDialog = false + // Show Dialog to the user to inform about the play store restriction + dialogShower.show(KiwixDialog.PlayStoreRestrictionPopup) + } + override fun onDestroyView() { super.onDestroyView() actionMode = null From c20b40e389414ad5e1748b98f48800a358a5a5c1 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Mon, 11 Dec 2023 19:00:43 +0530 Subject: [PATCH 5/7] Added a button to the startup message dialog to directly open the Kiwix website for downloading the APK. This will make it easier for the user who wants to download the full APK version of the Kiwix app. --- .../nav/destination/library/LocalLibraryFragment.kt | 12 +++++++++++- .../kiwix/kiwixmobile/core/main/CoreMainActivity.kt | 1 + .../kiwixmobile/core/utils/dialog/KiwixDialog.kt | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) 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 1514d59f6..a8e049ad1 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 @@ -64,10 +64,12 @@ import org.kiwix.kiwixmobile.core.base.BaseFragment import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.isManageExternalStoragePermissionGranted import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.navigate import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.viewModel +import org.kiwix.kiwixmobile.core.extensions.browserIntent import org.kiwix.kiwixmobile.core.extensions.coreMainActivity import org.kiwix.kiwixmobile.core.extensions.setBottomMarginToFragmentContainerView import org.kiwix.kiwixmobile.core.extensions.toast import org.kiwix.kiwixmobile.core.main.CoreMainActivity +import org.kiwix.kiwixmobile.core.main.KIWIX_APK_WEBSITE_URL import org.kiwix.kiwixmobile.core.navigateToAppSettings import org.kiwix.kiwixmobile.core.navigateToSettings import org.kiwix.kiwixmobile.core.utils.LanguageUtils @@ -380,7 +382,15 @@ class LocalLibraryFragment : BaseFragment() { // We should only ask for first time sharedPreferenceUtil.playStoreRestrictionPermissionDialog = false // Show Dialog to the user to inform about the play store restriction - dialogShower.show(KiwixDialog.PlayStoreRestrictionPopup) + dialogShower.show( + KiwixDialog.PlayStoreRestrictionPopup, + {}, + ::openKiwixWebsiteForDownloadingApk + ) + } + + private fun openKiwixWebsiteForDownloadingApk() { + requireActivity().startActivity(KIWIX_APK_WEBSITE_URL.toUri().browserIntent()) } override fun onDestroyView() { diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.kt index 5d61f77ef..978816689 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.kt @@ -55,6 +55,7 @@ import javax.inject.Inject import kotlin.system.exitProcess const val KIWIX_SUPPORT_URL = "https://www.kiwix.org/support" +const val KIWIX_APK_WEBSITE_URL = "https://download.kiwix.org/release/kiwix-android/" const val PAGE_URL_KEY = "pageUrl" const val SHOULD_OPEN_IN_NEW_TAB = "shouldOpenInNewTab" const val FIND_IN_PAGE_SEARCH_STRING = "findInPageSearchString" 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 6c400c669..507343a63 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 @@ -174,7 +174,7 @@ sealed class KiwixDialog( null, R.string.zim_files_not_showing_description, R.string.understood, - null + R.string.download ) data class ShowRate(override val args: List, val customIcon: Int?) : From 90dc8ec2928616887d50dd5c3ffc137a233eca7c Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Tue, 12 Dec 2023 17:50:58 +0530 Subject: [PATCH 6/7] Enhanced the visibility of the ZIM file on the help screen for testability. * Introduced test cases for the new functionality to ensure its expected behavior in both variants, such as Play Store and non-Play Store. * Updated other test cases to accommodate the testing of this new functionality. --- .../kiwixmobile/download/DownloadTest.kt | 1 + .../kiwixmobile/help/HelpFragmentTest.kt | 54 ++++++++ .../org/kiwix/kiwixmobile/help/HelpRobot.kt | 16 +++ .../initial/download/InitialDownloadTest.kt | 1 + .../language/LanguageFragmentTest.kt | 1 + .../LocalFileTransferTest.kt | 1 + .../main/TopLevelDestinationTest.kt | 1 + .../kiwixmobile/mimetype/MimeTypeTest.kt | 1 + .../PlayStoreRestrictionDialogRobot.kt | 65 ++++++++++ .../PlayStoreRestrictionDialogTest.kt | 117 ++++++++++++++++++ .../destination/library/LocalLibraryTest.kt | 1 + .../page/history/NavigationHistoryTest.kt | 1 + .../reader/KiwixReaderFragmentTest.kt | 1 + .../kiwixmobile/search/SearchFragmentTest.kt | 1 + .../webserver/ZimHostFragmentTest.kt | 1 + .../kiwixmobile/help/KiwixHelpFragment.kt | 4 +- .../kiwixmobile/core/help/HelpFragment.kt | 4 + .../core/utils/dialog/KiwixDialog.kt | 3 +- 18 files changed, 270 insertions(+), 4 deletions(-) create mode 100644 app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogRobot.kt create mode 100644 app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogTest.kt diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt index 4d2db7b40..08e5a1bd9 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt @@ -73,6 +73,7 @@ class DownloadTest : BaseActivityTest() { putBoolean(SharedPreferenceUtil.PREF_SHOW_STORAGE_OPTION, false) putBoolean(SharedPreferenceUtil.IS_PLAY_STORE_BUILD, true) putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true) + putBoolean(SharedPreferenceUtil.PREF_PLAY_STORE_RESTRICTION, false) } activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { moveToState(Lifecycle.State.RESUMED) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt index 59a2b09f0..e58c8d74a 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt @@ -17,23 +17,31 @@ */ package org.kiwix.kiwixmobile.help +import androidx.core.content.edit import androidx.lifecycle.Lifecycle +import androidx.preference.PreferenceManager import androidx.test.core.app.ActivityScenario +import androidx.test.espresso.IdlingRegistry import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice import leakcanary.LeakAssertions +import org.junit.After import org.junit.Before import org.junit.Rule import org.junit.Test import org.kiwix.kiwixmobile.BaseActivityTest import org.kiwix.kiwixmobile.R +import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil import org.kiwix.kiwixmobile.main.KiwixMainActivity import org.kiwix.kiwixmobile.testutils.RetryRule import org.kiwix.kiwixmobile.testutils.TestUtils.closeSystemDialogs import org.kiwix.kiwixmobile.testutils.TestUtils.isSystemUINotRespondingDialogVisible +import org.kiwix.kiwixmobile.utils.KiwixIdlingResource class HelpFragmentTest : BaseActivityTest() { + private lateinit var sharedPreferenceUtil: SharedPreferenceUtil + @Before override fun waitForIdle() { UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).apply { @@ -53,6 +61,7 @@ class HelpFragmentTest : BaseActivityTest() { @Test fun verifyHelpActivity() { + setShowPlayStoreRestriction(false) activityScenario.onActivity { it.navigate(R.id.helpFragment) } @@ -66,8 +75,53 @@ class HelpFragmentTest : BaseActivityTest() { clickOnHowToUpdateContent() assertHowToUpdateContentIsExpanded() clickOnHowToUpdateContent() + assertZimFileNotShowingIsNotVisible() clickOnSendFeedback() } LeakAssertions.assertNoLeaks() } + + @Test + fun verifyHelpActivityWithPlayStoreRestriction() { + setShowPlayStoreRestriction(true) + activityScenario.onActivity { + it.navigate(R.id.helpFragment) + } + help { + clickOnWhatDoesKiwixDo() + assertWhatDoesKiwixDoIsExpanded() + clickOnWhatDoesKiwixDo() + clickOnWhereIsContent() + assertWhereIsContentIsExpanded() + clickOnWhereIsContent() + clickOnHowToUpdateContent() + assertHowToUpdateContentIsExpanded() + clickOnHowToUpdateContent() + clickOnZimFileNotShowing() + assertZimFileNotShowingIsExpanded() + clickOnZimFileNotShowing() + clickOnSendFeedback() + } + LeakAssertions.assertNoLeaks() + } + + private fun setShowPlayStoreRestriction(showRestriction: Boolean) { + context.let { + sharedPreferenceUtil = SharedPreferenceUtil(it).apply { + setIntroShown() + putPrefWifiOnly(false) + setIsPlayStoreBuildType(showRestriction) + prefIsTest = true + } + } + } + + @After + fun finish() { + IdlingRegistry.getInstance().unregister(KiwixIdlingResource.getInstance()) + PreferenceManager.getDefaultSharedPreferences(context).edit { + putBoolean(SharedPreferenceUtil.IS_PLAY_STORE_BUILD, false) + putBoolean(SharedPreferenceUtil.PREF_IS_TEST, false) + } + } } 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 efbc89db0..cc5bdc8c4 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpRobot.kt @@ -17,6 +17,9 @@ */ package org.kiwix.kiwixmobile.help +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.assertion.ViewAssertions.doesNotExist +import androidx.test.espresso.matcher.ViewMatchers.withText import org.kiwix.kiwixmobile.BaseRobot import org.kiwix.kiwixmobile.Findable.StringId.TextId import org.kiwix.kiwixmobile.Findable.Text @@ -78,6 +81,19 @@ class HelpRobot : BaseRobot() { clickOn(ViewId(id.activity_help_feedback_text_view)) } + fun clickOnZimFileNotShowing() { + clickOn(TextId(string.zim_files_not_showing)) + } + + fun assertZimFileNotShowingIsExpanded() { + isVisible(TextId(string.zim_files_not_showing_description)) + } + + fun assertZimFileNotShowingIsNotVisible() { + onView(withText("Zim files not showing?")) + .check(doesNotExist()) + } + private fun helpTextFormat(vararg stringIds: Int) = stringIds.joinToString(separator = "\n", transform = context::getString) } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadTest.kt index eb7531ec2..bed20071d 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadTest.kt @@ -63,6 +63,7 @@ class InitialDownloadTest : BaseActivityTest() { putBoolean(SharedPreferenceUtil.PREF_SHOW_STORAGE_OPTION, true) putBoolean(SharedPreferenceUtil.IS_PLAY_STORE_BUILD, true) putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true) + putBoolean(SharedPreferenceUtil.PREF_PLAY_STORE_RESTRICTION, false) } activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { moveToState(Lifecycle.State.RESUMED) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageFragmentTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageFragmentTest.kt index e49692736..79300b463 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageFragmentTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageFragmentTest.kt @@ -75,6 +75,7 @@ class LanguageFragmentTest { .edit { putBoolean(SharedPreferenceUtil.PREF_SHOW_INTRO, false) putBoolean(SharedPreferenceUtil.PREF_WIFI_ONLY, false) + putBoolean(SharedPreferenceUtil.PREF_PLAY_STORE_RESTRICTION, false) } } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferTest.kt index c27e3f077..9364beb3e 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferTest.kt @@ -166,6 +166,7 @@ class LocalFileTransferTest { putBoolean(SharedPreferenceUtil.PREF_WIFI_ONLY, false) putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true) putBoolean(SharedPreferenceUtil.PREF_SHOW_SHOWCASE, shouldShowShowCase) + putBoolean(SharedPreferenceUtil.PREF_PLAY_STORE_RESTRICTION, false) } if (isResetShowCaseId) { // To clear showCaseID to ensure the showcase view will show. diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationTest.kt index 147dd0313..400542c36 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationTest.kt @@ -61,6 +61,7 @@ class TopLevelDestinationTest : BaseActivityTest() { putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true) putBoolean(SharedPreferenceUtil.PREF_EXTERNAL_LINK_POPUP, true) putBoolean(SharedPreferenceUtil.PREF_SHOW_SHOWCASE, false) + putBoolean(SharedPreferenceUtil.PREF_PLAY_STORE_RESTRICTION, false) } activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { moveToState(Lifecycle.State.RESUMED) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/mimetype/MimeTypeTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/mimetype/MimeTypeTest.kt index f007019c0..948374a6b 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/mimetype/MimeTypeTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/mimetype/MimeTypeTest.kt @@ -52,6 +52,7 @@ class MimeTypeTest : BaseActivityTest() { PreferenceManager.getDefaultSharedPreferences(context).edit { putBoolean(SharedPreferenceUtil.PREF_SHOW_INTRO, false) putBoolean(SharedPreferenceUtil.PREF_WIFI_ONLY, false) + putBoolean(SharedPreferenceUtil.PREF_PLAY_STORE_RESTRICTION, false) } activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { moveToState(Lifecycle.State.RESUMED) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogRobot.kt new file mode 100644 index 000000000..c2d7a39fc --- /dev/null +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogRobot.kt @@ -0,0 +1,65 @@ +/* + * Kiwix Android + * Copyright (c) 2023 Kiwix + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package org.kiwix.kiwixmobile.nav.destination + +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions.doesNotExist +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.withText +import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import applyWithViewHierarchyPrinting +import com.adevinta.android.barista.interaction.BaristaSleepInteractions +import org.kiwix.kiwixmobile.BaseRobot +import org.kiwix.kiwixmobile.Findable.ViewId +import org.kiwix.kiwixmobile.R +import org.kiwix.kiwixmobile.testutils.TestUtils + +fun playStoreRestriction(func: PlayStoreRestrictionDialogRobot.() -> Unit) = + PlayStoreRestrictionDialogRobot().applyWithViewHierarchyPrinting(func) + +class PlayStoreRestrictionDialogRobot : BaseRobot() { + + fun clickLibraryOnBottomNav() { + pauseForBetterTestPerformance() + clickOn(ViewId(R.id.libraryFragment)) + } + + fun assertPlayStoreRestrictionDialogDisplayed() { + pauseForBetterTestPerformance() + onView(withText("UNDERSTOOD")) + .check(matches(isDisplayed())) + } + + fun assetPlayStoreRestrictionDialogNotDisplayed() { + pauseForBetterTestPerformance() + onView(withText("UNDERSTOOD")) + .check(doesNotExist()) + } + + fun clickOnUnderstood() { + pauseForBetterTestPerformance() + onView(withText("UNDERSTOOD")) + .perform(click()) + } + + private fun pauseForBetterTestPerformance() { + BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) + } +} diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogTest.kt new file mode 100644 index 000000000..b9e651a51 --- /dev/null +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogTest.kt @@ -0,0 +1,117 @@ +/* + * Kiwix Android + * Copyright (c) 2023 Kiwix + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package org.kiwix.kiwixmobile.nav.destination + +import android.Manifest +import android.content.Context +import android.os.Build +import androidx.lifecycle.Lifecycle +import androidx.test.core.app.ActivityScenario +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.rule.GrantPermissionRule +import androidx.test.uiautomator.UiDevice +import leakcanary.LeakAssertions +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil +import org.kiwix.kiwixmobile.main.KiwixMainActivity +import org.kiwix.kiwixmobile.testutils.RetryRule +import org.kiwix.kiwixmobile.testutils.TestUtils + +class PlayStoreRestrictionDialogTest { + @Rule + @JvmField + var retryRule = RetryRule() + + private lateinit var sharedPreferenceUtil: SharedPreferenceUtil + + private lateinit var activityScenario: ActivityScenario + + private val permissions = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + arrayOf( + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE, + Manifest.permission.NEARBY_WIFI_DEVICES + ) + } else { + arrayOf( + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.ACCESS_FINE_LOCATION + ) + } + + @Rule + @JvmField + var permissionRules: GrantPermissionRule = + GrantPermissionRule.grant(*permissions) + private var context: Context? = null + + @Before + fun waitForIdle() { + context = InstrumentationRegistry.getInstrumentation().targetContext + UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).apply { + if (TestUtils.isSystemUINotRespondingDialogVisible(this)) { + TestUtils.closeSystemDialogs(context) + } + waitForIdle() + } + } + + @Test + fun showPlayStoreRestrictionDialog() { + setShowPlayStoreRestrictionDialog(true) + activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { + moveToState(Lifecycle.State.RESUMED) + } + playStoreRestriction { + clickLibraryOnBottomNav() + assertPlayStoreRestrictionDialogDisplayed() + clickOnUnderstood() + } + LeakAssertions.assertNoLeaks() + } + + @Test + fun testPlayStoreDialogShowOnlyOnce() { + setShowPlayStoreRestrictionDialog(false) + activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { + moveToState(Lifecycle.State.RESUMED) + } + playStoreRestriction { + clickLibraryOnBottomNav() + assetPlayStoreRestrictionDialogNotDisplayed() + } + LeakAssertions.assertNoLeaks() + } + + private fun setShowPlayStoreRestrictionDialog(showDialog: Boolean) { + context?.let { + sharedPreferenceUtil = SharedPreferenceUtil(it).apply { + setIntroShown() + putPrefWifiOnly(false) + setIsPlayStoreBuildType(true) + prefIsTest = true + playStoreRestrictionPermissionDialog = showDialog + } + } + } +} diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/library/LocalLibraryTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/library/LocalLibraryTest.kt index 583f33732..65f39e17a 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/library/LocalLibraryTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/library/LocalLibraryTest.kt @@ -70,6 +70,7 @@ class LocalLibraryTest : BaseActivityTest() { // the manage external storage permission dialog on Android 11 and above // while refreshing the content in LocalLibraryFragment. putBoolean(SharedPreferenceUtil.PREF_SHOW_MANAGE_PERMISSION_DIALOG_ON_REFRESH, false) + putBoolean(SharedPreferenceUtil.PREF_PLAY_STORE_RESTRICTION, false) } activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { moveToState(Lifecycle.State.RESUMED) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/page/history/NavigationHistoryTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/page/history/NavigationHistoryTest.kt index e2e1aa4c6..ab2d1c89d 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/page/history/NavigationHistoryTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/page/history/NavigationHistoryTest.kt @@ -63,6 +63,7 @@ class NavigationHistoryTest : BaseActivityTest() { putBoolean(SharedPreferenceUtil.PREF_SHOW_INTRO, false) putBoolean(SharedPreferenceUtil.PREF_WIFI_ONLY, false) putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true) + putBoolean(SharedPreferenceUtil.PREF_PLAY_STORE_RESTRICTION, false) } activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { moveToState(Lifecycle.State.RESUMED) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/reader/KiwixReaderFragmentTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/reader/KiwixReaderFragmentTest.kt index 28466b8a3..3590d25b0 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/reader/KiwixReaderFragmentTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/reader/KiwixReaderFragmentTest.kt @@ -62,6 +62,7 @@ class KiwixReaderFragmentTest : BaseActivityTest() { putBoolean(SharedPreferenceUtil.PREF_SHOW_INTRO, false) putBoolean(SharedPreferenceUtil.PREF_WIFI_ONLY, false) putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true) + putBoolean(SharedPreferenceUtil.PREF_PLAY_STORE_RESTRICTION, false) } activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { moveToState(Lifecycle.State.RESUMED) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/search/SearchFragmentTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/search/SearchFragmentTest.kt index 350d42ef0..d15df1e6f 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/search/SearchFragmentTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/search/SearchFragmentTest.kt @@ -62,6 +62,7 @@ class SearchFragmentTest : BaseActivityTest() { putBoolean(SharedPreferenceUtil.PREF_SHOW_INTRO, false) putBoolean(SharedPreferenceUtil.PREF_WIFI_ONLY, false) putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true) + putBoolean(SharedPreferenceUtil.PREF_PLAY_STORE_RESTRICTION, false) } activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { moveToState(Lifecycle.State.RESUMED) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/webserver/ZimHostFragmentTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/webserver/ZimHostFragmentTest.kt index a359a4431..78f74903e 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/webserver/ZimHostFragmentTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/webserver/ZimHostFragmentTest.kt @@ -85,6 +85,7 @@ class ZimHostFragmentTest { putPrefWifiOnly(false) setIsPlayStoreBuildType(true) prefIsTest = true + playStoreRestrictionPermissionDialog = false } } activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { 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 571693f9c..60f003439 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/help/KiwixHelpFragment.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/help/KiwixHelpFragment.kt @@ -18,14 +18,12 @@ package org.kiwix.kiwixmobile.help -import android.os.Build -import org.kiwix.kiwixmobile.BuildConfig.IS_PLAYSTORE import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.core.help.HelpFragment class KiwixHelpFragment : HelpFragment() { override fun rawTitleDescriptionMap() = - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && IS_PLAYSTORE) { + if (sharedPreferenceUtil.isPlayStoreBuildWithAndroid11OrAbove()) { listOf( R.string.help_2 to R.array.description_help_2, R.string.help_5 to R.array.description_help_5, 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 3db5702af..0bcf66930 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 @@ -39,9 +39,13 @@ import org.kiwix.kiwixmobile.core.extensions.toast import org.kiwix.kiwixmobile.core.main.CoreMainActivity import org.kiwix.kiwixmobile.core.utils.CONTACT_EMAIL_ADDRESS import org.kiwix.kiwixmobile.core.utils.LanguageUtils.Companion.getCurrentLocale +import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil +import javax.inject.Inject @Suppress("UnnecessaryAbstractClass") abstract class HelpFragment : BaseFragment() { + @Inject + lateinit var sharedPreferenceUtil: SharedPreferenceUtil private var fragmentHelpBinding: FragmentHelpBinding? = null protected open fun rawTitleDescriptionMap(): List> = emptyList() override val fragmentToolbar: Toolbar? by lazy { 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 507343a63..6482ebec3 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 @@ -174,7 +174,8 @@ sealed class KiwixDialog( null, R.string.zim_files_not_showing_description, R.string.understood, - R.string.download + R.string.download, + cancelable = false ) data class ShowRate(override val args: List, val customIcon: Int?) : From b572d02e6cc773f90625a7da2da49b79a540f54a Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Tue, 12 Dec 2023 22:06:36 +0530 Subject: [PATCH 7/7] Fixed HelpFragmentTest and PlayStoreRestrictionTest on api level 24 --- .../kiwixmobile/help/HelpFragmentTest.kt | 41 ++++++++++--------- .../PlayStoreRestrictionDialogTest.kt | 38 +++++++++-------- 2 files changed, 43 insertions(+), 36 deletions(-) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt index e58c8d74a..f3c514096 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt @@ -17,6 +17,7 @@ */ package org.kiwix.kiwixmobile.help +import android.os.Build import androidx.core.content.edit import androidx.lifecycle.Lifecycle import androidx.preference.PreferenceManager @@ -83,26 +84,28 @@ class HelpFragmentTest : BaseActivityTest() { @Test fun verifyHelpActivityWithPlayStoreRestriction() { - setShowPlayStoreRestriction(true) - activityScenario.onActivity { - it.navigate(R.id.helpFragment) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + setShowPlayStoreRestriction(true) + activityScenario.onActivity { + it.navigate(R.id.helpFragment) + } + help { + clickOnWhatDoesKiwixDo() + assertWhatDoesKiwixDoIsExpanded() + clickOnWhatDoesKiwixDo() + clickOnWhereIsContent() + assertWhereIsContentIsExpanded() + clickOnWhereIsContent() + clickOnHowToUpdateContent() + assertHowToUpdateContentIsExpanded() + clickOnHowToUpdateContent() + clickOnZimFileNotShowing() + assertZimFileNotShowingIsExpanded() + clickOnZimFileNotShowing() + clickOnSendFeedback() + } + LeakAssertions.assertNoLeaks() } - help { - clickOnWhatDoesKiwixDo() - assertWhatDoesKiwixDoIsExpanded() - clickOnWhatDoesKiwixDo() - clickOnWhereIsContent() - assertWhereIsContentIsExpanded() - clickOnWhereIsContent() - clickOnHowToUpdateContent() - assertHowToUpdateContentIsExpanded() - clickOnHowToUpdateContent() - clickOnZimFileNotShowing() - assertZimFileNotShowingIsExpanded() - clickOnZimFileNotShowing() - clickOnSendFeedback() - } - LeakAssertions.assertNoLeaks() } private fun setShowPlayStoreRestriction(showRestriction: Boolean) { diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogTest.kt index b9e651a51..495a4a26b 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogTest.kt @@ -78,29 +78,33 @@ class PlayStoreRestrictionDialogTest { @Test fun showPlayStoreRestrictionDialog() { - setShowPlayStoreRestrictionDialog(true) - activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { - moveToState(Lifecycle.State.RESUMED) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + setShowPlayStoreRestrictionDialog(true) + activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { + moveToState(Lifecycle.State.RESUMED) + } + playStoreRestriction { + clickLibraryOnBottomNav() + assertPlayStoreRestrictionDialogDisplayed() + clickOnUnderstood() + } + LeakAssertions.assertNoLeaks() } - playStoreRestriction { - clickLibraryOnBottomNav() - assertPlayStoreRestrictionDialogDisplayed() - clickOnUnderstood() - } - LeakAssertions.assertNoLeaks() } @Test fun testPlayStoreDialogShowOnlyOnce() { - setShowPlayStoreRestrictionDialog(false) - activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { - moveToState(Lifecycle.State.RESUMED) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + setShowPlayStoreRestrictionDialog(false) + activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { + moveToState(Lifecycle.State.RESUMED) + } + playStoreRestriction { + clickLibraryOnBottomNav() + assetPlayStoreRestrictionDialogNotDisplayed() + } + LeakAssertions.assertNoLeaks() } - playStoreRestriction { - clickLibraryOnBottomNav() - assetPlayStoreRestrictionDialogNotDisplayed() - } - LeakAssertions.assertNoLeaks() } private fun setShowPlayStoreRestrictionDialog(showDialog: Boolean) {