-
Notifications
You must be signed in to change notification settings - Fork 12
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
Fix back navigation issue from a secondary fragment to the map fragment #94
base: main
Are you sure you want to change the base?
Conversation
This change allows us creating a new instance of MapFragment even when MainActivity is resumed. Prior to this change creating another instance of MapFragment caused a crash from Activity#registerForActivityResult: java.lang.IllegalStateException: LifecycleOwner com.boolder.boolder.view.main.MainActivity@8aabcce is attempting to register while current state is RESUMED. LifecycleOwners must call register before they are STARTED.
This change fixes an annoying user experience issue - after opening MapFragment from a secondary screen it was not possible to get back to that secondary screen by pressing back button. The reason for this was that the back stack was popped up to the MapFragment destination which was assumed to be at the bottom of the stack. This commit changes this behavior and navigates to a new instance of MapFragment preserving the back stack - clicking on the back button from the new MapFragment would navigate the user back to the previous secondary screen. One consequence of this change is that now it's possible to get multiple instances of MapFragment on the back stack. While testing I couldn't find any issue with that and assume that it's not an issue.
Hello Sergey, |
Prior to this change pressing the back button on the topo bottom sheet would close the app (or navigate back in the back stack). This was a bit annoying as the standard UX behavior on Android should be closing the bottom sheet on back press click. Fix that by implementing a custom OnBackPressedCallback which is enabled while a topo is opened. I couldn't find a way of unselecting the problem in the view model and instead exposed the existing BoulderMap#unselectProblem method. I also added notifyListener parameter to it to automatically trigger the listener (if any). IMO it would be better to flip the default flag and set it to `true` and only use `false` where justified (I suppose in some cases we don't want to run bottom sheet toggle animations too often when, for example, selecting a new topo).
Hi @serso! 👋 First of all, thank you for your interest in the Boolder project! Can you provide two screen recordings that showcase the difference between the initial and the fixed behavior? |
Will do when I have time.
The second commit fixes the issue described in the PR. The third commit fixes another back press issue - when opening a topo from the map, pressing back doesn't close the topo but exits the app which is equally annoying to the original issue. |
@serso I just found out that some explanation was added in each commit, but I think you misunderstood the navigation of the app. The map fragment is not meant to be instantiated multiple times, as it is one of the start destinations that are accessible from the bottom navigation bar. Nevertheless, the fix on the back press with the topo bottom sheet being displayed is still relevant 👍 |
Here's the old and new new behavior on back press when a topo is opened from the map: Screen_recording_20240424_092747.mp4Screen_recording_20240424_092747.mp4Here's the old and new new behavior on back press when a topo is opened from a secondary screen: Screen_recording_20240424_092836.mp4Screen_recording_20240424_092511.mp4As you see from the videos above it was hard to quickly get back to the problems screen from the map once a problem was opened. You basically had to open the problems screen again. |
What exactly prevents the map fragment to be instantiated multiple times? This requirement makes it impossible to navigate If you don't want this navigation flow then the PR can be closed but, again, I find this behavior very annoying - it happened to me many times that the app closed while I tried to go back to the previous screen. A group of people I climbed with also mentioned this usability issue. |
The back stack should not be allowed to grow indefinitely, as it can have an impact on memory, and we also want to be able to run as smooth as possible on entry level devices. The navigation pattern that is proposed in this PR does not match the UX that we established in the app, but this is definitely an interesting point for a future redesign of the UX. We are actually curious about what motivates the need of having the list of problems right next to the map, and how this translates in physical usage in the forest. Anyway, we would like to thank you for your proposition, as any feedback is valuable for us! |
Why is that? I added a log statement in
As you see, as soon as
The way I used it was: I compiled a list of boulders I wanted to try at home, added them to projects and then went through the projects list in the forest. |
Reproduction steps:
Expected: Area/Problems screen is displayed
Actual: the app is closed