1
0
mirror of https://github.com/etesync/android synced 2025-02-09 22:22:57 +00:00

Cleanup error messages in notifications.

This commit is contained in:
Tom Hacohen 2017-02-20 19:47:14 +00:00
parent 09196e52a5
commit d832ae9bc6
4 changed files with 25 additions and 40 deletions

View File

@ -88,7 +88,7 @@ public class CalendarsSyncAdapterService extends SyncAdapterService {
syncResult.databaseError = true; syncResult.databaseError = true;
} }
String syncPhase = SyncManager.SYNC_PHASE_JOURNALS; int syncPhase = R.string.sync_phase_journals;
String title = getContext().getString(R.string.sync_error_calendar, account.name); String title = getContext().getString(R.string.sync_error_calendar, account.name);
notificationManager.setThrowable(e); notificationManager.setThrowable(e);
@ -102,7 +102,7 @@ public class CalendarsSyncAdapterService extends SyncAdapterService {
detailsIntent.putExtra(DebugInfoActivity.KEY_PHASE, syncPhase); detailsIntent.putExtra(DebugInfoActivity.KEY_PHASE, syncPhase);
} }
notificationManager.notify(title, syncPhase); notificationManager.notify(title, getContext().getString(syncPhase));
} }
App.log.info("Calendar sync complete"); App.log.info("Calendar sync complete");

View File

@ -84,7 +84,7 @@ public class ContactsSyncAdapterService extends SyncAdapterService {
syncResult.stats.numIoExceptions++; syncResult.stats.numIoExceptions++;
syncResult.delayUntil = (e.retryAfter > 0) ? e.retryAfter : Constants.DEFAULT_RETRY_DELAY; syncResult.delayUntil = (e.retryAfter > 0) ? e.retryAfter : Constants.DEFAULT_RETRY_DELAY;
} catch (Exception | OutOfMemoryError e) { } catch (Exception | OutOfMemoryError e) {
String syncPhase = SyncManager.SYNC_PHASE_JOURNALS; int syncPhase = R.string.sync_phase_journals;
String title = getContext().getString(R.string.sync_error_contacts, account.name); String title = getContext().getString(R.string.sync_error_contacts, account.name);
notificationManager.setThrowable(e); notificationManager.setThrowable(e);
@ -97,7 +97,7 @@ public class ContactsSyncAdapterService extends SyncAdapterService {
detailsIntent.putExtra(DebugInfoActivity.KEY_AUTHORITY, authority); detailsIntent.putExtra(DebugInfoActivity.KEY_AUTHORITY, authority);
detailsIntent.putExtra(DebugInfoActivity.KEY_PHASE, syncPhase); detailsIntent.putExtra(DebugInfoActivity.KEY_PHASE, syncPhase);
} }
notificationManager.notify(title, syncPhase); notificationManager.notify(title, getContext().getString(syncPhase));
} finally { } finally {
dbHelper.close(); dbHelper.close();
} }

View File

