Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,25 @@ class ContributionController @Inject constructor(@param:Named("default_preferenc
) {
locationPermissionCallback = object : LocationPermissionCallback {
override fun onLocationPermissionDenied(toastMessage: String) {
Toast.makeText(
activity,
toastMessage,
Toast.LENGTH_LONG
).show()
showLongToast(activity, toastMessage)
initiateCameraUpload(activity, resultLauncher)
}

override fun onLocationPermissionGranted() {
if (!locationPermissionsHelper!!.isLocationAccessToAppsTurnedOn()) {
showLocationOffDialog(
activity, R.string.in_app_camera_needs_location,
R.string.in_app_camera_location_unavailable, resultLauncher
locationPermissionsHelper!!.showLocationOffDialog(
activity, R.string.in_app_camera_needs_location
)
} else {
initiateCameraUpload(activity, resultLauncher)
}
}

// Fix:impleement the new callback method
override fun onLocationServiceUnAvailable() {
showLongToast(activity, R.string.in_app_camera_location_unavailable)
initiateCameraUpload(activity, resultLauncher)
}
}

locationPermissionsHelper = LocationPermissionsHelper(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,11 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi
onLocationChanged(LocationChangeType.PERMISSION_JUST_GRANTED, null)
}

override fun onLocationServiceUnAvailable() {
//showw a message to the user explaining why nearby images aren't appearing
showLongToast(requireContext(), R.string.explore_map_needs_location)
}

fun onLocationChanged(locationChangeType: LocationChangeType, location: Location?) {
if (locationChangeType == LocationChangeType.PERMISSION_JUST_GRANTED) {
val curLatLng = locationManager.getLastLocation() ?: getMapCenter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,8 @@ class LocationPermissionsHelper(
activity.getString(R.string.cancel),
{ openLocationSettings(activity) },
{
Toast.makeText(
activity,
activity.getString(dialogTextResource),
Toast.LENGTH_LONG
).show()
//notify the controller that the service is unavailable
callback?.onLocationServiceUnAvailable()
}
)
}
Expand Down Expand Up @@ -195,5 +192,6 @@ class LocationPermissionsHelper(
interface LocationPermissionCallback {
fun onLocationPermissionDenied(toastMessage: String)
fun onLocationPermissionGranted()
fun onLocationServiceUnAvailable()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,14 @@ class LocationPickerActivity : BaseActivity(), LocationPermissionCallback {
}
}

override fun onLocationServiceUnAvailable() {
//notify the user that they must pick the location manually since theGPS is off
fr.free.nrw.commons.utils.ViewUtil.showLongToast(
this,
R.string.nearby_location_not_available
)
}

/**
* Adds a marker at the user's GPS location
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1949,6 +1949,11 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(),
override fun onLocationPermissionGranted() {
}

override fun onLocationServiceUnAvailable() {
//for nearby, we show a toast and perhaps show the map at the last known location
showLongToast(requireContext(), R.string.nearby_needs_location)
}

/**
* onLogoutComplete is called after shared preferences and data stored in local database are
* cleared.
Expand Down