WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@bmander
Copy link
Contributor

@bmander bmander commented Jun 26, 2025

Fix: Preserve stop selection state when navigating back from trip details

Summary

This PR fixes a UX issue where the selected stop would lose its selection state when navigating back from the "Show trip status" screen, affecting both arrival list navigation and vehicle info bubble navigation.

Problem Description

When users followed these flows, the selected stop would become unselected upon returning to the map:

  1. Arrival List Flow: Select stop → View arrivals → "Show trip status" → Back button → Stop selection lost
  2. Vehicle Bubble Flow: Select stop → "Show vehicles on map" → Click vehicle info bubble → Back button → Stop selection lost

The root cause was that TripDetailsActivity was being launched without proper up navigation mode, causing the back button to recreate HomeActivity instead of returning to the existing instance, which lost the preserved stop selection state.

Solution

Replace static TripDetailsActivity.start() calls with the Builder pattern and set UP_MODE_BACK to ensure proper back navigation:

Changes Made

1. ArrivalsListFragment.java

  • Updated goToTripDetails() method to use Builder pattern
  • Added .setUpMode(NavHelp.UP_MODE_BACK) for proper navigation

2. VehicleOverlay.java

  • Updated onInfoWindowClick() method to use Builder pattern
  • Added .setUpMode("back") for both with/without focused stop scenarios

Technical Details

  • Uses TripDetailsActivity.Builder instead of static start() methods
  • Sets up mode to "back" which makes NavHelp.goUp() call activity.finish() instead of recreating HomeActivity
  • Preserves the activity stack and state restoration flow
  • No functional changes to trip details display or behavior

This makes the back button work properly.

Ensure proper navigation between info window-launched TripDetailsActivity and map screen
@amrhossamdev amrhossamdev requested a review from Copilot June 26, 2025 21:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the way TripDetailsActivity is launched by replacing static start() calls with a Builder pattern to correctly preserve the stop selection state during back navigation.

  • Updated ArrivalsListFragment to use the Builder pattern with the constant NavHelp.UP_MODE_BACK.
  • Updated VehicleOverlay to use the Builder pattern with a string literal "back" for up mode.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListFragment.java Refactored trip details launch to use a Builder pattern with NavHelp.UP_MODE_BACK for up navigation mode.
onebusaway-android/src/google/java/org/onebusaway/android/map/googlemapsv2/VehicleOverlay.java Refactored trip details launch to use a Builder pattern; however, up mode is set as a string literal "back" instead of the constant.
Comments suppressed due to low confidence (1)

onebusaway-android/src/google/java/org/onebusaway/android/map/googlemapsv2/VehicleOverlay.java:536

  • Consider using the constant NavHelp.UP_MODE_BACK for setting up mode (instead of the string literal "back") to ensure consistency with ArrivalsListFragment.
                            .setUpMode("back")

@amrhossamdev amrhossamdev self-requested a review June 26, 2025 21:51
Copy link
Member

@amrhossamdev amrhossamdev left a comment

Choose a reason for hiding this comment

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

LGTM 🔥

@amrhossamdev amrhossamdev merged commit 62c6ede into OneBusAway:main Jun 27, 2025
2 checks passed
@bmander bmander deleted the brandon/fix-screens-switch-squash branch June 27, 2025 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants