Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Feature/kak/add geofencing#44 #73

Merged

Conversation

flibbertigibbet
Copy link
Contributor

@flibbertigibbet flibbertigibbet commented Jun 5, 2018

Overview

Add geofences when user flags a place or an event with an associated destination as "want to go". Remove geofences when flag changes to something else. Add geofences back after reboot. Send a notification when user enters a geofenced area. Notification links in to the detail page for the place or event.

Demo

screenshot_1528172229

Notes

Device location settings must be set to "high accuracy" for geofence events to fire.

Testing

  • On app launch, system settings for location will open if "high accuracy" not set (emulator default is "device only")
  • Flag a place or event "want to go"
  • Send a location to the emulator within 300 meters of the place
  • Open Maps to cause the device to request location
  • Location may need to be sent repeatedly for device location to move to place
  • Should receive notification that links to detail page

Closes #44
Closes #45

Copy link
Contributor

@maurizi maurizi left a comment

Choose a reason for hiding this comment

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

This is looking great, and working well! I tested both the production mode by going to a nearby destination as well as the debug mode in the emulator and they both worked as expected 🎉

I left a few small notes, but they're fairly small - fell free to merge this w/o another round of review.


// Sanity check the data before starting the worker
if (latitudes.length == 0 || latitudes.length != longitudes.length ||
latitudes.length != labels.length) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check names.length as well?

} else if (haveExistingGeofence) {
Log.e(LOG_LABEL, "Removing geofence from event list");
RemoveGeofenceWorker.removeOneGeofence(String.valueOf(eventInfo.getAttraction().getId()));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This same code pattern pattern shows up in several activities. Consider pulling it out into a helper method that takes AttractionInfo and haveExistingGeofence parameters.

// https://developer.android.com/training/location/geofencing
// TODO: geofences should be re-registered on PROVIDERS_CHANGED
// but implicit system broadcast cannot read DB in background to find
// what to fence.
Copy link
Contributor

Choose a reason for hiding this comment

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

Reminder to create an issue for any follow-up here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#75

@@ -65,8 +65,6 @@ protected void saveCallResult(@NonNull DestinationQueryResponse response) {
item.setDestination(null);
}
item.setTimestamp(timestamp);
// TODO: Remove
if (item.getDestination() != null && item.getDestination() == 20) { continue; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing this! 😊

Listen to broadcasts to add geofences or handle geofence transitions.
Add method that does not require Activity context to get last known location.
Not needed by any background workers yet.
Set up dependency injection for reading from database to find geofences to add
when setting them up again after reboot.
Start listening to geofence on flag set in UI.
Send simple notification on geofence entry or exit.
Open details on notification tap.
Include place name in notification message.
Add worker to remove geofences after user unselects "want to go" for a place,
and also to re-register geofences on exit.
Ensure background task gets released after worker started.
Intent callbacks for geofences may return places not added with the registered callback intent, so its data
must come from the database on handling the event.
@flibbertigibbet flibbertigibbet force-pushed the feature/kak/add-geofencing#44 branch from c9f463e to ca4a9ba Compare June 6, 2018 18:56
@flibbertigibbet flibbertigibbet merged commit c4b3081 into azavea:develop Jun 6, 2018
@flibbertigibbet flibbertigibbet deleted the feature/kak/add-geofencing#44 branch June 6, 2018 18:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants