Fixed blank screen showing in custom application after giving permission from settings

This commit is contained in:
MohitMali 2023-03-15 12:08:02 +05:30
parent 585c5a1ecd
commit 8de9f28b0d
2 changed files with 16 additions and 4 deletions

View File

@ -268,7 +268,7 @@
<string name="tag_text_only">Text Only</string>
<string name="tag_short_text">Short Text</string>
<string name="storage_permission_denied">Storage Permission Denied</string>
<string name="grant_read_storage_permission">This app requires the ability to read storage permission to function. Please grant the storage permission in your app setting</string>
<string name="grant_read_storage_permission">This app requires the ability to read storage to function. Please grant the permission in your settings</string>
<string name="go_to_settings">Go to Hotspot Settings</string>
<string name="no_results">No Results</string>
<string name="no_bookmarks">No Bookmarks</string>
@ -334,5 +334,5 @@
<string name="forward_history">Forward history</string>
<string name="clear_all_navigation_history_message">Clears all (backward, forward) navigation history</string>
<string name="navigation_history_cleared">Navigation History Cleared</string>
<string name="go_to_settings_label">Go to Setting</string>
<string name="go_to_settings_label">Go to Settings</string>
</resources>

View File

@ -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()
}
}
}