diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml index ac43b0ec1..ba5ea27ac 100644 --- a/MyTracks/res/values/strings.xml +++ b/MyTracks/res/values/strings.xml @@ -1184,6 +1184,12 @@ limitations under the License. Character limit: ~20 (1 line)"> Share + + Sync to Google Drive + Switch account - - All files in the %1$s Google Drive ‘%2$s’ folder will be imported as new tracks. If - not desired, move the files to a different folder beforehand. - All tracks will be synced to %1$s Google Drive - - Sync to Google Drive - Total time - - - + + + + All files in the %1$s Google Drive ‘%2$s’ folder will be imported as new tracks. If + not desired, move the files to a different folder beforehand. + + This will allow you to view your tracks in Google Drive and view the tracks shared with you. All tracks synced to Google Drive will be private by default. - + Sync with Google Drive? - + + android:title="@string/menu_sync_drive" /> \ No newline at end of file diff --git a/MyTracks/src/com/google/android/apps/mytracks/AbstractSendToGoogleActivity.java b/MyTracks/src/com/google/android/apps/mytracks/AbstractSendToGoogleActivity.java index 341686e42..ef4796642 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/AbstractSendToGoogleActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/AbstractSendToGoogleActivity.java @@ -22,6 +22,8 @@ import com.google.android.apps.mytracks.fragments.ChooseAccountDialogFragment; import com.google.android.apps.mytracks.fragments.ChooseAccountDialogFragment.ChooseAccountCaller; import com.google.android.apps.mytracks.fragments.ConfirmDialogFragment; import com.google.android.apps.mytracks.fragments.ConfirmDialogFragment.ConfirmCaller; +import com.google.android.apps.mytracks.fragments.ConfirmSyncDialogFragment; +import com.google.android.apps.mytracks.fragments.ConfirmSyncDialogFragment.ConfirmSyncCaller; import com.google.android.apps.mytracks.fragments.InstallEarthDialogFragment; import com.google.android.apps.mytracks.fragments.ShareTrackDialogFragment; import com.google.android.apps.mytracks.fragments.ShareTrackDialogFragment.ShareTrackCaller; @@ -65,7 +67,7 @@ import java.io.IOException; * @author Jimmy Shih */ public abstract class AbstractSendToGoogleActivity extends AbstractMyTracksActivity implements - ChooseAccountCaller, CheckPermissionCaller, ShareTrackCaller, ConfirmCaller { + ChooseAccountCaller, ConfirmSyncCaller, CheckPermissionCaller, ShareTrackCaller, ConfirmCaller { private static final String TAG = AbstractMyTracksActivity.class.getSimpleName(); private static final String SEND_REQUEST_KEY = "send_request_key"; @@ -132,27 +134,39 @@ public abstract class AbstractSendToGoogleActivity extends AbstractMyTracksActiv } sendRequest.setAccount(new Account(googleAccount, Constants.ACCOUNT_TYPE)); - // Check Drive permission - boolean needDrivePermission = sendRequest.isSendDrive(); - if (!needDrivePermission && sendRequest.isSendFusionTables()) { - needDrivePermission = PreferencesUtils.getBoolean(this, - R.string.export_google_fusion_tables_public_key, - PreferencesUtils.EXPORT_GOOGLE_FUSION_TABLES_PUBLIC_DEFAULT); - } - if (!needDrivePermission) { - needDrivePermission = sendRequest.isSendSpreadsheets(); - } - - if (needDrivePermission) { - Fragment fragment = CheckPermissionFragment.newInstance( - sendRequest.getAccount().name, SendToGoogleUtils.DRIVE_SCOPE); - getSupportFragmentManager() - .beginTransaction().add(fragment, CheckPermissionFragment.CHECK_PERMISSION_TAG).commit(); + if (sendRequest.isSendDrive() && sendRequest.isDriveSync() && sendRequest.isDriveSyncConfirm()) { + new ConfirmSyncDialogFragment().show( + getSupportFragmentManager(), ConfirmSyncDialogFragment.CONFIRM_SYNC_DIALOG_TAG); } else { - onDrivePermissionSuccess(); + onConfirmSyncDone(true); } } + @Override + public void onConfirmSyncDone(boolean enable) { + if (enable) { + // Check Drive permission + boolean needDrivePermission = sendRequest.isSendDrive(); + if (!needDrivePermission && sendRequest.isSendFusionTables()) { + needDrivePermission = PreferencesUtils.getBoolean(this, + R.string.export_google_fusion_tables_public_key, + PreferencesUtils.EXPORT_GOOGLE_FUSION_TABLES_PUBLIC_DEFAULT); + } + if (!needDrivePermission) { + needDrivePermission = sendRequest.isSendSpreadsheets(); + } + + if (needDrivePermission) { + Fragment fragment = CheckPermissionFragment.newInstance( + sendRequest.getAccount().name, SendToGoogleUtils.DRIVE_SCOPE); + getSupportFragmentManager().beginTransaction() + .add(fragment, CheckPermissionFragment.CHECK_PERMISSION_TAG).commit(); + } else { + onDrivePermissionSuccess(); + } + } + } + @Override public void onCheckPermissionDone(String scope, boolean success, Intent intent) { if (success) { diff --git a/MyTracks/src/com/google/android/apps/mytracks/TrackListActivity.java b/MyTracks/src/com/google/android/apps/mytracks/TrackListActivity.java index a9b9112a8..e65db3318 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/TrackListActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/TrackListActivity.java @@ -19,10 +19,10 @@ package com.google.android.apps.mytracks; import com.google.android.apps.mytracks.content.MyTracksProviderUtils; import com.google.android.apps.mytracks.content.Track; import com.google.android.apps.mytracks.content.TracksColumns; -import com.google.android.apps.mytracks.fragments.ConfirmSyncDialogFragment; -import com.google.android.apps.mytracks.fragments.ConfirmSyncDialogFragment.ConfirmSyncCaller; import com.google.android.apps.mytracks.fragments.DeleteTrackDialogFragment; import com.google.android.apps.mytracks.fragments.DeleteTrackDialogFragment.DeleteTrackCaller; +import com.google.android.apps.mytracks.fragments.EnableSyncDialogFragment; +import com.google.android.apps.mytracks.fragments.EnableSyncDialogFragment.EnableSyncCaller; import com.google.android.apps.mytracks.fragments.EulaDialogFragment; import com.google.android.apps.mytracks.fragments.EulaDialogFragment.EulaCaller; import com.google.android.apps.mytracks.fragments.FileTypeDialogFragment; @@ -93,7 +93,7 @@ import java.util.Locale; * @author Leif Hendrik Wilden */ public class TrackListActivity extends AbstractSendToGoogleActivity - implements EulaCaller, ConfirmSyncCaller, DeleteTrackCaller, FileTypeCaller { + implements EulaCaller, EnableSyncCaller, DeleteTrackCaller, FileTypeCaller { private static final String TAG = TrackListActivity.class.getSimpleName(); private static final int GOOGLE_PLAY_SERVICES_REQUEST_CODE = 0; @@ -293,10 +293,10 @@ public class TrackListActivity extends AbstractSendToGoogleActivity // Menu items private MenuItem searchMenuItem; private MenuItem startGpsMenuItem; - private MenuItem importAllMenuItem; - private MenuItem exportAllMenuItem; - private MenuItem deleteAllMenuItem; private MenuItem refreshMenuItem; + private MenuItem exportAllMenuItem; + private MenuItem importAllMenuItem; + private MenuItem deleteAllMenuItem; private MenuItem feedbackMenuItem; private boolean startGps = false; // true to start gps @@ -469,10 +469,10 @@ public class TrackListActivity extends AbstractSendToGoogleActivity searchMenuItem = menu.findItem(R.id.track_list_search); startGpsMenuItem = menu.findItem(R.id.track_list_start_gps); - importAllMenuItem = menu.findItem(R.id.track_list_import_all); - exportAllMenuItem = menu.findItem(R.id.track_list_export_all); - deleteAllMenuItem = menu.findItem(R.id.track_list_delete_all); refreshMenuItem = menu.findItem(R.id.track_list_refresh); + exportAllMenuItem = menu.findItem(R.id.track_list_export_all); + importAllMenuItem = menu.findItem(R.id.track_list_import_all); + deleteAllMenuItem = menu.findItem(R.id.track_list_delete_all); feedbackMenuItem = menu.findItem(R.id.track_list_feedback); feedbackMenuItem.setVisible(ApiAdapterFactory.getApiAdapter().isGoogleFeedbackAvailable()); @@ -533,27 +533,37 @@ public class TrackListActivity extends AbstractSendToGoogleActivity } myTracksLocationManager.close(); return true; - case R.id.track_list_import_all: - FileTypeDialogFragment.newInstance(R.id.track_list_import_all, - R.string.import_selection_title, R.string.import_selection_option, 2) - .show(getSupportFragmentManager(), FileTypeDialogFragment.FILE_TYPE_DIALOG_TAG); + case R.id.track_list_refresh: + if (driveSync) { + SyncUtils.syncNow(this); + } else { + PreferencesUtils.setString( + this, R.string.google_account_key, PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT); + SendRequest sendRequest = new SendRequest(-1L); + sendRequest.setSendDrive(true); + sendRequest.setDriveSync(true); + sendRequest.setDriveSyncConfirm(true); + sendToGoogle(sendRequest); + } + return true; + case R.id.track_list_aggregated_statistics: + intent = IntentUtils.newIntent(this, AggregatedStatsActivity.class); + startActivity(intent); return true; case R.id.track_list_export_all: FileTypeDialogFragment.newInstance(R.id.track_list_export_all, R.string.export_all_title, R.string.export_all_option, 4) .show(getSupportFragmentManager(), FileTypeDialogFragment.FILE_TYPE_DIALOG_TAG); return true; + case R.id.track_list_import_all: + FileTypeDialogFragment.newInstance(R.id.track_list_import_all, + R.string.import_selection_title, R.string.import_selection_option, 2) + .show(getSupportFragmentManager(), FileTypeDialogFragment.FILE_TYPE_DIALOG_TAG); + return true; case R.id.track_list_delete_all: DeleteTrackDialogFragment.newInstance(true, new long[] {}) .show(getSupportFragmentManager(), DeleteTrackDialogFragment.DELETE_TRACK_DIALOG_TAG); return true; - case R.id.track_list_aggregated_statistics: - intent = IntentUtils.newIntent(this, AggregatedStatsActivity.class); - startActivity(intent); - return true; - case R.id.track_list_refresh: - SyncUtils.syncNow(this); - return true; case R.id.track_list_settings: intent = IntentUtils.newIntent(this, SettingsActivity.class); startActivity(intent); @@ -693,17 +703,16 @@ public class TrackListActivity extends AbstractSendToGoogleActivity private void showEnableSync() { if (EulaUtils.getShowEnableSync(this)) { Fragment fragment = getSupportFragmentManager() - .findFragmentByTag(ConfirmSyncDialogFragment.CONFIRM_SYNC_DIALOG_TAG); + .findFragmentByTag(EnableSyncDialogFragment.ENABLE_SYNC_DIALOG_TAG); if (fragment == null) { - ConfirmSyncDialogFragment.newInstance( - R.string.sync_enable_title, getString(R.string.sync_enable_message)) - .show(getSupportFragmentManager(), ConfirmSyncDialogFragment.CONFIRM_SYNC_DIALOG_TAG); + new EnableSyncDialogFragment().show( + getSupportFragmentManager(), EnableSyncDialogFragment.ENABLE_SYNC_DIALOG_TAG); } } } @Override - public void onConfirmSyncDone(boolean enable) { + public void onEnableSyncDone(boolean enable) { EulaUtils.setShowEnableSync(this); if (enable) { SendRequest sendRequest = new SendRequest(-1L); @@ -728,18 +737,18 @@ public class TrackListActivity extends AbstractSendToGoogleActivity isGpsStarted ? R.drawable.menu_stop_gps : R.drawable.menu_start_gps); } } - if (importAllMenuItem != null) { - importAllMenuItem.setVisible(!isRecording); + if (refreshMenuItem != null) { + refreshMenuItem.setTitle(driveSync ? R.string.menu_refresh : R.string.menu_sync_drive); } if (exportAllMenuItem != null) { exportAllMenuItem.setVisible(!isRecording); } + if (importAllMenuItem != null) { + importAllMenuItem.setVisible(!isRecording); + } if (deleteAllMenuItem != null) { deleteAllMenuItem.setVisible(!isRecording); } - if (refreshMenuItem != null) { - refreshMenuItem.setVisible(driveSync); - } } /** diff --git a/MyTracks/src/com/google/android/apps/mytracks/fragments/ConfirmSyncDialogFragment.java b/MyTracks/src/com/google/android/apps/mytracks/fragments/ConfirmSyncDialogFragment.java index 8d55797cc..89867d894 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/fragments/ConfirmSyncDialogFragment.java +++ b/MyTracks/src/com/google/android/apps/mytracks/fragments/ConfirmSyncDialogFragment.java @@ -50,22 +50,9 @@ public class ConfirmSyncDialogFragment extends DialogFragment { public static final String CONFIRM_SYNC_DIALOG_TAG = "confirmSyncDialog"; - private static final String KEY_TITLE_ID = "titleId"; - private static final String KEY_MESSAGE = "message"; - private ConfirmSyncCaller caller; private FragmentActivity fragmentActivity; - public static ConfirmSyncDialogFragment newInstance(int titleId, String message) { - Bundle bundle = new Bundle(); - bundle.putInt(KEY_TITLE_ID, titleId); - bundle.putString(KEY_MESSAGE, message); - - ConfirmSyncDialogFragment confirmSyncDialogFragment = new ConfirmSyncDialogFragment(); - confirmSyncDialogFragment.setArguments(bundle); - return confirmSyncDialogFragment; - } - @Override public void onAttach(Activity activity) { super.onAttach(activity); @@ -91,8 +78,10 @@ public class ConfirmSyncDialogFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - int titleId = getArguments().getInt(KEY_TITLE_ID); - String message = getArguments().getString(KEY_MESSAGE); + String googleAccount = PreferencesUtils.getString( + fragmentActivity, R.string.google_account_key, PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT); + String message = getString( + R.string.sync_drive_confirm_message, googleAccount, getString(R.string.my_tracks_app_name)); return new AlertDialog.Builder(fragmentActivity).setMessage(message) .setNegativeButton(R.string.generic_no, new OnClickListener() { @Override @@ -104,7 +93,7 @@ public class ConfirmSyncDialogFragment extends DialogFragment { public void onClick(DialogInterface dialog, int which) { caller.onConfirmSyncDone(true); } - }).setTitle(titleId).create(); + }).setTitle(R.string.sync_drive_title).create(); } @Override diff --git a/MyTracks/src/com/google/android/apps/mytracks/fragments/EnableSyncDialogFragment.java b/MyTracks/src/com/google/android/apps/mytracks/fragments/EnableSyncDialogFragment.java new file mode 100644 index 000000000..d19a0e2f6 --- /dev/null +++ b/MyTracks/src/com/google/android/apps/mytracks/fragments/EnableSyncDialogFragment.java @@ -0,0 +1,99 @@ +/* + * Copyright 2013 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.android.apps.mytracks.fragments; + +import com.google.android.apps.mytracks.util.PreferencesUtils; +import com.google.android.maps.mytracks.R; + +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; +import android.os.Bundle; +import android.support.v4.app.DialogFragment; +import android.support.v4.app.FragmentActivity; + +/** + * A DialogFrament to enable sync to Google Drive. + * + * @author Jimmy Shih + */ +public class EnableSyncDialogFragment extends DialogFragment { + + /** + * Interface for caller of this dialog fragment. + * + * @author Jimmy Shih + */ + public interface EnableSyncCaller { + + /** + * Called when enable sync is done. + */ + public void onEnableSyncDone(boolean enable); + } + + public static final String ENABLE_SYNC_DIALOG_TAG = "enableSyncDialog"; + + private EnableSyncCaller caller; + private FragmentActivity fragmentActivity; + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + try { + caller = (EnableSyncCaller) activity; + } catch (ClassCastException e) { + throw new ClassCastException( + activity.toString() + " must implement " + EnableSyncCaller.class.getSimpleName()); + } + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + fragmentActivity = getActivity(); + if (PreferencesUtils.getBoolean( + fragmentActivity, R.string.drive_sync_key, PreferencesUtils.DRIVE_SYNC_DEFAULT)) { + dismiss(); + caller.onEnableSyncDone(false); + return; + } + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + return new AlertDialog.Builder(fragmentActivity).setMessage(R.string.sync_drive_enable_message) + .setNegativeButton(R.string.generic_no, new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + caller.onEnableSyncDone(false); + } + }).setPositiveButton(R.string.generic_yes, new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + caller.onEnableSyncDone(true); + } + }).setTitle(R.string.sync_drive_title).create(); + } + + @Override + public void onCancel(DialogInterface arg0) { + caller.onEnableSyncDone(false); + } +} diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/SendRequest.java b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/SendRequest.java index f64c39f37..3fbd2ed0e 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/SendRequest.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/SendRequest.java @@ -36,7 +36,8 @@ public class SendRequest implements Parcelable { private boolean sendFusionTables = false; private boolean sendSpreadsheets = false; - private boolean driveSync = false; // to enable Drive sync + private boolean driveSync = false; // to enable Drive sync + private boolean driveSyncConfirm = false; private boolean driveShare = false; // to enable Drive share private String driveShareEmails = null; // for driveShare, emails to share private boolean driveSharePublic = false; // for driveShare, share as public @@ -102,6 +103,14 @@ public class SendRequest implements Parcelable { this.driveSync = driveSync; } + public boolean isDriveSyncConfirm() { + return driveSyncConfirm; + } + + public void setDriveSyncConfirm(boolean driveSyncConfirm) { + this.driveSyncConfirm = driveSyncConfirm; + } + public boolean isDriveShare() { return driveShare; } @@ -181,6 +190,7 @@ public class SendRequest implements Parcelable { sendFusionTables = in.readByte() == 1; sendSpreadsheets = in.readByte() == 1; driveSync = in.readByte() == 1; + driveSyncConfirm = in.readByte() == 1; driveShare = in.readByte() == 1; driveShareEmails = in.readString(); driveSharePublic = in.readByte() == 1; @@ -205,6 +215,7 @@ public class SendRequest implements Parcelable { out.writeByte((byte) (sendFusionTables ? 1 : 0)); out.writeByte((byte) (sendSpreadsheets ? 1 : 0)); out.writeByte((byte) (driveSync ? 1 : 0)); + out.writeByte((byte) (driveSyncConfirm ? 1 : 0)); out.writeByte((byte) (driveShare ? 1 : 0)); out.writeString(driveShareEmails); out.writeByte((byte) (driveSharePublic ? 1 : 0)); diff --git a/MyTracks/src/com/google/android/apps/mytracks/settings/GoogleSettingsActivity.java b/MyTracks/src/com/google/android/apps/mytracks/settings/GoogleSettingsActivity.java index 2bf61347a..42da9b351 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/settings/GoogleSettingsActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/settings/GoogleSettingsActivity.java @@ -144,14 +144,12 @@ public class GoogleSettingsActivity extends AbstractSettingsActivity { this, R.string.settings_google_account_confirm_message, null); break; case DIALOG_CONFIRM_DRIVE_SYNC_ON: - dialog = DialogUtils.createConfirmationDialog(this, - R.string.settings_google_drive_sync_confirm_message, - new DialogInterface.OnClickListener() { + dialog = DialogUtils.createConfirmationDialog(this, R.string.sync_drive_title, + R.string.sync_drive_confirm_message, null, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface d, int button) { - final String googleAccount = PreferencesUtils.getString( - GoogleSettingsActivity.this, R.string.google_account_key, - PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT); + final String googleAccount = PreferencesUtils.getString(GoogleSettingsActivity.this, + R.string.google_account_key, PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT); /* * This class, a PreferenceActivity, needs to support api level * 8+, thus cannot use CheckPermissionFragment because a @@ -181,7 +179,7 @@ public class GoogleSettingsActivity extends AbstractSettingsActivity { }); thread.start(); } - }); + }, null); break; default: dialog = null; @@ -237,8 +235,7 @@ public class GoogleSettingsActivity extends AbstractSettingsActivity { }); break; case DIALOG_CONFIRM_DRIVE_SYNC_ON: - alertDialog.setMessage(getString( - R.string.settings_google_drive_sync_confirm_message, googleAccount, + alertDialog.setMessage(getString(R.string.sync_drive_confirm_message, googleAccount, getString(R.string.my_tracks_app_name))); break; default: diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/DialogUtils.java b/MyTracks/src/com/google/android/apps/mytracks/util/DialogUtils.java index d99822ad9..8b7695a82 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/DialogUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/DialogUtils.java @@ -36,44 +36,44 @@ public class DialogUtils { /** * Creates a confirmation dialog. - * + * * @param context the context * @param messageId the message id * @param okListener the listener when OK is clicked */ public static Dialog createConfirmationDialog( Context context, int messageId, DialogInterface.OnClickListener okListener) { - return createConfirmationDialog(context, messageId, null, okListener, null); + return createConfirmationDialog( + context, R.string.generic_confirm_title, messageId, null, okListener, null); } /** * Creates a confirmation dialog. * * @param context the context + * @param titleId the titleId * @param messageId the messageId * @param view the view * @param okListener the listener when OK is clicked * @param cancelListener the listener when cancel is clicked */ - public static Dialog createConfirmationDialog( - Context context, int messageId, View view, DialogInterface.OnClickListener okListener, + public static Dialog createConfirmationDialog(Context context, int titleId, int messageId, + View view, DialogInterface.OnClickListener okListener, DialogInterface.OnClickListener cancelListener) { - AlertDialog.Builder builder = new AlertDialog.Builder(context) - .setCancelable(true) + AlertDialog.Builder builder = new AlertDialog.Builder(context).setCancelable(true) .setIcon(android.R.drawable.ic_dialog_alert) .setNegativeButton(R.string.generic_no, cancelListener) - .setPositiveButton(R.string.generic_yes, okListener) - .setTitle(R.string.generic_confirm_title); + .setPositiveButton(R.string.generic_yes, okListener).setTitle(titleId); if (messageId != -1) { builder.setMessage(messageId); } if (view != null) { builder.setView(view); } - + return builder.create(); } - + /** * Creates a spinner progress dialog. * diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/SendRequestTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/SendRequestTest.java index 4b587fe18..94f84dfc9 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/SendRequestTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/SendRequestTest.java @@ -128,6 +128,7 @@ public class SendRequestTest extends AndroidTestCase { parcel.writeByte((byte) 1); parcel.writeByte((byte) 1); parcel.writeByte((byte) 1); + parcel.writeByte((byte) 1); parcel.writeString(DRIVE_SHARE_EMAILS); parcel.writeByte((byte) 1); Account account = new Account(ACCOUNTNAME, ACCOUNTYPE); @@ -145,6 +146,7 @@ public class SendRequestTest extends AndroidTestCase { assertTrue(sendRequest.isSendFusionTables()); assertTrue(sendRequest.isSendSpreadsheets()); assertTrue(sendRequest.isDriveSync()); + assertTrue(sendRequest.isDriveSyncConfirm()); assertTrue(sendRequest.isDriveShare()); assertEquals(DRIVE_SHARE_EMAILS, sendRequest.getDriveShareEmails()); assertTrue(sendRequest.isDriveSharePublic()); @@ -169,6 +171,7 @@ public class SendRequestTest extends AndroidTestCase { parcel.writeByte((byte) 0); parcel.writeByte((byte) 0); parcel.writeByte((byte) 0); + parcel.writeByte((byte) 0); parcel.writeString(null); parcel.writeByte((byte) 0); Account account = new Account(ACCOUNTNAME, ACCOUNTYPE); @@ -186,6 +189,7 @@ public class SendRequestTest extends AndroidTestCase { assertFalse(sendRequest.isSendFusionTables()); assertFalse(sendRequest.isSendSpreadsheets()); assertFalse(sendRequest.isDriveSync()); + assertFalse(sendRequest.isDriveSyncConfirm()); assertFalse(sendRequest.isDriveShare()); assertNull(sendRequest.getDriveShareEmails()); assertFalse(sendRequest.isDriveSharePublic()); @@ -211,7 +215,8 @@ public class SendRequestTest extends AndroidTestCase { boolean sendMaps = parcel.readByte() == 1; boolean sendFusionTables = parcel.readByte() == 1; boolean sendSpreadsheets = parcel.readByte() == 1; - boolean driveEnableSync = parcel.readByte() == 1; + boolean driveSync = parcel.readByte() == 1; + boolean driveSyncConfirm = parcel.readByte() == 1; boolean driveShare = parcel.readByte() == 1; String dirveShareEmails = parcel.readString(); boolean driveSharePublic = parcel.readByte() == 1; @@ -226,7 +231,8 @@ public class SendRequestTest extends AndroidTestCase { assertFalse(sendMaps); assertFalse(sendFusionTables); assertFalse(sendSpreadsheets); - assertFalse(driveEnableSync); + assertFalse(driveSync); + assertFalse(driveSyncConfirm); assertFalse(driveShare); assertNull(dirveShareEmails); assertFalse(driveSharePublic); @@ -248,6 +254,7 @@ public class SendRequestTest extends AndroidTestCase { sendRequest.setSendFusionTables(true); sendRequest.setSendSpreadsheets(true); sendRequest.setDriveSync(true); + sendRequest.setDriveSyncConfirm(true); sendRequest.setDriveShare(true); sendRequest.setDriveShareEmails(DRIVE_SHARE_EMAILS); sendRequest.setDriveSharePublic(true); @@ -267,7 +274,8 @@ public class SendRequestTest extends AndroidTestCase { boolean sendMaps = parcel.readByte() == 1; boolean sendFusionTables = parcel.readByte() == 1; boolean sendSpreadsheets = parcel.readByte() == 1; - boolean driveEnableSync = parcel.readByte() == 1; + boolean driveSync = parcel.readByte() == 1; + boolean driveSyncConfirm = parcel.readByte() == 1; boolean driveShare = parcel.readByte() == 1; String driveShareEmails = parcel.readString(); boolean driveSharePublic = parcel.readByte() == 1; @@ -282,7 +290,8 @@ public class SendRequestTest extends AndroidTestCase { assertTrue(sendMaps); assertTrue(sendFusionTables); assertTrue(sendSpreadsheets); - assertTrue(driveEnableSync); + assertTrue(driveSync); + assertTrue(driveSyncConfirm); assertTrue(driveShare); assertEquals(DRIVE_SHARE_EMAILS, driveShareEmails); assertTrue(driveSharePublic); diff --git a/MyTracksTest_E2E/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java b/MyTracksTest_E2E/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java index 6c5994bc6..ac634b515 100644 --- a/MyTracksTest_E2E/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java +++ b/MyTracksTest_E2E/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java @@ -340,7 +340,7 @@ public class EndToEndTestUtils { if ((getButtonOnScreen(activityMytracks.getString(R.string.eula_accept), false, false) != null)) { getButtonOnScreen(activityMytracks.getString(R.string.eula_accept), true, true); } - if (SOLO.waitForText(activityMytracks.getString(R.string.sync_enable_title))) { + if (SOLO.waitForText(activityMytracks.getString(R.string.sync_drive_title))) { // Click for Sync with Google Drive(Don't enable sync as default). getButtonOnScreen(activityMytracks.getString(R.string.generic_no), true, true); instrumentation.waitForIdleSync(); diff --git a/MyTracksTest_E2E/src/com/google/android/apps/mytracks/endtoendtest/common/SettingTest.java b/MyTracksTest_E2E/src/com/google/android/apps/mytracks/endtoendtest/common/SettingTest.java index 62af903ca..992ae55e5 100644 --- a/MyTracksTest_E2E/src/com/google/android/apps/mytracks/endtoendtest/common/SettingTest.java +++ b/MyTracksTest_E2E/src/com/google/android/apps/mytracks/endtoendtest/common/SettingTest.java @@ -428,27 +428,26 @@ public class SettingTest extends ActivityInstrumentationTestCase2