collect
collect copied to clipboard
Fix back button on select one from map
Closes #5165 ~~Blocked by #5164 and on a stabler release of Fragment 1.5.0~~
The problem stemmed from the fact that when displaying in a Dialog, the back button will be handled by that and not the current Activity. The new OnBackPressedDispatcher API provides a neat way to deal with this - ComponentDialog owns an OnBackPressedDispatcher that can be passed through to any child Fragment objects and used instead of the host Activity one.
What has been done to verify that this works as intended?
New tests and verified manually.
Why is this the best possible solution? Were any other approaches considered?
The alternative would be to pass custom listeners around which I'm assuming no one will be in favour of.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Should just fix the issue. Good to play around with both selection maps (select one from map and form map) paying special attention to the back button behaviour.
Before submitting this PR, please make sure you have:
- [x] run
./gradlew checkAlland confirmed all checks still pass OR confirm CircleCI build passes and run./gradlew connectedDebugAndroidTestlocally. - [x] verified that any code or assets from external sources are properly credited in comments and/or in the about file.
- [x] verified that any new UI elements use theme colors. UI Components Style guidelines
Fragments 1.5.3 is the current stable release, so this is hopefully unblocked.
Thank you, @grzesiek2010! 😊
Android version
10, 13
Device used
Redmi 9T, Pixel 6a
Problem description
After rotating the screen in Select one from map form, the app crashes or sometimes the form is closed. In Google maps, Mapbox , Osm.
Steps to reproduce the problem
- Go to Select one from map form.
- Tap "Select place".
- Rotate the screen.
Expected behavior
The app shouldn't crash.
Other information
On master 4925521801d471055ad8d0aa1a61918bc0a45901 and the store version the issue doesn't occur.
Android version
10, 13
Device used
Redmi 9T, Pixel 6a
Problem description
If don’t keep activities is on, the app crashes or the form is closed after locking the screen, minimizing the app(Android 13 minimizing + going to different app and back to Collect), rotating the screen
Steps to reproduce the problem
- In device settings don’t keep activities is on.
- Go to Select one from map form.
- Tap "Select place".
- Lock and unlock the screen or minimize the app and go back to the app.
Expected behavior
The app shouldn’t crash or the form shouldn’t close.
Other information
The issue occurs also on store version(v2022.3.6) but it doesn’t occur on master 4925521801d471055ad8d0aa1a61918bc0a45901. I rebased the PR onto the master and the issue is present.
@dbemke those problems should be fixed now
Android version
8.1, 10, 11, 12, 13 (probably all)
Problem description
When Mapbox is chosen as a source of maps, after selecting a point in the form map, rotating and clicking the device back button the form closes. The form should not close – the bottom sheet should collapse.
Steps to reproduce the problem
- In Collect settings choose Mapbox as a source of maps.
- Go to All widgets.
- Go to Geopoint widget (with no appearance).
- Add a geo point and save the form.
- Go to the form map of All widgets.
- Tap the point (bottom sheet opens).
- Rotate the screen.
- Click the device back button.
Expected behavior
The bottom sheet should close. The form shouldn’t close.
@dbemke and definitely not happening in Google Maps or OSM right? That's what I'm seeing, but wanted to double check as it's not making much sense to me so far.
I checked again on the demo project and a different project and it occurs only in Mapbox. @srujner Can you check on Android 13?
@seadowg @dbemke I can confirm that this only happens in Mapbox on Android 13.
@srujner @dbemke I haven't been able to quickly find any reason for Mapbox having this problem. Let's continue testing, and then if everything else is ok we can merge this and create a new issue for the Mapbox/rotate specific problem. My thinking is that the changes here still fix the bug for 99% of scenarios. Sound good?
@seadowg What do you think should be the default zoom in this situation? Kyiv is the point selected at the beginning and then I select and deselect a different point and rotate the screen.
https://user-images.githubusercontent.com/56479916/198031967-d63e1583-26df-4ef8-a45d-9752d5151024.mp4
@dbemke I think we already have an issue for that: https://github.com/getodk/collect/issues/5113
Tested with Success!
Verified on Android 10
Verified cases:
- issue #5165 and issues described in the PR are no longer reproducing
- forms: Select one from map, All widgets, placement_map, geojson, Encrypted geopoint, map-internal-select, S1FromMap, map-internal-select-localized
- map view and form map
- adding, saving, editing geo points
- Google maps, Mapbox, OSM
- clicking back button when a point is selected/ deselected
- clicking back button when the bottom sheet is expanded
- clicking back button after all buttons on a map
- regression checks: display submissions on map and Geo widgets
- don’t keep activities enabled/disabled
- offline layers
- dark/light mode
- rotating, minimizing, locking the screen
Tested with Success!
Verified on Android 13
Issue with mapbox has been reported separately: https://github.com/getodk/collect/issues/5326