Browse Source

Revert "Halt early when not enabled"

This reverts commit 48603f20b6.
main
M66B 6 years ago
parent
commit
8efdee1e8a
2 changed files with 8 additions and 8 deletions
  1. +1
    -1
      app/src/main/java/eu/faircode/email/FragmentOptions.java
  2. +7
    -7
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java

+ 1
- 1
app/src/main/java/eu/faircode/email/FragmentOptions.java View File

@ -61,7 +61,7 @@ public class FragmentOptions extends FragmentEx {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("enabled", checked).apply(); prefs.edit().putBoolean("enabled", checked).apply();
ServiceSynchronize.start(getContext());
ServiceSynchronize.reload(getContext(), "enabled");
} }
}); });


+ 7
- 7
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

@ -179,13 +179,6 @@ public class ServiceSynchronize extends LifecycleService {
Log.i(Helper.TAG, "Service command intent=" + intent); Log.i(Helper.TAG, "Service command intent=" + intent);
super.onStartCommand(intent, flags, startId); super.onStartCommand(intent, flags, startId);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (!prefs.getBoolean("enabled", true)) {
Log.i(Helper.TAG, "Not enabled, halt");
stopSelf();
return START_STICKY;
}
startForeground(NOTIFICATION_SYNCHRONIZE, getNotificationService(0, 0, 0).build()); startForeground(NOTIFICATION_SYNCHRONIZE, getNotificationService(0, 0, 0).build());
DB db = DB.getInstance(this); DB db = DB.getInstance(this);
@ -1944,6 +1937,13 @@ public class ServiceSynchronize extends LifecycleService {
private void start() { private void start() {
EntityLog.log(ServiceSynchronize.this, "Main start"); EntityLog.log(ServiceSynchronize.this, "Main start");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ServiceSynchronize.this);
if (!prefs.getBoolean("enabled", true)) {
EntityLog.log(ServiceSynchronize.this, "Not enabled, halt");
stopSelf();
return;
}
state = new ServiceState(); state = new ServiceState();
state.thread = new Thread(new Runnable() { state.thread = new Thread(new Runnable() {
private List<ServiceState> threadState = new ArrayList<>(); private List<ServiceState> threadState = new ArrayList<>();


Loading…
Cancel
Save