Add AddEmail after choosing an account.

This commit is contained in:
Jimmy Shih
2013-02-15 13:05:54 -08:00
parent d1db798f16
commit 15a2024614
16 changed files with 185 additions and 107 deletions
@@ -39,7 +39,7 @@ public class SendDriveActivity extends AbstractSendActivity {
@Override
protected AbstractSendAsyncTask createAsyncTask() {
return new SendDriveAsyncTask(
this, sendRequest.getTrackId(), sendRequest.getAccount(), sendRequest.getAcl());
this, sendRequest.getTrackId(), sendRequest.getAccount(), sendRequest.getDriveShareEmails());
}
@Override
@@ -17,6 +17,8 @@
package com.google.android.apps.mytracks.io.sendtogoogle;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.fragments.AddEmailsDialogFragment;
import com.google.android.apps.mytracks.fragments.AddEmailsDialogFragment.AddEmailsCaller;
import com.google.android.apps.mytracks.io.drive.SendDriveActivity;
import com.google.android.apps.mytracks.io.fusiontables.SendFusionTablesActivity;
import com.google.android.apps.mytracks.io.gdata.maps.MapsConstants;
@@ -39,6 +41,7 @@ import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.widget.Toast;
@@ -49,7 +52,7 @@ import java.io.IOException;
*
* @author Jimmy Shih
*/
public class AccountChooserActivity extends Activity {
public class AccountChooserActivity extends FragmentActivity implements AddEmailsCaller {
private static final String TAG = AccountChooserActivity.class.getSimpleName();
private static final int DIALOG_NO_ACCOUNT_ID = 0;
@@ -143,6 +146,17 @@ public class AccountChooserActivity extends Activity {
}
}
@Override
public void onAddEmailsDone(String emails) {
if (emails != null && !emails.equals("")) {
sendRequest.setDriveShareEmails(emails);
Intent intent = IntentUtils.newIntent(this, SendDriveActivity.class)
.putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
startActivity(intent);
}
finish();
}
/**
* Creates a chooser dialog.
*/
@@ -327,7 +341,13 @@ public class AccountChooserActivity extends Activity {
private void startNextActivity() {
Class<?> next;
if (sendRequest.isSendDrive()) {
next = SendDriveActivity.class;
if (sendRequest.isDriveShare()) {
AddEmailsDialogFragment.newInstance(sendRequest.getTrackId())
.show(getSupportFragmentManager(), AddEmailsDialogFragment.ADD_EMAILS_DIALOG_TAG);
return;
} else {
next = SendDriveActivity.class;
}
} else if (sendRequest.isSendMaps()) {
next = sendRequest.isNewMap() ? SendMapsActivity.class : ChooseMapActivity.class;
} else if (sendRequest.isSendFusionTables()) {
@@ -33,11 +33,12 @@ public class SendRequest implements Parcelable {
private long trackId = -1L;
private String sharingAppPackageName = null;
private String sharingAppClassName = null;
private String acl = null;
private boolean sendDrive = false;
private boolean sendMaps = false;
private boolean sendFusionTables = false;
private boolean sendSpreadsheets = false;
private boolean driveShare = false;
private String driveShareEmails = null;
private boolean newMap = false;
private Account account = null;
private String mapId = null;
@@ -94,22 +95,6 @@ public class SendRequest implements Parcelable {
this.sharingAppClassName = sharingAppClassName;
}
/**
* Gets the email address of the user to share the track with.
*/
public String getAcl() {
return acl;
}
/**
* Sets the email address of the user to share the track with.
*
* @param acl the email address
*/
public void setAcl(String acl) {
this.acl = acl;
}
/**
* True if the user has selected the send to Google Drive option.
*/
@@ -178,6 +163,22 @@ public class SendRequest implements Parcelable {
this.sendSpreadsheets = sendSpreadsheets;
}
public boolean isDriveShare() {
return driveShare;
}
public void setDriveShare(boolean driveShare) {
this.driveShare = driveShare;
}
public String getDriveShareEmails() {
return driveShareEmails;
}
public void setDriveShareEmails(String driveShareEmails) {
this.driveShareEmails = driveShareEmails;
}
/**
* True if the user has selected to create a new Google Maps.
*/
@@ -297,11 +298,12 @@ public class SendRequest implements Parcelable {
trackId = in.readLong();
sharingAppPackageName = in.readString();
sharingAppClassName = in.readString();
acl = in.readString();
sendDrive = in.readByte() == 1;
sendMaps = in.readByte() == 1;
sendFusionTables = in.readByte() == 1;
sendSpreadsheets = in.readByte() == 1;
driveShare = in.readByte() == 1;
driveShareEmails = in.readString();
newMap = in.readByte() == 1;
account = in.readParcelable(null);
mapId = in.readString();
@@ -321,11 +323,12 @@ public class SendRequest implements Parcelable {
out.writeLong(trackId);
out.writeString(sharingAppPackageName);
out.writeString(sharingAppClassName);
out.writeString(acl);
out.writeByte((byte) (sendDrive ? 1 : 0));
out.writeByte((byte) (sendMaps ? 1 : 0));
out.writeByte((byte) (sendFusionTables ? 1 : 0));
out.writeByte((byte) (sendSpreadsheets ? 1 : 0));
out.writeByte((byte) (driveShare ? 1 : 0));
out.writeString(driveShareEmails);
out.writeByte((byte) (newMap ? 1 : 0));
out.writeParcelable(account, 0);
out.writeString(mapId);