Add menu option to Sync to Google Drive.

This commit is contained in:
Jimmy Shih
2013-06-24 14:09:25 -07:00
parent 176b2b05d3
commit 2d4cabf4ef
13 changed files with 250 additions and 129 deletions
+21 -25
View File
@@ -1184,6 +1184,12 @@ limitations under the License.
Character limit: ~20 (1 line)">
Share
</string>
<string name="menu_sync_drive"
translation_description="In the menu, to sync to Google Drive.
Character limit: ~20 (1 line)">
Sync to Google Drive
</string>
<string name="menu_show_on_map"
translation_description="In the menu, to show a track or a marker on the map.
@@ -1581,15 +1587,6 @@ limitations under the License.
Character limit: ~23 (1 line)">
Switch account
</string>
<string name="settings_google_drive_sync_confirm_message"
translation_description="In the 'Accounts and sync' settings, the confirmation message when
checking the 'Sync to Google Drive' checkbox.
%1$s account name. E.g., 'foo@foo.com'.
%2$s folder name. E.g., 'My Tracks'.">
All files in the %1$s Google Drive &#8216;%2$s&#8217; folder will be imported as new tracks. If
not desired, move the files to a different folder beforehand.
</string>
<string name="settings_google_drive_sync_summary_on"
translation_description="In the 'Accounts and sync' settings, the summary for the 'Sync to
Google Drive' checkbox when it is checked explaining that all tracks will be synced to a
@@ -1598,13 +1595,6 @@ limitations under the License.
%1$s account name. E.g., 'foo@foo.com'.">
All tracks will be synced to %1$s Google Drive
</string>
<string name="settings_google_drive_sync_title"
translation_description="In the 'Accounts and sync' settings, the checkbox to sync tracks with
Google Drive.
Character limit: ~23 (1 line)">
Sync to Google Drive
</string>
<!-- Settings Map -->
<string name="settings_map_medium"
@@ -2163,20 +2153,26 @@ limitations under the License.
translation_description="In the 'Stats' page, the total time.">
Total time
</string>
<!-- Sync -->
<string name="sync_enable_message"
translation_description="The dialog message asking the user if he wants to enable sync with
Google Drive.">
<!-- Sync Drive -->
<string name="sync_drive_confirm_message"
translation_description="The dialog message to confirm sync to Google Drive.
%1$s account name. E.g., 'foo@foo.com'.
%2$s folder name. E.g., 'My Tracks'.">
All files in the %1$s Google Drive &#8216;%2$s&#8217; folder will be imported as new tracks. If
not desired, move the files to a different folder beforehand.
</string>
<string name="sync_drive_enable_message"
translation_description="The dialog message to enable sync to Google Drive.">
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.
</string>
<string name="sync_enable_title"
translation_description="The dialog title asking the user if he wants to enable sync with Google
Drive.">
<string name="sync_drive_title"
translation_description="The dialog title to sync to Google Drive.">
Sync with Google Drive?
</string>
<!-- Track -->
<string name="track_name_format"
translation_description="When creating a new track, the string format to name the track.
+1 -1
View File
@@ -23,5 +23,5 @@ limitations under the License.
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/drive_sync_key"
android:title="@string/settings_google_drive_sync_title" />
android:title="@string/menu_sync_drive" />
</PreferenceScreen>
@@ -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) {
@@ -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);
}
}
/**
@@ -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
@@ -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);
}
}
@@ -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));
@@ -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:
@@ -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.
*
@@ -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);
@@ -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();
@@ -428,27 +428,26 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
EndToEndTestUtils.SOLO.clickOnText(GoogleUtils.ACCOUNT_NAME_1);
instrumentation.waitForIdleSync();
EndToEndTestUtils.SOLO.waitForText(activityMyTracks
.getString(R.string.settings_google_drive_sync_title));
.getString(R.string.menu_sync_drive));
assertTrue(EndToEndTestUtils.findTextView(
activityMyTracks.getString(R.string.settings_google_drive_sync_title)).isEnabled());
activityMyTracks.getString(R.string.menu_sync_drive)).isEnabled());
} else {
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.value_none));
instrumentation.waitForIdleSync();
EndToEndTestUtils.SOLO.waitForText(activityMyTracks
.getString(R.string.settings_google_drive_sync_title));
.getString(R.string.menu_sync_drive));
assertFalse(EndToEndTestUtils.findTextView(
activityMyTracks.getString(R.string.settings_google_drive_sync_title)).isEnabled());
activityMyTracks.getString(R.string.menu_sync_drive)).isEnabled());
return;
}
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks
.getString(R.string.settings_google_drive_sync_title));
.getString(R.string.menu_sync_drive));
boolean isSyncChecked = false;
if (EndToEndTestUtils.SOLO
.waitForText(activityMyTracks
.getString(R.string.settings_google_drive_sync_confirm_message).split("%")[0], 1,
EndToEndTestUtils.SHORT_WAIT_TIME)) {
if (EndToEndTestUtils.SOLO.waitForText(
activityMyTracks.getString(R.string.sync_drive_confirm_message).split("%")[0], 1,
EndToEndTestUtils.SHORT_WAIT_TIME)) {
isSyncChecked = true;
} else {
isSyncChecked = false;
@@ -203,12 +203,10 @@ public class SyncTestUtils {
CheckBox syncCheckBox = EndToEndTestUtils.SOLO.getCurrentViews(CheckBox.class).get(0);
if (!syncCheckBox.isChecked()) {
EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.activityMytracks
.getString(R.string.settings_google_drive_sync_title));
.getString(R.string.menu_sync_drive));
EndToEndTestUtils.SOLO.waitForText(
EndToEndTestUtils.activityMytracks.getString(
R.string.settings_google_drive_sync_confirm_message).split("%")[0], 1,
EndToEndTestUtils.SHORT_WAIT_TIME);
EndToEndTestUtils.SOLO.waitForText(EndToEndTestUtils.activityMytracks.getString(
R.string.sync_drive_confirm_message).split("%")[0], 1, EndToEndTestUtils.SHORT_WAIT_TIME);
Assert.assertTrue(EndToEndTestUtils.SOLO.searchText(accountName, true));
EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.activityMytracks
.getString(R.string.generic_yes));