diff --git a/OsmAnd/res/xml/profile_appearance.xml b/OsmAnd/res/xml/profile_appearance.xml
index 9c042ddeaa..53a1fa2a1c 100644
--- a/OsmAnd/res/xml/profile_appearance.xml
+++ b/OsmAnd/res/xml/profile_appearance.xml
@@ -21,7 +21,7 @@
colors = new ArrayList<>();
+ for (ProfileIconColors color : ProfileIconColors.values()) {
+ colors.add(ContextCompat.getColor(app, color.getColor(isNightMode())));
}
- updateProfileNameAppearance();
- updateProfileButton();
+ colorsCard = new ColorsCard(mapActivity, selectedColor, this, colors, app.getSettings().CUSTOM_ICON_COLORS, getSelectedAppMode());
+ colorsCard.setListener(this);
+ parentView.removeAllViews();
+ parentView.addView(colorsCard.build(app));
+ updateColorName();
}
private void updateProfileNameAppearance() {
@@ -939,6 +906,18 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
}
}
+ private void updateColorName() {
+ if (colorsCard == null || colorName == null) {
+ return;
+ }
+ int selectedColor = colorsCard.getSelectedColor();
+ if (colorsCard.isBaseColor(selectedColor)) {
+ colorName.setText(changedProfile.getProfileColorByColorValue(selectedColor).getName());
+ } else {
+ colorName.setText(R.string.custom_color);
+ }
+ }
+
@Override
public void onProfileSelected(Bundle args) {
String profileKey = args.getString(PROFILE_KEY_ARG);
@@ -946,6 +925,54 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
updateParentProfile(profileKey, imported);
}
+ @Override
+ public void onCardLayoutNeeded(@NonNull BaseCard card) {
+ }
+
+ @Override
+ public void onCardPressed(@NonNull BaseCard card) {
+ if (card instanceof ColorsCard) {
+ ColorsCard cardOfColors = (ColorsCard) card;
+ int color = cardOfColors.getSelectedColor();
+
+ if (color == changedProfile.getActualColor()) {
+ return;
+ }
+
+
+ if (cardOfColors.isBaseColor(color)) {
+ changedProfile.customColorIndex = -1;
+ changedProfile.color = changedProfile.getProfileColorByColorValue(color);
+ } else {
+ changedProfile.customColorIndex = color;
+ changedProfile.color = null;
+ }
+
+ if (iconItems != null) {
+ updateIconColor(changedProfile.iconRes);
+ }
+
+ updateColorName();
+ updateProfileNameAppearance();
+ updateProfileButton();
+ setVerticalScrollBarEnabled(false);
+ updatePreference(findPreference(MASTER_PROFILE));
+ updatePreference(findPreference(LOCATION_ICON_ITEMS));
+ updatePreference(findPreference(NAV_ICON_ITEMS));
+ setVerticalScrollBarEnabled(true);
+ }
+ }
+
+ @Override
+ public void onCardButtonPressed(@NonNull BaseCard card, int buttonIndex) {
+ }
+
+ @Override
+ public void onColorSelected(Integer prevColor, int newColor) {
+ colorsCard.onColorSelected(prevColor, newColor);
+ this.onCardPressed(colorsCard);
+ }
+
public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, @Nullable String appMode, boolean imported) {
try {
Fragment fragment = Fragment.instantiate(activity, screenType.fragmentName);