Open saraolson opened 3 weeks ago
I also struggled with layout issue. My tablet supports split screen, and when I first tried Habitica and switched to split screen what I saw was
Fortunately, Habitica correctly determines screen ratio if you start it in a split screen mode, it just don't adjust it on the fly. So if you stop Habitica app, open another app you want to use alongside, and then start Habitica in a split screen, then it starts in phone layout, which retains at least for some time after you exit split screen. It still would be nice to be able to switch mode manually on a particular device (or set your own preferred screen ratio to switch modes).
So there are 2 seperate things going on here.
One is #2087. When the main screen open, that layout that is chosen for the current orientation, is the one that gets used even after the orientation changes. Folding the phone counts as an orientation change, which causes the weird squished behavior when you fold the phone. This one is easy to fix and and I already have a PR out for it.
The other problem is the that the same thing happens for multiwindow mode. If you take the existing window, and resize it so much that it should start using the phone layout, it doesn't adapt, causing the same squished behavior.
This one is harder to fix. Normally allowing the entire activity to be recreated on orientation changes is fine, because they happen occasionally, and each time it is rebuilt it can reselect its layout.
For multi window though, if you configure it this way, every time the user adjusts the size of the window the activity will get recreated. Which can be a lot of churn as the user drags things around.
In fact it looks like the app did at one point function that way, but this was changed to "improve multi window support"
Unfortunately good multi-window support is something notoriously difficult to add into apps after the fact.
Older apps tend to define different layouts for different types of screen and orentiations. But good support for multi windows functions better with a single layout that adapts to size changes more gracefully.
That require rebuilding the entire layout for the MainActivity, which might be quite an undertaking.
There are some alternatives:
@saraolson by the way you can work around the weird behavior with the squished layout.
If you open the app while the phone is folded, then open the phone. You will get stuck with the phone layout on both. Which is not super great unfolded, but is at least usable when folded.
This: https://github.com/user-attachments/assets/c4b2263c-214f-4f8c-9bb2-5a7a659e3789
Is an example of what the flow is like today. This is the app built in debug mode from main. Resizing causes some memory leaks but doesn't take very long. It shows the squished UI when the window is sized down too much.
This: https://github.com/user-attachments/assets/f111e487-c460-46e6-9272-b6cfcab10ada
Is an exmaple with with the entire configChanges line removed. Every time you resize the window the activity gets recreated. It is noticeable slower, and also still triggers some memory leaks. But the UI is functional at all sizes.
I will leave it up to the habitica team to decide if that approach is acceptable. It is probablythe only way to change the experience without reworking the entire layout of the most complex Acitivty. But it is slower.
on certain larger devices, we switch to a tablet layout when it should still be showing the phone layout. this results in an extremely squished main view.
should adjust when we switch to tablet layout to accommodate this better
ex. pixel 9 pro fold is showing tablet layout when only on one screen. opening it up to use both screens correctly shows the tablet layout.