collect icon indicating copy to clipboard operation
collect copied to clipboard

Fix back button on select one from map

Open seadowg opened this issue 3 years ago • 1 comments

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 checkAll and confirmed all checks still pass OR confirm CircleCI build passes and run ./gradlew connectedDebugAndroidTest locally.
  • [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

seadowg avatar Jun 22 '22 14:06 seadowg

Fragments 1.5.3 is the current stable release, so this is hopefully unblocked.

seadowg avatar Sep 29 '22 09:09 seadowg

Thank you, @grzesiek2010! 😊

lognaturel avatar Oct 20 '22 16:10 lognaturel

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

  1. Go to Select one from map form.
  2. Tap "Select place".
  3. Rotate the screen.

Expected behavior

The app shouldn't crash.

Other information

On master 4925521801d471055ad8d0aa1a61918bc0a45901 and the store version the issue doesn't occur.

dbemke avatar Oct 21 '22 08:10 dbemke

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

  1. In device settings don’t keep activities is on.
  2. Go to Select one from map form.
  3. Tap "Select place".
  4. 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 avatar Oct 21 '22 09:10 dbemke

@dbemke those problems should be fixed now

seadowg avatar Oct 21 '22 11:10 seadowg

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

  1. In Collect settings choose Mapbox as a source of maps.
  2. Go to All widgets.
  3. Go to Geopoint widget (with no appearance).
  4. Add a geo point and save the form.
  5. Go to the form map of All widgets.
  6. Tap the point (bottom sheet opens).
  7. Rotate the screen.
  8. Click the device back button.

Expected behavior

The bottom sheet should close. The form shouldn’t close.

dbemke avatar Oct 24 '22 11:10 dbemke

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

seadowg avatar Oct 25 '22 16:10 seadowg

I checked again on the demo project and a different project and it occurs only in Mapbox. @srujner Can you check on Android 13?

dbemke avatar Oct 26 '22 07:10 dbemke

@seadowg @dbemke I can confirm that this only happens in Mapbox on Android 13.

srujner avatar Oct 26 '22 08:10 srujner

@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 avatar Oct 26 '22 09:10 seadowg

@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 avatar Oct 26 '22 12:10 dbemke

@dbemke I think we already have an issue for that: https://github.com/getodk/collect/issues/5113

seadowg avatar Oct 26 '22 16:10 seadowg

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

dbemke avatar Oct 27 '22 07:10 dbemke

Tested with Success!

Verified on Android 13

Issue with mapbox has been reported separately: https://github.com/getodk/collect/issues/5326

srujner avatar Oct 27 '22 09:10 srujner