Tusky-App-Android/app/src
Christophe Beyls ad1afdd241
Refactor permissions requests to use ActivityResultContract (#4391)
The app currently uses a custom callback system for requesting
permissions, located in `BaseActivity`.
This code doesn't work when the activity gets re-created before the
permission is granted: the callback will be lost with the Activity and
no action will be performed after the permission is granted.

To avoid these issues while still simplifying the code, Google
recommends to use the ActivityResultContract APIs to request
permissions, which allow to register persistent callbacks. This pull
request removes the legacy API and replaces the calls with
`registerForActivityResult(ActivityResultContracts.RequestPermission())`.

- `ActivityResultContracts.RequestPermission` will check if the
permission is already granted and call the callback synchronously when
possible. So this check doesn't need to be performed anymore.
- In `SearchStatusesFragment` and `SFragment`, the download action to
launch after granting the permission requires an argument (a list of
media URLs). This argument is temporarily stored in a Fragment field and
saved and restored as part of the instance state, so the action can
properly resume after an Activity re-creation.
2024-05-03 21:42:35 +02:00
..
androidTest/java/com/keylesspalace/tusky Replace Gson library with Moshi (#4309) 2024-04-02 21:01:04 +02:00
blue/res new app icon (#2695) 2022-09-13 19:48:09 +02:00
green/res Enforce lint cleanliness when building (#3363) 2023-03-13 10:23:42 +01:00
main Refactor permissions requests to use ActivityResultContract (#4391) 2024-05-03 21:42:35 +02:00
test/java Refactor notifications to Kotlin & paging (#4026) 2024-05-03 18:27:10 +02:00