mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-05 16:43:26 +02:00
Added option to disable notifying in the foreground
This commit is contained in:
@@ -102,6 +102,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
private int lastAccounts = 0;
|
||||
private int lastOperations = 0;
|
||||
|
||||
private boolean foreground = false;
|
||||
private Map<Long, Core.State> coreStates = new Hashtable<>();
|
||||
private MutableLiveData<ConnectionHelper.NetworkState> liveNetworkState = new MutableLiveData<>();
|
||||
private MutableLiveData<List<TupleAccountState>> liveAccountState = new MutableLiveData<>();
|
||||
@@ -509,7 +510,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Core.notifyMessages(ServiceSynchronize.this, messages, groupNotifying);
|
||||
Core.notifyMessages(ServiceSynchronize.this, messages, groupNotifying, foreground);
|
||||
} catch (SecurityException ex) {
|
||||
Log.w(ex);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ServiceSynchronize.this);
|
||||
@@ -717,6 +718,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
onWakeup(intent);
|
||||
break;
|
||||
|
||||
case "state":
|
||||
onState(intent);
|
||||
break;
|
||||
|
||||
case "alarm":
|
||||
onAlarm(intent);
|
||||
break;
|
||||
@@ -772,6 +777,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
}
|
||||
}
|
||||
|
||||
private void onState(Intent intent) {
|
||||
foreground = intent.getBooleanExtra("foreground", false);
|
||||
}
|
||||
|
||||
private void onAlarm(Intent intent) {
|
||||
Bundle command = new Bundle();
|
||||
schedule(this);
|
||||
@@ -2145,6 +2154,13 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
.setAction("alarm"));
|
||||
}
|
||||
|
||||
static void state(Context context, boolean foreground) {
|
||||
start(context,
|
||||
new Intent(context, ServiceSynchronize.class)
|
||||
.setAction("state")
|
||||
.putExtra("foreground", foreground));
|
||||
}
|
||||
|
||||
static void watchdog(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean enabled = prefs.getBoolean("enabled", true);
|
||||
|
||||
Reference in New Issue
Block a user