Pressing the back button on the action bar of these 3 activities
resulted in no action.
At some point in the past, just calling setDisplayHomeAsUpEnabled(true)
was enough, but looks like these days nothing happens by default.
Fix the problem by explicitly handling android.R.id.home and there
finishing the current activity.
Import from file is normally a non-blocking operation, so it can be done
on the UI, except when going via the storage access framework, e.g. when
the file is provided by nextcloud. This resulted in a crash like:
2023-10-13 22:10:48.342 7896-7896 AndroidRuntime hu.vmiklos.plees_tracker.debug E FATAL EXCEPTION: main
at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:153)
at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:814)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:2043)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1858)
at android.content.ContentResolver.openInputStream(ContentResolver.java:1528)
at hu.vmiklos.plees_tracker.DataModel.importData(DataModel.kt:163)
The NetworkOnMainThreadException is thrown because we actually do
networking on the main thread, but that should be done on a thread to
not block the UI.
Fix the problem by wrapping the IO part of importData() in a
`withContext(Dispatchers.IO)` block, but keep the toast on the main
thread, as UI calls are only allowed on the main thread.
Fixes <https://github.com/vmiklos/plees-tracker/issues/407>.
Change-Id: Ia9d691fd178c343554ede86c39a801134f2aab2e
It turns out openOutputStream() can throw an exception, which is not
obvious at first, since it returns a nullable output stream, so first I
assumed that it returns a null output stream on failure.
Also, given that it was assumed export can't reach showing a toast on
failure, we always presented success. Fix this and report an error on
failure.
Fixes <https://github.com/vmiklos/plees-tracker/issues/406>.
Change-Id: Ic5922e4b38f544debe0888bd636d21be8fe35f49
This could happen when the quick setting tile launched the activity,
then rotation re-launched the activity with the same intent parameters,
so the tracking stopped.
As suggested in the issue, just remove the parameter once consumed.
Fixes <https://github.com/vmiklos/plees-tracker/issues/365>.
Change-Id: I9b95959fe10065008492e8aa49f9045400420ea5