diff --git a/api/res/values/keys.xml b/api/res/values/keys.xml
index 1cb65b7e4..0106ccb5e 100644
--- a/api/res/values/keys.xml
+++ b/api/res/values/keys.xml
@@ -31,5 +31,7 @@
sync_forget
sync_options
+
+ sync_last_error
diff --git a/api/res/values/strings.xml b/api/res/values/strings.xml
index 9a5c0e014..fcdcfb621 100644
--- a/api/res/values/strings.xml
+++ b/api/res/values/strings.xml
@@ -200,6 +200,13 @@
Logged in as:
+
+ Last Error
+
+ Click to send a report to the Astrid team
+
+ Send Report
+
Log Out
diff --git a/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java b/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java
index 9cad00c1c..31793c8f7 100644
--- a/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java
+++ b/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java
@@ -2,6 +2,7 @@ package com.todoroo.astrid.sync;
import java.util.Date;
+import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
@@ -170,6 +171,43 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
if(view != null)
view.setBackgroundColor(statusColor);
}
+ else if (r.getString(R.string.sync_SPr_key_last_error).equals(preference.getKey())) {
+ if (getUtilities().getLastError() != null) {
+ // Display error
+ final String lastError = getUtilities().getLastError();
+ preference.setTitle(R.string.sync_SPr_last_error);
+ preference.setSummary(R.string.sync_SPr_last_error_subtitle);
+
+ preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ @SuppressWarnings("nls")
+ public boolean onPreferenceClick(Preference pref) {
+ // Show last error
+ new AlertDialog.Builder(SyncProviderPreferences.this)
+ .setTitle(R.string.sync_SPr_last_error)
+ .setMessage(lastError)
+ .setPositiveButton(R.string.sync_SPr_send_report, new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Intent emailIntent = new Intent(Intent.ACTION_SEND);
+ emailIntent.setType("plain/text")
+ .putExtra(Intent.EXTRA_EMAIL, new String[] { "android-bugs@astrid.com"} )
+ .putExtra(Intent.EXTRA_SUBJECT, getTitle() + " Sync Error")
+ .putExtra(Intent.EXTRA_TEXT, lastError);
+ startActivity(Intent.createChooser(emailIntent, r.getString(R.string.sync_SPr_send_report)));
+ }
+ })
+ .setNegativeButton(R.string.DLG_close, null)
+ .create().show();
+ return true;
+ }
+ });
+
+ } else {
+ PreferenceCategory statusCategory = (PreferenceCategory) findPreference(r.getString(R.string.sync_SPr_group_status));
+ statusCategory.removePreference(findPreference(r.getString(R.string.sync_SPr_key_last_error)));
+ }
+ }
// log out button
else if (r.getString(R.string.sync_SPr_forget_key).equals(preference.getKey())) {
boolean loggedIn = getUtilities().isLoggedIn();
diff --git a/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java b/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java
index 466d34324..0869d029b 100644
--- a/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java
+++ b/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java
@@ -95,7 +95,7 @@ abstract public class SyncProviderUtilities {
editor.commit();
}
- /** Set Last Successful Sync Date */
+ /** Set Last Error */
public void setLastError(String error) {
Editor editor = getPrefs().edit();
editor.putString(getIdentifier() + PREF_LAST_ERROR, error);
@@ -123,7 +123,7 @@ abstract public class SyncProviderUtilities {
editor.putLong(getIdentifier() + PREF_LAST_ATTEMPTED_SYNC,
DateUtilities.now());
editor.remove(getIdentifier() + PREF_LAST_ERROR);
- editor.putBoolean(getIdentifier() + PREF_ONGOING, true);
+ // editor.putBoolean(getIdentifier() + PREF_ONGOING, true);
editor.commit();
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java
index 225a008d7..c5f3dc0a2 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java
@@ -112,6 +112,8 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
final AtomicInteger finisher = new AtomicInteger(2);
+ actFmPreferenceService.recordSyncStart();
+
startTagFetcher(callback, finisher);
startTaskFetcher(manual, callback, finisher);
diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java
index 42aed8d84..a7d67d559 100644
--- a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java
+++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java
@@ -103,6 +103,8 @@ public class GtasksSyncV2Provider extends SyncV2Provider {
callback.started();
callback.incrementMax(100);
+ gtasksPreferenceService.recordSyncStart();
+
new Thread(new Runnable() {
public void run() {
callback.incrementProgress(50);
diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml
index a52911368..c7af11315 100644
--- a/astrid/res/values/keys.xml
+++ b/astrid/res/values/keys.xml
@@ -314,6 +314,8 @@
sync_forget
sync_options
+
+ sync_last_error
actfmHttps
diff --git a/astrid/res/xml/preferences_actfm.xml b/astrid/res/xml/preferences_actfm.xml
index de8364955..b1430fd97 100644
--- a/astrid/res/xml/preferences_actfm.xml
+++ b/astrid/res/xml/preferences_actfm.xml
@@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android">
+
+
+
+
+
+