Skip to content

feat(listing): choose the pickup location or meeting place on a map - #369

Merged
thanna23 merged 4 commits into
mainfrom
feature/listing-location-form-ui
Nov 19, 2026
Merged

thanna23 merged 4 commits into
mainfrom
feature/listing-location-form-ui

Conversation

@thanna23

@thanna23 thanna23 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #365. Part of #339 (2 of 2). Lenders can now choose where a listing is offered: "Pickup location" for items, "Meeting place" for services. They pick it on a full-screen map in the create and edit forms, then name the place. Builds on #366, which holds the form logic, and #388, which tells the form whether the device is online (review those first)

What

  • One location field below the availability field:
    • With no location, "Choose on the map" opens the picker.
    • Once a point is set, the same row becomes the editable place name ("Name the place…", counter n/80, error "Give the place a name." when blank), with "Move the pin" and "Remove location" beside it.
    • It is disabled while the form can't be edited or is saving.
  • Full-screen picker:
    • A map with a pin fixed in the centre, opening on the saved point, else the lender's approximate location, else EPFL.
    • "Confirm location" sets the point under the pin. Close and system back save nothing, and the picker stays open where it was after rotation.
  • "Show my location":
    • Asks for ACCESS_COARSE_LOCATION only when tapped. Once granted, the map shows the device and asks the form for the lender's position.
    • The camera follows that position until the lender moves the map. The comparison allows about 1 m, because Google Maps writes back a slightly different target after layout.
  • Offline:
    • "Choose on the map", "Move the pin" and "Confirm location" are disabled, with "Connect to the internet to choose a location" shown under the field.
    • Removing or renaming the place still works, and so does the rest of the form.
  • Wiring: ListingFormActions gets five location callbacks connected to the ViewModel, including onLocationNameFieldLeft, so the "Give the place a name." error shows once the name field loses focus, like price and refund. CreateListingContent and EditListingContent take a locationMap, so tests can use a fake map instead of Google Maps.
  • Resources: ic_map_pin.xml and the location strings.

Why

#338 let a listing store and show a location, and #366 let the form set one, but lenders had no way to choose it. Renters need to know where to pick up an item or meet for a service. The location stays optional, so the form still works offline and without the location permission.

Validation

  • ./gradlew ktfmtCheck check: passes.
  • ListingLocationFieldTest uses Robolectric with a fake map and a fake permission registry. It covers:
    • field states, the place name, the counter and the error;
    • disabled states while saving, after a load error and offline;
    • confirming, panning, close and back, and recreation;
    • the camera follow, including a fake map that writes back a slightly shifted target like Google Maps;
    • the permission refused, granted and already granted;
    • end to end through a real ViewModel: create with a typed name, and edit picking UNIL.

Follow-ups

  • "Don't ask again" (no issue yet): after the lender picks it on the permission prompt, "Show my location" does nothing. It could point to the app settings.

AI use

Claude Code (Claude Opus 5.5) planned the change with me, then ran three agents:

  • Coder: wrote the field, the picker, the offline handling, and the single-field redesign I asked for.
  • Tester: wrote the Robolectric tests, including the test that imitates Google Maps shifting the camera slightly, and measured coverage.
  • Reviewer: reviewed each round. It caught the exact-equality camera check that would have stopped the map following the lender on real devices, and asked for a test of "Confirm" being disabled offline.

It then rebased this PR onto #388 after the #366 review and wired leaveLocationNameField() to the name field.

I reviewed the changes and can explain them.

@thanna23
thanna23 changed the base branch from main to feature/listing-location-form-state November 17, 2026 20:34
@thanna23
thanna23 added this pull request to stack #370 November 17, 2026 20:34
@thanna23
thanna23 force-pushed the feature/listing-location-form-ui branch from fa5b722 to 4cbbe91 Compare November 17, 2026 20:35
@thanna23
thanna23 marked this pull request as ready for review November 17, 2026 20:35
@thanna23
thanna23 marked this pull request as draft November 17, 2026 20:36
@thanna23 thanna23 self-assigned this Nov 17, 2026
@thanna23
thanna23 force-pushed the feature/listing-location-form-ui branch from 4cbbe91 to b219328 Compare November 19, 2026 11:13
@thanna23
thanna23 removed this pull request from stack #370 November 19, 2026 11:18
@thanna23
thanna23 changed the base branch from feature/listing-location-form-state to feature/listing-connectivity November 19, 2026 11:18
@thanna23
thanna23 added this pull request to stack #389 November 19, 2026 11:18
@thanna23
thanna23 marked this pull request as ready for review November 19, 2026 11:41
Base automatically changed from feature/listing-connectivity to main November 19, 2026 15:42

