Fix crash when user insist on exporting preferences while denying granting storage permission

* Handles IO errors and display toast about FS / permission errors
* Clarify text - storage permissions are needed not only for logs, but for export too
This commit is contained in:
Dominik Dzienia 2020-07-23 13:33:15 +02:00
parent 4068cd72ca
commit 3d0c214f44
2 changed files with 12 additions and 1 deletions

View file

@ -209,6 +209,17 @@ class ImportExportPrefs @Inject constructor(
} catch (e: IOException) {
ToastUtils.errorToast(activity, e.message)
log.error(TAG, "Unhandled exception", e)
} catch (e: PrefFileNotFoundError) {
ToastUtils.Long.errorToast(activity, resourceHelper.gs(R.string.preferences_export_canceled)
+ "\n\n" + resourceHelper.gs(R.string.filenotfound)
+ ": " + e.message
+ "\n\n" + resourceHelper.gs(R.string.needstoragepermission))
log.error(TAG, "File system exception", e)
} catch (e: PrefIOError) {
ToastUtils.Long.errorToast(activity, resourceHelper.gs(R.string.preferences_export_canceled)
+ "\n\n" + resourceHelper.gs(R.string.needstoragepermission)
+ ": " + e.message)
log.error(TAG, "File system exception", e)
}
}
}

View file

@ -950,7 +950,7 @@
<string name="askforpermission">Ask for permission</string>
<string name="needsystemwindowpermission">Application needs system window permission for notifications</string>
<string name="needlocationpermission">Application needs location permission for BT scan and WiFi identification</string>
<string name="needstoragepermission">Application needs storage permission to be able store log files</string>
<string name="needstoragepermission">Application needs storage permission to be able store log files and export settings</string>
<string name="request">Request</string>
<string name="insulinsourcesetup">Configure Insulin plugin</string>
<string name="exit">Exit</string>