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

Implement per-app language setting for Android 13 #1554

Closed
wants to merge 2 commits into from

Conversation

leondzn
Copy link
Contributor

@leondzn leondzn commented Oct 18, 2022

Overview

This addresses #929 and #879

Android 13 introduces per-app language setting where you can now change the app language on a centralized location in the system settings without relying on the currently active system language. And also without having to create a custom language picker inside the app.

Accessible via Settings > System > Languages & Input > App Languages

However only apps that explicitly support Per-App Language settings will appear on the menu.

This PR enables that.

There are two changes that have been done in order to do that:

  1. Updating the compile SDK version to API level 33 (Android 13)
    This will enable us to use the android:localeConfig attribute on the AndroidManifest. I've also took the liberty of also updating the target SDK version to match. In doing so, however, there are a breaking change with the GestureDetector.OnGestureListener interface. In which the MotionEvent parameters on the interface methods are now non-nullable. There are only two implementing classes namely AndroidDataView.kt and ScrollableChart.kt in which I updated the implementing method parameters. UI tests that use these classes has also been updated.

  2. Added a locales_config.xml resource file to specify the supported languages that should appear on the menu. As of now I based the language codes from the available strings.xml localized files.

Testing

I've manually tested this on a Pixel 6 emulator and a physical Pixel 4a both running Android 13.
There is a warning on the Android manifest file about android:localeConfig being only available for API 33 and not on lower sdk versions but the app still works fine. I tested on an emulated Pixel 4 running Android 11. My guess is since Per-App language setting doesn't exist in < API 33, the android:localeConfig attribute will never be queried anyway.

For automated tests, all existing unit tests passed.
Some of the UI tests are failing even before I made these changes. While tests involving AndroidDataView.kt and ScrollableChart.kt are still passing.

Most of the breaking changes here are the `MotionEvent` parameters
on `GestureDetector.OnGestureListener` interface are now non-nullable.

I've updated the implementing classes accordingly
@hiqua hiqua requested a review from iSoron November 25, 2022 16:32
@iSoron
Copy link
Owner

iSoron commented Dec 20, 2022

Thanks for the PR, @leondzn. All the changes look good to me. Android 13 also introduces Notification runtime permissions. Do we need any changes to support that?

@oscfdezdz
Copy link

0e13997 enables monochrome icon introduced in #1497 for me, with the latest stable version it is not displayed.

@leondzn
Copy link
Contributor Author

leondzn commented Mar 22, 2023

@iSoron Apologies for the late response. I haven't visited this PR in a while. But I will try and take a look and confirm if we need to have any changes for Notification runtime permissions when I have the time. I'll let you know as soon as I can.

@hiqua
Copy link
Collaborator

hiqua commented Jul 3, 2023

@leondzn did you have time to have a look?

@hiqua
Copy link
Collaborator

hiqua commented Aug 7, 2023

Superseded by #1783

@hiqua hiqua marked this pull request as draft August 10, 2023 21:50
@hiqua hiqua self-assigned this Aug 10, 2023
@hiqua hiqua closed this Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants