Hook up gtasks login with modern auth manager

pull/14/head
Tim Su 14 years ago
parent 1193108523
commit 2fe3512ab9

@ -1,6 +1,7 @@
package com.todoroo.astrid.gtasks;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import com.google.android.googlelogin.GoogleLoginServiceConstants;
@ -8,6 +9,7 @@ import com.google.android.googlelogin.GoogleLoginServiceHelper;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.gtasks.auth.ModernAuthManager;
import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider;
import com.todoroo.astrid.sync.SyncProviderPreferences;
import com.todoroo.astrid.sync.SyncProviderUtilities;
@ -72,7 +74,10 @@ public class GtasksPreferences extends SyncProviderPreferences {
public void getCredentials(OnGetCredentials onGetCredentials) {
credentialsListener = onGetCredentials;
GoogleLoginServiceHelper.getAccount(this, REQUEST_CODE_GOOGLE, false);
if(Integer.parseInt(Build.VERSION.SDK) >= 7)
credentialsListener.getCredentials(ModernAuthManager.getAccounts(this));
else
GoogleLoginServiceHelper.getAccount(this, REQUEST_CODE_GOOGLE, false);
}
}

@ -207,4 +207,12 @@ public class ModernAuthManager implements AuthManager {
}).start();
}
}
public static String[] getAccounts(Activity activity) {
final Account[] accounts = AccountManager.get(activity).getAccountsByType("com.google"); //$NON-NLS-1$
String[] accountNames = new String[accounts.length];
for(int i = 0; i < accounts.length; i++)
accountNames[i] = accounts[i].name;
return accountNames;
}
}

Loading…
Cancel
Save