|
|
|
|
@ -11,11 +11,14 @@ import org.tasks.data.MergedGeofence
|
|
|
|
|
import org.tasks.data.Place
|
|
|
|
|
import javax.inject.Inject
|
|
|
|
|
|
|
|
|
|
class GeofenceClient @Inject constructor(@ApplicationContext private val context: Context) {
|
|
|
|
|
@Suppress("unused")
|
|
|
|
|
class AndroidGeofencing @Inject constructor(
|
|
|
|
|
@ApplicationContext private val context: Context
|
|
|
|
|
): Geofencing {
|
|
|
|
|
private val client = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager
|
|
|
|
|
|
|
|
|
|
@SuppressLint("MissingPermission")
|
|
|
|
|
fun addGeofences(@Suppress("UNUSED_PARAMETER") geofence: MergedGeofence) {
|
|
|
|
|
override fun addGeofences(geofence: MergedGeofence) {
|
|
|
|
|
client.addProximityAlert(
|
|
|
|
|
geofence.latitude,
|
|
|
|
|
geofence.longitude,
|
|
|
|
|
@ -25,7 +28,7 @@ class GeofenceClient @Inject constructor(@ApplicationContext private val context
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun removeGeofences(@Suppress("UNUSED_PARAMETER") place: Place) {
|
|
|
|
|
override fun removeGeofences(place: Place) {
|
|
|
|
|
client.removeProximityAlert(createPendingIntent(place.id))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -33,7 +36,7 @@ class GeofenceClient @Inject constructor(@ApplicationContext private val context
|
|
|
|
|
PendingIntent.getBroadcast(
|
|
|
|
|
context,
|
|
|
|
|
0,
|
|
|
|
|
Intent(context, GeofenceTransitionsIntentService.Broadcast::class.java)
|
|
|
|
|
Intent(context, AndroidGeofenceTransitionIntentService.Broadcast::class.java)
|
|
|
|
|
.setData(Uri.parse("tasks://geofence/$place")),
|
|
|
|
|
PendingIntent.FLAG_UPDATE_CURRENT
|
|
|
|
|
)
|