On Android 14, imported messages are not visible if their
subscriptionId[1] does not correspond to one of the SIMs in the
device. As a workaround, we set subscriptionId to -1 ("unknown") on
all messages during import.
This does mean that when exporting then importing on the same device,
the SIM associations will be lost. But that doesn't seem noticeable.
Credit: SMS Import / Export app,
https://www.github.com/tmo1/sms-ie/issues/128Fixes#191.
[1] https://developer.android.com/identity/user-data-ids#mobile-subscription-status
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.
No behaviour change.
- Simplify insertOrUpdateConversation(), since the previous code was long and
hard to follow.
- Inline constants into selection queries instead of using '?' arguments.
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.)