Skip to content

Refactor: Centralize location service unavailability handling and resolve technical debt #6611

@Kota-Jagadeesh

Description

@Kota-Jagadeesh

Description

The Problem

  • Currently, the ContributionController contains a TODO to move its location service handling logic into the shared LocationPermissionsHelper. The controller is manually building a showLocationOffDialog because the existing LocationPermissionCallback interface does not have a way to notify the caller when a user declines to turn on system GPS/Location services. This leads to redundant UI code and inconsistent logic across different parts of the app like Nearby, Explore, and the In-app camera.

Proposed Changes

I have refactored the location flow to centralize this behavior:

  • Enhanced Callback: Added onLocationServiceUnAvailable() to the LocationPermissionCallback interface in LocationPermissionsHelper.kt.
  • Helper Logic: Updated LocationPermissionsHelper.showLocationOffDialog to trigger this new callback when the user selects "Cancel" on the system settings prompt.
  • Controller Cleanup: Removed the redundant dialog logic from ContributionController.kt and utilized the new callback to handle the camera upload fallback.
  • App-wide Consistency: Implemented the required callback method in ExploreMapFragment, LocationPickerActivity, and NearbyParentFragment to ensure a unified response when location services are unavailable.

Impact

  • Resolves long-standing technical debt in the contribution flow.
  • Ensures that if a user cancels a location prompt, the app reacts predictably (showing a toast and allowing manual override) instead of potentially hanging or requiring custom logic in every fragment.

Steps to Reproduce

  1. Turn off system Location/GPS on the device.
  2. Open the app and attempt to take a photo via the in-app camera.
  3. When prompted to turn on location, tap "Cancel".
  4. Current result (Technical Debt): The controller has to manually handle this to open the camera.
  5. Expected result (Post-refactor): The Helper manages the dialog and tells the controller to open the camera via the new callback signal.

Part of #6508

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions