Fix fragmented DeckPicker menu ownership and sw600dp split detection - #21620
sanjaysargam wants to merge 2 commits into
Conversation
|
Snapshot diff report vs
All 17 changed screenshotsPreferencesScreenshotTest
ReviewRemindersScreenshotTest
|
|
@ericli3690 Could you opine on the menu changes. And probably add an issue for a unit test to ossify the decision on the displayed menu items. |
ericli3690
left a comment
There was a problem hiding this comment.
Oops, this somehow slipped my notification radar somehow, apologies for the late reply.
| private inline fun <T> withStudyOptionsFragment(block: StudyOptionsFragment.() -> T): T? = | ||
| if (fragmented) { | ||
| fragment?.block() | ||
| } else { | ||
| null | ||
| } |
There was a problem hiding this comment.
This feels... kinda hacky. Are we sure this is the intent of the TODO comment you've deleted? I was under the impression that the TODO is instructing a future developer to move the logic from the Fragment into the Activity, not just to hotwire calls to the Fragment code in.
Checking the history of the TODO comment, it's a suggestion from @david-allison (#16425), perhaps he could clarify what he initially wanted.
There was a problem hiding this comment.
I know a lot more about menus now. I'll change my opinion
Fragments should define their own menus (MenuProvider)
The Menu host (typically the activity) either coordinates, or provides the state to the fragments for them to hide their items
The menu host implicitly defines ordering, consider orderInCategory if you want finer grained control
Edit: I'll stand by my original point that one fragment should not own the menus of its siblings
509fa58 to
c2cb3a7
Compare
|
Tests are failing |
c2cb3a7 to
21a32af
Compare
| override var fragmented: Boolean | ||
| get() = | ||
| resources.configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK == | ||
| Configuration.SCREENLAYOUT_SIZE_XLARGE | ||
| resources.configuration.smallestScreenWidthDp >= 600 | ||
| set(_) = throw UnsupportedOperationException() |
There was a problem hiding this comment.
I feel this continues to cause problems. Let's use
override var fragmented: Boolean
get() = binding.studyoptionsFragment != null
set(_) = throw UnsupportedOperationException()We've discussed (maybe in Discord) that users are unhappy in 2.24 regarding both the Deck Picker and the Note Editor split screen changes, especially the modifications in the 'fragmented' threshold, and what acceptable values are for foldables.
I don't think we've done sufficient research/testing [proposed work in the linked issue] to come to a consensus on what this value should be.
There was a problem hiding this comment.
Agreed. This also means you'd be able to align line 517:
if (binding.studyoptionsFragment == null) {To instead be if (!fragmented) {
Then update unit tests to match
| override var fragmented: Boolean | ||
| get() = | ||
| resources.configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK == | ||
| Configuration.SCREENLAYOUT_SIZE_XLARGE | ||
| resources.configuration.smallestScreenWidthDp >= 600 | ||
| set(_) = throw UnsupportedOperationException() |
There was a problem hiding this comment.
Agreed. This also means you'd be able to align line 517:
if (binding.studyoptionsFragment == null) {To instead be if (!fragmented) {
Then update unit tests to match
| android:theme="@style/Theme_Dark.Launcher" | ||
| android:exported="false" | ||
| android:configChanges="keyboardHidden|orientation|screenSize" | ||
| android:configChanges="keyboardHidden|orientation" |
There was a problem hiding this comment.
Hm, my LLM claims that it doesn't make sense to do only orientation; double check, but apparently if you remove screenSize you should be safe to remove orientation too
1856a68 to
73e55f6
Compare
| android:theme="@style/Theme_Dark.Launcher" | ||
| android:exported="false" | ||
| android:configChanges="keyboardHidden|orientation|screenSize" | ||
| android:configChanges="keyboardHidden" |
There was a problem hiding this comment.
Drop this, it's out of scope, (would need its own PR to discuss)
| @Test | ||
| fun checkDisplayOfStudyOptionsOnTablet() { | ||
| assumeTrue("We are running on a tablet", qualifiers!!.contains("xlarge")) | ||
| assumeTrue("We are running on a tablet", resources.configuration.smallestScreenWidthDp >= 600) |
There was a problem hiding this comment.
I still feel this is out of scope for the PR, we shouldn't be mixing redefining the layout widths in with this PR, and the prerequistite research hasn't been performed to determine the qualifier we want to use for a split screen.
`fragmented` checked `SCREENLAYOUT_SIZE_XLARGE`, which does not match the `layout-sw600dp` resource boundary that the split-pane layout actually uses, so the flag could disagree with the inflated layout. Derive it from the layout itself: fragmented iff the layout provides the side panel container, so the flag and the UI can never disagree regardless of device geometry
fragments define their own menus via MenuProvider, and the menu host dispatches creation, preparation and selection to them; one fragment must not own or drive the menus of its siblings.
73e55f6 to
b695711
Compare
Note
Assisted-by: GPT-5.4 Mini
Purpose / Description
This moves split pane study options menu handling from
StudyOptionsFragmentintoDeckPicker, aligns the fragmented-layout check with the real sw600dp breakpoint, and removesscreenSizefromDeckPickerconfig handling so foldable and resizable window changes recreate the correct UI stateFixes
Approach
Centralize fragmented menu delegation in DeckPicker
How Has This Been Tested?
Pixel 10 Pro Foldable
Checklist
Please, go through these checks before submitting the PR.