The user has to specify the language they're posting in, and sometimes
they might get it wrong (e.g., replying to a post that also had the
language set incorrectly, forgetfulness, etc).
This has accessiblity issues (only following statuses in a given
language fails, translation can fail, etc).
Prevent this by trying to detect the language the status is written in
when the user tries to post it. If the detected language and the set
language do not match, and the detection is 60+% confident, warn the
user the status language might be incorrect, and offer to correct it
before posting.
How this works differs by device and API level.
- API 23 - 28, fdroid and github build flavours
- Not supported. A no-op language detector is used.
- API 29 and above, fdroid and github build flavours
- Uses Android TextClassifier to detect the likely language
- AP 23 and above, google build flavour
- Uses ML Kit language identification
To do this:
- Add `LanguageIdentifier`, with methods to do the identification, and
`LanguageIdentifier.Factory` to create the identifiers.
- Inject the factory in `ComposeActivity`
- Detect the language when the user posts, showing a dialog if there's a
sufficiently large discrepancy.
The ML Kit dependencies (language models) will be installed by the Play
libraries, so there's some machinery to check that they're installed,
and kick off the installation if not. If they can't be installed then
the language check is bypassed.
Update the privacy policy, as the ML Kit libraries may send some data to
Google.
While drafting the policy I noticed that the `READ_MEDIA_*` permissions
could be added (for newer devices), the `ACCESS_NETWORK_STATE`
permission was missing, and `VIBRATE` was unnecessary.