mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-09 13:52:52 +00:00
Use local broadcast receivers
This commit is contained in:
parent
875a959188
commit
199c5d8b14
4 changed files with 33 additions and 8 deletions
|
@ -41,6 +41,7 @@ import android.webkit.CookieManager;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.os.LocaleListCompat;
|
||||
import androidx.emoji2.text.DefaultEmojiCompatConfig;
|
||||
import androidx.emoji2.text.EmojiCompat;
|
||||
|
@ -264,7 +265,10 @@ public class ApplicationEx extends Application
|
|||
}
|
||||
}
|
||||
|
||||
registerReceiver(onScreenOff, new IntentFilter(Intent.ACTION_SCREEN_OFF));
|
||||
ContextCompat.registerReceiver(this,
|
||||
onScreenOff,
|
||||
new IntentFilter(Intent.ACTION_SCREEN_OFF),
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||
|
||||
long end = new Date().getTime();
|
||||
Log.i("App created " + (end - start) + " ms");
|
||||
|
|
|
@ -5153,7 +5153,10 @@ public class FragmentMessages extends FragmentBase
|
|||
cm.registerNetworkCallback(builder.build(), networkCallback);
|
||||
|
||||
updateAirplaneMode(ConnectionHelper.airplaneMode(context));
|
||||
context.registerReceiver(airplanemode, new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED));
|
||||
ContextCompat.registerReceiver(context,
|
||||
airplanemode,
|
||||
new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED),
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||
|
||||
boolean isIgnoring = !Boolean.FALSE.equals(Helper.isIgnoringOptimizations(context));
|
||||
//boolean canSchedule = AlarmManagerCompatEx.canScheduleExactAlarms(context);
|
||||
|
|
|
@ -179,7 +179,10 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|||
IntentFilter iif = new IntentFilter();
|
||||
iif.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
iif.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||
registerReceiver(connectionChangedReceiver, iif);
|
||||
ContextCompat.registerReceiver(this,
|
||||
connectionChangedReceiver,
|
||||
iif,
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
|
|
@ -212,22 +212,37 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
IntentFilter iif = new IntentFilter();
|
||||
iif.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
iif.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||
registerReceiver(connectionChangedReceiver, iif);
|
||||
ContextCompat.registerReceiver(this,
|
||||
connectionChangedReceiver,
|
||||
iif,
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
registerReceiver(idleModeChangedReceiver, new IntentFilter(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED));
|
||||
ContextCompat.registerReceiver(this,
|
||||
idleModeChangedReceiver,
|
||||
new IntentFilter(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED),
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
registerReceiver(dataSaverChanged, new IntentFilter(ConnectivityManager.ACTION_RESTRICT_BACKGROUND_CHANGED));
|
||||
ContextCompat.registerReceiver(this,
|
||||
dataSaverChanged,
|
||||
new IntentFilter(ConnectivityManager.ACTION_RESTRICT_BACKGROUND_CHANGED),
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
IntentFilter suspend = new IntentFilter();
|
||||
suspend.addAction(Intent.ACTION_MY_PACKAGE_SUSPENDED);
|
||||
suspend.addAction(Intent.ACTION_MY_PACKAGE_UNSUSPENDED);
|
||||
registerReceiver(suspendChanged, suspend);
|
||||
ContextCompat.registerReceiver(this,
|
||||
suspendChanged,
|
||||
suspend,
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||
}
|
||||
|
||||
registerReceiver(batteryChanged, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
ContextCompat.registerReceiver(this,
|
||||
batteryChanged,
|
||||
new IntentFilter(Intent.ACTION_BATTERY_CHANGED),
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue