mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-05 20:34:49 +01:00
Moved screen off handling to application
This commit is contained in:
@@ -24,7 +24,10 @@ import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationChannelGroup;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.webkit.CookieManager;
|
||||
@@ -107,6 +110,8 @@ public class ApplicationEx extends Application {
|
||||
WorkerWatchdog.init(this);
|
||||
WorkerCleanup.queue(this);
|
||||
|
||||
registerReceiver(onScreenOff, new IntentFilter(Intent.ACTION_SCREEN_OFF));
|
||||
|
||||
long end = new Date().getTime();
|
||||
Log.i("App created " + (end - start) + " ms");
|
||||
}
|
||||
@@ -412,4 +417,13 @@ public class ApplicationEx extends Application {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private BroadcastReceiver onScreenOff = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.i("Received " + intent);
|
||||
Log.logExtras(intent);
|
||||
Helper.clearAuthentication(ApplicationEx.this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -148,7 +148,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
iif.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
iif.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||
registerReceiver(connectionChangedReceiver, iif);
|
||||
registerReceiver(onScreenOff, new IntentFilter(Intent.ACTION_SCREEN_OFF));
|
||||
|
||||
DB db = DB.getInstance(this);
|
||||
|
||||
@@ -582,7 +581,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
prefs.unregisterOnSharedPreferenceChangeListener(this);
|
||||
|
||||
unregisterReceiver(onScreenOff);
|
||||
unregisterReceiver(connectionChangedReceiver);
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
@@ -1683,15 +1681,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
}
|
||||
};
|
||||
|
||||
private BroadcastReceiver onScreenOff = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.i("Received " + intent);
|
||||
Log.logExtras(intent);
|
||||
Helper.clearAuthentication(ServiceSynchronize.this);
|
||||
}
|
||||
};
|
||||
|
||||
private class MediatorState extends MediatorLiveData<List<TupleAccountNetworkState>> {
|
||||
boolean running = true;
|
||||
private ConnectionHelper.NetworkState lastNetworkState = null;
|
||||
|
||||
Reference in New Issue
Block a user