mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 20:57:25 +01:00
Fix app crashes when changing a wallpaper. Fix Apply Material You option not working.
This commit is contained in:
parent
e3578c59dd
commit
30bce5b798
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,13 @@ 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;
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user