Option to report last error in sync prefs

pull/14/head
Sam Bosley 13 years ago
parent 9d55c233dd
commit 4ed70def25

@ -31,5 +31,7 @@
<string name="sync_SPr_forget_key">sync_forget</string>
<!-- Preference Key (do not translate) -->
<string name="sync_SPr_key_options">sync_options</string>
<!-- Preference Key (do not translate) -->
<string name="sync_SPr_key_last_error">sync_last_error</string>
</resources>

@ -200,6 +200,13 @@
<!-- Sync: Prefix string before logged in identifier -->
<string name="sync_SPr_logged_in_prefix">Logged in as:</string>
<!-- Sync: Last error -->
<string name="sync_SPr_last_error">Last Error</string>
<!-- Sync: last error click for more -->
<string name="sync_SPr_last_error_subtitle">Click to send a report to the Astrid team</string>
<!-- Sync: send error report button -->
<string name="sync_SPr_send_report">Send Report</string>
<!-- Sync: Clear Data Title -->
<string name="sync_SPr_forget">Log Out</string>
<!-- Sync: Clear Data Description -->

@ -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();

@ -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();
}

@ -112,6 +112,8 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
final AtomicInteger finisher = new AtomicInteger(2);
actFmPreferenceService.recordSyncStart();
startTagFetcher(callback, finisher);
startTaskFetcher(manual, callback, finisher);

@ -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);

@ -314,6 +314,8 @@
<string name="sync_SPr_forget_key">sync_forget</string>
<!-- Preference Key (do not translate) -->
<string name="sync_SPr_key_options">sync_options</string>
<!-- Preference Key (do not translate) -->
<string name="sync_SPr_key_last_error">sync_last_error</string>
<!-- ===========================================================ACTFM == -->
<string name="actfm_https_key">actfmHttps</string>

@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="@string/sync_SPr_group_status"
android:title="@string/sync_SPr_group_status">
<com.todoroo.astrid.ui.MultilinePreference
@ -11,6 +12,11 @@
android:textSize="24sp"
android:gravity="center"/>
<com.todoroo.astrid.ui.MultilinePreference
android:key="@string/sync_SPr_key_last_error"
android:textSize="24sp"
android:gravity="center"/>
</PreferenceCategory>
<PreferenceCategory

@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="@string/sync_SPr_group_status"
android:title="@string/sync_SPr_group_status">
<com.todoroo.astrid.ui.MultilinePreference
@ -11,6 +12,11 @@
android:textSize="24sp"
android:gravity="center"/>
<com.todoroo.astrid.ui.MultilinePreference
android:key="@string/sync_SPr_key_last_error"
android:textSize="24sp"
android:gravity="center"/>
</PreferenceCategory>
<PreferenceCategory

@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="@string/sync_SPr_group_status"
android:title="@string/sync_SPr_group_status">
<com.todoroo.astrid.ui.MultilinePreference
@ -11,6 +12,11 @@
android:textSize="24sp"
android:gravity="center"/>
<com.todoroo.astrid.ui.MultilinePreference
android:key="@string/sync_SPr_key_last_error"
android:textSize="24sp"
android:gravity="center"/>
</PreferenceCategory>
<PreferenceCategory

Loading…
Cancel
Save