@Julkzein Julkzein 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.

Really nice feature: one field that turns from "Choose on the map" into the editable place name, a centred pin whose tip is placed exactly (the 5/12 offset checks out), "Show my location" asking for coarse location only when tapped, and the ~1 m tolerance because Google Maps writes back a slightly different target, which is a subtle catch. Offline handling is clear too: picking needs the internet, renaming and removing don't. The tests are thorough, especially the fake map that shifts the camera like Google Maps.

Two blocking points: the branch no longer merges cleanly with main (below), and the picker's Google map is likely to crash on Android 9+ (inline). Also, GitHub counts +1750 because #366 and #388 are still in the branch's history even though they're merged; once main is merged in, the real diff should drop to around 950 lines, mostly tests, which is fine.

One coordination note: my #392 (Map tab) also adds locationRepository to AppNavHost and builds FusedLocationRepository in MainActivity, the same way you do. Whichever of us merges second will just keep one copy.

Important: Merging main into this branch gives conflicts in 9 files. Most come from #366 and #388 being squash merged (ConnectivityRepository and its test, AppNavHost, the navigation tests, ListingFormViewModelTest), so main's versions can be taken there. Two clash with #357/#358, which are on main now: ic_map_pin.xml is the same icon with another comment, so one copy is enough, but this fake has a different API on main (location, failure, gate, calls), and the map tests use it. Could you keep main's version and set failure (or location) in your tests instead of result? Happy to help with the merge if you want.

@Composable (camera: CameraPositionState, showMyLocation: Boolean) -> Unit

val DefaultListingLocationMap: ListingLocationMap = { camera, showMyLocation ->
GoogleMap(

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.

Important: I believe this GoogleMap will crash on Android 9+ devices: on #391, an instrumented test opening a GoogleMap on the CI emulator (API 34) failed with NoClassDefFoundError: org/apache/http/ProtocolVersion from Play Services' Maps module, which still uses Apache HTTP. Google's fix is <uses-library android:name="org.apache.http.legacy" android:required="false"/> in the manifest's <application>; #391 adds it, but this PR doesn't depend on it. Since the picker isn't run on a device by the tests, could you add the line here (or we make sure #391 lands first)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good catch. I added the org.apache.http.legacy to the manifest, copied exactly from #391, so whichever of the two merges second won't conflict on it.

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.

Perfect, same line as #391 so no conflict whichever lands first, thanks!

thanna23 and others added 4 commits November 19, 2026 17:35
Add one location field, opens a full-screen picker with a fixed centre pin, and once a point is set the field becomes the editable place name with buttons to move the pin or remove it. \"Show my location\" asks for the approximate location only when tapped, and the map follows the lender's position until they move it. Offline, choosing on the map is disabled with a hint, while removing or renaming the place still works
#366 now shows the location name error only after leaveLocationNameField(), like price and refund. Call it when the name field loses focus, so the error appears after the lender leaves the field blank instead of never.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thanna23
thanna23 force-pushed the feature/listing-location-form-ui branch from ad7243c to 3c3f3a5 Compare November 19, 2026 16:36
@sonarqubecloud

Copy link
Copy Markdown

@Julkzein Julkzein 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.

After the back and forth this looks good to me: main is merged in cleanly (the fake keeps main's API, one ic_map_pin), and the picker now loads Apache HTTP for Google Maps on Android 9+. The real diff is down to +911/−5. Only follow-up is the "Don't ask again" case you listed. lgtm.

@thanna23
thanna23 merged commit 462170f into main Nov 19, 2026
3 checks passed
@thanna23
thanna23 deleted the feature/listing-location-form-ui branch November 19, 2026 17:23
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.

Choose the location on a map in Create/Edit listing

2 participants