Small fixes

This commit is contained in:
cepprice 2021-02-23 18:42:26 +05:00
parent f75a8f8b58
commit 837219bebb
2 changed files with 9 additions and 4 deletions

View file

@ -1,5 +1,6 @@
package net.osmand.plus.settings.backend; package net.osmand.plus.settings.backend;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
@ -464,12 +465,14 @@ public class ApplicationMode {
return app.getSettings().LOCATION_ICON.getModeValue(this); return app.getSettings().LOCATION_ICON.getModeValue(this);
} }
@ColorInt
public int getProfileColor(boolean nightMode) { public int getProfileColor(boolean nightMode) {
int index = getCustomIconColorIndex(); int index = getCustomIconColorIndex();
if (index == -1) { List<String> customColors = getCustomIconColors();
if (index < 0 || index >= customColors.size()) {
return ContextCompat.getColor(app, getIconColorInfo().getColor(nightMode)); return ContextCompat.getColor(app, getIconColorInfo().getColor(nightMode));
} }
return Integer.parseInt(getCustomIconColors().get(index)); return Algorithms.parseColor(customColors.get(index));
} }
public void setLocationIcon(LocationIcon locationIcon) { public void setLocationIcon(LocationIcon locationIcon) {

View file

@ -944,7 +944,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
changedProfile.customColorIndex = -1; changedProfile.customColorIndex = -1;
changedProfile.color = changedProfile.getProfileColorByColorValue(color); changedProfile.color = changedProfile.getProfileColorByColorValue(color);
} else { } else {
changedProfile.customColorIndex = color; changedProfile.customColorIndex = cardOfColors.getIndexOfSelectedColor();
changedProfile.color = null; changedProfile.color = null;
} }
@ -1006,7 +1006,9 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
LocationIcon locationIcon; LocationIcon locationIcon;
public int getActualColor() { 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) { public ProfileIconColors getProfileColorByColorValue(int colorValue) {