HabitRPG / habitica-android

Native Android app for Habitica
GNU General Public License v3.0
1.47k stars 521 forks source link

when launching app in landscape mode (with auto-rotate on) UI does not reorient properly when switching to portrait #2002

Open rilygreat opened 1 year ago

rilygreat commented 1 year ago

Device: realme realme C12 Android Version: 30 AppVersion: Version 4.2.2 (6121) User ID: fd87d2bb-6690-49ec-ba5e-ec9fe6eaf0ff Level: 3 Class: warrior Is in Inn: false Uses Costume: false Custom Day Start: 0 Timezone Offset: -330 Details:

When I try to open the app in landscape mode and then switch to portrait mode right before the logo disappears and the app menu shows the side panel is open and I can't close it and the app isn't loaded properly and won't respond either.

steps to reproduce:

  1. fully close habitica app if it's open
  2. hold phone in landscape mode when on the phone's home screen
  3. launch the habitica app
  4. app should be in landscape mode
  5. turn phone back to portrait mode

Screenshot_2023-06-17-20-32-15-12_d3b8fcda37c80214ab0c31f986be6207

EanLombardo commented 2 months ago

I recently switched to a foldable device and this issue is way worse for those devices. If you open habitica with the device unfolded you get the nice wide layout, but when you close it, you get the layout as pictured above.

What is happening here is that the MainActivity has 2 layouts, one for normal screens and one for wide screens. When the device is rotated the screen is wider so that one gets used.

However, the code has:

android:configChanges="screenSize | smallestScreenSize | screenLayout | orientation"

The last bit there tells the system to notify the activity when the orientation changes instead of recreating it. The activity doesn't actually have any code to handle this though.

This means that then app is opened, it ends up using whichever layout is appropriate for the current orientation/screen size, and then it never changes until the Activity is recreated. Since you spend 90% of your time in just this 1 Activity that doesn't happen very often.

There is a commit from a while back mentioning that screenSize and such were added to improve multi window behavior, but it is unclear to me why MainActivity would ever ignore orientation changes.

Removing that bit ca