diff options
Diffstat (limited to 'app/src')
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; }); } |