Skip to content

feat(connectivity): know whether the device is online in the listing form - #388

Merged
thanna23 merged 16 commits into
mainfrom
feature/listing-connectivity
Nov 19, 2026
Merged

thanna23 merged 16 commits into
mainfrom
feature/listing-connectivity

Conversation

@thanna23

@thanna23 thanna23 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part of #365. The listing form now knows whether the device is online, so the map picker in #369 can be disabled offline. Split out of #366 after review, since it isn't part of #364. Builds on #366 (review that first); #369 builds on this one.

What

  • ConnectivityRepository: an interface exposing isOnline as a StateFlow<Boolean>. AndroidConnectivityRepository follows the default network and counts it as online only once it is validated.
  • Permission: ACCESS_NETWORK_STATE in the manifest.
  • ListingFormViewModel: takes a ConnectivityRepository (interface only) and exposes isOnline in the form state. It is followed live and never saved.
  • Wiring: one AndroidConnectivityRepository for the whole process, created in MainActivity and passed through AppNavHost to both listing forms. It is never released, because the forms' ViewModels outlive a rotated activity and its network callback should be registered only once. FakeConnectivityRepository is added in sharedTest.

Why

Choosing a location on the map needs map tiles, so the picker should be disabled offline with a hint, while the rest of the form keeps working. It was first in #366, but the review pointed out that nothing there reads isOnline, so it moves next to the UI that uses it.

Validation

  • ./gradlew ktfmtCheck check: passes, lint included (run on feat(listing): choose the pickup location or meeting place on a map #369 rebased on top of this branch).
  • AndroidConnectivityRepositoryTest checks that it starts offline without a validated internet network and then follows the default network. ListingFormViewModelTest checks that isOnline follows the repository and is kept when the edited listing loads and when the form resets after saving.

AI use

Claude Code (Claude Opus 5.5) wrote the repository and the wiring with me and tested them. After the #366 review, it moved these commits into this PR and resolved the conflicts with main. I reviewed the diff.

thanna23 and others added 14 commits November 17, 2026 21:35
A point within 600 m of the EPFL or UNIL centre is named \"EPFL campus\" or \"UNIL campus\", the nearer one winning.
The picker opens on the chosen or saved location, else the lender's approximate location, else EPFL. A campus name is dropped when the pin moves off campus, and a blank name blocks saving. Wire FusedLocationRepository into both listing forms.
Add ConnectivityRepository and its Android version, which follows the default network and counts it as online only once validated. Part of #364.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The form state exposes isOnline, followed live and never saved, so the location picker can be disabled offline. One ConnectivityRepository per process is passed through AppNavHost to both forms. Part of #364.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the conflicts where the location repository is passed to AppNavHost, next to the photo-message chat repository and the booking repository from main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reverts 69be9ba. Nothing reads isOnline yet, and it isn't part of #364: it moves to its own PR next to the map picker (#365), which disables the picker offline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reverts 62728eb (ConnectivityRepository, its Android version and fake, and the ACCESS_NETWORK_STATE permission). Not part of #364; it moves to its own PR with #365.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… device

The LocationRepository KDoc and the ACCESS_COARSE_LOCATION comment said the location is never stored, but the listing form now keeps it in its saved state to reopen the map picker there after the app is killed. It is still never sent to the backend.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Like the price and refund, showLocationNameError now waits for leaveLocationNameField(), so picking a point off campus no longer shows an error before the lender can type a name. Saving stays blocked while the name is blank. clearLocation() resets the flag, and it survives the app being killed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add ConnectivityRepository and its Android version, which follows the default network and counts it as online only once validated. Part of #364.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The form state exposes isOnline, followed live and never saved, so the location picker can be disabled offline. One ConnectivityRepository per process is passed through AppNavHost to both forms. Part of #364.

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

@adrimikh adrimikh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The repository cleanly isolates Android connectivity behind a StateFlow, and the form observes it live without saving it into the draft. Requiring a validated network is a reasonable way to avoid treating a captive portal as online.
I just requested a change and everything will be good.

Base automatically changed from feature/listing-location-form-state to main November 19, 2026 15:25
thanna23 and others added 2 commits November 19, 2026 16:29
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
During a Wi-Fi/mobile handoff, the old network's onLost can arrive after
the new one became the default. The repository now remembers the current
default network and only reports offline when that one is lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@adrimikh adrimikh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@thanna23
thanna23 merged commit 3b05753 into main Nov 19, 2026
3 checks passed
@thanna23
thanna23 deleted the feature/listing-connectivity branch November 19, 2026 15:42
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