Page MenuHomePhabricator

If not disabled in preferences, use GPS to find nearby categories even when coordinates are not embedded in pictures (optional)
Closed, ResolvedPublic

Description

Optional task, aimed at enhancing location-based category suggestions, as many users do not enable location tagging in their camera.

Implement via either:

  1. If uploaded picture has no coordinates, show a 'GPS' button that users can tap to get their current location
  2. If uploaded picture has no coordinates, get user's current location automatically. Add option to enable/disable this feature in Preferences

If have extra time, add:

  • A map showing the location that allows the user to touch the real location

Plan:

  1. Get geolocation via method described here - http://stackoverflow.com/questions/1513485/how-do-i-get-the-current-gps-location-programmatically-in-android
  2. Another possible method of getting geolocation - http://android-developers.blogspot.co.nz/2011/06/deep-dive-into-location.html

Event Timeline

josephine_l claimed this task.
josephine_l raised the priority of this task from to Medium.
josephine_l updated the task description. (Show Details)
josephine_l moved this task from Backlog to Week-size tasks on the Commons-App-Android-Upload board.
josephine_l set Security to None.
josephine_l updated the task description. (Show Details)
josephine_l updated the task description. (Show Details)

Hi @Nicolas_Raoul,

@Niedzielski and I were discussing what we should do next, and we thought this task would be a good one for me to focus on this week. :) What do you think?

@Niedzielski (cc: @Nicolas_Raoul) I read the article that you linked me yesterday, and while it's definitely informative, I'm unsure about its suitability for our task. I don't think we need passive listeners or even listeners at all, since it seems to me that we only want to get the location once (upon image upload, if image has no coords), instead of listening for location updates like a Yelp or Foursquare app.

I implemented a simple method that just calls locationManager.getLastKnownLocation when an image is uploaded that has no coords. Submitted a pull request at https://github.com/nicolas-raoul/apps-android-commons/pull/55 . Do let me know if I'm on the right track, or if I'm off-base.

The preference to enable/disable this function is next on the to-do list.

getLastKnownLocation sounds like it might not get the correct location.

My understanding is that the listener is here to wait until a sufficient number of satellites is reached? or something like that?

If we start requestLocationUpdates immediately after we get the image, then there is probably enough time to get a fix while the user fills in the image title and description.

yaeh, getLastKnownLocation can actually return null IIRC (maybe try disabling location service and rebooting?). If you want something little less effort, maybe you can called LocationManager.requestSingleUpdate() in Activity / Fragment.onResume and just use the result if / when available.

@josephine_l, I think I would avoid the fused location provider unless you know it works on Amazon devices and you gracefully fallback for devices (like old emulators) that don't have Google Location Services.

@Niedzielski @Nicolas_Raoul - Thanks for the feedback. I've made a second attempt at implementing the location check, using a MyLocationListener subclass and onLocationChanged callback. Code is on the same pull request, do let me know what you think. It seems to work fine for me when I test it.

Also, I think I should be calling

locationManager.removeUpdates(this);

at some point but I can't figure out where would be best to put it?

Preference checking implemented and merged into the current pull request.

@josephine, nice :) I've followed up in the patch.

Thanks @Niedzielski ! Followed up on your follow-up. :)

josephine_l moved this task from Doing to Done on the Commons-App-Android-Upload board.