Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Warn the user if the posting language might be incorrect #792

Merged
merged 5 commits into from
Jul 2, 2024

Commits on Jul 1, 2024

  1. feat: Warn the user if the posting language might be incorrect

    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.
    
    This is currently implemented using Google's ML Kit, and therefore only
    available in the `google` store flavour.
    
    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 discrepency.
    
    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 MLKit libraries may send some data
    to Google.
    nikclayton committed Jul 1, 2024
    Configuration menu
    Copy the full SHA
    aae377d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    03fbf14 View commit details
    Browse the repository at this point in the history

Commits on Jul 2, 2024

  1. Cleanup further

    - Move the language identifiers for API 29 and NOP in to the primary
      code, as they don't have dependency issues.
    
    - Provide a default language detector factory for all devices.
    
    - Return Result<> from language detection to cover possible exceptions.
    
    - Pay attention to trying to use the language detector after close.
    nikclayton committed Jul 2, 2024
    Configuration menu
    Copy the full SHA
    58466e8 View commit details
    Browse the repository at this point in the history
  2. Lint and build

    nikclayton committed Jul 2, 2024
    Configuration menu
    Copy the full SHA
    5d48f2a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3db818b View commit details
    Browse the repository at this point in the history