aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-11-15 11:06:05 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-11-15 11:06:05 +0000
commitf94bd5039c2c809ac465af54496b8dafca8caada (patch)
tree7a32312030c36eb16090dabc86395376c0bb5cde /app/src
parent2e0725e25e3f8eea0871c9e3a48fec673618298a (diff)
downloadinfinity-for-reddit-f94bd5039c2c809ac465af54496b8dafca8caada.tar
infinity-for-reddit-f94bd5039c2c809ac465af54496b8dafca8caada.tar.gz
infinity-for-reddit-f94bd5039c2c809ac465af54496b8dafca8caada.tar.bz2
infinity-for-reddit-f94bd5039c2c809ac465af54496b8dafca8caada.tar.lz
infinity-for-reddit-f94bd5039c2c809ac465af54496b8dafca8caada.tar.xz
infinity-for-reddit-f94bd5039c2c809ac465af54496b8dafca8caada.tar.zst
infinity-for-reddit-f94bd5039c2c809ac465af54496b8dafca8caada.zip
Don't start MaterialYouService if Material You is not enabled.
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java13
2 files changed, 15 insertions, 3 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
index e0eb462d..2b990071 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
@@ -43,6 +43,9 @@ public class Infinity extends Application implements LifecycleObserver {
private boolean canStartLockScreenActivity = false;
private boolean isSecureMode;
@Inject
+ @Named("default")
+ SharedPreferences mSharedPreferences;
+ @Inject
@Named("security")
SharedPreferences mSecuritySharedPreferences;
@@ -127,7 +130,7 @@ public class Infinity extends Application implements LifecycleObserver {
new NetworkWifiStatusReceiver(() -> EventBus.getDefault().post(new ChangeNetworkStatusEvent(Utils.getConnectedNetwork(getApplicationContext()))));
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)
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java b/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java
index 5a596308..e65b97f8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java
@@ -3,16 +3,25 @@ package ml.docilealligator.infinityforreddit.broadcastreceivers;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import androidx.core.content.ContextCompat;
import ml.docilealligator.infinityforreddit.services.MaterialYouService;
+import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class WallpaperChangeReceiver extends BroadcastReceiver {
+ private SharedPreferences sharedPreferences;
+
+ public WallpaperChangeReceiver(SharedPreferences sharedPreferences) {
+ this.sharedPreferences = sharedPreferences;
+ }
@Override
public void onReceive(Context context, Intent intent) {
- Intent materialYouIntent = new Intent(context, MaterialYouService.class);
- ContextCompat.startForegroundService(context, materialYouIntent);
+ if (sharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_MATERIAL_YOU, false)) {
+ Intent materialYouIntent = new Intent(context, MaterialYouService.class);
+ ContextCompat.startForegroundService(context, materialYouIntent);
+ }
}
}