diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml
index 1644344d7..846786fdc 100644
--- a/astrid/AndroidManifest.xml
+++ b/astrid/AndroidManifest.xml
@@ -25,6 +25,7 @@
+
diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/api/GtasksService.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/api/GtasksService.java
index d75e364c0..e8c1195d4 100644
--- a/astrid/plugin-src/com/todoroo/astrid/gtasks/api/GtasksService.java
+++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/api/GtasksService.java
@@ -2,6 +2,9 @@ package com.todoroo.astrid.gtasks.api;
import java.io.IOException;
+import android.app.Activity;
+import android.content.Context;
+
import com.google.api.client.extensions.android2.AndroidHttp;
import com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAccessProtectedResource;
import com.google.api.client.http.HttpResponseException;
@@ -13,6 +16,12 @@ import com.google.api.services.tasks.v1.Tasks.TasksOperations.Move;
import com.google.api.services.tasks.v1.model.Task;
import com.google.api.services.tasks.v1.model.TaskList;
import com.google.api.services.tasks.v1.model.TaskLists;
+import com.timsu.astrid.R;
+import com.todoroo.andlib.service.Autowired;
+import com.todoroo.andlib.service.ContextManager;
+import com.todoroo.andlib.service.DependencyInjectionService;
+import com.todoroo.andlib.service.ExceptionService;
+import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator;
/**
@@ -27,11 +36,14 @@ public class GtasksService {
private GoogleAccessProtectedResource accessProtectedResource;
private String token;
+ @Autowired ExceptionService exceptionService;
+
private static final String API_KEY = "AIzaSyCIYZTBo6haRHxmiplZsfYdagFEpaiFnAk"; // non-production API key
public static final String AUTH_TOKEN_TYPE = "oauth2:https://www.googleapis.com/auth/tasks";
public GtasksService(String authToken) {
+ DependencyInjectionService.getInstance().inject(this);
authenticate(authToken);
}
@@ -45,7 +57,7 @@ public class GtasksService {
}
//If we get a 401 or 403, try revalidating the auth token before bailing
- private synchronized void handleException(IOException e) {
+ private synchronized void handleException(IOException e) throws IOException {
if (e instanceof HttpResponseException) {
HttpResponseException h = (HttpResponseException)e;
if (h.response.statusCode == 401 || h.response.statusCode == 403) {
@@ -53,6 +65,16 @@ public class GtasksService {
if (token != null) {
accessProtectedResource.setAccessToken(token);
}
+ } else if (h.response.statusCode == 503) { // 503 errors are generally either 1) quota limit reached or 2) problems on Google's end
+ final Context context = ContextManager.getContext();
+ String message = context.getString(R.string.gtasks_error_backend);
+ exceptionService.reportError(message, h);
+
+ if(context instanceof Activity) {
+ DialogUtilities.okDialog((Activity)context,
+ message, null);
+ }
+ throw h;
}
}
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncProvider.java
index 0db3943ae..fd4a48bcd 100644
--- a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncProvider.java
+++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncProvider.java
@@ -199,7 +199,7 @@ public class GtasksSyncProvider extends SyncProvider {
syncSuccess = true;
} catch (IllegalStateException e) {
// occurs when application was closed
- } catch (Exception e) {
+ } catch (IOException e) {
handleException("gtasks-sync", e, true); //$NON-NLS-1$
} finally {
StatisticsService.reportEvent("gtasks-sync-finished",
@@ -207,8 +207,7 @@ public class GtasksSyncProvider extends SyncProvider {
}
}
- private void getActiveList(TaskLists taskView) throws JSONException,
- IOException {
+ private void getActiveList(TaskLists taskView) throws IOException {
String listId;
if(taskView.items.size() == 0) {
if(Constants.DEBUG)
@@ -298,7 +297,7 @@ public class GtasksSyncProvider extends SyncProvider {
* Populate SyncData data structure
* @throws JSONException
*/
- private SyncData populateSyncData() throws JSONException, IOException {
+ private SyncData populateSyncData() throws IOException {
// fetch remote tasks
ArrayList remoteTasks = readAllRemoteTasks(false);
diff --git a/astrid/res/values/strings-gtasks.xml b/astrid/res/values/strings-gtasks.xml
index 4162e5e0a..94549a768 100644
--- a/astrid/res/values/strings-gtasks.xml
+++ b/astrid/res/values/strings-gtasks.xml
@@ -66,7 +66,7 @@
Error authenticating! Please check your username and password in your phone\'s account manager
-
+
You may have encountered a captcha.
Try logging in from the browser, then come back to try again:
@@ -84,6 +84,11 @@
Astrid: Google Tasks
+
+
+ Google\'s Task API is in beta and has encountered an error. The service may be down, please try again later.
+
+