diff --git a/build.gradle b/build.gradle index 69fd98eef..081ff38d8 100644 --- a/build.gradle +++ b/build.gradle @@ -27,8 +27,8 @@ android { buildToolsVersion "22.0.1" defaultConfig { - versionCode 357 - versionName "4.7.9" + versionCode 358 + versionName "4.7.10" minSdkVersion 7 targetSdkVersion 22 } diff --git a/src/googleplay/AndroidManifest.xml b/src/googleplay/AndroidManifest.xml index 68ad93ca9..e103d8092 100644 --- a/src/googleplay/AndroidManifest.xml +++ b/src/googleplay/AndroidManifest.xml @@ -12,6 +12,7 @@ + diff --git a/src/googleplay/java/org/tasks/dialogs/LocationPickerDialog.java b/src/googleplay/java/org/tasks/dialogs/LocationPickerDialog.java index b38d69094..70432bfbd 100644 --- a/src/googleplay/java/org/tasks/dialogs/LocationPickerDialog.java +++ b/src/googleplay/java/org/tasks/dialogs/LocationPickerDialog.java @@ -46,7 +46,6 @@ public class LocationPickerDialog extends InjectingDialogFragment { @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - managedGoogleApi.requestGeoData(); managedGoogleApi.connect(); View layout = inflater.inflate(R.layout.location_picker_dialog, null); diff --git a/src/googleplay/java/org/tasks/location/GeofenceApi.java b/src/googleplay/java/org/tasks/location/GeofenceApi.java index ceb7b171c..c9c8eab13 100644 --- a/src/googleplay/java/org/tasks/location/GeofenceApi.java +++ b/src/googleplay/java/org/tasks/location/GeofenceApi.java @@ -89,9 +89,7 @@ public class GeofenceApi { } private void newClient(final GoogleApi.GoogleApiClientConnectionHandler handler) { - new GoogleApi(context) - .requestLocationServices() - .connect(handler); + new GoogleApi(context).connect(handler); } private List getRequests(List geofences) { diff --git a/src/googleplay/java/org/tasks/location/GeofenceTransitionsIntentService.java b/src/googleplay/java/org/tasks/location/GeofenceTransitionsIntentService.java index 600146a35..6f326e48a 100644 --- a/src/googleplay/java/org/tasks/location/GeofenceTransitionsIntentService.java +++ b/src/googleplay/java/org/tasks/location/GeofenceTransitionsIntentService.java @@ -3,6 +3,8 @@ package org.tasks.location; import android.content.Intent; import com.google.android.gms.location.GeofencingEvent; +import com.todoroo.astrid.dao.MetadataDao; +import com.todoroo.astrid.data.Metadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,8 +19,8 @@ public class GeofenceTransitionsIntentService extends InjectingIntentService { private static final Logger log = LoggerFactory.getLogger(GeofenceTransitionsIntentService.class); - @Inject GeofenceService geofenceService; @Inject Broadcaster broadcaster; + @Inject MetadataDao metadataDao; public GeofenceTransitionsIntentService() { super(GeofenceTransitionsIntentService.class.getSimpleName()); @@ -47,11 +49,13 @@ public class GeofenceTransitionsIntentService extends InjectingIntentService { } private void triggerNotification(com.google.android.gms.location.Geofence triggeringGeofence) { + String requestId = triggeringGeofence.getRequestId(); try { - Geofence geofence = geofenceService.getGeofenceById(Long.parseLong(triggeringGeofence.getRequestId())); + Metadata fetch = metadataDao.fetch(Long.parseLong(requestId), Metadata.TASK, GeofenceFields.PLACE, GeofenceFields.LATITUDE, GeofenceFields.LONGITUDE, GeofenceFields.RADIUS); + Geofence geofence = new Geofence(fetch); broadcaster.requestNotification(geofence.getMetadataId(), geofence.getTaskId()); } catch(Exception e) { - log.error(e.getMessage(), e); + log.error(String.format("Error triggering geofence %s: %s", requestId, e.getMessage()), e); } } } \ No newline at end of file diff --git a/src/googleplay/java/org/tasks/location/GoogleApi.java b/src/googleplay/java/org/tasks/location/GoogleApi.java index 796ae084c..af0c679e9 100644 --- a/src/googleplay/java/org/tasks/location/GoogleApi.java +++ b/src/googleplay/java/org/tasks/location/GoogleApi.java @@ -31,19 +31,11 @@ public class GoogleApi implements GoogleApiClient.OnConnectionFailedListener, Go @Inject public GoogleApi(@ForApplication Context context) { builder = new GoogleApiClient.Builder(context, this, this) + .addApi(LocationServices.API) + .addApi(Places.GEO_DATA_API) .addConnectionCallbacks(this); } - public GoogleApi requestLocationServices() { - builder.addApi(LocationServices.API); - return this; - } - - public GoogleApi requestGeoData() { - builder.addApi(Places.GEO_DATA_API); - return this; - } - public void connect(final GoogleApiClientConnectionHandler googleApiClientConnectionHandler) { this.googleApiClientConnectionHandler = googleApiClientConnectionHandler; googleApiClient = builder.build(); diff --git a/src/googleplay/java/org/tasks/location/ManagedGoogleApi.java b/src/googleplay/java/org/tasks/location/ManagedGoogleApi.java index 41cd0c1ba..00f1f5993 100644 --- a/src/googleplay/java/org/tasks/location/ManagedGoogleApi.java +++ b/src/googleplay/java/org/tasks/location/ManagedGoogleApi.java @@ -66,13 +66,12 @@ public class ManagedGoogleApi extends GoogleApi implements GoogleApi.GoogleApiCl } public void getPlaceDetails(final String placeId, final ResultCallback callback) { - Places.GeoDataApi.getPlaceById(googleApiClient, placeId) - .setResultCallback(new ResultCallback() { - @Override - public void onResult(PlaceBuffer places) { - callback.onResult(places); - } - }, 15, TimeUnit.SECONDS); + Places.GeoDataApi.getPlaceById(googleApiClient, placeId).setResultCallback(new ResultCallback() { + @Override + public void onResult(PlaceBuffer places) { + callback.onResult(places); + } + }); } public void getAutocompletePredictions(final String constraint, final ResultCallback callback) { @@ -91,6 +90,7 @@ public class ManagedGoogleApi extends GoogleApi implements GoogleApi.GoogleApiCl Location lastLocation = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); return new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()); } catch (Exception e) { + log.error(e.getMessage(), e); return new LatLng(0, 0); } } diff --git a/src/googleplay/res/values/bools.xml b/src/googleplay/res/values-v9/bools.xml similarity index 100% rename from src/googleplay/res/values/bools.xml rename to src/googleplay/res/values-v9/bools.xml diff --git a/src/main/java/com/todoroo/andlib/utility/AndroidUtilities.java b/src/main/java/com/todoroo/andlib/utility/AndroidUtilities.java index 06432c7de..215a8893b 100644 --- a/src/main/java/com/todoroo/andlib/utility/AndroidUtilities.java +++ b/src/main/java/com/todoroo/andlib/utility/AndroidUtilities.java @@ -367,10 +367,6 @@ public class AndroidUtilities { return !atLeastJellybean(); } - public static boolean preLollipop() { - return !atLeastLollipop(); - } - public static boolean atLeastFroyo() { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO; } diff --git a/src/main/java/org/tasks/location/GeofenceService.java b/src/main/java/org/tasks/location/GeofenceService.java index a2ae9569b..aa0213a6d 100644 --- a/src/main/java/org/tasks/location/GeofenceService.java +++ b/src/main/java/org/tasks/location/GeofenceService.java @@ -39,10 +39,6 @@ public class GeofenceService { this.geofenceApi = geofenceApi; } - public Geofence getGeofenceById(long metadataId) { - return new Geofence(metadataDao.fetch(metadataId, Metadata.TASK, GeofenceFields.PLACE, GeofenceFields.LATITUDE, GeofenceFields.LONGITUDE, GeofenceFields.RADIUS)); - } - public List getGeofences(long taskId) { return toGeofences(metadataDao.toList(Query.select( Metadata.PROPERTIES).where(MetadataCriteria.byTaskAndwithKey(