From 837219bebb91b2a26a8761aea2634a5616760e23 Mon Sep 17 00:00:00 2001 From: cepprice Date: Tue, 23 Feb 2021 18:42:26 +0500 Subject: [PATCH] Small fixes --- .../net/osmand/plus/settings/backend/ApplicationMode.java | 7 +++++-- .../plus/settings/fragments/ProfileAppearanceFragment.java | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java index f259884d6c..0348bf3eb7 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java @@ -1,5 +1,6 @@ package net.osmand.plus.settings.backend; +import androidx.annotation.ColorInt; import androidx.annotation.DrawableRes; import androidx.core.content.ContextCompat; @@ -464,12 +465,14 @@ public class ApplicationMode { return app.getSettings().LOCATION_ICON.getModeValue(this); } + @ColorInt public int getProfileColor(boolean nightMode) { int index = getCustomIconColorIndex(); - if (index == -1) { + List customColors = getCustomIconColors(); + if (index < 0 || index >= customColors.size()) { return ContextCompat.getColor(app, getIconColorInfo().getColor(nightMode)); } - return Integer.parseInt(getCustomIconColors().get(index)); + return Algorithms.parseColor(customColors.get(index)); } public void setLocationIcon(LocationIcon locationIcon) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index eda8bb5f97..1e8f689178 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -944,7 +944,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O changedProfile.customColorIndex = -1; changedProfile.color = changedProfile.getProfileColorByColorValue(color); } else { - changedProfile.customColorIndex = color; + changedProfile.customColorIndex = cardOfColors.getIndexOfSelectedColor(); changedProfile.color = null; } @@ -1006,7 +1006,9 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O LocationIcon locationIcon; public int getActualColor() { - return customColorIndex != -1 ? customColorIndex : ContextCompat.getColor(app, color.getColor(isNightMode())); + return customColorIndex != -1 ? + Algorithms.parseColor(settings.CUSTOM_ICON_COLORS.getStringsListForProfile(getSelectedAppMode()).get(customColorIndex)) : + ContextCompat.getColor(app, color.getColor(isNightMode())); } public ProfileIconColors getProfileColorByColorValue(int colorValue) {