-
-
Notifications
You must be signed in to change notification settings - Fork 689
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
Android: update layout after rotation #1507
Conversation
…nges with OnGlobalLayoutListener
The size of the content area was previously calculated by measuring the whole screen and subtracting the height of the status bar and action bar. This PR replaces that with some simpler code which gets the size of the content area directly, which should be much more reliable. With this approach, The example from beeware/briefcase-android-gradle-template#50 now looks like this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed that this works; nice work. However, I'm wondering if it might be worth making some small structural tweaks - in particular:
- Making the Viewport the layout listener, rather than the Window
- Making the
self.size
property a property of the viewport, rather than the window (and possibly renaming to something like "last observed size")
The reason I'm suggesting this is that with this change, we now have effectively 3 "size" properties - window.size, window.get_size(), and window.viewport.width/height... and while it obviously works, it's going to get confusing if we need to make modifications in future unless it's very clear which size is which, and which to use for which purpose.
This suggestion is in the category of "strong opinions, weakly held"; if you disagree, I'd be more than happy to back down to just renaming self.size
to something less ambiguous, plus some in-code docstrings elaborating exactly which extents different sizes refer to.
More broadly, this is an area of weakness that is common on most platforms - the connection between "main window", "main window content", "viewport" - and, on some platforms, "the widget that manages main windows content content" (e.g., the macOS ViewController). There are also some inconsistencies around what sizes refer to (e.g., differentiating between the Window's external size, internal content size, and available internal content size after toolbars/menus etc). That isn't a problem we need to solve right now, but I wanted to flag it as an area where there is a "top level" design issue that we need to resolve, as it intersects with some of the window layout/resize problems we've been seeing, and will impact on the design of some widgets (like stack-based navigation widgets).
Codecov Report
|
OK, I've changed I've also changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 That rationale all makes sense to me.
This is the Toga part of the fix described in beeware/briefcase-android-gradle-template#50. It mostly works, but the viewport height is slightly wrong after rotation because the action bar is narrower in landscape orientation. I'll look into this and add another commit.
PR Checklist: