From 8de9f28b0df218fb02b2cbe553fade2d5a62cee1 Mon Sep 17 00:00:00 2001 From: MohitMali Date: Wed, 15 Mar 2023 12:08:02 +0530 Subject: [PATCH] Fixed blank screen showing in custom application after giving permission from settings --- core/src/main/res/values/strings.xml | 4 ++-- .../custom/main/CustomReaderFragment.kt | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 667048174..70d3a218a 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -268,7 +268,7 @@ Text Only Short Text Storage Permission Denied - This app requires the ability to read storage permission to function. Please grant the storage permission in your app setting + This app requires the ability to read storage to function. Please grant the permission in your settings Go to Hotspot Settings No Results No Bookmarks @@ -334,5 +334,5 @@ Forward history Clears all (backward, forward) navigation history Navigation History Cleared - Go to Setting + Go to Settings diff --git a/custom/src/main/java/org/kiwix/kiwixmobile/custom/main/CustomReaderFragment.kt b/custom/src/main/java/org/kiwix/kiwixmobile/custom/main/CustomReaderFragment.kt index 95fe5da41..ce90cd784 100644 --- a/custom/src/main/java/org/kiwix/kiwixmobile/custom/main/CustomReaderFragment.kt +++ b/custom/src/main/java/org/kiwix/kiwixmobile/custom/main/CustomReaderFragment.kt @@ -70,6 +70,7 @@ class CustomReaderFragment : CoreReaderFragment() { @Inject var dialogShower: DialogShower? = null private var permissionRequiredDialog: Dialog? = null + private var appSettingsLaunched = false override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) if (enforcedLanguage()) { @@ -182,10 +183,13 @@ class CustomReaderFragment : CoreReaderFragment() { super.onRequestPermissionsResult(requestCode, permissions, grantResults) if (permissions.isNotEmpty() && permissions[0] == Manifest.permission.READ_EXTERNAL_STORAGE) { if (readStorageHasBeenPermanentlyDenied(grantResults)) { - if (permissionRequiredDialog == null || permissionRequiredDialog?.isShowing == false) { + if (permissionRequiredDialog?.isShowing != true) { permissionRequiredDialog = dialogShower?.create( KiwixDialog.ReadPermissionRequired, - requireActivity()::navigateToAppSettings + { + requireActivity().navigateToAppSettings() + appSettingsLaunched = true + } ) permissionRequiredDialog?.show() } @@ -263,4 +267,12 @@ class CustomReaderFragment : CoreReaderFragment() { super.onDestroyView() permissionRequiredDialog = null } + + override fun onResume() { + super.onResume() + if (appSettingsLaunched) { + appSettingsLaunched = false + openObbOrZim() + } + } }