akexorcist / Localization

[Android] In-app language changing library
Apache License 2.0
983 stars 154 forks source link

Not working for new AndroidX appcompat versions #53

Closed alashow closed 4 years ago

alashow commented 4 years ago

Recently I upgraded my AndroidX dependency versions (from 1.1.0 to 1.2.0-beta01) and some users started reporting that the app's locale changing feature stopped working. I was using the 1.2.2 version at the time now I changed upgraded it 1.2.4 but it didn't fix it.

It was working fine on my Pixel 3 XL and Android emulator (different Android versions) but I've seen at least 2 complaints in reviews. So after some digging, I was finally able to reproduce it by using appetize.io emulator. I reverted AndroidX version back to 1.1.0 and it worked properly as before (diff).

When it's not working, it uses the system language. It changes only when the system language changes.

Any ideas on what might be wrong?

alashow commented 4 years ago

It might be appcompat issue: https://stackoverflow.com/questions/55265834/change-locale-not-work-after-migrate-to-androidx Will keep updated

alashow commented 4 years ago

Okay, I narrowed down the problem. This if statement fails and nothing never gets applied: https://github.com/akexorcist/Android-Localization/blob/46fdbf2c552a1cb5c92fbcef0d2564ba70642870/localization/src/main/java/com/akexorcist/localizationactivity/core/LocalizationUtility.kt#L17

baseLocale and currentLocale are always equal.

And it only fails on specific devices (galaxy s8, j6+ + appetize.io emulator) and when AppCompat version is 1.2.0-beta01.

I decided to just remove that condition for now.

akexorcist commented 4 years ago

I solved this issue on 1.2.6. Please waiting for update.

Tested on AppCompat 1.2.0-beta01

Feel free to tell me if you still have any problem from the library.

DJansse commented 4 years ago

Apologies for replying to a closed bug, but I wanted to confirm that using the Localiation lib v1.2.5 together with AndroidX 1.2.0-beta01 appcompat is working on Android 7, but on Android > 7 it appears to display the same issue as the topic starter mentioned...

Have you been able to get it to work on Android versions > 7? I'm using the delegate way due to using the Calligraphy3 library and the ViewPump wrapper.

If I need to report a new issue, I will. We've been successfully using this wonderful library for years, thank you for the continued effort to make it even better.

Kind regards, Davy

akexorcist commented 4 years ago

@DJansse I updated this library to 1.2.6 with some issue fixed. If you still have any problem. Please feel free to open new issue.