aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-07-04 00:44:31 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-07-04 00:44:31 +0000
commit30bce5b798750230b050eb564eddd5570655b184 (patch)
tree35a2606634639b9348c6d65269a027986d3e8674 /app/src/main/java/ml
parente3578c59dd7cb65c3d78a1bd219d05577472a0b6 (diff)
downloadinfinity-for-reddit-30bce5b798750230b050eb564eddd5570655b184.tar
infinity-for-reddit-30bce5b798750230b050eb564eddd5570655b184.tar.gz
infinity-for-reddit-30bce5b798750230b050eb564eddd5570655b184.tar.bz2
infinity-for-reddit-30bce5b798750230b050eb564eddd5570655b184.tar.lz
infinity-for-reddit-30bce5b798750230b050eb564eddd5570655b184.tar.xz
infinity-for-reddit-30bce5b798750230b050eb564eddd5570655b184.tar.zst
infinity-for-reddit-30bce5b798750230b050eb564eddd5570655b184.zip
Fix app crashes when changing a wallpaper. Fix Apply Material You option not working.
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/services/MaterialYouService.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java15
3 files changed, 17 insertions, 24 deletions
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 ae9392f7..f994b1a9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/broadcastreceivers/WallpaperChangeReceiver.java
@@ -3,24 +3,14 @@ package ml.docilealligator.infinityforreddit.broadcastreceivers;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.content.SharedPreferences;
-
-import javax.inject.Inject;
-import javax.inject.Named;
import ml.docilealligator.infinityforreddit.services.MaterialYouService;
-import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class WallpaperChangeReceiver extends BroadcastReceiver {
- @Inject
- @Named("default")
- SharedPreferences mSharedPreferences;
@Override
public void onReceive(Context context, Intent intent) {
- if (mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_MATERIAL_YOU, false)) {
- Intent materialYouIntent = new Intent(context, MaterialYouService.class);
- context.startService(materialYouIntent);
- }
+ Intent materialYouIntent = new Intent(context, MaterialYouService.class);
+ context.startService(materialYouIntent);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/MaterialYouService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/MaterialYouService.java
index 221b980b..7fc764f8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/MaterialYouService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/MaterialYouService.java
@@ -14,10 +14,14 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.utils.MaterialYouUtils;
+import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class MaterialYouService extends IntentService {
@Inject
+ @Named("default")
+ SharedPreferences mSharedPreferences;
+ @Inject
@Named("light_theme")
SharedPreferences lightThemeSharedPreferences;
@Inject
@@ -40,8 +44,10 @@ public class MaterialYouService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
((Infinity) getApplication()).getAppComponent().inject(this);
- MaterialYouUtils.changeTheme(this, executor, new Handler(), redditDataRoomDatabase,
- customThemeWrapper, lightThemeSharedPreferences, darkThemeSharedPreferences,
- amoledThemeSharedPreferences);
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_MATERIAL_YOU, false)) {
+ MaterialYouUtils.changeTheme(this, executor, new Handler(), redditDataRoomDatabase,
+ customThemeWrapper, lightThemeSharedPreferences, darkThemeSharedPreferences,
+ amoledThemeSharedPreferences);
+ }
}
} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java
index 2e94f166..9dafc175 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java
@@ -190,15 +190,12 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat {
return true;
});
- applyMaterialYouPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- MaterialYouUtils.changeTheme(activity, executor, new Handler(),
- redditDataRoomDatabase, customThemeWrapper,
- lightThemeSharedPreferences, darkThemeSharedPreferences,
- amoledThemeSharedPreferences);
- return true;
- }
+ applyMaterialYouPreference.setOnPreferenceClickListener(preference -> {
+ MaterialYouUtils.changeTheme(activity, executor, new Handler(),
+ redditDataRoomDatabase, customThemeWrapper,
+ lightThemeSharedPreferences, darkThemeSharedPreferences,
+ amoledThemeSharedPreferences);
+ return true;
});
}