Placeholder logic for a sync refresh/debug button

pull/14/head
Sam Bosley 12 years ago
parent 0f52169f74
commit c2fb314b19

@ -144,6 +144,21 @@ public final class ActFmSyncService {
}
}
public String refreshToken() {
try {
JSONObject result = invoke("refresh_token");
String newToken = result.optString("token");
if (!TextUtils.isEmpty(newToken)) {
actFmPreferenceService.setToken(newToken);
checkForToken();
}
return newToken;
} catch (IOException e) {
//
}
return null;
}
// --- generic invokation
/** invoke authenticated method against the server */

@ -24,6 +24,8 @@ import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.andlib.utility.TodorooPreferenceActivity;
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
import com.todoroo.astrid.actfm.sync.ActFmSyncThread;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gcal.GCalHelper;
@ -43,6 +45,8 @@ public class OldTaskPreferences extends TodorooPreferenceActivity {
@Autowired MetadataService metadataService;
@Autowired Database database;
@Autowired ActFmSyncService actFmSyncService;
ProgressDialog pd;
@Override
@ -65,6 +69,15 @@ public class OldTaskPreferences extends TodorooPreferenceActivity {
}
});
preference = screen.findPreference(getString(R.string.EPr_reset_sync_state));
preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference p) {
showResetSyncStateDialog();
return true;
}
});
preference = screen.findPreference(getString(R.string.EPr_manage_purge_deleted));
preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference p) {
@ -287,6 +300,22 @@ public class OldTaskPreferences extends TodorooPreferenceActivity {
}, null);
}
private void showResetSyncStateDialog() {
DialogUtilities.okCancelDialog(this, getString(R.string.EPr_reset_sync_state_detailed), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
pd = DialogUtilities.runWithProgressDialog(OldTaskPreferences.this, new Runnable() {
@Override
public void run() {
actFmSyncService.refreshToken();
ActFmSyncThread.clearTablePushedAtValues();
//TODO: Maybe clear outstanding tables?
}
});
}
}, null);
}
protected void showResult(int resourceText, int result) {
DialogUtilities.okDialog(this, getString(resourceText, result), null);
}

@ -376,5 +376,9 @@
<string name="actfm_sync_ongoing">Sync ongoing...</string>
<string name="EPr_reset_sync_state">Reset sync</string>
<string name="EPr_reset_sync_state_summary">Refreshes sync token and resets some local data to help resolve sync errors</string>
<string name="EPr_reset_sync_state_detailed">The next time you sync, your tasks and lists will be changed to mirror what exists on Astrid.com, which may help resolve sync errors. Do you wish to continue?</string>
</resources>

@ -8,6 +8,11 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/EPr_manage_header">
<com.todoroo.astrid.ui.MultilinePreference
android:title="@string/EPr_reset_sync_state"
android:key="@string/EPr_reset_sync_state"
android:summary="@string/EPr_reset_sync_state_summary" />
<com.todoroo.astrid.ui.MultilinePreference
android:title="@string/EPr_manage_delete_completed"
android:key="@string/EPr_manage_delete_completed"

Loading…
Cancel
Save