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

Accomodate larger phones and folding phones better #2086

Open
saraolson opened this issue Sep 24, 2024 · 5 comments
Open

Accomodate larger phones and folding phones better #2086

saraolson opened this issue Sep 24, 2024 · 5 comments

Comments

@saraolson
Copy link
Collaborator

saraolson commented Sep 24, 2024

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.

@marlet
Copy link

marlet commented Sep 29, 2024

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
photo_2024-09-29_11-58-04

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).

@EanLombardo
Copy link
Contributor

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"

@EanLombardo
Copy link
Contributor

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:

  1. Revert the above change, allow Android to recreate the activity on resize.
    • I am not sure what that experience feels like, or why that change was made.
  2. Try and write some code that recreates the activity whenever a resize crossess a threshold, such that a different layout should be used.
    • I am not sure if there is a cleean way to do this. I don't know if Android has a good API for seeing which layouts are available what the criteria for them are.
    • Also since in this case there is just the one activity with just 2 layouts, you could literally hard code the case.

@EanLombardo
Copy link
Contributor

@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.

@EanLombardo
Copy link
Contributor

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.

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

No branches or pull requests

3 participants