Sometimes Android reports the MIME type as "application/octet-stream"
even if the file has a .json extension (specifically, on Android 8 and
9 for backups exported outside the Download folder). Previously, such
files could not be selected in the file picker when importing.
As a workaround, allow files with that MIME type.
Fixes#88.
Very similar to FossifyOrg/Notes#14 (which has a more detailed commit
message). Basically, some file pickers don't automatically append the
extension, so we should do it ourselves. It doesn't cause problems.
Reported in #88.
If ActivityResultContracts.CreateDocument launches the native Files
app (com.android.documentsui), then it will create the file before the
Uri is returned to us.
So if we don't complete the export (due to an exception or because
there are no messages) we should delete the file, otherwise there will
be an empty/incomplete file left behind.
When importing/exporting large files we can run out of memory, in
which case we should display a toast to the user (as we do for other
exceptions). Previously, the OutOfMemoryError was not caught because
it inherits from Error, not from Exception.
(We have to manually call .toString() because Context.showErrorToast()
from Commons takes an Exception or a String, not Throwable.)