Skip to content

Restore trip-change notification tap into the directions focus (#1939)#1940

Merged
bmander merged 1 commit into
mainfrom
restore-tripchange-notification-directions-1939
Jul 18, 2026
Merged

Restore trip-change notification tap into the directions focus (#1939)#1940
bmander merged 1 commit into
mainfrom
restore-tripchange-notification-directions-1939

Conversation

@bmander

@bmander bmander commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

What & why

Fixes #1939.

PR #1872 embedded directions into the home map and retired the standalone TripPlanScreen, whose maybeRestoreFromIntent was the only consumer of the trip-plan monitor's "your trip changed" notification intent. With that screen gone, tapping the alert opened generic HOME instead of the changed trip — a regression relative to pre-#1872 behavior.

The producer side was left intact and staged for this follow-up: TripPlanMonitorService.notifyChange still builds a HomeActivity intent carrying the simplified request bundle (copyIntoBundleSimple), the updated itineraries (OTPConstants.ITINERARIES, JSON), and OTPConstants.INTENT_SOURCE = Source.NOTIFICATION. Nothing in HOME read those extras. This PR re-adds the missing consumer.

Change

One file — HomeActivity.kt. A new maybeRestoreDirectionsFromIntent(intent) in the launch-intent side-effect path (applyLaunchIntentSideEffects, which runs once per real intent, cold and warm, lifecycle-gated to STARTED):

  • Guards strictly on INTENT_SOURCE == Source.NOTIFICATION (via IntentCompat.getSerializableExtra, avoiding the deprecated getSerializable so the strict warnings-as-errors gate stays green).
  • JSON-decodes ITINERARIES with String.toTripItineraries(); bails if empty.
  • Rehydrates the request via TripRequestBuilder.initFromBundleSimple.
  • Drives the two Activity-scoped VMs: homeViewModel.enterDirections() then tripPlanViewModel.restoreFrom(...), injecting the precomputed itineraries as PlanResult.Successno re-plan.

The existing directions render path (directions results sheet → map draw) reacts to the Directions focus + PlanResult.Success with no further changes. restoreFrom was already present but had no callers; this wires it up. Mirrors the deleted maybeRestoreFromIntent, and follows the same two-call shape as the recent long-press "directions from/to here" feature (#1938).

Notes

  • No re-restore guard needed: the launchIntents channel submits each real intent exactly once (cold onCreate seed gated on a null savedInstanceState, warm onNewIntent), so a config change doesn't re-fire the restore; the activity-scoped TripPlanViewModel keeps the results across rotation.
  • params = null (trip-update monitor not re-armed from the restore) matches pre-Trip planner: map-overlay layout (top-sheet form + bottom-sheet directions) #1872 behavior — out of scope here.
  • Kept the original's @Suppress("UnwrappedClockValue") + rationale for the "default to device now when the intent carries no time" fallback.

Verification

  • Compiles clean under the CI warning gate: ./gradlew :onebusaway-android:compileObaGoogleDebugKotlin -PwarningsAsErrors=true.
  • Manual end-to-end (not yet run on device): arm a trip watch → trigger a change so the notification fires → background the app → tap the alert. Expect HOME to open in the directions focus with the form pre-filled and the notification's itineraries shown + drawn on the map (no spinner/re-plan), for both cold-launch and warm-relaunch. Non-notification intents (add-region deep link, FCM reminders, ordinary launches) skip the new branch (strict INTENT_SOURCE + decodable ITINERARIES gate).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added support for restoring trip directions when opening a trip-change notification.
    • Restored itineraries, locations, travel date and time, and arrival preferences so updated trip details are readily available.
    • Automatically opens the Directions view with the refreshed trip plan.

PR #1872 embedded directions into the home map and retired the standalone
TripPlanScreen, whose maybeRestoreFromIntent was the only consumer of the
trip-plan monitor's "your trip changed" notification intent. With that gone,
tapping the alert opened generic HOME instead of the changed trip: the intent
still carried the request bundle (copyIntoBundleSimple), the updated itineraries
(OTPConstants.ITINERARIES, JSON), and INTENT_SOURCE=NOTIFICATION, but nothing in
HOME read them.

Re-add the consumer in HomeActivity's launch-intent side-effect path, driving
the Activity-scoped VMs instead of the retired screen's: guard on
INTENT_SOURCE=NOTIFICATION, JSON-decode the itineraries, rehydrate the request
via TripRequestBuilder.initFromBundleSimple, then enterDirections() +
TripPlanViewModel.restoreFrom(...) to inject the precomputed itineraries as
PlanResult.Success without re-planning. The existing directions render path
(results sheet + map draw) reacts with no further changes; the producer side and
restoreFrom were already intact.

No re-restore guard is needed: the launch-intent channel submits each real
intent exactly once (cold onCreate seed, warm onNewIntent), so a config change
doesn't re-fire it. params=null (monitor not re-armed from the restore) matches
pre-#1872 behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d35b8284-6862-4cb0-9655-baaa45ba616c

📥 Commits

Reviewing files that changed from the base of the PR and between f3bd405 and f14f34c.

📒 Files selected for processing (1)
  • onebusaway-android/src/main/java/org/onebusaway/android/ui/HomeActivity.kt

📝 Walkthrough

Walkthrough

HomeActivity now handles trip-change notification intents by rebuilding the directions request, decoding updated itineraries, entering directions focus, and restoring the trip planner state.

Changes

Notification trip restoration

Layer / File(s) Summary
Restore directions from notification intent
onebusaway-android/src/main/java/org/onebusaway/android/ui/HomeActivity.kt
HomeActivity detects notification launches, rebuilds the trip request from intent extras, decodes itineraries, enters directions focus, and restores the planner with geocoded locations, date-time, arrival mode, and itineraries.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Notification
  participant HomeActivity
  participant TripRequestBuilder
  participant TripPlanViewModel
  Notification->>HomeActivity: Launch with request and itinerary extras
  HomeActivity->>TripRequestBuilder: Rebuild trip request
  HomeActivity->>HomeActivity: Decode updated itineraries
  HomeActivity->>TripPlanViewModel: Restore directions state
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes restoring notification taps into the directions focus.
Linked Issues check ✅ Passed The changes match #1939 by restoring notification intents into directions, rehydrating the trip form, and injecting decoded itineraries without replanning.
Out of Scope Changes check ✅ Passed The diff appears limited to the notification-restore flow in HomeActivity with no unrelated changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch restore-tripchange-notification-directions-1939

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@bmander
bmander merged commit 05b2801 into main Jul 18, 2026
3 checks passed
@bmander
bmander deleted the restore-tripchange-notification-directions-1939 branch July 18, 2026 06:35
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.

Restore trip-change notification tap into the directions focus

1 participant