mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Don't start MaterialYouService if Material You is not enabled.
This commit is contained in:
parent
2e0725e25e
commit
f94bd5039c
@ -43,6 +43,9 @@ public class Infinity extends Application implements LifecycleObserver {
|
|||||||
private boolean canStartLockScreenActivity = false;
|
private boolean canStartLockScreenActivity = false;
|
||||||
private boolean isSecureMode;
|
private boolean isSecureMode;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("default")
|
||||||
|
SharedPreferences mSharedPreferences;
|
||||||
|
@Inject
|
||||||
@Named("security")
|
@Named("security")
|
||||||
SharedPreferences mSecuritySharedPreferences;
|
SharedPreferences mSecuritySharedPreferences;
|
||||||
|
|
||||||
@ -127,7 +130,7 @@ public class Infinity extends Application implements LifecycleObserver {
|
|||||||
new NetworkWifiStatusReceiver(() -> EventBus.getDefault().post(new ChangeNetworkStatusEvent(Utils.getConnectedNetwork(getApplicationContext()))));
|
new NetworkWifiStatusReceiver(() -> EventBus.getDefault().post(new ChangeNetworkStatusEvent(Utils.getConnectedNetwork(getApplicationContext()))));
|
||||||
registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
||||||
|
|
||||||
registerReceiver(new WallpaperChangeReceiver(), new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
|
registerReceiver(new WallpaperChangeReceiver(mSharedPreferences), new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_START)
|
@OnLifecycleEvent(Lifecycle.Event.ON_START)
|
||||||
|
@ -3,16 +3,25 @@ package ml.docilealligator.infinityforreddit.broadcastreceivers;
|
|||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.services.MaterialYouService;
|
import ml.docilealligator.infinityforreddit.services.MaterialYouService;
|
||||||
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
public class WallpaperChangeReceiver extends BroadcastReceiver {
|
public class WallpaperChangeReceiver extends BroadcastReceiver {
|
||||||
|
private SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
|
public WallpaperChangeReceiver(SharedPreferences sharedPreferences) {
|
||||||
|
this.sharedPreferences = sharedPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
Intent materialYouIntent = new Intent(context, MaterialYouService.class);
|
if (sharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_MATERIAL_YOU, false)) {
|
||||||
ContextCompat.startForegroundService(context, materialYouIntent);
|
Intent materialYouIntent = new Intent(context, MaterialYouService.class);
|
||||||
|
ContextCompat.startForegroundService(context, materialYouIntent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user