From 9cdac0aa560238063019e908e97232c55a9f7286 Mon Sep 17 00:00:00 2001 From: MohitMali Date: Wed, 18 May 2022 14:46:19 +0530 Subject: [PATCH] Fixed Mobile Network Permission Dialog not showing --- .../library/OnlineLibraryFragment.kt | 25 ++++++++++++++----- .../core/utils/dialog/KiwixDialog.kt | 7 ++++++ core/src/main/res/values/strings.xml | 2 ++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/OnlineLibraryFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/OnlineLibraryFragment.kt index c2339222b..5a8d17aa1 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/OnlineLibraryFragment.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/OnlineLibraryFragment.kt @@ -154,12 +154,7 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions { zimManageViewModel.networkStates.observe(viewLifecycleOwner, Observer(::onNetworkStateChange)) zimManageViewModel.shouldShowWifiOnlyDialog.observe(viewLifecycleOwner, Observer { if (it) { - dialogShower.show( - WifiOnly, - { sharedPreferenceUtil.putPrefWifiOnly(false) }, - { onRefreshStateChange(false) } - ) - zimManageViewModel.shouldShowWifiOnlyDialog.value = false + showAllowMobileNetworkDialog() } }) @@ -171,6 +166,24 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions { }) } + private fun showAllowMobileNetworkDialog() { + dialogShower.show(WifiOnly, { + sharedPreferenceUtil.putPrefWifiOnly(false) + zimManageViewModel.shouldShowWifiOnlyDialog.value = false + }, { + dialogShower.show( + KiwixDialog.AllowMobileNetwork, + ::showAllowMobileNetworkDialog, { + onRefreshStateChange(false) + context.toast( + resources.getString(R.string.denied_internet_permission_message), + Toast.LENGTH_SHORT + ) + } + ) + }) + } + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { super.onCreateOptionsMenu(menu, inflater) inflater.inflate(R.menu.menu_zim_manager, menu) 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 f01df81c0..4199b9229 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 @@ -68,6 +68,13 @@ sealed class KiwixDialog( android.R.string.cancel ) + object AllowMobileNetwork : KiwixDialog( + null, + R.string.allow_network_access, + android.R.string.yes, + android.R.string.cancel + ) + object EnableWifiP2pServices : KiwixDialog( null, R.string.request_enable_wifi, R.string.yes, android.R.string.no ) diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index db9001289..2d097b4a1 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -143,6 +143,7 @@ Next Previous Allow downloading content via mobile network? + Since you are on mobile network we required network access or enable wifi If you choose “Yes” you won\'t be warned in future. However, you can always change this in Settings Download content only via WiFi day @@ -297,6 +298,7 @@ In order to access all the zim files across device we need to have All Files Permission Allowed Not allowed + Please enable wifi to download content /Android Please select a folder for external storage. System unable to grant permission!