@ -34,6 +34,7 @@ import at.bitfire.davdroid.GsonHelper;
import at.bitfire.davdroid.HttpClient; import at.bitfire.davdroid.HttpClient;
import at.bitfire.davdroid.InvalidAccountException; import at.bitfire.davdroid.InvalidAccountException;
import at.bitfire.davdroid.NotificationHelper; import at.bitfire.davdroid.NotificationHelper;
import at.bitfire.davdroid.R;
import at.bitfire.davdroid.journalmanager.Exceptions; import at.bitfire.davdroid.journalmanager.Exceptions;
import at.bitfire.davdroid.journalmanager.JournalEntryManager; import at.bitfire.davdroid.journalmanager.JournalEntryManager;
import at.bitfire.davdroid.model.CollectionInfo; import at.bitfire.davdroid.model.CollectionInfo;
@ -48,18 +49,6 @@ import lombok.Getter;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
abstract public class SyncManager { abstract public class SyncManager {
final static String SYNC_PHASE_PREPARE = "sync_phase_prepare",
SYNC_PHASE_JOURNALS = "sync_phase_journals",
SYNC_PHASE_QUERY_CAPABILITIES = "sync_phase_query_capabilities",
SYNC_PHASE_PREPARE_LOCAL = "sync_phase_prepare_local",
SYNC_PHASE_CREATE_LOCAL_ENTRIES = "sync_phase_create_local_entries",
SYNC_PHASE_FETCH_ENTRIES = "sync_phase_fetch_entries",
SYNC_PHASE_APPLY_REMOTE_ENTRIES = "sync_phase_apply_remote_entries",
SYNC_PHASE_APPLY_LOCAL_ENTRIES = "sync_phase_apply_local_entries",
SYNC_PHASE_PUSH_ENTRIES = "sync_phase_push_entries",
SYNC_PHASE_POST_PROCESSING = "sync_phase_post_processing";
protected final NotificationHelper notificationManager; protected final NotificationHelper notificationManager;
protected final String uniqueCollectionId; protected final String uniqueCollectionId;
@ -122,7 +111,7 @@ abstract public class SyncManager {
@TargetApi(21) @TargetApi(21)
public void performSync() { public void performSync() {
String syncPhase = SYNC_PHASE_PREPARE; int syncPhase = R.string.sync_phase_prepare;
try { try {
App.log.info("Sync phase: " + syncPhase); App.log.info("Sync phase: " + syncPhase);
if (!prepare()) { if (!prepare()) {
@ -132,51 +121,51 @@ abstract public class SyncManager {
if (Thread.interrupted()) if (Thread.interrupted())
return; return;
syncPhase = SYNC_PHASE_QUERY_CAPABILITIES; syncPhase = R.string.sync_phase_query_capabilities;
App.log.info("Sync phase: " + syncPhase); App.log.info("Sync phase: " + syncPhase);
queryCapabilities(); queryCapabilities();
if (Thread.interrupted()) if (Thread.interrupted())
return; return;
syncPhase = SYNC_PHASE_PREPARE_LOCAL; syncPhase = R.string.sync_phase_prepare_local;
App.log.info("Sync phase: " + syncPhase); App.log.info("Sync phase: " + syncPhase);
prepareLocal(); prepareLocal();
if (Thread.interrupted()) if (Thread.interrupted())
return; return;
syncPhase = SYNC_PHASE_FETCH_ENTRIES; syncPhase = R.string.sync_phase_fetch_entries;
App.log.info("Sync phase: " + syncPhase); App.log.info("Sync phase: " + syncPhase);
fetchEntries(); fetchEntries();
if (Thread.interrupted()) if (Thread.interrupted())
return; return;
syncPhase = SYNC_PHASE_APPLY_REMOTE_ENTRIES; syncPhase = R.string.sync_phase_apply_remote_entries;
App.log.info("Sync phase: " + syncPhase); App.log.info("Sync phase: " + syncPhase);
applyRemoteEntries(); applyRemoteEntries();
/* Create journal entries out of local changes. */ /* Create journal entries out of local changes. */
if (Thread.interrupted()) if (Thread.interrupted())
return; return;
syncPhase = SYNC_PHASE_CREATE_LOCAL_ENTRIES; syncPhase = R.string.sync_phase_create_local_entries;
App.log.info("Sync phase: " + syncPhase); App.log.info("Sync phase: " + syncPhase);
createLocalEntries(); createLocalEntries();
if (Thread.interrupted()) if (Thread.interrupted())
return; return;
syncPhase = SYNC_PHASE_APPLY_LOCAL_ENTRIES; syncPhase = R.string.sync_phase_apply_local_entries;
App.log.info("Sync phase: " + syncPhase); App.log.info("Sync phase: " + syncPhase);
applyLocalEntries(); applyLocalEntries();
if (Thread.interrupted()) if (Thread.interrupted())
return; return;
syncPhase = SYNC_PHASE_PUSH_ENTRIES; syncPhase = R.string.sync_phase_push_entries;
App.log.info("Sync phase: " + syncPhase); App.log.info("Sync phase: " + syncPhase);
pushEntries(); pushEntries();
/* Cleanup and finalize changes */ /* Cleanup and finalize changes */
if (Thread.interrupted()) if (Thread.interrupted())
return; return;
syncPhase = SYNC_PHASE_POST_PROCESSING; syncPhase = R.string.sync_phase_post_processing;
App.log.info("Sync phase: " + syncPhase); App.log.info("Sync phase: " + syncPhase);
postProcess(); postProcess();
} catch (IOException e) { } catch (IOException e) {
@ -211,7 +200,7 @@ abstract public class SyncManager {
detailsIntent.putExtra(DebugInfoActivity.KEY_PHASE, syncPhase); detailsIntent.putExtra(DebugInfoActivity.KEY_PHASE, syncPhase);
} }
notificationManager.notify(getSyncErrorTitle(), syncPhase); notificationManager.notify(getSyncErrorTitle(), context.getString(syncPhase));
} }
} }

View File

@ -269,20 +269,16 @@
<string name="sync_error_http_dav">Server error while %s</string> <string name="sync_error_http_dav">Server error while %s</string>
<string name="sync_error_unavailable">Could not connect to server while %s</string> <string name="sync_error_unavailable">Could not connect to server while %s</string>
<string name="sync_error_local_storage">Database error while %s</string> <string name="sync_error_local_storage">Database error while %s</string>
<string-array name="sync_error_phases"> <string name="sync_phase_prepare">preparing synchronization</string>
<item>preparing synchronization</item> <string name="sync_phase_journals">syncronizing journals</string>
<item>querying capabilities</item> <string name="sync_phase_query_capabilities">querying capabilities</string>
<item>processing locally deleted entries</item> <string name="sync_phase_prepare_local">preparing local entries</string>
<item>preparing created/modified entries</item> <string name="sync_phase_create_local_entries">creating local entries</string>
<item>uploading created/modified entries</item> <string name="sync_phase_fetch_entries">fetching remote entries</string>
<item>checking sync state</item> <string name="sync_phase_apply_remote_entries">applying remote entries</string>
<item>listing local entries</item> <string name="sync_phase_apply_local_entries">reapplying local entries</string>
<item>listing remote entries</item> <string name="sync_phase_push_entries">pushing entries</string>
<item>comparing local/remote entries</item> <string name="sync_phase_post_processing">post processing</string>
<item>downloading remote entries</item>
<item>post-processing</item>
<item>saving sync state</item>
</string-array>
<string name="sync_error_unauthorized">Authentication failed</string> <string name="sync_error_unauthorized">Authentication failed</string>
<!-- cert4android --> <!-- cert4android -->