Skip to content

Conversation

@lukstbit
Copy link
Contributor

@lukstbit lukstbit commented Nov 30, 2020

What does it fix?

For #251

This error seems to show up when you go the the about screen, attempt to change the language, but pick the same language as before in the dropdown.

It doesn't happen just in that case, you can also see it if you navigate to the Observer's guide screen. This is happening because the forms, observer's guide and about are the 3 fragments in the navigation graph and when you go to one and then return to the others they get recreated. This seems to make the fragments to revert to the default locale(which is english) and ignore the locale we set(I don't understand why this happens). I tried something and it seems to work:

  • to fix the wrong locale in the fragments I used a LocaleManager.wrapContext() in the base fragment to again apply the selected locale to the fragments.
  • in the VisitedPollingStationsActivity I removed the label from the manifest(is applied before our locale is set and it relies on the system resources) and I set the title manually.
  • in the PollingStationsDetailsFragment and its ViewModel I modified the pollingStationLiveData to return a pair of the needed values and let the fragment get the string. The ViewModel was using the application Context which is not going to have our locale applied to it. Here there's still a bug because I didn't changed the error strings(as above for pollingStationLiveData )when the user doesn't select area/gender/time because the messageIdToastLiveData is from the super class and it is also used in other places as well.

My changes seem to solve the bug but I'm not very comfortable with the code because I don't really get what is happening(and I don't know if I introduced bugs elsewhere). I made the PR so you could have a solution if you want it.

How has it been tested?

I've played around with the app and it seems to keep the selected language.

@lukstbit lukstbit requested a review from aniri as a code owner November 30, 2020 14:55
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@aniri
Copy link
Member

aniri commented Nov 30, 2020

Ouch, weird bug 🐛 . I'll see if I have time to test this properly before the elections and include it too. If not, we'll check it after the elections ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants