Made progress in gtasks sync pre-Android 2.1. We can get a token, but it doesn't seem to work

pull/14/head
Tim Su 14 years ago
parent 3fda486a50
commit bb4635f0a0

@ -15,6 +15,6 @@
<classpathentry exported="true" kind="lib" path="libs/rfc2445-no-joda.jar"/>
<classpathentry exported="true" kind="lib" path="libs/locale_platform.jar"/>
<classpathentry exported="true" kind="lib" path="libs/todoroo-g.jar"/>
<classpathentry kind="lib" path="libs/googleloginclient-helper.jar"/>
<classpathentry kind="lib" path="libs/framework.jar"/>
<classpathentry kind="output" path="ecbuild"/>
</classpath>

Binary file not shown.

@ -1,8 +1,13 @@
package com.todoroo.astrid.gtasks;
import android.content.Intent;
import android.os.Bundle;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.gtasks.auth.AuthManager;
import com.todoroo.astrid.gtasks.auth.AuthManagerFactory;
import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider;
import com.todoroo.astrid.sync.SyncProviderPreferences;
import com.todoroo.astrid.sync.SyncProviderUtilities;
@ -18,11 +23,33 @@ public class GtasksPreferences extends SyncProviderPreferences {
@Autowired private GtasksPreferenceService gtasksPreferenceService;
private static final int REQUEST_CODE_GOOGLE = 1;
private final AuthManager authManager = AuthManagerFactory.getAuthManager(
this, REQUEST_CODE_GOOGLE, new Bundle(), false, "goanna_mobile"); //$NON-NLS-1$
public GtasksPreferences() {
super();
DependencyInjectionService.getInstance().inject(this);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQUEST_CODE_GOOGLE){
authManager.authResult(resultCode, data);
}
}
public AuthManager getAuthManager() {
return authManager;
}
@Override
public int getPreferenceResource() {
return R.xml.preferences_gtasks;

@ -22,8 +22,8 @@ import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.google.android.googlelogindist.GoogleLoginServiceConstants;
import com.google.android.googlelogindist.GoogleLoginServiceHelper;
import com.google.android.googlelogin.GoogleLoginServiceConstants;
import com.google.android.googlelogin.GoogleLoginServiceHelper;
/**
* AuthManager keeps track of the current auth token for a user. The advantage
@ -106,6 +106,7 @@ public class AuthManagerOld implements AuthManager {
private class LoginRunnable implements Runnable {
@Override
public void run() {
GoogleLoginServiceHelper.getCredentials(
activity, code, extras, requireGoogle, service, true);
}

@ -16,7 +16,6 @@ import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.flurry.android.FlurryAgent;
@ -43,8 +42,6 @@ import com.todoroo.astrid.gtasks.GtasksMetadataService;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.gtasks.GtasksPreferences;
import com.todoroo.astrid.gtasks.GtasksTaskListUpdater;
import com.todoroo.astrid.gtasks.auth.AuthManager;
import com.todoroo.astrid.gtasks.auth.AuthManagerFactory;
import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.sync.SyncBackgroundService;
import com.todoroo.astrid.sync.SyncContainer;
@ -80,8 +77,7 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
AstridDependencyInjector.initialize();
}
@Autowired
protected ExceptionService exceptionService;
@Autowired protected ExceptionService exceptionService;
public GtasksSyncProvider() {
super();
@ -128,6 +124,7 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
// occurs when network error
} else if(!(e instanceof GoogleTasksException) && e instanceof IOException) {
message = context.getString(R.string.SyP_ioerror);
exceptionService.reportError(tag + "-ioexception", e); //$NON-NLS-1$
} else {
message = context.getString(R.string.DLG_error, e.toString());
exceptionService.reportError(tag + "-unhandled", e); //$NON-NLS-1$
@ -181,17 +178,15 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
// check if we have a token & it works
if(authToken == null) {
try {
final AuthManager authManager = AuthManagerFactory.getAuthManager(
activity, 0, new Bundle(), true, "goanna_mobile");
authManager.invalidateAndRefresh(new Runnable() {
final GtasksPreferences preferenceActivity = (GtasksPreferences)activity;
preferenceActivity.getAuthManager().invalidateAndRefresh(new Runnable() {
@Override
public void run() {
String token = authManager.getAuthToken();
String token = preferenceActivity.getAuthManager().getAuthToken();
if(token != null) {
gtasksPreferenceService.setToken(token);
//activity.startService(new Intent(SyncBackgroundService.SYNC_ACTION, null,
// activity, GtasksBackgroundService.class));
System.err.println("yay! " + token);
activity.startService(new Intent(SyncBackgroundService.SYNC_ACTION, null,
activity, GtasksBackgroundService.class));
activity.finish();
}
}

@ -35,7 +35,7 @@
android:key="@string/sync_SPr_forget_key"
android:title="@string/sync_SPr_forget"
android:summary="@string/sync_SPr_forget_description" />
</PreferenceCategory>
</PreferenceScreen>

@ -26,6 +26,7 @@ public class AstridPreferences {
Preferences.setIfUnset(prefs, editor, r, R.string.p_default_reminders_key, 6);
Preferences.setIfUnset(prefs, editor, r, R.string.p_rmd_default_random_hours, 0);
Preferences.setIfUnset(prefs, editor, r, R.string.p_fontSize, 20);
Preferences.setIfUnset(prefs, editor, r, R.string.p_showNotes, false);
editor.commit();
}

Loading…
Cancel
Save