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

Fragment's menu not localized on rotation #20

Open
RumataEstorish opened this issue Feb 18, 2020 · 5 comments
Open

Fragment's menu not localized on rotation #20

RumataEstorish opened this issue Feb 18, 2020 · 5 comments

Comments

@RumataEstorish
Copy link
Contributor

RumataEstorish commented Feb 18, 2020

Steps to reproduce:

  • Create fragment
  • Add menu to fragment
  • Rotate device

If you add something like this:
override fun onPrepareOptionsMenu(menu: Menu) {
super.onPrepareOptionsMenu(menu)
menu.clear()
MenuInflater(activity?.applicationContext).let {
it.inflate(R.menu.main_menu, menu)
super.onPrepareOptionsMenu(menu)
}
}

it solves problem, but adds new one - app:showAsAction="always" is ignored

I've created fork to test this out and maybe add some fixes if have any, but no luck.
If you want sample, please check https://github.com/RumataEstorish/lingver/tree/fragment_menu_test

@YarikSOffice
Copy link
Owner

YarikSOffice commented Feb 20, 2020

Unfortunately, I can't reproduce it across different android versions on emulator and my Pixel2 using your sample project.
What device are you testing on?

@RumataEstorish
Copy link
Contributor Author

RumataEstorish commented Feb 20, 2020

Ok, lets add more steps to reproduce :)

Environment:

  • Emulator API 28 (Pixel 2 XL skin my case)
  • Languages: English primary, Russian secondary
  • Auto rotation is turned ON
  • Device orientation - portrait

Steps:

  • Open app. Language is English
  • Switch to Russian
  • Press "Screen 1"
  • Open 3 dots menu. Observe "второй пункт меню". Note first menu item displays as icon for test needs (yes, green on green bar :))
  • Without closing menu rotate emulator.

Expected result:

  • We still see "второй пункт меню"

Actual result:

  • We can see "second menu item"

изображение

Note:
Fragment stays in Russian as expected and we can see "произовольный текст 1"

@RumataEstorish
Copy link
Contributor Author

изображение

@YarikSOffice
Copy link
Owner

Okay, just reproduced it. It's important to keep the menu open before rotating the device to replicate the issue.

Will dive deeper and see what I can do. Thank you for reporting!

@RumataEstorish
Copy link
Contributor Author

RumataEstorish commented Feb 20, 2020

Well, there are more cases when this can happen. Not only when menu is kept opened, but when you open/close navigation drawer and some other. But they require much more code for testing.

Unfortunately, only option I've used to solve this is manually set title for each menu item in onPrepareOptionsMenu.

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

No branches or pull requests

2 participants