diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDisplayFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDisplayFragment.java index 5feae1cc..ccea1052 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDisplayFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDisplayFragment.java @@ -40,8 +40,13 @@ public class SettingsDisplayFragment extends BaseSettingsFragment{ AccountLocalPreferences lp=s.getLocalPreferences(); List> items=new ArrayList<>(); items.add(themeItem=new ListItem<>(R.string.settings_theme, getAppearanceValue(), R.drawable.ic_dark_mode_24px, this::onAppearanceClick)); - if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.S) - items.add(dynamicColorsItem=new CheckableListItem<>(R.string.settings_use_dynamic_colors, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.useDynamicColors, R.drawable.ic_palette_24px, this::onDynamicColorsClick)); + if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.S){ + items.add(dynamicColorsItem=new CheckableListItem<>(R.string.settings_use_dynamic_colors, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.useDynamicColors, R.drawable.ic_palette_24px, item->{ + toggleCheckableItem(item); + setUseDynamicColors(item.checked); + })); + dynamicColorsItem.checkedChangeListener=this::setUseDynamicColors; + } items.add(showCWsItem=new CheckableListItem<>(R.string.settings_show_cws, 0, CheckableListItem.Style.SWITCH, lp.showCWs, R.drawable.ic_warning_24px, this::toggleCheckableItem)); items.add(hideSensitiveMediaItem=new CheckableListItem<>(R.string.settings_hide_sensitive_media, 0, CheckableListItem.Style.SWITCH, lp.hideSensitiveMedia, R.drawable.ic_no_adult_content_24px, this::toggleCheckableItem)); items.add(interactionCountsItem=new CheckableListItem<>(R.string.settings_show_interaction_counts, 0, CheckableListItem.Style.SWITCH, lp.showInteractionCounts, R.drawable.ic_social_leaderboard_24px, this::toggleCheckableItem)); @@ -112,10 +117,9 @@ public class SettingsDisplayFragment extends BaseSettingsFragment{ .show(); } - private void onDynamicColorsClick(CheckableListItem item){ - item.toggle(); - rebindItem(item); - GlobalUserPreferences.useDynamicColors=item.checked; + private void setUseDynamicColors(boolean useDynamicColors){ + dynamicColorsItem.checked=useDynamicColors; + GlobalUserPreferences.useDynamicColors=useDynamicColors; GlobalUserPreferences.save(); restartActivityToApplyNewTheme(); } diff --git a/mastodon/src/main/res/values/styles.xml b/mastodon/src/main/res/values/styles.xml index e63d4b6a..5d292f75 100644 --- a/mastodon/src/main/res/values/styles.xml +++ b/mastodon/src/main/res/values/styles.xml @@ -5,7 +5,7 @@ false false false - @color/m3_sys_light_surface + ?colorM3Surface @style/Widget.Mastodon.EditText @style/Widget.Mastodon.Spinner @style/action_mode_close @@ -90,7 +90,7 @@ false false false - @color/m3_sys_dark_surface + ?colorM3Surface @style/Widget.Mastodon.EditText @style/Widget.Mastodon.Spinner @style/action_mode_close