Warn when logging into your second sync provider

pull/14/head
Sam Bosley 12 years ago
parent a033a856c6
commit 268d57d498

@ -1,5 +1,6 @@
package com.todoroo.astrid.actfm;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.preference.Preference;
@ -7,8 +8,10 @@ import android.preference.PreferenceCategory;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.actfm.sync.ActFmSyncV2Provider;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.sync.SyncProviderPreferences;
import com.todoroo.astrid.sync.SyncProviderUtilities;
@ -22,6 +25,7 @@ import com.todoroo.astrid.sync.SyncProviderUtilities;
public class ActFmPreferences extends SyncProviderPreferences {
@Autowired ActFmPreferenceService actFmPreferenceService;
@Autowired GtasksPreferenceService gtasksPreferenceService;
@Override
public int getPreferenceResource() {
@ -31,14 +35,28 @@ public class ActFmPreferences extends SyncProviderPreferences {
@Override
public void startSync() {
if (!actFmPreferenceService.isLoggedIn()) {
Intent intent = new Intent(this, ActFmLoginActivity.class);
startActivityForResult(intent, REQUEST_LOGIN);
if (gtasksPreferenceService.isLoggedIn()) {
DialogUtilities.okCancelDialog(this, getString(R.string.DLG_warning), getString(R.string.actfm_dual_sync_warning),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startLogin();
}
}, null);
} else {
startLogin();
}
} else {
setResult(RESULT_CODE_SYNCHRONIZE);
finish();
}
}
private void startLogin() {
Intent intent = new Intent(this, ActFmLoginActivity.class);
startActivityForResult(intent, REQUEST_LOGIN);
}
@Override
public void logOut() {
new ActFmSyncV2Provider().signOut();

@ -1,11 +1,14 @@
package com.todoroo.astrid.gtasks;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity;
import com.todoroo.astrid.gtasks.sync.GtasksSyncV2Provider;
import com.todoroo.astrid.sync.SyncProviderPreferences;
@ -21,6 +24,7 @@ import com.todoroo.astrid.sync.SyncProviderUtilities;
public class GtasksPreferences extends SyncProviderPreferences {
@Autowired private GtasksPreferenceService gtasksPreferenceService;
@Autowired private ActFmPreferenceService actFmPreferenceService;
public GtasksPreferences() {
super();
@ -40,14 +44,28 @@ public class GtasksPreferences extends SyncProviderPreferences {
@Override
public void startSync() {
if (!gtasksPreferenceService.isLoggedIn()) {
Intent intent = new Intent(this, GtasksLoginActivity.class);
startActivityForResult(intent, REQUEST_LOGIN);
if (actFmPreferenceService.isLoggedIn()) {
DialogUtilities.okCancelDialog(this, getString(R.string.DLG_warning), getString(R.string.gtasks_dual_sync_warning),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startLogin();
}
}, null);
} else {
startLogin();
}
} else {
setResult(RESULT_CODE_SYNCHRONIZE);
finish();
}
}
private void startLogin() {
Intent intent = new Intent(this, GtasksLoginActivity.class);
startActivityForResult(intent, REQUEST_LOGIN);
}
@Override
public void logOut() {
GtasksSyncV2Provider.getInstance().signOut();

@ -287,5 +287,9 @@
<!-- text for notification when comments are received -->
<string name="actfm_notification_comments">New comments received / click for more details</string>
<string name="actfm_dual_sync_warning">You are currently synchronizing with Google Tasks.
Be advised that synchronizing with both services can in some cases lead to unexpected results.
Are you sure you want to sync with Astrid.com?</string>
</resources>

@ -67,6 +67,8 @@
<string name="DLG_undo">Undo</string>
<string name="DLG_warning">Warning</string>
<!-- =============================================================== UI == -->
<!-- Label for DateButtons with no value -->

@ -104,6 +104,9 @@
<!-- Error when authorization error happens in background sync -->
<string name="gtasks_error_background_sync_auth">Error authenticating in background. Please try initiating a sync while Astrid is running.</string>
<string name="gtasks_dual_sync_warning">You are currently synchronizing with Astrid.com.
Be advised that synchronizing with both services can in some cases lead to unexpected results.
Are you sure you want to sync with Google Tasks?</string>
</resources>

Loading…
Cancel
Save