Skip to content

Fix location handling for gallery uploads in Nearby flow#6739

Open
devendrachoudharycodes wants to merge 1 commit intocommons-app:mainfrom
devendrachoudharycodes:fix/nearby-location-issue-5073
Open

Fix location handling for gallery uploads in Nearby flow#6739
devendrachoudharycodes wants to merge 1 commit intocommons-app:mainfrom
devendrachoudharycodes:fix/nearby-location-issue-5073

Conversation

@devendrachoudharycodes
Copy link
Contributor

When selecting an image from the gallery for Nearby uploads, the selected place location was not automatically applied.

This happened because the previous condition contained !isInAppCameraUpload. Since gallery images are not captured using the in-app camera, !isInAppCameraUpload evaluated to true, causing the location validation block to always execute and preventing the selected nearby location from being applied.

Additionally, the location difference check relies on LOCATION_BEFORE_IMAGE_CAPTURE i.e. prevLocation, which is only passed in the intent when an image is captured using the in-app camera. For gallery uploads this value is not available, so the distance validation is not applicable.

Fixes #5073

The condition was updated to remove !isInAppCameraUpload and instead apply the distance validation only when the image is captured using the in-app camera:
(isInAppCameraUpload && locationDifference > 100)

This ensures that:

  1. Distance validation runs only for in-app camera uploads.
  2. Gallery uploads skip the location difference check since LOCATION_BEFORE_IMAGE_CAPTURE is not passed in the intent.
  3. The selected nearby location is correctly applied for gallery uploads.

Tested ProdDebug on Pixel 5 emulator with API level 33.

Steps tested:

  1. Open Nearby places.
  2. Select a nearby location.
  3. Choose an image from the gallery.
  4. Verified that the selected place location is automatically applied on the upload screen.

Screenshot
Before
image

After
image

Copy link
Contributor

@Shoaibkhalid65 Shoaibkhalid65 left a comment

Choose a reason for hiding this comment

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

The fix looks correct. Combining isInAppCameraUpload && locationDifference > 100 properly gates the distance check to camera-only uploads. One thought: since LOCATION_BEFORE_IMAGE_CAPTURE is never passed in the intent for gallery uploads, it might be worth adding a brief inline comment on this condition explaining why the distance check is skipped for gallery — makes the intent clearer for future contributors. Otherwise the logic is sound and the fix addresses the root cause cleanly.

…images since capture location is not passed in intent from Nearby to Upload screeand comments to the code for future ref
@devendrachoudharycodes devendrachoudharycodes force-pushed the fix/nearby-location-issue-5073 branch from b0b4346 to 462d29c Compare March 16, 2026 04:31
@devendrachoudharycodes
Copy link
Contributor Author

@Shoaibkhalid65 thanks for pointing it out just did that 😊.. please check this out

@github-actions
Copy link

✅ Generated APK variants!

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.

Nearby upload via gallery: Always no location

2 participants