From 8a9b59c66a4bda63fa6dd5863c29f9197bf31658 Mon Sep 17 00:00:00 2001 From: sk Date: Wed, 21 Dec 2022 14:49:38 +0100 Subject: [PATCH] generalize color picker settings item --- .../android/fragments/SettingsFragment.java | 54 ++++++++++++------- ...or_picker.xml => item_settings_button.xml} | 18 ++++--- 2 files changed, 44 insertions(+), 28 deletions(-) rename mastodon/src/main/res/layout/{item_settings_color_picker.xml => item_settings_button.xml} (73%) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java index ca0165403..e6f10dd99 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -102,7 +102,18 @@ public class SettingsFragment extends MastodonToolbarFragment{ GlobalUserPreferences.disableMarquee=i.checked; GlobalUserPreferences.save(); })); - items.add(new ColorPalettePicker()); + items.add(new ButtonItem(R.string.sk_settings_color_palette, R.drawable.ic_fluent_color_24_regular, b->{ + b.setText(switch(GlobalUserPreferences.color){ + case MATERIAL3 -> R.string.sk_color_palette_material3; + case PINK -> R.string.sk_color_palette_pink; + case PURPLE -> R.string.sk_color_palette_purple; + case GREEN -> R.string.sk_color_palette_green; + case BLUE -> R.string.sk_color_palette_blue; + case BROWN -> R.string.sk_color_palette_brown; + case RED -> R.string.sk_color_palette_red; + case YELLOW -> R.string.sk_color_palette_yellow; + }); + })); items.add(new HeaderItem(R.string.settings_behavior)); items.add(new SwitchItem(R.string.sk_settings_show_federated_timeline, R.drawable.ic_fluent_earth_24_regular, GlobalUserPreferences.showFederatedTimeline, i->{ @@ -489,7 +500,17 @@ public class SettingsFragment extends MastodonToolbarFragment{ } } - public class ColorPalettePicker extends Item{ + public class ButtonItem extends Item{ + private int text; + private int icon; + private Consumer