mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-08 01:53:25 +02:00
Enable/disable via sync service
This commit is contained in:
@@ -152,6 +152,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
static final int PI_ALARM = 1;
|
||||
static final int PI_BACKOFF = 2;
|
||||
static final int PI_KEEPALIVE = 3;
|
||||
static final int PI_ENABLE = 4;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
@@ -792,6 +793,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
if (action != null)
|
||||
try {
|
||||
switch (action.split(":")[0]) {
|
||||
case "enable":
|
||||
onEnable(intent);
|
||||
break;
|
||||
|
||||
case "eval":
|
||||
onEval(intent);
|
||||
break;
|
||||
@@ -827,6 +832,13 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
private void onEnable(Intent intent) {
|
||||
boolean enabled = intent.getBooleanExtra("enabled", true);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
prefs.edit().putBoolean("enabled", enabled).apply();
|
||||
onEval(intent);
|
||||
}
|
||||
|
||||
private void onEval(Intent intent) {
|
||||
Bundle command = new Bundle();
|
||||
command.putString("name", "eval");
|
||||
|
||||
Reference in New Issue
Block a user