B3nedikt / restring

Restring is a android library to replace string resources dynamically
Apache License 2.0
319 stars 31 forks source link

Using ViewPump 4.0.2 doesn't change strings set in xml #70

Closed hkarimka closed 4 years ago

hkarimka commented 4 years ago

Hello! I am sorry, but using ViewPump 4.0.2 doesn't change strings that were set from xml layout using android:text=@string/some_text. Using ViewPump 4.0.1 changes that strings, but breaks all in styles attributes.

B3nedikt commented 4 years ago

Thanks for reporting this, I think I am getting close to fixing this remaining issues ;) Next time major versions of my libs will get beta releases I guess xD That aside I am not sure what you mean, for me this seems to work. If you have the time you can fork this repository and modify the example app so it recreates the issue, so I can analyze it.

hkarimka commented 4 years ago

Ok, maybe that's because I override gerResources() in my Application class to handle language changing in my application.. I do something like that

val res: Resources = resources
val conf: Configuration = res.configuration
conf.setLocale(locale)
localizedResources = Restring.wrapContext(createConfigurationContext(conf)).resources

And also I override getAssets() to make my WebView work

override fun getAssets(): AssetManager {
    return resources.assets
}
B3nedikt commented 4 years ago

@hkarimka Okay, a bit more testing uncovered a issue with android < Q not updating some texts on some views. ViewPump 4.0.3 should fixed this, just increase the version.

Yeah, this resource overwrite is not good anymore if you use appcompat 1.2.0 as explained in the other ticket. But downgrading to appcompat 1.1.0 is not an option as this version contains some bugs. You can either integrate AppLocale as I show in my example app in this repository, or just set the language using: Restring.locale = Locale.TAIWAN,

Btw. I integrate the new ViewPump in a quite big app tomorrow, this may uncover an other bug ;)

hkarimka commented 4 years ago

Ok! Thank you :)

B3nedikt commented 4 years ago

You're welcome :) Integrating the new ViewPump into the big app uncovered no bugs on different android versions and devices for me. I close this for now, feel free to reopen this issue if you find an other similar bug.