diff --git a/api/res/values/strings.xml b/api/res/values/strings.xml
index fcdcfb621..dad2a5599 100644
--- a/api/res/values/strings.xml
+++ b/api/res/values/strings.xml
@@ -215,6 +215,10 @@
Log out / clear synchronization data?
+
+ It looks like you had some network connectivity problems
+ the last time you tried to sync with %s. Please try again later!
+
- disable
diff --git a/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java b/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java
index 31793c8f7..fc90dc447 100644
--- a/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java
+++ b/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java
@@ -1,6 +1,7 @@
package com.todoroo.astrid.sync;
import java.util.Date;
+import java.util.HashMap;
import android.app.AlertDialog;
import android.content.DialogInterface;
@@ -174,7 +175,9 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
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();
+ final String service = getTitle().toString();
+ final String lastErrorFull = getUtilities().getLastError();
+ final String lastErrorDisplay = adjustErrorForDisplay(r, lastErrorFull, service);
preference.setTitle(R.string.sync_SPr_last_error);
preference.setSummary(R.string.sync_SPr_last_error_subtitle);
@@ -185,15 +188,15 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
// Show last error
new AlertDialog.Builder(SyncProviderPreferences.this)
.setTitle(R.string.sync_SPr_last_error)
- .setMessage(lastError)
+ .setMessage(lastErrorDisplay)
.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);
+ .putExtra(Intent.EXTRA_SUBJECT, service + " Sync Error")
+ .putExtra(Intent.EXTRA_TEXT, lastErrorFull);
startActivity(Intent.createChooser(emailIntent, r.getString(R.string.sync_SPr_send_report)));
}
})
@@ -233,6 +236,28 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
}
}
+ /**
+ * We can define exception strings in this map that we want to replace with more user-friendly
+ * messages. As we discover new exception types, we can expand the map
+ */
+ private static HashMap exceptionsToDisplayMessages;
+
+ @SuppressWarnings("nls")
+ private static HashMap getExceptionMap() {
+ if (exceptionsToDisplayMessages == null) {
+ exceptionsToDisplayMessages = new HashMap();
+ exceptionsToDisplayMessages.put("java.net.ConnectionException", R.string.sync_error_offline);
+ }
+ return exceptionsToDisplayMessages;
+ }
+
+ private static final String adjustErrorForDisplay(Resources r, String lastError, String service) {
+ Integer resource = getExceptionMap().get(lastError);
+ if (resource == null)
+ return lastError;
+ return r.getString(resource.intValue(), service);
+ }
+
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_LOGIN && resultCode == RESULT_OK) {
diff --git a/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java b/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java
index 0869d029b..42831ff5d 100644
--- a/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java
+++ b/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java
@@ -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();
}