Fixing cupcake uploading by not referencing the Account object.

This commit is contained in:
Rodrigo Damazio
2011-08-01 14:46:51 -03:00
parent d9a1e56282
commit 097b338d19
5 changed files with 31 additions and 8 deletions
@@ -24,7 +24,6 @@ import com.google.android.apps.mytracks.io.mymaps.MapsFacade;
import com.google.android.apps.mytracks.io.mymaps.MyMapsConstants;
import com.google.android.maps.mytracks.R;
import android.accounts.Account;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
@@ -96,14 +95,13 @@ public class MyMapsList extends Activity implements MapsFacade.MapsListCallback
return;
}
Account account = new Account(accountName, accountType);
doLogin(account);
doLogin(auth.getAccountObject(accountName, accountType));
} else {
doLogin(null);
}
}
private void doLogin(final Account account) {
private void doLogin(final Object account) {
// Starts in the UI thread.
auth.doLogin(new AuthCallback() {
@Override
@@ -81,4 +81,13 @@ public interface AuthManager {
* is successfully fetched
*/
void invalidateAndRefresh(AuthCallback whenFinished);
/**
* Returns an object that represents the given account, if possible.
*
* @param accountName the name of the account
* @param accountType the type of the account
* @return the account object
*/
Object getAccountObject(String accountName, String accountType);
}
@@ -133,4 +133,9 @@ public class AuthManagerOld implements AuthManager {
}
});
}
@Override
public Object getAccountObject(String accountName, String accountType) {
throw new UnsupportedOperationException("Legacy auth manager knows nothing about accounts");
}
}
@@ -213,4 +213,9 @@ public class ModernAuthManager implements AuthManager {
}).start();
}
}
@Override
public Object getAccountObject(String accountName, String accountType) {
return new Account(accountName, accountType);
}
}
@@ -118,7 +118,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
// Authentication
private AuthManager lastAuth;
private final HashMap<String, AuthManager> authMap = new HashMap<String, AuthManager>();
private final AccountChooser accountChooser = new AccountChooser();
private AccountChooser accountChooser;
private String lastAccountName;
private String lastAccountType;
@@ -268,9 +268,6 @@ public class SendActivity extends Activity implements ProgressIndicator {
lastAccountName = savedInstanceState.getString(STATE_ACCOUNT_NAME);
lastAccountType = savedInstanceState.getString(STATE_ACCOUNT_TYPE);
if (lastAccountName != null && lastAccountType != null) {
accountChooser.setChosenAccount(lastAccountName, lastAccountType);
}
}
@Override
@@ -762,6 +759,15 @@ public class SendActivity extends Activity implements ProgressIndicator {
}
private void chooseAccount(final int requestCode, final String service) {
if (accountChooser == null) {
accountChooser = new AccountChooser();
// Restore state if necessary.
if (lastAccountName != null && lastAccountType != null) {
accountChooser.setChosenAccount(lastAccountName, lastAccountType);
}
}
accountChooser.chooseAccount(SendActivity.this,
new AccountChooser.AccountHandler() {
@Override