Code cleanup: move request code to AbstractSendToGoogleActivity

This commit is contained in:
Jimmy Shih
2013-06-24 16:46:42 -07:00
parent d8e0d4ab73
commit 60ce1916f6
5 changed files with 21 additions and 24 deletions
@@ -47,20 +47,14 @@ public class SendToGoogleUtils {
private static final String TAG = SendToGoogleUtils.class.getSimpleName();
// Request code to obtain Drive permission
public static final int DRIVE_PERMISSION_REQUEST_CODE = 1;
public static final String DRIVE_SCOPE = DriveScopes.DRIVE;
public static final int DRIVE_NOTIFICATION_ID = 1;
// Request code to obtain Fusion Tables permission
public static final int FUSION_TABLES_PERMISSION_REQUEST_CODE = 2;
public static final String FUSION_TABLES_SCOPE = FusiontablesScopes.FUSIONTABLES;
public static final int FUSION_TABLES_NOTIFICATION_ID = 2;
// Request code to obtain Spreadsheet permission
public static final int SPREADSHEET_PERMISSION_REQUEST_CODE = 3;
public static final String SPREADSHEET_SCOPE = "https://spreadsheets.google.com/feeds";
public static final int SPREADSHEET_NOTIFICATION_ID = 3;
public static final String SPREADSHEETS_SCOPE = "https://spreadsheets.google.com/feeds";
public static final int SPREADSHEETS_NOTIFICATION_ID = 3;
private SendToGoogleUtils() {}
@@ -103,7 +103,7 @@ public class SendSpreadsheetsAsyncTask extends AbstractSendAsyncTask {
Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod());
credential.setAccessToken(
SendToGoogleUtils.getToken(context, account.name, SendToGoogleUtils.SPREADSHEET_SCOPE));
SendToGoogleUtils.getToken(context, account.name, SendToGoogleUtils.SPREADSHEETS_SCOPE));
spreadsheetService.setOAuth2Credentials(credential);
Track track = myTracksProviderUtils.getTrack(trackId);
@@ -141,14 +141,14 @@ public class SendSpreadsheetsAsyncTask extends AbstractSendAsyncTask {
return true;
} catch (UserRecoverableAuthException e) {
SendToGoogleUtils.sendNotification(
context, account.name, e.getIntent(), SendToGoogleUtils.SPREADSHEET_NOTIFICATION_ID);
context, account.name, e.getIntent(), SendToGoogleUtils.SPREADSHEETS_NOTIFICATION_ID);
return false;
} catch (GoogleAuthException e) {
Log.e(TAG, "GoogleaAuthException", e);
return retryTask();
} catch (UserRecoverableAuthIOException e) {
SendToGoogleUtils.sendNotification(
context, account.name, e.getIntent(), SendToGoogleUtils.SPREADSHEET_NOTIFICATION_ID);
context, account.name, e.getIntent(), SendToGoogleUtils.SPREADSHEETS_NOTIFICATION_ID);
return false;
} catch (IOException e) {
Log.e(TAG, "IOException", e);