Provide a better explanation as to why sync is disabled
This commit is contained in:
parent
fc90a8eadb
commit
b54f6ee11b
4 changed files with 53 additions and 3 deletions
|
@ -8,6 +8,7 @@ import android.text.format.DateUtils;
|
|||
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.AccountStats;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.controller.MessagingListener;
|
||||
import com.fsck.k9.service.MailService;
|
||||
|
@ -44,6 +45,18 @@ public class ActivityListener extends MessagingListener {
|
|||
return context.getString(R.string.status_next_poll,
|
||||
DateUtils.getRelativeTimeSpanString(nextPollTime, System.currentTimeMillis(),
|
||||
DateUtils.MINUTE_IN_MILLIS, 0));
|
||||
} else if (K9.DEBUG && MailService.isSyncDisabled()) {
|
||||
if (MailService.hasNoConnectivity()) {
|
||||
return context.getString(R.string.status_no_network);
|
||||
} else if (MailService.isSyncNoBackground()) {
|
||||
return context.getString(R.string.status_no_background);
|
||||
} else if (MailService.isSyncBlocked()) {
|
||||
return context.getString(R.string.status_syncing_blocked);
|
||||
} else if (MailService.isPollAndPushDisabled()) {
|
||||
return context.getString(R.string.status_poll_and_push_disabled);
|
||||
} else {
|
||||
return context.getString(R.string.status_syncing_off);
|
||||
}
|
||||
} else if (MailService.isSyncDisabled()) {
|
||||
return context.getString(R.string.status_syncing_off);
|
||||
} else {
|
||||
|
|
|
@ -34,6 +34,8 @@ public class MailService extends CoreService {
|
|||
private static long nextCheck = -1;
|
||||
private static boolean pushingRequested = false;
|
||||
private static boolean pollingRequested = false;
|
||||
private static boolean syncNoBackground = false;
|
||||
private static boolean syncNoConnectivity = false;
|
||||
private static boolean syncBlocked = false;
|
||||
|
||||
public static void actionReset(Context context, Integer wakeLockId) {
|
||||
|
@ -106,6 +108,8 @@ public class MailService extends CoreService {
|
|||
break;
|
||||
}
|
||||
|
||||
syncNoBackground = !doBackground;
|
||||
syncNoConnectivity = !hasConnectivity;
|
||||
syncBlocked = !(doBackground && hasConnectivity);
|
||||
|
||||
if (K9.DEBUG)
|
||||
|
@ -315,6 +319,22 @@ public class MailService extends CoreService {
|
|||
return syncBlocked || (!pollingRequested && !pushingRequested);
|
||||
}
|
||||
|
||||
public static boolean hasNoConnectivity() {
|
||||
return syncNoConnectivity;
|
||||
}
|
||||
|
||||
public static boolean isSyncNoBackground() {
|
||||
return syncNoBackground;
|
||||
}
|
||||
|
||||
public static boolean isSyncBlocked() {
|
||||
return syncBlocked;
|
||||
}
|
||||
|
||||
public static boolean isPollAndPushDisabled() {
|
||||
return (!pollingRequested && !pushingRequested);
|
||||
}
|
||||
|
||||
private void stopPushers() {
|
||||
MessagingController.getInstance(getApplication()).stopAllPushing();
|
||||
PushService.stopService(MailService.this);
|
||||
|
|
|
@ -107,6 +107,10 @@ Please submit bug reports, contribute new features and ask questions at
|
|||
<string name="folder_progress">\u0020<xliff:g id="completed">%d</xliff:g>/<xliff:g id="total">%d</xliff:g></string>
|
||||
|
||||
<string name="status_next_poll">Next poll <xliff:g id="nexttime">%s</xliff:g></string>
|
||||
<string name="status_no_network">Sync disabled - No network</string>
|
||||
<string name="status_no_background">Sync disabled - No background activity</string>
|
||||
<string name="status_poll_and_push_disabled">Polling and pushing disabled</string>
|
||||
<string name="status_syncing_blocked">Syncing blocked</string>
|
||||
<string name="status_syncing_off">Syncing disabled</string>
|
||||
|
||||
<string name="actionbar_selected"><xliff:g id="selection_count">%d</xliff:g> selected</string>
|
||||
|
|
|
@ -4,6 +4,7 @@ package com.fsck.k9.activity;
|
|||
import android.content.Context;
|
||||
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.K9RobolectricTestRunner;
|
||||
import com.fsck.k9.mail.Message;
|
||||
import org.junit.Before;
|
||||
|
@ -74,7 +75,11 @@ public class ActivityListenerTest {
|
|||
|
||||
String operation = activityListener.getOperation(context);
|
||||
|
||||
assertEquals("Syncing disabled", operation);
|
||||
if (K9.DEBUG) {
|
||||
assertEquals("Polling and pushing disabled", operation);
|
||||
} else {
|
||||
assertEquals("Syncing disabled", operation);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -85,7 +90,11 @@ public class ActivityListenerTest {
|
|||
|
||||
String operation = activityListener.getOperation(context);
|
||||
|
||||
assertEquals("Syncing disabled", operation);
|
||||
if (K9.DEBUG) {
|
||||
assertEquals("Polling and pushing disabled", operation);
|
||||
} else {
|
||||
assertEquals("Syncing disabled", operation);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -95,7 +104,11 @@ public class ActivityListenerTest {
|
|||
|
||||
String operation = activityListener.getOperation(context);
|
||||
|
||||
assertEquals("Syncing disabled", operation);
|
||||
if (K9.DEBUG) {
|
||||
assertEquals("Polling and pushing disabled", operation);
|
||||
} else {
|
||||
assertEquals("Syncing disabled", operation);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in a new issue