Updated to google-api-client-1.18.0-rc

pull/189/head
Alex Baker 11 years ago
parent 9819a9ed45
commit 0985536896

@ -80,26 +80,15 @@ dependencies {
compile project(":api")
compile fileTree(dir: "libs", includes: [
"framework.jar",
"google-api-services-tasks-v1-1.3.0-beta.jar",
"googleloginclient-helper.jar",
"jsr305.jar", // BSD-new
"rfc2445-4Mar2011.jar"
])
compile group: 'com.rubiconproject.oss', name: 'jchronic', version: '0.2.6', transitive: false // MIT
compile group: 'com.google.guava', name: 'guava', version: '11.0.1', transitive: false
compile group: 'com.google.code.gson', name: 'gson', version: '1.7.1', transitive: false
compile group: 'com.google.api-client', name: 'google-api-client', version: '1.6.0-beta', transitive: false
compile group: 'com.google.api-client', name: 'google-api-client-extensions', version: '1.6.0-beta', transitive: false
compile group: 'com.google.api-client', name: 'google-api-client-extensions-android2', version: '1.6.0-beta', transitive: false
compile group: 'com.google.http-client', name: 'google-http-client', version: '1.6.0-beta', transitive: false
compile group: 'com.google.http-client', name: 'google-http-client-extensions', version: '1.6.0-beta', transitive: false
compile group: 'com.google.http-client', name: 'google-http-client-extensions-android2', version: '1.6.0-beta', transitive: false
compile group: 'com.google.http-client', name: 'google-http-client-extensions-android3', version: '1.6.0-beta', transitive: false
compile group: 'com.google.oauth-client', name: 'google-oauth-client', version: '1.6.0-beta', transitive: false
compile group: 'com.google.oauth-client', name: 'google-oauth-client-extensions', version: '1.6.0-beta', transitive: false
compile group: 'com.google.apis', name: 'google-api-services-tasks', version: 'v1-rev33-1.18.0-rc'
compile group: 'com.google.api-client', name: 'google-api-client-android', version: '1.18.0-rc'
compile group: 'com.google.http-client', name: 'google-http-client-android', version: '1.18.0-rc'
compile group: 'com.google.http-client', name: 'google-http-client-gson', version: '1.18.0-rc'
androidTestCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.5', transitive: false // MIT
androidTestCompile group: 'com.google.dexmaker', name: 'dexmaker', version: '1.1'

Binary file not shown.

Binary file not shown.

@ -21,7 +21,7 @@ import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.api.client.googleapis.extensions.android2.auth.GoogleAccountManager;
import com.google.api.client.googleapis.extensions.android.accounts.GoogleAccountManager;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.utility.DialogUtilities;
@ -115,7 +115,7 @@ public class ActFmGoogleAuthActivity extends ListActivity {
if (bundle.containsKey(AccountManager.KEY_AUTHTOKEN)) {
authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);
if (!onSuccess) {
accountManager.manager.invalidateAuthToken(AUTH_TOKEN_TYPE, authToken);
accountManager.getAccountManager().invalidateAuthToken(AUTH_TOKEN_TYPE, authToken);
getAuthToken(a, pd);
onSuccess = true;
} else {
@ -146,7 +146,7 @@ public class ActFmGoogleAuthActivity extends ListActivity {
}.start();
}
};
accountManager.manager.getAuthToken(a, AUTH_TOKEN_TYPE, null, this, callback, null);
accountManager.getAccountManager().getAuthToken(a, AUTH_TOKEN_TYPE, null, this, callback, null);
}
private void onAuthCancel() {

@ -2,10 +2,9 @@ package com.todoroo.astrid.gtasks.api;
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.extensions.android.http.AndroidHttp;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.http.HttpResponseException;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.tasks.Tasks;
import com.google.api.services.tasks.Tasks.TasksOperations.Insert;
@ -34,35 +33,36 @@ public class GtasksInvoker {
private static final Logger log = LoggerFactory.getLogger(GtasksInvoker.class);
private Tasks service;
private GoogleAccessProtectedResource accessProtectedResource;
private GoogleCredential credential = new GoogleCredential();
private final GtasksTokenValidator gtasksTokenValidator;
private String token;
private final String key;
public static final String AUTH_TOKEN_TYPE = "Manage your tasks"; //"oauth2:https://www.googleapis.com/auth/tasks";
public GtasksInvoker(GtasksTokenValidator gtasksTokenValidator, String authToken) {
this.gtasksTokenValidator = gtasksTokenValidator;
this.token = authToken;
accessProtectedResource = new GoogleAccessProtectedResource(authToken);
JsonFactory jsonFactory = new GsonFactory();
Context context = ContextManager.getContext();
String key = context.getString(R.string.gapi_key);
service = new Tasks(AndroidHttp.newCompatibleTransport(), accessProtectedResource, jsonFactory);
service.setKey(key);
service.setApplicationName("Tasks");
key = context.getString(R.string.gapi_key);
credential.setAccessToken(authToken);
service = new Tasks.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential)
.setApplicationName("Tasks")
.build();
}
//If we get a 401 or 403, try revalidating the auth token before bailing
private synchronized void handleException(IOException e) throws IOException {
if (e instanceof HttpResponseException) {
HttpResponseException h = (HttpResponseException)e;
int statusCode = h.getResponse().getStatusCode();
log.error(statusCode + ": " + h.getResponse().getStatusMessage(), e);
int statusCode = h.getStatusCode();
log.error(statusCode + ": " + h.getStatusMessage(), e);
if (statusCode == 401 || statusCode == 403) {
token = gtasksTokenValidator.validateAuthToken(ContextManager.getContext(), token);
if (token != null) {
accessProtectedResource.setAccessToken(token);
credential.setAccessToken(token);
}
} else if (statusCode == 400 || statusCode == 500) {
throw h;
@ -84,16 +84,25 @@ public class GtasksInvoker {
* @throws IOException
*/
public void ping() throws IOException {
service.tasklists().get("@default").execute();
service.tasklists().get("@default")
.setOauthToken(token)
.setKey(key)
.execute();
}
public TaskLists allGtaskLists() throws IOException {
TaskLists toReturn = null;
try {
toReturn = service.tasklists().list().execute();
toReturn = service
.tasklists()
.list()
.setKey(key)
.execute();
} catch (IOException e) {
handleException(e);
toReturn = service.tasklists().list().execute();
toReturn = service.tasklists().list()
.setKey(key)
.execute();
} finally {
log("All gtasks lists", toReturn);
}
@ -103,10 +112,14 @@ public class GtasksInvoker {
public TaskList getGtaskList(String id) throws IOException {
TaskList toReturn = null;
try {
toReturn = service.tasklists().get(id).execute();
toReturn = service.tasklists().get(id)
.setKey(key)
.execute();
} catch (IOException e) {
handleException(e);
toReturn = service.tasklists().get(id).execute();
toReturn = service.tasklists().get(id)
.setKey(key)
.execute();
} finally {
log("Get gtask list, id: " + id, toReturn);
}
@ -118,10 +131,14 @@ public class GtasksInvoker {
newList.setTitle(title);
TaskList toReturn = null;
try {
toReturn = service.tasklists().insert(newList).execute();
toReturn = service.tasklists().insert(newList)
.setKey(key)
.execute();
} catch (IOException e) {
handleException(e);
toReturn = service.tasklists().insert(newList).execute();
toReturn = service.tasklists().insert(newList)
.setKey(key)
.execute();
} finally {
log("Create gtask list, title: " + title, toReturn);
}
@ -135,10 +152,14 @@ public class GtasksInvoker {
request.setShowHidden(includeHidden);
request.setUpdatedMin(GtasksApiUtilities.unixTimeToGtasksCompletionTime(lastSyncDate).toStringRfc3339());
try {
toReturn = request.execute();
toReturn = request
.setKey(key)
.execute();
} catch (IOException e) {
handleException(e);
toReturn = request.execute();
toReturn = request
.setKey(key)
.execute();
} finally {
log("Get all tasks, list: " + listId + ", include deleted: " + includeDeleted, toReturn);
}
@ -152,10 +173,14 @@ public class GtasksInvoker {
Task toReturn = null;
try {
toReturn = insertOp.execute();
toReturn = insertOp
.setKey(key)
.execute();
} catch (IOException e) {
handleException(e);
toReturn = insertOp.execute();
toReturn = insertOp
.setKey(key)
.execute();
} finally {
log("Creating gtask, title: " + task.getTitle(), toReturn);
}
@ -165,10 +190,18 @@ public class GtasksInvoker {
public void updateGtask(String listId, Task task) throws IOException {
Task toReturn = null;
try {
toReturn = service.tasks().update(listId, task.getId(), task).execute();
toReturn = service
.tasks()
.update(listId, task.getId(), task)
.setKey(key)
.execute();
} catch (IOException e) {
handleException(e);
toReturn = service.tasks().update(listId, task.getId(), task).execute();
toReturn = service
.tasks()
.update(listId, task.getId(), task)
.setKey(key)
.execute();
} finally {
log("Update gtask, title: " + task.getTitle(), toReturn);
}
@ -181,10 +214,14 @@ public class GtasksInvoker {
Task toReturn = null;
try {
toReturn = move.execute();
toReturn = move
.setKey(key)
.execute();
} catch (IOException e) {
handleException(e);
toReturn = move.execute();
toReturn = move
.setKey(key)
.execute();
} finally {
log("Move task " + taskId + "to parent: " + parentId + ", prior sibling: " + previousId, toReturn);
}
@ -193,10 +230,18 @@ public class GtasksInvoker {
public void deleteGtask(String listId, String taskId) throws IOException {
try {
service.tasks().delete(listId, taskId).execute();
service
.tasks()
.delete(listId, taskId)
.setKey(key)
.execute();
} catch (IOException e) {
handleException(e);
service.tasks().delete(listId, taskId).execute();
service
.tasks()
.delete(listId, taskId)
.setKey(key)
.execute();
} finally {
log("Delete task, id: " + taskId, null);
}

@ -20,7 +20,7 @@ import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.api.client.googleapis.extensions.android2.auth.GoogleAccountManager;
import com.google.api.client.googleapis.extensions.android.accounts.GoogleAccountManager;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
@ -132,7 +132,7 @@ public class GtasksLoginActivity extends InjectingListActivity {
}.start();
}
};
accountManager.manager.getAuthToken(a, GtasksInvoker.AUTH_TOKEN_TYPE, null, this, callback, null);
accountManager.getAccountManager().getAuthToken(a, GtasksInvoker.AUTH_TOKEN_TYPE, null, this, callback, null);
}
private void onAuthCancel() {

@ -13,7 +13,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.google.api.client.googleapis.extensions.android2.auth.GoogleAccountManager;
import com.google.api.client.googleapis.extensions.android.accounts.GoogleAccountManager;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.gtasks.api.GoogleTasksException;
@ -66,7 +66,7 @@ public class GtasksTokenValidator {
accountManager.invalidateAuthToken(token);
// try with notify-auth-failure = false
AccountManagerFuture<Bundle> future = accountManager.manager.getAuthToken(a, GtasksInvoker.AUTH_TOKEN_TYPE, false, null, null);
AccountManagerFuture<Bundle> future = accountManager.getAccountManager().getAuthToken(a, GtasksInvoker.AUTH_TOKEN_TYPE, false, null, null);
token = getTokenFromFuture(c, future);
if(TOKEN_INTENT_RECEIVED.equals(token)) {

Loading…
Cancel
Save