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

Dismiss the offline layers confirmation dialog on activity recreation #6243

Merged
merged 2 commits into from
Jul 4, 2024

Conversation

grzesiek2010
Copy link
Member

@grzesiek2010 grzesiek2010 commented Jul 1, 2024

Closes #6219

Why is this the best possible solution? Were any other approaches considered?

We agreed in the issue that dismissing the dialog is the solution we want for now.
I wanted to handle that case in OfflineMapLayersImporter but it didn't seem to be easy so I did it in OfflineMapLayersPicker (the dialog that shows the confirmation dialog).

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?

This requires ensuring that the dialog is being dismissed on activity recreation (the case described in the issue). This should not happen on configuration changes (for example when you rotate your device).

Do we need any specific form for testing your changes? If so, please attach one.

No.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

No.

Before submitting this PR, please make sure you have:

  • added or modified tests for any new or changed behavior
  • run ./gradlew connectedAndroidTest (or ./gradlew testLab) and confirmed all checks still pass
  • added a comment above any new strings describing it for translators
  • added any new strings with date formatting to DateFormatsTest
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@grzesiek2010 grzesiek2010 marked this pull request as ready for review July 1, 2024 13:16
@grzesiek2010 grzesiek2010 requested a review from seadowg July 1, 2024 13:16
@@ -116,6 +116,13 @@ class OfflineMapLayersPicker(
dismiss()
}

if (sharedViewModel.layersToImport.value?.value == null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the right way to solve this, but it does feel like we're working against ourselves here a little to have to write specific code for this case.

Considering it more, I'm realizing an alternative would be to fully support this case with Fragment args - pass the list of URIs as an arg to OfflineMapLayersImporter (and then have it call loadExistingLayers) instead of communicating them via the ViewModel. I don't like this nearly as much, but it does feel like where Android is pushing us given we have state we want to this Fragment to be able between full recreations.

Another alternative (which wouldn't support full recreation) would be to rework the UI a little to not show OfflineMapLayersImporter until there layersToImport is available. This would prevent us from having to deal with the lifecycle problem at all.

What do you think? Perhaps we could look at one of those as part of #6198 and go with this approach (just avoiding the crash) for now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another alternative (which wouldn't support full recreation) would be to rework the UI a little to not show OfflineMapLayersImporter until there layersToImport is available. This would prevent us from having to deal with the lifecycle problem at all.

This would require dismissing the confirmation dialog programmatically either way (that's the thing we don't like the most I guess). Plus I think it's better to display that dialog immediately and have the loading indicator there not in the first one (at least it makes more sense with the current UI).

I will take a look at the first option which was my first implementation and I liked it. If it doesn't require a lot of changes I will do that otherwise we can think about it later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take a look at the first option which was my first implementation and I liked it. If it doesn't require a lot of changes I will do that otherwise we can think about it later.

Sounds good!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I still like option 1 but I think we should leave it as is for now (merge this pr) and see if it's still the best solution once we figure out how we want to rework the UI in #6198

@WKobus
Copy link

WKobus commented Jul 5, 2024

Tested with Success!

Verified on a device with Android 14

Verified Cases:

@dbemke
Copy link

dbemke commented Jul 5, 2024

Tested with Success!

Verified on a device with Android 10

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