diff --git a/OsmAnd/res/layout/preference_colors_card.xml b/OsmAnd/res/layout/preference_colors_card.xml
new file mode 100644
index 0000000000..97ad948f70
--- /dev/null
+++ b/OsmAnd/res/layout/preference_colors_card.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/xml/profile_appearance.xml b/OsmAnd/res/xml/profile_appearance.xml
index 9c042ddeaa..87ec511b69 100644
--- a/OsmAnd/res/xml/profile_appearance.xml
+++ b/OsmAnd/res/xml/profile_appearance.xml
@@ -21,12 +21,12 @@
diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java
index e410aac3d3..f385a4af8e 100644
--- a/OsmAnd/src/net/osmand/AndroidUtils.java
+++ b/OsmAnd/src/net/osmand/AndroidUtils.java
@@ -336,6 +336,43 @@ public class AndroidUtils {
);
}
+ public static ColorStateList createCheckedColorIntStateList(@ColorInt int normal, @ColorInt int checked) {
+ return createCheckedColorIntStateList(false, normal, checked, 0, 0);
+ }
+
+ public static ColorStateList createCheckedColorIntStateList(boolean night,
+ @ColorInt int lightNormal, @ColorInt int lightChecked,
+ @ColorInt int darkNormal, @ColorInt int darkChecked) {
+ return createColorIntStateList(night, android.R.attr.state_checked,
+ lightNormal, lightChecked, darkNormal, darkChecked);
+ }
+
+ public static ColorStateList createEnabledColorIntStateList(@ColorInt int normal, @ColorInt int pressed) {
+ return createEnabledColorIntStateList(false, normal, pressed, 0, 0);
+ }
+
+ public static ColorStateList createEnabledColorIntStateList(boolean night,
+ @ColorInt int lightNormal, @ColorInt int lightPressed,
+ @ColorInt int darkNormal, @ColorInt int darkPressed) {
+ return createColorIntStateList(night, android.R.attr.state_enabled,
+ lightNormal, lightPressed, darkNormal, darkPressed);
+ }
+
+ private static ColorStateList createColorIntStateList(boolean night, int state,
+ @ColorInt int lightNormal, @ColorInt int lightState,
+ @ColorInt int darkNormal, @ColorInt int darkState) {
+ return new ColorStateList(
+ new int[][]{
+ new int[]{state},
+ new int[]{}
+ },
+ new int[]{
+ night ? darkState : lightState,
+ night ? darkNormal : lightNormal
+ }
+ );
+ }
+
public static StateListDrawable createCheckedStateListDrawable(Drawable normal, Drawable checked) {
return createStateListDrawable(normal, checked, android.R.attr.state_checked);
}
diff --git a/OsmAnd/src/net/osmand/aidl/ConnectedApp.java b/OsmAnd/src/net/osmand/aidl/ConnectedApp.java
index bbfa4f89b8..b8a467d991 100644
--- a/OsmAnd/src/net/osmand/aidl/ConnectedApp.java
+++ b/OsmAnd/src/net/osmand/aidl/ConnectedApp.java
@@ -133,7 +133,7 @@ public class ConnectedApp implements Comparable {
CompoundButton btn = view.findViewById(R.id.toggle_item);
if (btn != null && btn.getVisibility() == View.VISIBLE) {
btn.setChecked(!btn.isChecked());
- menuAdapter.getItem(position).setColorRes(btn.isChecked() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ menuAdapter.getItem(position).setColor(app, btn.isChecked() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
return false;
}
@@ -146,7 +146,7 @@ public class ConnectedApp implements Comparable {
if (layersPref.set(isChecked)) {
ContextMenuItem item = adapter.getItem(position);
if (item != null) {
- item.setColorRes(isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ item.setColor(app, isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
item.setSelected(isChecked);
adapter.notifyDataSetChanged();
}
@@ -162,7 +162,7 @@ public class ConnectedApp implements Comparable {
.setListener(listener)
.setSelected(layersEnabled)
.setIcon(R.drawable.ic_extension_dark)
- .setColor(layersEnabled ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, layersEnabled ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.createItem());
}
diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
index 381125e0ec..5fdea403d3 100644
--- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
@@ -249,8 +249,7 @@ public class ContextMenuAdapter {
final ContextMenuItem item = getItem(position);
int layoutId = item.getLayout();
layoutId = layoutId != ContextMenuItem.INVALID_ID ? layoutId : DEFAULT_LAYOUT_ID;
- int currentModeColorRes = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode);
- int currentModeColor = ContextCompat.getColor(app, currentModeColorRes);
+ int currentModeColor = app.getSettings().getApplicationMode().getProfileColor(nightMode);
if (layoutId == R.layout.mode_toggles) {
final Set selected = new LinkedHashSet<>();
return AppModeDialog.prepareAppModeDrawerView((Activity) getContext(),
@@ -278,15 +277,13 @@ public class ContextMenuAdapter {
}
if (layoutId == R.layout.main_menu_drawer_btn_switch_profile ||
layoutId == R.layout.main_menu_drawer_btn_configure_profile) {
- int colorResId = item.getColorRes();
- int colorNoAlpha = ContextCompat.getColor(app, colorResId);
-
+ int colorNoAlpha = item.getColor();
TextView title = convertView.findViewById(R.id.title);
title.setText(item.getTitle());
if (layoutId == R.layout.main_menu_drawer_btn_switch_profile) {
ImageView icon = convertView.findViewById(R.id.icon);
- icon.setImageDrawable(mIconsCache.getIcon(item.getIcon(), colorResId));
+ icon.setImageDrawable(mIconsCache.getPaintedIcon(item.getIcon(), colorNoAlpha));
ImageView icArrow = convertView.findViewById(R.id.ic_expand_list);
icArrow.setImageDrawable(mIconsCache.getIcon(item.getSecondaryIcon()));
TextView desc = convertView.findViewById(R.id.description);
@@ -306,16 +303,13 @@ public class ContextMenuAdapter {
return convertView;
}
if (layoutId == R.layout.profile_list_item) {
-
int tag = item.getTag();
-
- int colorResId = item.getColorRes();
- int colorNoAlpha = ContextCompat.getColor(app, colorResId);
+ int colorNoAlpha = item.getColor();
TextView title = convertView.findViewById(R.id.title);
TextView desc = convertView.findViewById(R.id.description);
ImageView icon = convertView.findViewById(R.id.icon);
title.setText(item.getTitle());
-
+
convertView.findViewById(R.id.divider_up).setVisibility(View.INVISIBLE);
convertView.findViewById(R.id.divider_bottom).setVisibility(View.INVISIBLE);
convertView.findViewById(R.id.menu_image).setVisibility(View.GONE);
@@ -331,7 +325,7 @@ public class ContextMenuAdapter {
AndroidUiHelper.updateVisibility(icon, true);
AndroidUiHelper.updateVisibility(desc, true);
AndroidUtils.setTextPrimaryColor(app, title, nightMode);
- icon.setImageDrawable(mIconsCache.getIcon(item.getIcon(), colorResId));
+ icon.setImageDrawable(mIconsCache.getPaintedIcon(item.getIcon(), colorNoAlpha));
desc.setText(item.getDescription());
boolean selectedMode = tag == PROFILES_CHOSEN_PROFILE_TAG;
if (selectedMode) {
@@ -419,17 +413,18 @@ public class ContextMenuAdapter {
}
} else {
if (item.getIcon() != ContextMenuItem.INVALID_ID) {
- int colorRes = item.getColorRes();
- if (colorRes == ContextMenuItem.INVALID_ID) {
- if (!item.shouldSkipPainting()) {
- colorRes = lightTheme ? R.color.icon_color_default_light : R.color.icon_color_default_dark;
- } else {
- colorRes = 0;
- }
+ Integer color = item.getColor();
+ Drawable drawable;
+ if (color == null) {
+ int colorRes = lightTheme ? R.color.icon_color_default_light : R.color.icon_color_default_dark;
+ colorRes = item.shouldSkipPainting() ? 0 : colorRes;
+ drawable = mIconsCache.getIcon(item.getIcon(), colorRes);
} else if (profileDependent) {
- colorRes = currentModeColorRes;
+ drawable = mIconsCache.getPaintedIcon(item.getIcon(), currentModeColor);
+ } else {
+ drawable = mIconsCache.getPaintedIcon(item.getIcon(), color);
}
- final Drawable drawable = mIconsCache.getIcon(item.getIcon(), colorRes);
+
((AppCompatImageView) convertView.findViewById(R.id.icon)).setImageDrawable(drawable);
convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE);
} else if (convertView.findViewById(R.id.icon) != null) {
diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java
index 3718169532..1ab526cbeb 100644
--- a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java
+++ b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java
@@ -19,8 +19,8 @@ public class ContextMenuItem {
private String title;
@DrawableRes
private int mIcon;
- @ColorRes
- private int colorRes;
+ @ColorInt
+ private Integer color;
@DrawableRes
private int secondaryIcon;
private Boolean selected;
@@ -48,7 +48,7 @@ public class ContextMenuItem {
private ContextMenuItem(@StringRes int titleId,
String title,
@DrawableRes int icon,
- @ColorRes int colorRes,
+ @ColorInt Integer color,
@DrawableRes int secondaryIcon,
Boolean selected,
int progress,
@@ -72,7 +72,7 @@ public class ContextMenuItem {
this.titleId = titleId;
this.title = title;
this.mIcon = icon;
- this.colorRes = colorRes;
+ this.color = color;
this.secondaryIcon = secondaryIcon;
this.selected = selected;
this.progress = progress;
@@ -109,23 +109,17 @@ public class ContextMenuItem {
return mIcon;
}
- @ColorRes
- public int getColorRes() {
- return colorRes;
- }
-
- @ColorRes
- public int getThemedColorRes(Context context) {
- if (skipPaintingWithoutColor || getColorRes() != INVALID_ID) {
- return getColorRes();
- } else {
- return UiUtilities.getDefaultColorRes(context);
- }
+ @ColorInt
+ public Integer getColor() {
+ return color;
}
@ColorInt
public int getThemedColor(Context context) {
- return ContextCompat.getColor(context, getThemedColorRes(context));
+ if (skipPaintingWithoutColor || color != null) {
+ return color;
+ }
+ return ContextCompat.getColor(context, UiUtilities.getDefaultColorRes(context));
}
@DrawableRes
@@ -212,8 +206,10 @@ public class ContextMenuItem {
this.secondaryIcon = secondaryIcon;
}
- public void setColorRes(int colorRes) {
- this.colorRes = colorRes;
+ public void setColor(Context context, @ColorRes int colorRes) {
+ if (colorRes != INVALID_ID) {
+ this.color = ContextCompat.getColor(context, colorRes);
+ }
}
public void setSelected(boolean selected) {
@@ -268,8 +264,8 @@ public class ContextMenuItem {
private String mTitle;
@DrawableRes
private int mIcon = INVALID_ID;
- @ColorRes
- private int mColorRes = INVALID_ID;
+ @ColorInt
+ private Integer mColor = null;
@DrawableRes
private int mSecondaryIcon = INVALID_ID;
private Boolean mSelected = null;
@@ -307,8 +303,15 @@ public class ContextMenuItem {
return this;
}
- public ItemBuilder setColor(@ColorRes int colorRes) {
- mColorRes = colorRes;
+ public ItemBuilder setColor(@ColorInt Integer color) {
+ mColor = color;
+ return this;
+ }
+
+ public ItemBuilder setColor(Context context, @ColorRes int colorRes) {
+ if (colorRes != INVALID_ID) {
+ mColor = ContextCompat.getColor(context, colorRes);
+ }
return this;
}
@@ -422,7 +425,7 @@ public class ContextMenuItem {
}
public ContextMenuItem createItem() {
- ContextMenuItem item = new ContextMenuItem(mTitleId, mTitle, mIcon, mColorRes, mSecondaryIcon,
+ ContextMenuItem item = new ContextMenuItem(mTitleId, mTitle, mIcon, mColor, mSecondaryIcon,
mSelected, mProgress, mLayout, mLoading, mIsCategory, mIsClickable, mSkipPaintingWithoutColor,
mOrder, mDescription, mOnUpdateCallback, mItemClickListener, mIntegerListener, mProgressListener,
mItemDeleteAction, mHideDivider, mHideCompoundButton, mMinHeight, mTag, mId);
diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java
index 0b2683fcc6..2dbd4f6dd9 100644
--- a/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java
+++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java
@@ -59,7 +59,7 @@ public class OsmAndLocationSimulation {
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
ApplicationMode appMode = app.getSettings().getApplicationMode();
- int selectedModeColor = ContextCompat.getColor(app, appMode.getIconColorInfo().getColor(nightMode));
+ int selectedModeColor = appMode.getProfileColor(nightMode);
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ma, themeRes));
builder.setTitle(R.string.animate_route);
diff --git a/OsmAnd/src/net/osmand/plus/UiUtilities.java b/OsmAnd/src/net/osmand/plus/UiUtilities.java
index aaa9d01f8b..269800c630 100644
--- a/OsmAnd/src/net/osmand/plus/UiUtilities.java
+++ b/OsmAnd/src/net/osmand/plus/UiUtilities.java
@@ -553,7 +553,7 @@ public class UiUtilities {
switch (type) {
case PROFILE_DEPENDENT:
ApplicationMode appMode = app.getSettings().getApplicationMode();
- activeColor = ContextCompat.getColor(app, appMode.getIconColorInfo().getColor(nightMode));
+ activeColor = appMode.getProfileColor(nightMode);
break;
case TOOLBAR:
activeColor = Color.WHITE;
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
index 2bb6f5caec..bfc5077b2e 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
@@ -753,7 +753,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.addItem(new ItemBuilder().setLayout(R.layout.profile_list_item)
.setIcon(appMode.getIconRes())
- .setColor(appMode.getIconColorInfo().getColor(nightMode))
+ .setColor(appMode.getProfileColor(nightMode))
.setTag(tag)
.setTitle(appMode.toHumanString())
.setDescription(modeDescription)
@@ -770,7 +770,7 @@ public class MapActivityActions implements DialogProvider {
int activeColorPrimaryResId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
optionsMenuHelper.addItem(new ItemBuilder().setLayout(R.layout.profile_list_item)
- .setColor(activeColorPrimaryResId)
+ .setColor(app, activeColorPrimaryResId)
.setTag(PROFILES_CONTROL_BUTTON_TAG)
.setTitle(getString(R.string.shared_string_manage))
.setListener(new ItemClickListener() {
@@ -1083,7 +1083,7 @@ public class MapActivityActions implements DialogProvider {
.setId(DRAWER_SWITCH_PROFILE_ID)
.setIcon(currentMode.getIconRes())
.setSecondaryIcon(icArrowResId)
- .setColor(currentMode.getIconColorInfo().getColor(nightMode))
+ .setColor(currentMode.getProfileColor(nightMode))
.setTitle(currentMode.toHumanString())
.setDescription(modeDescription)
.setListener(new ItemClickListener() {
@@ -1097,7 +1097,7 @@ public class MapActivityActions implements DialogProvider {
.createItem());
optionsMenuHelper.addItem(new ItemBuilder().setLayout(R.layout.main_menu_drawer_btn_configure_profile)
.setId(DRAWER_CONFIGURE_PROFILE_ID)
- .setColor(currentMode.getIconColorInfo().getColor(nightMode))
+ .setColor(currentMode.getProfileColor(nightMode))
.setTitle(getString(R.string.configure_profile))
.setListener(new ItemClickListener() {
@Override
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
index 8c0d09f150..ccdef9484e 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
@@ -437,7 +437,7 @@ public class MapActivityLayers {
} else {
builder.setIcon(R.drawable.mx_user_defined);
}
- builder.setColor(ContextMenuItem.INVALID_ID);
+ builder.setColor(activity, ContextMenuItem.INVALID_ID);
builder.setSkipPaintingWithoutColor(true);
adapter.addItem(builder.createItem());
}
@@ -495,7 +495,7 @@ public class MapActivityLayers {
OsmandApplication app = getApplication();
boolean nightMode = isNightMode(app);
int themeRes = getThemeRes(app);
- int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode));
+ int selectedModeColor = settings.getApplicationMode().getProfileColor(nightMode);
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
items, nightMode, selectedItem, app, selectedModeColor, themeRes, new View.OnClickListener() {
@Override
diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java
index 44222d5586..639bed2bdf 100644
--- a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java
+++ b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java
@@ -120,13 +120,13 @@ public class AppModeDialog {
final View selection = tb.findViewById(R.id.selection);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
if (checked) {
- iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
+ iv.setImageDrawable(ctx.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode)));
iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_checked)));
- selection.setBackgroundResource(mode.getIconColorInfo().getColor(nightMode));
+ selection.setBackgroundColor(mode.getProfileColor(nightMode));
selection.setVisibility(View.VISIBLE);
} else {
if (useMapTheme) {
- iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
+ iv.setImageDrawable(ctx.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode)));
iv.setBackgroundResource(AndroidUtils.resolveAttribute(themedCtx, android.R.attr.selectableItemBackground));
} else {
iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes()));
@@ -171,7 +171,7 @@ public class AppModeDialog {
final boolean checked = selected.contains(mode);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
ImageView selection = tb.findViewById(R.id.selection);
- Drawable drawable = ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode));
+ Drawable drawable = ctx.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode));
if (checked) {
iv.setImageDrawable(drawable);
iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_checked)));
@@ -184,7 +184,7 @@ public class AppModeDialog {
} else {
if (useMapTheme) {
if (Build.VERSION.SDK_INT >= 21) {
- Drawable active = ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode));
+ Drawable active = ctx.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode));
drawable = AndroidUtils.createPressedStateListDrawable(drawable, active);
}
iv.setImageDrawable(drawable);
@@ -195,7 +195,7 @@ public class AppModeDialog {
AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.btn_border_pressed_trans_light, R.drawable.btn_border_pressed_trans_light);
}
} else {
- iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
+ iv.setImageDrawable(ctx.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode)));
}
iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_unchecked)));
}
@@ -232,7 +232,7 @@ public class AppModeDialog {
int metricsY = (int) ctx.getResources().getDimension(R.dimen.route_info_modes_height);
View tb = layoutInflater.inflate(layoutId, null);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
- iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(isNightMode(ctx, useMapTheme))));
+ iv.setImageDrawable(ctx.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(isNightMode(ctx, useMapTheme))));
iv.setContentDescription(mode.toHumanString());
// tb.setCompoundDrawablesWithIntrinsicBounds(null, ctx.getIconsCache().getIcon(mode.getIconId(), R.color.app_mode_icon_color), null, null);
LayoutParams lp = new LinearLayout.LayoutParams(metricsX, metricsY);
diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java b/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java
index c8c9a70785..4728c0bce3 100644
--- a/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java
+++ b/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java
@@ -121,7 +121,7 @@ public class StartGPSStatus extends OsmAndAction {
cb.setLayoutParams(lp);
cb.setPadding(dp8, 0, 0, 0);
int textColorPrimary = ContextCompat.getColor(activity, isNightMode() ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
- int selectedModeColor = ContextCompat.getColor(activity, getSettings().getApplicationMode().getIconColorInfo().getColor(isNightMode()));
+ int selectedModeColor = getSettings().getApplicationMode().getProfileColor(isNightMode());
cb.setTextColor(textColorPrimary);
UiUtilities.setupCompoundButton(isNightMode(), selectedModeColor, cb);
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
index b7f15624b4..6d425ef65e 100644
--- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
@@ -678,7 +678,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
if (itemId == R.string.layer_recordings) {
SHOW_RECORDINGS.set(!SHOW_RECORDINGS.get());
- adapter.getItem(pos).setColorRes(SHOW_RECORDINGS.get() ?
+ adapter.getItem(pos).setColor(app, SHOW_RECORDINGS.get() ?
R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
updateLayers(mapView, mapActivity);
@@ -690,7 +690,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
.setId(RECORDING_LAYER)
.setSelected(SHOW_RECORDINGS.get())
.setIcon(R.drawable.ic_action_micro_dark)
- .setColor(SHOW_RECORDINGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(mapActivity, SHOW_RECORDINGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setItemDeleteAction(makeDeleteAction(SHOW_RECORDINGS))
.setListener(listener).createItem());
}
diff --git a/OsmAnd/src/net/osmand/plus/base/BottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/BottomSheetDialogFragment.java
index c33b183b65..4a9924fd0e 100644
--- a/OsmAnd/src/net/osmand/plus/base/BottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/base/BottomSheetDialogFragment.java
@@ -10,6 +10,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
+import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
@@ -91,6 +92,16 @@ public abstract class BottomSheetDialogFragment extends DialogFragment {
}
}
+ @Nullable
+ protected Drawable getPaintedIcon(@DrawableRes int drawableRes, @ColorInt int color) {
+ OsmandApplication app = getMyApplication();
+ if (app != null) {
+ return app.getUIUtilities().getPaintedIcon(drawableRes, color);
+ } else {
+ return null;
+ }
+ }
+
@Nullable
protected Drawable getContentIcon(@DrawableRes int drawableRes) {
OsmandApplication app = getMyApplication();
diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java
index 10fa8a461e..a8c508433e 100644
--- a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java
+++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java
@@ -8,6 +8,7 @@ import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
+import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.LayoutRes;
import androidx.core.content.ContextCompat;
@@ -22,6 +23,7 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
private ColorStateList buttonTintList;
private OnCheckedChangeListener onCheckedChangeListener;
@ColorRes private int compoundButtonColorId;
+ @ColorInt private Integer compoundButtonColor;
private CompoundButton compoundButton;
@@ -80,6 +82,10 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
this.compoundButtonColorId = compoundButtonColorId;
}
+ public void setCompoundButtonColor(@ColorInt int compoundButtonColor) {
+ this.compoundButtonColor = compoundButtonColor;
+ }
+
public CompoundButton getCompoundButton() {
return compoundButton;
}
@@ -91,7 +97,9 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
if (compoundButton != null) {
compoundButton.setChecked(checked);
compoundButton.setOnCheckedChangeListener(onCheckedChangeListener);
- if (compoundButtonColorId != INVALID_ID) {
+ if (compoundButtonColor != null) {
+ UiUtilities.setupCompoundButton(nightMode, compoundButtonColor, compoundButton);
+ } else if (compoundButtonColorId != INVALID_ID) {
UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(context, compoundButtonColorId), compoundButton);
} else {
CompoundButtonCompat.setButtonTintList(compoundButton, buttonTintList);
@@ -105,6 +113,7 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
protected ColorStateList buttonTintList;
protected OnCheckedChangeListener onCheckedChangeListener;
@ColorRes protected int compoundButtonColorId = INVALID_ID;
+ @ColorInt protected Integer compoundButtonColor = null;
public Builder setChecked(boolean checked) {
this.checked = checked;
@@ -125,6 +134,11 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
this.compoundButtonColorId = compoundButtonColorId;
return this;
}
+
+ public Builder setCompoundButtonColor(@ColorInt int compoundButtonColor) {
+ this.compoundButtonColor = compoundButtonColor;
+ return this;
+ }
public BottomSheetItemWithCompoundButton create() {
return new BottomSheetItemWithCompoundButton(customView,
diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
index 5b8f38d2b9..5a69f5b2cd 100644
--- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
+++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
@@ -172,7 +172,7 @@ public class ConfigureMapMenu {
final MapActivity activity, final int themeRes, final boolean nightMode) {
final OsmandApplication app = activity.getMyApplication();
final OsmandSettings settings = app.getSettings();
- final int selectedProfileColorRes = settings.getApplicationMode().getIconColorInfo().getColor(nightMode);
+ final int selectedProfileColor = settings.getApplicationMode().getProfileColor(nightMode);
MapLayerMenuListener l = new MapLayerMenuListener(activity, adapter);
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(SHOW_CATEGORY_ID)
@@ -184,7 +184,7 @@ public class ConfigureMapMenu {
.setId(FAVORITES_ID)
.setTitleId(R.string.shared_string_favorites, activity)
.setSelected(settings.SHOW_FAVORITES.get())
- .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_action_favorite)
.setItemDeleteAction(makeDeleteAction(settings.SHOW_FAVORITES))
.setListener(l)
@@ -196,7 +196,7 @@ public class ConfigureMapMenu {
.setTitleId(R.string.layer_poi, activity)
.setSelected(selected)
.setDescription(app.getPoiFilters().getSelectedPoiFiltersName(wiki))
- .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_action_info_dark)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(l).createItem());
@@ -205,7 +205,7 @@ public class ConfigureMapMenu {
.setId(POI_OVERLAY_LABELS_ID)
.setTitleId(R.string.layer_amenity_label, activity)
.setSelected(settings.SHOW_POI_LABEL.get())
- .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_action_text_dark)
.setItemDeleteAction(makeDeleteAction(settings.SHOW_POI_LABEL))
.setListener(l).createItem());
@@ -217,7 +217,7 @@ public class ConfigureMapMenu {
.setIcon(R.drawable.ic_action_transport_bus)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setSelected(selected)
- .setColor(selected ? selectedProfileColorRes : ContextMenuItem.INVALID_ID)
+ .setColor(selected ? selectedProfileColor : null)
.setListener(l).createItem());
selected = app.getSelectedGpxHelper().isShowingAnyGpxFiles();
@@ -226,7 +226,7 @@ public class ConfigureMapMenu {
.setTitleId(R.string.layer_gpx_layer, activity)
.setSelected(app.getSelectedGpxHelper().isShowingAnyGpxFiles())
.setDescription(app.getSelectedGpxHelper().getGpxDescription())
- .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_action_polygom_dark)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(l).createItem());
@@ -236,7 +236,7 @@ public class ConfigureMapMenu {
.setId(MAP_MARKERS_ID)
.setTitleId(R.string.map_markers, activity)
.setSelected(selected)
- .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_action_flag)
.setItemDeleteAction(makeDeleteAction(settings.SHOW_MAP_MARKERS))
.setListener(l).createItem());
@@ -267,8 +267,7 @@ public class ConfigureMapMenu {
final int themeRes, final boolean nightMode) {
final OsmandApplication app = activity.getMyApplication();
final OsmandSettings settings = app.getSettings();
- final int selectedProfileColorRes = settings.APPLICATION_MODE.get().getIconColorInfo().getColor(nightMode);
- final int selectedProfileColor = ContextCompat.getColor(app, selectedProfileColorRes);
+ final int selectedProfileColor = settings.APPLICATION_MODE.get().getProfileColor(nightMode);
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_map_rendering, activity)
.setId(MAP_RENDERING_CATEGORY_ID)
@@ -705,7 +704,6 @@ public class ConfigureMapMenu {
for (int i = 0; i < prefs.size(); i++) {
prefs.get(i).set(false);
}
- adapter.getItem(pos).setColorRes(ContextMenuItem.INVALID_ID);
a.notifyDataSetInvalidated();
activity.refreshMapComplete();
activity.getMapLayers().updateLayers(activity.getMapView());
@@ -739,7 +737,7 @@ public class ConfigureMapMenu {
}
}
}
- builder.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ builder.setColor(activity, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
if (useDescription) {
final String descr = getDescription(prefs, includedPrefs);
builder.setDescription(descr);
@@ -840,7 +838,7 @@ public class ConfigureMapMenu {
selected |= prefs.get(i).get();
}
adapter.getItem(pos).setSelected(selected);
- adapter.getItem(pos).setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ adapter.getItem(pos).setColor(activity, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
a.notifyDataSetInvalidated();
}
});
@@ -875,7 +873,7 @@ public class ConfigureMapMenu {
} else {
adapter.getItem(pos).setSelected(selected);
}
- adapter.getItem(pos).setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ adapter.getItem(pos).setColor(activity, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
}
a.notifyDataSetInvalidated();
activity.refreshMapComplete();
diff --git a/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java b/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java
index 673f1ce3e7..fbfc5e6fc6 100644
--- a/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java
@@ -98,7 +98,7 @@ public class DetailsBottomSheet extends BasePreferenceBottomSheet {
@Override
public void createMenuItems(Bundle savedInstanceState) {
- int selectedProfileColorRes = app.getSettings().APPLICATION_MODE.get().getIconColorInfo().getColor(nightMode);
+ int selectedProfileColor = app.getSettings().APPLICATION_MODE.get().getProfileColor(nightMode);
float spacing = getResources().getDimension(R.dimen.line_spacing_extra_description);
LinearLayout linearLayout = new LinearLayout(app);
linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
@@ -139,7 +139,7 @@ public class DetailsBottomSheet extends BasePreferenceBottomSheet {
streetLightsNightPref.set(!onLeftClick);
}
})
- .setCompoundButtonColorId(selectedProfileColorRes)
+ .setCompoundButtonColor(selectedProfileColor)
.setChecked(pref.get())
.setTitle(propertyName)
.setIconHidden(true)
@@ -160,7 +160,7 @@ public class DetailsBottomSheet extends BasePreferenceBottomSheet {
} else if (!STREET_LIGHTING_NIGHT.equals(property.getAttrName())) {
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
- .setCompoundButtonColorId(selectedProfileColorRes)
+ .setCompoundButtonColor(selectedProfileColor)
.setChecked(pref.get())
.setTitle(propertyName)
.setIconHidden(true)
@@ -217,7 +217,7 @@ public class DetailsBottomSheet extends BasePreferenceBottomSheet {
}
if (adapter != null) {
adapter.getItem(position).setSelected(checked);
- adapter.getItem(position).setColorRes(checked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ adapter.getItem(position).setColor(app, checked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.getItem(position).setDescription(getString(
R.string.ltr_or_rtl_combine_via_slash,
String.valueOf(selected),
diff --git a/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java b/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java
index 29a64bcee4..d3f6fc053d 100644
--- a/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java
+++ b/OsmAnd/src/net/osmand/plus/dialogs/MapLayerMenuListener.java
@@ -77,7 +77,7 @@ final class MapLayerMenuListener extends OnRowItemClick {
public boolean processResult(Boolean result) {
if (item != null) {
item.setSelected(result);
- item.setColorRes(result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ item.setColor(mapActivity, result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
}
return true;
@@ -86,7 +86,7 @@ final class MapLayerMenuListener extends OnRowItemClick {
boolean selected = TransportLinesMenu.isShowLines(mapActivity.getMyApplication());
if (!selected && item != null) {
item.setSelected(true);
- item.setColorRes(R.color.osmand_orange);
+ item.setColor(mapActivity, R.color.osmand_orange);
adapter.notifyDataSetChanged();
}
return false;
@@ -94,7 +94,7 @@ final class MapLayerMenuListener extends OnRowItemClick {
CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item);
if (btn != null && btn.getVisibility() == View.VISIBLE) {
btn.setChecked(!btn.isChecked());
- menuAdapter.getItem(pos).setColorRes(btn.isChecked() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ menuAdapter.getItem(pos).setColor(mapActivity, btn.isChecked() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
return false;
} else {
@@ -110,7 +110,7 @@ final class MapLayerMenuListener extends OnRowItemClick {
final PoiFiltersHelper poiFiltersHelper = mapActivity.getMyApplication().getPoiFilters();
final ContextMenuItem item = menuAdapter.getItem(pos);
if (item.getSelected() != null) {
- item.setColorRes(isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ item.setColor(mapActivity, isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
}
if (itemId == R.string.layer_poi) {
PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter();
@@ -139,7 +139,7 @@ final class MapLayerMenuListener extends OnRowItemClick {
@Override
public boolean processResult(Boolean result) {
item.setSelected(result);
- item.setColorRes(result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ item.setColor(mapActivity, result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
return true;
}
@@ -171,7 +171,7 @@ final class MapLayerMenuListener extends OnRowItemClick {
boolean selected = app.getSelectedGpxHelper().isShowingAnyGpxFiles();
item.setSelected(selected);
item.setDescription(app.getSelectedGpxHelper().getGpxDescription());
- item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ item.setColor(mapActivity, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
}
});
@@ -189,7 +189,7 @@ final class MapLayerMenuListener extends OnRowItemClick {
boolean selected = pf.isShowingAnyPoi(wiki);
item.setSelected(selected);
item.setDescription(pf.getSelectedPoiFiltersName(wiki));
- item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ item.setColor(mapActivity, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
}
};
diff --git a/OsmAnd/src/net/osmand/plus/dialogs/SelectMapViewQuickActionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/dialogs/SelectMapViewQuickActionsBottomSheet.java
index 4c5f199824..5b7ba9cc9e 100644
--- a/OsmAnd/src/net/osmand/plus/dialogs/SelectMapViewQuickActionsBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/dialogs/SelectMapViewQuickActionsBottomSheet.java
@@ -174,8 +174,8 @@ public class SelectMapViewQuickActionsBottomSheet extends MenuBottomSheetDialogF
if (appMode != null) {
boolean selected = key.equals(selectedItem);
int iconId = appMode.getIconRes();
- int colorId = appMode.getIconColorInfo().getColor(nightMode);
- Drawable icon = getIcon(iconId, colorId);
+ int color = appMode.getProfileColor(nightMode);
+ Drawable icon = getPaintedIcon(iconId, color);
String translatedName = appMode.toHumanString();
createItemRow(selected, counter, icon, translatedName, key);
counter++;
diff --git a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java
index 3081c0680b..3b259ab241 100644
--- a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java
@@ -516,13 +516,13 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
.setTitleId(R.string.shared_string_refresh, getContext())
.setIcon(R.drawable.ic_action_refresh_dark)
.setListener(listener)
- .setColor(iconColorResId)
+ .setColor(getContext(), iconColorResId)
.createItem());
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.shared_string_delete, getContext())
.setIcon(R.drawable.ic_action_delete_dark)
.setListener(listener)
- .setColor(iconColorResId)
+ .setColor(getContext(), iconColorResId)
.createItem());
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.local_index_mi_backup, getContext())
@@ -554,7 +554,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
}
if (contextMenuItem.getIcon() != -1) {
- Drawable icMenuItem = getMyApplication().getUIUtilities().getIcon(contextMenuItem.getIcon(), contextMenuItem.getColorRes());
+ Drawable icMenuItem = getMyApplication().getUIUtilities().getPaintedIcon(contextMenuItem.getIcon(), contextMenuItem.getColor());
item.setIcon(icMenuItem);
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java
index d8eac1ca9a..c4799987f0 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java
@@ -477,7 +477,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
if (!ColorDialogs.isPaletteColor(customColor)) {
colors.add(customColor);
}
- colorsCard = new ColorsCard(mapActivity, selectedColor, this, colors);
+ colorsCard = new ColorsCard(mapActivity, selectedColor, this, colors, app.getSettings().CUSTOM_TRACK_COLORS, null);
colorsCard.setListener(this);
LinearLayout selectColor = view.findViewById(R.id.select_color);
selectColor.addView(colorsCard.build(view.getContext()));
diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java
index 6b03cd3a6a..3cf0398d87 100644
--- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java
@@ -61,8 +61,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
final int backgroundColor = ContextCompat.getColor(getActivity(),
nightMode ? R.color.activity_background_color_dark : R.color.activity_background_color_light);
final DateFormat dateFormat = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
- final int currentModeColorRes = getMyApplication().getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode);
- final int currentModeColor = ContextCompat.getColor(getActivity(), currentModeColorRes);
+ final int currentModeColor = getMyApplication().getSettings().getApplicationMode().getProfileColor(nightMode);
final View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_mapillary_filters, null);
view.findViewById(R.id.mapillary_filters_linear_layout).setBackgroundColor(backgroundColor);
@@ -71,17 +70,17 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
final View toggleRow = view.findViewById(R.id.toggle_row);
final boolean selected = settings.SHOW_MAPILLARY.get();
final int toggleActionStringId = selected ? R.string.shared_string_on : R.string.shared_string_off;
- int toggleIconColorId;
+ int toggleIconColor;
int toggleIconId;
if (selected) {
toggleIconId = R.drawable.ic_action_view;
- toggleIconColorId = currentModeColorRes;
+ toggleIconColor = currentModeColor;
} else {
toggleIconId = R.drawable.ic_action_hide;
- toggleIconColorId = nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light;
+ toggleIconColor = ContextCompat.getColor(getContext(), nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light);
}
((AppCompatTextView) toggleRow.findViewById(R.id.toggle_row_title)).setText(toggleActionStringId);
- final Drawable drawable = getIcon(toggleIconId, toggleIconColorId);
+ final Drawable drawable = getPaintedContentIcon(toggleIconId, toggleIconColor);
((AppCompatImageView) toggleRow.findViewById(R.id.toggle_row_icon)).setImageDrawable(drawable);
final CompoundButton toggle = (CompoundButton) toggleRow.findViewById(R.id.toggle_row_toggle);
toggle.setOnCheckedChangeListener(null);
diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java
index bc2b0dbc95..4be50700cc 100644
--- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java
@@ -185,7 +185,7 @@ public class MapillaryPlugin extends OsmandPlugin {
ContextMenuItem item = adapter.getItem(pos);
if (item != null) {
item.setSelected(settings.SHOW_MAPILLARY.get());
- item.setColorRes(settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ item.setColor(app, settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
}
}
@@ -201,7 +201,7 @@ public class MapillaryPlugin extends OsmandPlugin {
.setTitleId(R.string.street_level_imagery, mapActivity)
.setDescription("Mapillary")
.setSelected(settings.SHOW_MAPILLARY.get())
- .setColor(settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_action_mapillary)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setItemDeleteAction(makeDeleteAction(settings.SHOW_MAPILLARY))
diff --git a/OsmAnd/src/net/osmand/plus/mapsource/InputZoomLevelsBottomSheet.java b/OsmAnd/src/net/osmand/plus/mapsource/InputZoomLevelsBottomSheet.java
index fcf881c0eb..2d883e223c 100644
--- a/OsmAnd/src/net/osmand/plus/mapsource/InputZoomLevelsBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/mapsource/InputZoomLevelsBottomSheet.java
@@ -99,8 +99,7 @@ public class InputZoomLevelsBottomSheet extends MenuBottomSheetDialogFragment {
final TextView maxZoomValue = sliderView.findViewById(R.id.zoom_value_max);
maxZoomValue.setText(String.valueOf(maxZoom));
RangeSlider slider = sliderView.findViewById(R.id.zoom_slider);
- int colorProfileRes = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode);
- int colorProfile = ContextCompat.getColor(app, colorProfileRes);
+ int colorProfile = app.getSettings().getApplicationMode().getProfileColor(nightMode);
UiUtilities.setupSlider(slider, nightMode, colorProfile, true);
slider.setValueFrom(SLIDER_FROM);
slider.setValueTo(SLIDER_TO);
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
index bf6ee212dc..5454febb86 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
@@ -1350,7 +1350,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
snapToRoadBtn.setVisibility(View.VISIBLE);
profileWithConfig.setVisibility(View.GONE);
} else {
- icon = getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode));
+ icon = getPaintedContentIcon(appMode.getIconRes(), appMode.getProfileColor(nightMode));
snapToRoadBtn.setVisibility(View.GONE);
profileWithConfig.setVisibility(View.VISIBLE);
}
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java
index 35397f269e..8c8eacee67 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java
@@ -55,7 +55,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
icon = getContentIcon(R.drawable.ic_action_split_interval);
} else {
description = routeAppMode.toHumanString();
- icon = getIcon(routeAppMode.getIconRes(), routeAppMode.getIconColorInfo().getColor(nightMode));
+ icon = getPaintedIcon(routeAppMode.getIconRes(), routeAppMode.getProfileColor(nightMode));
}
} else {
description = getString(R.string.shared_string_undefined);
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java b/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java
index 8fc3be3037..179ad54645 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java
@@ -49,7 +49,7 @@ public class ProfileCard extends BaseCard {
for (int i = 0; i < modes.size(); i++) {
ApplicationMode mode = modes.get(i);
LinearLayout container = view.findViewById(R.id.content_container);
- Drawable icon = app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode));
+ Drawable icon = app.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode));
String title = mode.toHumanString();
View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java
index 54bc3469be..12eff78327 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java
@@ -117,7 +117,7 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetBeha
for (int i = 0; i < modes.size(); i++) {
ApplicationMode mode = modes.get(i);
if (!"public_transport".equals(mode.getRoutingProfile())) {
- icon = app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode));
+ icon = app.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode));
addProfileView(navigationType, onClickListener, i, icon, mode.toHumanString(), mode.equals(appMode));
}
}
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java
index b18592edb8..d482299931 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java
@@ -403,7 +403,7 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
if (MeasurementEditingContext.DEFAULT_APP_MODE.equals(routeAppMode)) {
icon = getContentIcon(R.drawable.ic_action_split_interval);
} else {
- icon = getIcon(routeAppMode.getIconRes(), routeAppMode.getIconColorInfo().getColor(nightMode));
+ icon = getPaintedIcon(routeAppMode.getIconRes(), routeAppMode.getProfileColor(nightMode));
}
return icon;
}
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SnapToRoadBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SnapToRoadBottomSheetDialogFragment.java
index 35f3bc47cd..082633a854 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/SnapToRoadBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/SnapToRoadBottomSheetDialogFragment.java
@@ -106,7 +106,7 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme
for (int i = 0; i < modes.size(); i++) {
ApplicationMode mode = modes.get(i);
- Drawable icon = app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode));
+ Drawable icon = app.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode));
addProfileView(container, onClickListener, i, icon, mode.toHumanString());
}
diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
index a3d2b78bd5..2799ac8ded 100644
--- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
@@ -560,7 +560,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
ApplicationMode appMode = app.getSettings().getApplicationMode();
int textColorPrimary = ContextCompat.getColor(app, nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
int textColorSecondary = ContextCompat.getColor(app, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light);
- int selectedModeColor = ContextCompat.getColor(uiCtx, appMode.getIconColorInfo().getColor(nightMode));
+ int selectedModeColor = appMode.getProfileColor(nightMode);
LinearLayout ll = new LinearLayout(uiCtx);
final int dp24 = AndroidUtils.dpToPx(uiCtx, 24f);
final int dp8 = AndroidUtils.dpToPx(uiCtx, 8f);
diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java
index 640d01e4c9..bbaf9295f7 100644
--- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java
@@ -116,8 +116,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
container = itemView.findViewById(R.id.always_ask_and_range_slider_container);
RangeSlider intervalSlider = itemView.findViewById(R.id.interval_slider);
intervalSlider.setValueTo(secondsLength + minutesLength - 1);
- int currentModeColorRes = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode);
- int currentModeColor = ContextCompat.getColor(app, currentModeColorRes);
+ int currentModeColor = app.getSettings().getApplicationMode().getProfileColor(nightMode);
UiUtilities.setupSlider(intervalSlider, nightMode, currentModeColor, true);
container.setVisibility(View.GONE);
intervalSlider.addOnChangeListener(new RangeSlider.OnChangeListener() {
diff --git a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java
index 1e8efe343b..674ee76042 100644
--- a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java
@@ -121,7 +121,7 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment
final ApplicationMode mode = app.getSettings().getApplicationMode();
final BottomSheetItemWithCompoundButton[] showOnMapItem = new BottomSheetItemWithCompoundButton[1];
showOnMapItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
- .setCompoundButtonColorId(mode.getIconColorInfo().getColor(nightMode))
+ .setCompoundButtonColor(mode.getProfileColor(nightMode))
.setChecked(checked)
.setTitle(getString(R.string.shared_string_show_on_map))
.setCustomView(getCustomButtonView(app, mode, checked, nightMode))
diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java
index 39951b4c2c..1a2be2b134 100644
--- a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java
+++ b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java
@@ -78,7 +78,7 @@ public class OnlineRoutingCard extends BaseCard {
bottomDivider = view.findViewById(R.id.bottom_divider);
button = view.findViewById(R.id.button);
- int activeColor = ContextCompat.getColor(app, appMode.getIconColorInfo().getColor(nightMode));
+ int activeColor = appMode.getProfileColor(nightMode);
textFieldBoxes.setPrimaryColor(activeColor);
textFieldBoxes.setGravityFloatingLabel(Gravity.START);
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java
index 4f25b58761..731129e915 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java
@@ -324,7 +324,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
.setTitleId(R.string.layer_osm_bugs, mapActivity)
.setSelected(settings.SHOW_OSM_BUGS.get())
.setIcon(R.drawable.ic_action_osm_note)
- .setColor(settings.SHOW_OSM_BUGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, settings.SHOW_OSM_BUGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(new ContextMenuAdapter.OnRowItemClick() {
@@ -343,7 +343,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
if (itemId == R.string.layer_osm_bugs) {
OsmandPreference showOsmBugs = settings.SHOW_OSM_BUGS;
showOsmBugs.set(isChecked);
- adapter.getItem(pos).setColorRes(showOsmBugs.get() ?
+ adapter.getItem(pos).setColor(app, showOsmBugs.get() ?
R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
updateLayers(mapActivity.getMapView(), mapActivity);
@@ -359,14 +359,14 @@ public class OsmEditingPlugin extends OsmandPlugin {
.setTitleId(R.string.layer_osm_edits, mapActivity)
.setSelected(settings.SHOW_OSM_EDITS.get())
.setIcon(R.drawable.ic_action_openstreetmap_logo)
- .setColor(settings.SHOW_OSM_EDITS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, settings.SHOW_OSM_EDITS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setListener(new ContextMenuAdapter.OnRowItemClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
if (itemId == R.string.layer_osm_edits) {
OsmandPreference showOsmEdits = settings.SHOW_OSM_EDITS;
showOsmEdits.set(isChecked);
- adapter.getItem(pos).setColorRes(showOsmEdits.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ adapter.getItem(pos).setColor(app, showOsmEdits.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
updateLayers(mapActivity.getMapView(), mapActivity);
}
@@ -404,7 +404,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
final AvailableGPXFragment f = ((AvailableGPXFragment) fragment);
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.local_index_mi_upload_gpx, activity)
.setIcon(R.drawable.ic_action_export)
- .setColor(R.color.color_white)
+ .setColor(app, R.color.color_white)
.setListener(new ItemClickListener() {
@Override
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java
index 3c7c387a36..f521eba6b1 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java
@@ -46,7 +46,7 @@ public class OsmNotesMenu {
final boolean nightMode = isNightMode(app);
final int themeRes = getThemeRes(app);
- final int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode));
+ final int selectedModeColor = settings.getApplicationMode().getProfileColor(nightMode);
final int osmNotesStringId = R.string.layer_osm_bugs;
final int showZoomLevelStringId = R.string.show_from_zoom_level;
@@ -110,7 +110,7 @@ public class OsmNotesMenu {
.setTitleId(osmNotesStringId, mapActivity)
.setDescription(mapActivity.getString(R.string.switch_osm_notes_visibility_desc))
.setIcon(R.drawable.ic_action_osm_note)
- .setColor(toggleIconColorId)
+ .setColor(app, toggleIconColorId)
.setListener(l)
.setSelected(showOsmBugs)
.createItem());
diff --git a/OsmAnd/src/net/osmand/plus/poi/RearrangePoiFiltersFragment.java b/OsmAnd/src/net/osmand/plus/poi/RearrangePoiFiltersFragment.java
index 8ddd677be2..55d8d350e1 100644
--- a/OsmAnd/src/net/osmand/plus/poi/RearrangePoiFiltersFragment.java
+++ b/OsmAnd/src/net/osmand/plus/poi/RearrangePoiFiltersFragment.java
@@ -310,13 +310,12 @@ public class RearrangePoiFiltersFragment extends DialogFragment implements Selec
ImageView profileIcon = (ImageView) view.findViewById(R.id.profile_icon);
if (profileIcon != null) {
int iconRes = selectedAppMode.getIconRes();
- int iconColor = selectedAppMode.getIconColorInfo().getColor(nightMode);
- profileIcon.setImageDrawable(uiUtilities.getPaintedIcon(iconRes, iconColor));
+ profileIcon.setImageDrawable(uiUtilities.getPaintedIcon(iconRes, selectedAppMode.getProfileColor(nightMode)));
}
View profileButton = view.findViewById(R.id.profile_button);
if (profileButton != null) {
- int iconColor = getSelectedAppMode().getIconColorInfo().getColor(nightMode);
+ int iconColor = getSelectedAppMode().getProfileColor(nightMode);
int bgColor = ContextCompat.getColor(app, nightMode ?
R.color.divider_color_dark : R.color.active_buttons_and_links_text_light);
int selectedColor = UiUtilities.getColorWithAlpha(iconColor, 0.3f);
diff --git a/OsmAnd/src/net/osmand/plus/profiles/AppProfileArrayAdapter.java b/OsmAnd/src/net/osmand/plus/profiles/AppProfileArrayAdapter.java
index 58f1c721ab..6107476426 100644
--- a/OsmAnd/src/net/osmand/plus/profiles/AppProfileArrayAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/profiles/AppProfileArrayAdapter.java
@@ -67,7 +67,7 @@ public class AppProfileArrayAdapter extends ArrayAdapter {
Drawable iconDrawable;
boolean lightContent = app.getSettings().isLightContent();
if (mode.isSelected()) {
- iconDrawable = app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColor(!lightContent));
+ iconDrawable = app.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getIconColor(!lightContent));
} else {
iconDrawable = app.getUIUtilities().getIcon(mode.getIconRes(), lightContent);
}
diff --git a/OsmAnd/src/net/osmand/plus/profiles/ConfigureProfileMenuAdapter.java b/OsmAnd/src/net/osmand/plus/profiles/ConfigureProfileMenuAdapter.java
index a2e024f860..6a92563647 100644
--- a/OsmAnd/src/net/osmand/plus/profiles/ConfigureProfileMenuAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/profiles/ConfigureProfileMenuAdapter.java
@@ -6,10 +6,12 @@ import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
+import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.view.ContextThemeWrapper;
+import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import net.osmand.PlatformUtil;
@@ -35,8 +37,8 @@ public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter getItems() {
@@ -137,9 +140,9 @@ public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter() {
@@ -274,8 +275,9 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
private boolean deleted;
private boolean customProfile;
- EditProfileDataObject(String stringKey, String name, String descr, int iconRes, boolean isSelected, boolean customProfile, boolean deleted, ProfileIconColors iconColor, int order) {
- super(name, descr, stringKey, iconRes, isSelected, iconColor);
+ EditProfileDataObject(String stringKey, String name, String descr, int iconRes, boolean isSelected,
+ boolean customProfile, boolean deleted, @ColorInt int iconColorLight, @ColorInt int iconColorDark, int order) {
+ super(name, descr, stringKey, iconRes, isSelected, iconColorLight, iconColorDark);
this.customProfile = customProfile;
this.deleted = deleted;
this.order = order;
@@ -365,10 +367,9 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
if (iconRes == 0 || iconRes == -1) {
iconRes = R.drawable.ic_action_world_globe;
}
- int profileColorResId = mode.getIconColor(nightMode);
- int colorNoAlpha = ContextCompat.getColor(app, profileColorResId);
+ int colorNoAlpha = mode.getIconColor(nightMode);
- profileViewHolder.icon.setImageDrawable(uiUtilities.getIcon(iconRes, profileColorResId));
+ profileViewHolder.icon.setImageDrawable(uiUtilities.getPaintedIcon(iconRes, colorNoAlpha));
//set up cell color
Drawable drawable = UiUtilities.getColoredSelectableDrawable(app, colorNoAlpha, 0.3f);
diff --git a/OsmAnd/src/net/osmand/plus/profiles/OnlineRoutingEngineDataObject.java b/OsmAnd/src/net/osmand/plus/profiles/OnlineRoutingEngineDataObject.java
index fd0f593462..ea513b405c 100644
--- a/OsmAnd/src/net/osmand/plus/profiles/OnlineRoutingEngineDataObject.java
+++ b/OsmAnd/src/net/osmand/plus/profiles/OnlineRoutingEngineDataObject.java
@@ -12,7 +12,7 @@ public class OnlineRoutingEngineDataObject extends ProfileDataObject {
String description,
String stringKey,
int order) {
- super(name, description, stringKey, R.drawable.ic_world_globe_dark, false, null);
+ super(name, description, stringKey, R.drawable.ic_world_globe_dark, false, null, null);
this.order = order;
}
diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfileDataObject.java b/OsmAnd/src/net/osmand/plus/profiles/ProfileDataObject.java
index 35b5be5620..048c7693d1 100644
--- a/OsmAnd/src/net/osmand/plus/profiles/ProfileDataObject.java
+++ b/OsmAnd/src/net/osmand/plus/profiles/ProfileDataObject.java
@@ -1,5 +1,6 @@
package net.osmand.plus.profiles;
+import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
@@ -12,15 +13,20 @@ public class ProfileDataObject implements Comparable {
private String stringKey;
private boolean isSelected;
private boolean isEnabled;
- private ProfileIconColors iconColor;
+ @ColorInt
+ private Integer iconColorLight;
+ @ColorInt
+ private Integer iconColorDark;
- public ProfileDataObject(String name, String description, String stringKey, int iconRes, boolean isSelected, ProfileIconColors iconColor) {
+ public ProfileDataObject(String name, String description, String stringKey, int iconRes, boolean isSelected,
+ @ColorInt Integer iconColorLight, @ColorInt Integer iconColorDark) {
this.name = name;
this.iconRes = iconRes;
this.description = description;
this.isSelected = isSelected;
this.stringKey = stringKey;
- this.iconColor = iconColor;
+ this.iconColorLight = iconColorLight;
+ this.iconColorDark = iconColorDark;
}
public String getName() {
@@ -55,8 +61,9 @@ public class ProfileDataObject implements Comparable {
return stringKey;
}
- @ColorRes public int getIconColor(boolean isNightMode) {
- return iconColor.getColor(isNightMode);
+ @ColorInt
+ public int getIconColor(boolean isNightMode) {
+ return isNightMode ? iconColorDark : iconColorLight;
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfileDataUtils.java b/OsmAnd/src/net/osmand/plus/profiles/ProfileDataUtils.java
index 6306dee9cc..bc939546cf 100644
--- a/OsmAnd/src/net/osmand/plus/profiles/ProfileDataUtils.java
+++ b/OsmAnd/src/net/osmand/plus/profiles/ProfileDataUtils.java
@@ -33,7 +33,7 @@ public class ProfileDataUtils {
description = getAppModeDescription(app, mode);
}
profiles.add(new ProfileDataObject(mode.toHumanString(), description,
- mode.getStringKey(), mode.getIconRes(), false, mode.getIconColorInfo()));
+ mode.getStringKey(), mode.getIconRes(), false, mode.getProfileColor(false), mode.getProfileColor(true)));
}
return profiles;
}
diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfileIconColors.java b/OsmAnd/src/net/osmand/plus/profiles/ProfileIconColors.java
index 3fd97cc523..e7bccfde64 100644
--- a/OsmAnd/src/net/osmand/plus/profiles/ProfileIconColors.java
+++ b/OsmAnd/src/net/osmand/plus/profiles/ProfileIconColors.java
@@ -31,6 +31,7 @@ public enum ProfileIconColors {
return name;
}
+ @ColorRes
public int getColor(boolean nightMode) {
return nightMode ? nightColor : dayColor;
}
diff --git a/OsmAnd/src/net/osmand/plus/profiles/RoutingProfileDataObject.java b/OsmAnd/src/net/osmand/plus/profiles/RoutingProfileDataObject.java
index ab808de360..43c3b80953 100644
--- a/OsmAnd/src/net/osmand/plus/profiles/RoutingProfileDataObject.java
+++ b/OsmAnd/src/net/osmand/plus/profiles/RoutingProfileDataObject.java
@@ -11,7 +11,7 @@ public class RoutingProfileDataObject extends ProfileDataObject {
private String fileName;
public RoutingProfileDataObject(String stringKey, String name, String descr, int iconRes, boolean isSelected, String fileName) {
- super(name, descr, stringKey, iconRes, isSelected, null);
+ super(name, descr, stringKey, iconRes, isSelected, null, null);
this.fileName = fileName;
}
diff --git a/OsmAnd/src/net/osmand/plus/profiles/SelectCopyProfilesMenuAdapter.java b/OsmAnd/src/net/osmand/plus/profiles/SelectCopyProfilesMenuAdapter.java
index efe1b00a2e..53dbef23bd 100644
--- a/OsmAnd/src/net/osmand/plus/profiles/SelectCopyProfilesMenuAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/profiles/SelectCopyProfilesMenuAdapter.java
@@ -67,10 +67,9 @@ public class SelectCopyProfilesMenuAdapter extends AbstractProfileMenuAdapter {
private static final Log LOG = PlatformUtil.getLog(SelectProfileMenuAdapter.class);
@@ -33,8 +33,8 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter items = new ArrayList<>();
private final OsmandApplication app;
private ApplicationMode appMode;
- @ColorRes
- private int selectedIconColorRes;
+ @ColorInt
+ private int selectedIconColor;
private boolean bottomButton;
private String bottomButtonText;
private static final String BUTTON_ITEM = "button_item";
@@ -53,9 +53,8 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter getItems() {
@@ -100,11 +99,10 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter extends QuickAction {
OsmandApplication app = (OsmandApplication) context.getApplicationContext();
- Drawable icon = app.getUIUtilities().getIcon(
- getItemIconRes(app, item), getItemIconColorRes(app, item));
+ Drawable icon = app.getUIUtilities().getPaintedIcon(
+ getItemIconRes(app, item), getItemIconColor(app, item));
holder.icon.setImageDrawable(icon);
holder.title.setText(getItemName(context, item));
@@ -310,10 +312,11 @@ public abstract class SwitchableAction extends QuickAction {
return R.drawable.ic_map;
}
- @ColorRes
- protected int getItemIconColorRes(OsmandApplication app, T item) {
+ @ColorInt
+ protected int getItemIconColor(OsmandApplication app, T item) {
boolean nightMode = !app.getSettings().isLightContent();
- return nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light;
+ int colorRes = nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light;
+ return ContextCompat.getColor(app, colorRes);
}
protected abstract
diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHidePoiAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHidePoiAction.java
index 4c2d452e64..51b9b300ed 100644
--- a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHidePoiAction.java
+++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHidePoiAction.java
@@ -353,7 +353,6 @@ public class ShowHidePoiAction extends QuickAction {
builder.setIcon(R.drawable.mx_user_defined);
}
- builder.setColor(ContextMenuItem.INVALID_ID);
builder.setSkipPaintingWithoutColor(true);
adapter.addItem(builder.createItem());
}
diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/SwitchProfileAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/SwitchProfileAction.java
index 3710f9832b..da31b61466 100644
--- a/OsmAnd/src/net/osmand/plus/quickaction/actions/SwitchProfileAction.java
+++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/SwitchProfileAction.java
@@ -5,6 +5,7 @@ import android.text.TextUtils;
import android.view.View;
import android.widget.Toast;
+import androidx.annotation.ColorInt;
import androidx.appcompat.widget.SwitchCompat;
import com.google.gson.Gson;
@@ -182,13 +183,14 @@ public class SwitchProfileAction extends SwitchableAction {
}
@Override
- protected int getItemIconColorRes(OsmandApplication app, String item) {
+ @ColorInt
+ protected int getItemIconColor(OsmandApplication app, String item) {
ApplicationMode appMode = getModeForKey(item);
if (appMode != null) {
boolean nightMode = !app.getSettings().isLightContent();
- return appMode.getIconColorInfo().getColor(nightMode);
+ return appMode.getProfileColor(nightMode);
}
- return super.getItemIconColorRes(app, item);
+ return super.getItemIconColor(app, item);
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java
index 59ba2dadf7..b43171e632 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java
@@ -13,7 +13,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
-import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@@ -325,7 +324,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
: mapActivity.getString(R.string.shared_string_none);
item.setDescription(overlayMapDescr);
item.setSelected(hasOverlayDescription);
- item.setColorRes(hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ item.setColor(app, hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
}
}
@@ -350,7 +349,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
item.setDescription(underlayMapDescr);
item.setSelected(hasUnderlayDescription);
- item.setColorRes(hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ item.setColor(app, hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
@@ -383,7 +382,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
.setId(OVERLAY_MAP)
.setDescription(overlayMapDescr)
.setSelected(hasOverlayDescription)
- .setColor(hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_layer_top)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(listener)
@@ -399,7 +398,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
.setId(UNDERLAY_MAP)
.setDescription(underlayMapDescr)
.setSelected(hasUnderlayDescription)
- .setColor(hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_layer_bottom)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(listener)
@@ -485,7 +484,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
final boolean[] selected = new boolean[downloaded.size()];
boolean nightMode = isNightMode(activity);
int themeResId = getThemeRes(activity);
- int selectedProfileColor = ContextCompat.getColor(app, app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode));
+ int selectedProfileColor = app.getSettings().getApplicationMode().getProfileColor(nightMode);
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createMultiChoiceAdapter(names, nightMode, selected, app,
selectedProfileColor, themeResId, new View.OnClickListener() {
@Override
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java
index 38f6053887..41147171c5 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java
@@ -11,6 +11,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -64,8 +65,8 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
private List compoundButtons = new ArrayList<>();
private boolean hideImpassableRoads;
- @ColorRes
- private int compoundButtonColorId = INVALID_ID;
+ @ColorInt
+ private Integer compoundButtonColor = null;
private ApplicationMode appMode;
public void setHideImpassableRoads(boolean hideImpassableRoads) {
@@ -236,7 +237,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
- .setCompoundButtonColorId(compoundButtonColorId)
+ .setCompoundButtonColor(compoundButtonColor)
.setChecked(selected)
.setTitle(parameterName)
.setLayoutId(R.layout.bottom_sheet_item_with_switch_no_icon)
@@ -254,8 +255,8 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
}
}
- public void setCompoundButtonColorId(@ColorRes int compoundButtonColorId) {
- this.compoundButtonColorId = compoundButtonColorId;
+ public void setCompoundButtonColor(@ColorInt int compoundButtonColor) {
+ this.compoundButtonColor = compoundButtonColor;
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
index 8ba86dfe35..25c158a042 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
@@ -11,6 +11,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.appcompat.widget.SwitchCompat;
import androidx.core.content.ContextCompat;
@@ -84,8 +85,8 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private RoutingHelper routingHelper;
private RoutingOptionsHelper routingOptionsHelper;
private ApplicationMode applicationMode;
- @ColorRes
- private int selectedModeColorId;
+ @ColorInt
+ private int selectedModeColor;
private boolean currentMuteState;
private boolean currentUseHeightState;
private MapActivity mapActivity;
@@ -149,7 +150,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
if (dialogMode == null) {
dialogMode = DialogMode.DIRECTIONS;
}
- selectedModeColorId = applicationMode.getIconColorInfo().getColor(nightMode);
+ selectedModeColor = applicationMode.getProfileColor(nightMode);
voiceMuteChangeListener = new StateChangedListener() {
@Override
public void stateChanged(Boolean change) {
@@ -271,7 +272,6 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private BaseBottomSheetItem createMuteSoundItem(final LocalRoutingParameter optionsItem) {
boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode);
- int selectedModeColor = ContextCompat.getColor(app, selectedModeColorId);
final View itemView = UiUtilities.getInflater(app, nightMode).inflate(
R.layout.bottom_sheet_item_with_descr_switch_and_additional_button_56dp, null, false);
final ImageView icon = itemView.findViewById(R.id.icon);
@@ -310,7 +310,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
Drawable drawable = app.getUIUtilities().getIcon(R.drawable.ic_action_settings,
nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
if (Build.VERSION.SDK_INT >= 21) {
- Drawable activeDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_settings, selectedModeColorId);
+ Drawable activeDrawable = app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_settings, selectedModeColor);
drawable = AndroidUtils.createPressedStateListDrawable(drawable, activeDrawable);
}
voicePromptsBtnImage.setImageDrawable(drawable);
@@ -358,7 +358,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(!active)
- .setCompoundButtonColorId(selectedModeColorId)
+ .setCompoundButtonColor(selectedModeColor)
.setDescription(getElevationDescription(parameter))
.setIcon(getContentIcon(active ? parameter.getActiveIconId() : parameter.getDisabledIconId()))
.setTitle(getString(R.string.routing_attr_height_obstacles_name))
@@ -387,7 +387,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private BaseBottomSheetItem createTimeConditionalRoutingItem(final LocalRoutingParameter optionsItem) {
final BottomSheetItemWithCompoundButton[] timeConditionalRoutingItem = new BottomSheetItemWithCompoundButton[1];
timeConditionalRoutingItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
- .setCompoundButtonColorId(selectedModeColorId)
+ .setCompoundButtonColor(selectedModeColor)
.setChecked(settings.ENABLE_TIME_CONDITIONAL_ROUTING.getModeValue(applicationMode))
.setIcon(getContentIcon((optionsItem.getActiveIconId())))
.setTitle(getString(R.string.temporary_conditional_routing))
@@ -433,7 +433,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private BaseBottomSheetItem createRouteSimulationItem(final LocalRoutingParameter optionsItem) {
final BottomSheetItemWithCompoundButton[] simulateNavigationItem = new BottomSheetItemWithCompoundButton[1];
simulateNavigationItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
- .setCompoundButtonColorId(selectedModeColorId)
+ .setCompoundButtonColor(selectedModeColor)
.setChecked(settings.simulateNavigation)
.setIcon(getContentIcon(R.drawable.ic_action_start_navigation))
.setTitle(getString(R.string.simulate_navigation))
@@ -470,7 +470,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment();
avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
- avoidRoadsFragment.setCompoundButtonColorId(selectedModeColorId);
+ avoidRoadsFragment.setCompoundButtonColor(selectedModeColor);
avoidRoadsFragment.setApplicationMode(applicationMode);
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
updateMenu();
@@ -492,7 +492,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment();
avoidRoadsFragment.setHideImpassableRoads(true);
avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
- avoidRoadsFragment.setCompoundButtonColorId(selectedModeColorId);
+ avoidRoadsFragment.setCompoundButtonColor(selectedModeColor);
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
updateMenu();
}
@@ -565,7 +565,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
if (parameter != null) {
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
BottomSheetItemWithCompoundButton.Builder builder = new BottomSheetItemWithCompoundButton.Builder();
- builder.setCompoundButtonColorId(selectedModeColorId);
+ builder.setCompoundButtonColor(selectedModeColor);
int iconId = -1;
if (parameter.routingParameter != null || parameter instanceof RoutingOptionsHelper.OtherLocalRoutingParameter) {
builder.setTitle(parameter.getText(mapActivity));
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java
index 72e985c353..165ca20944 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java
@@ -153,7 +153,7 @@ public class RoutingOptionsHelper {
Context themedContext = UiUtilities.getThemedContext(mapActivity, nightMode);
int themeRes = getThemeRes(app);
ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode();
- int selectedModeColor = ContextCompat.getColor(app, selectedAppMode.getIconColorInfo().getColor(nightMode));
+ int selectedModeColor = selectedAppMode.getProfileColor(nightMode);
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
entries, nightMode, selected, app, selectedModeColor, themeRes, new View.OnClickListener() {
@Override
@@ -334,7 +334,7 @@ public class RoutingOptionsHelper {
final boolean nightMode = isNightMode(app);
Context themedContext = UiUtilities.getThemedContext(mapActivity, nightMode);
ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode();
- final int selectedModeColor = ContextCompat.getColor(app, selectedAppMode.getIconColorInfo().getColor(nightMode));
+ final int selectedModeColor = selectedAppMode.getProfileColor(nightMode);
AlertDialog.Builder builder = new AlertDialog.Builder(themedContext);
final int layout = R.layout.list_menu_item_native_singlechoice;
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java
index 7272b7a2ea..48707d7713 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java
@@ -356,7 +356,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
}
}
});
- int selectedProfileColor = ContextCompat.getColor(app, getAppMode().getIconColorInfo().getColor(isNightMode(app)));
+ int selectedProfileColor = getAppMode().getProfileColor(isNightMode(app));
UiUtilities.setupCompoundButton(nightMode, selectedProfileColor, compoundButton);
convertView.setOnClickListener(new View.OnClickListener() {
@@ -516,7 +516,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
selected = i;
}
}
- int selectedProfileColor = ContextCompat.getColor(app, getAppMode().getIconColorInfo().getColor(nightMode));
+ int selectedProfileColor = getAppMode().getProfileColor(nightMode);
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
names, nightMode, selected, app, selectedProfileColor, themeRes, new View.OnClickListener() {
@Override
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java
index 29a50aae4b..f707f82f88 100644
--- a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java
@@ -1,6 +1,8 @@
package net.osmand.plus.settings.backend;
+import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
+import androidx.core.content.ContextCompat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -469,6 +471,15 @@ public class ApplicationMode {
return app.getSettings().LOCATION_ICON.getModeValue(this);
}
+ @ColorInt
+ public int getProfileColor(boolean nightMode) {
+ Integer customProfileColor = getCustomIconColor();
+ if (customProfileColor != null) {
+ return customProfileColor;
+ }
+ return ContextCompat.getColor(app, getIconColorInfo().getColor(nightMode));
+ }
+
public void setLocationIcon(LocationIcon locationIcon) {
if (locationIcon != null) {
app.getSettings().LOCATION_ICON.setModeValue(this, locationIcon);
@@ -485,6 +496,28 @@ public class ApplicationMode {
}
}
+ public List getCustomIconColors() {
+ return app.getSettings().CUSTOM_ICON_COLORS.getStringsListForProfile(this);
+ }
+
+ public void setCustomIconColors(List customColors) {
+ app.getSettings().CUSTOM_ICON_COLORS.setModeValues(this, customColors);
+ }
+
+ public Integer getCustomIconColor() {
+ try {
+ String customColor = app.getSettings().CUSTOM_ICON_COLOR.getModeValue(this);
+ return Algorithms.isEmpty(customColor) ? null : Algorithms.parseColor(customColor);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
+
+ public void setCustomIconColor(Integer customIconColor) {
+ String valueToSave = customIconColor == null ? null : Algorithms.colorToString(customIconColor);
+ app.getSettings().CUSTOM_ICON_COLOR.setModeValue(this, valueToSave);
+ }
+
public int getOrder() {
return app.getSettings().APP_MODE_ORDER.getModeValue(this);
}
@@ -582,6 +615,7 @@ public class ApplicationMode {
mode.setRoutingProfile(builder.routingProfile);
mode.setRouteService(builder.routeService);
mode.setIconColor(builder.iconColor);
+ mode.setCustomIconColor(builder.customIconColor);
mode.setLocationIcon(builder.locationIcon);
mode.setNavigationIcon(builder.navigationIcon);
mode.setOrder(builder.order);
@@ -604,6 +638,7 @@ public class ApplicationMode {
builder.setUserProfileName(modeBean.userProfileName);
builder.setIconResName(modeBean.iconName);
builder.setIconColor(modeBean.iconColor);
+ builder.setCustomIconColor(modeBean.customIconColor);
builder.setRoutingProfile(modeBean.routingProfile);
builder.setRouteService(modeBean.routeService);
builder.setLocationIcon(modeBean.locIcon);
@@ -623,6 +658,7 @@ public class ApplicationMode {
mb.stringKey = stringKey;
mb.userProfileName = getUserProfileName();
mb.iconColor = getIconColorInfo();
+ mb.customIconColor = getCustomIconColor();
mb.iconName = getIconName();
mb.parent = parentAppMode != null ? parentAppMode.getStringKey() : null;
mb.routeService = getRouteService();
@@ -699,6 +735,7 @@ public class ApplicationMode {
private String routingProfile;
private String iconResName;
private ProfileIconColors iconColor;
+ private Integer customIconColor;
private LocationIcon locationIcon;
private NavigationIcon navigationIcon;
private int order = -1;
@@ -722,6 +759,7 @@ public class ApplicationMode {
applicationMode.setRouteService(routeService);
applicationMode.setRoutingProfile(routingProfile);
applicationMode.setIconResName(iconResName);
+ applicationMode.setCustomIconColor(customIconColor);
applicationMode.setIconColor(iconColor);
applicationMode.setLocationIcon(locationIcon);
applicationMode.setNavigationIcon(navigationIcon);
@@ -770,6 +808,11 @@ public class ApplicationMode {
return this;
}
+ public ApplicationModeBuilder setCustomIconColor(Integer customIconColor) {
+ this.customIconColor = customIconColor;
+ return this;
+ }
+
public ApplicationModeBuilder setOrder(int order) {
this.order = order;
return this;
@@ -798,6 +841,8 @@ public class ApplicationMode {
@Expose
public ProfileIconColors iconColor = ProfileIconColors.DEFAULT;
@Expose
+ public Integer customIconColor = null;
+ @Expose
public String routingProfile = null;
@Expose
public RouteService routeService = RouteService.OSMAND;
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java
index 44831fa52c..2854520bbf 100644
--- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java
@@ -983,6 +983,10 @@ public class OsmandSettings {
public final CommonPreference ICON_COLOR = new EnumStringPreference<>(this,
"app_mode_icon_color", ProfileIconColors.DEFAULT, ProfileIconColors.values()).makeProfile().cache();
+ public final ListStringPreference CUSTOM_ICON_COLORS = (ListStringPreference) new ListStringPreference(this, "custom_icon_colors", null, ",").makeProfile().cache();
+
+ public final CommonPreference CUSTOM_ICON_COLOR = new StringPreference(this, "custom_icon_color", null).makeProfile().cache();
+
public final CommonPreference USER_PROFILE_NAME = new StringPreference(this, "user_profile_name", "").makeProfile().cache();
public final CommonPreference PARENT_APP_MODE = new StringPreference(this, "parent_app_mode", null).makeProfile().cache();
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java
index 88405fd010..203c0a2323 100644
--- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java
@@ -301,6 +301,7 @@ public class ProfileSettingsItem extends OsmandSettingsItem {
OsmandSettings settings = app.getSettings();
return new String[] {
settings.ICON_COLOR.getId(),
+ settings.CUSTOM_ICON_COLOR.getId(),
settings.ICON_RES_NAME.getId(),
settings.PARENT_APP_MODE.getId(),
settings.ROUTING_PROFILE.getId(),
diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/AnnouncementTimeBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/AnnouncementTimeBottomSheet.java
index 00db145474..bbec0c6211 100644
--- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/AnnouncementTimeBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/AnnouncementTimeBottomSheet.java
@@ -171,7 +171,7 @@ public class AnnouncementTimeBottomSheet extends BasePreferenceBottomSheet
}
private void setProfileColorToSeekBar() {
- int color = ContextCompat.getColor(app, getAppMode().getIconColorInfo().getColor(nightMode));
+ int color = getAppMode().getProfileColor(nightMode);
LayerDrawable seekBarProgressLayer =
(LayerDrawable) ContextCompat.getDrawable(app, R.drawable.seekbar_progress_announcement_time);
diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java
index 5eb3dd226c..6b0e2089d8 100644
--- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java
@@ -103,7 +103,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
})
.create();
if (isProfileDependent()) {
- preferenceBtn[0].setCompoundButtonColorId(getAppMode().getIconColorInfo().getColor(nightMode));
+ preferenceBtn[0].setCompoundButtonColor(getAppMode().getProfileColor(nightMode));
}
items.add(preferenceBtn[0]);
@@ -133,8 +133,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
Context themedCtx = UiUtilities.getThemedContext(app, nightMode);
View buttonView = customView.findViewById(R.id.button_container);
- int colorRes = mode.getIconColorInfo().getColor(nightMode);
- int color = checked ? ContextCompat.getColor(themedCtx, colorRes) : AndroidUtils.getColorFromAttr(themedCtx, R.attr.divider_color_basic);
+ int color = checked ? mode.getProfileColor(nightMode) : AndroidUtils.getColorFromAttr(themedCtx, R.attr.divider_color_basic);
int bgColor = UiUtilities.getColorWithAlpha(color, checked ? 0.1f : 0.5f);
int selectedColor = UiUtilities.getColorWithAlpha(color, checked ? 0.3f : 0.5f);
diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java
index badfcbfb2c..25b00e338c 100644
--- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java
@@ -5,6 +5,7 @@ import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
+import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@@ -65,6 +66,7 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment {
private int checkedColor;
private int uncheckedColor;
private int disabledColor;
+ @ColorInt
private int appModeColor;
@Override
@@ -101,7 +103,7 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment {
on = getString(R.string.shared_string_enabled);
off = getString(R.string.shared_string_disabled);
- appModeColor = appMode.getIconColorInfo().getColor(nightMode);
+ appModeColor = appMode.getProfileColor(nightMode);
activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic);
disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary);
checkedColor = (nightMode ? app.getResources().getColor(R.color.text_color_primary_dark) : app.getResources().getColor(R.color.text_color_primary_light));
@@ -122,7 +124,7 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment {
private void createUseHeightButton(Context context) {
boolean checked = useHeightPref.getModeValue(appMode);
useHeightButton = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
- .setCompoundButtonColorId(appModeColor)
+ .setCompoundButtonColor(appModeColor)
.setChecked(checked)
.setTitle(checked ? on : off)
.setTitleColorId(checked ? activeColor : disabledColor)
diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/MultiSelectPreferencesBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/MultiSelectPreferencesBottomSheet.java
index 71881876b3..90b88a264d 100644
--- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/MultiSelectPreferencesBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/MultiSelectPreferencesBottomSheet.java
@@ -89,7 +89,7 @@ public class MultiSelectPreferencesBottomSheet extends BasePreferenceBottomSheet
.setTag(prefId)
.create();
if (isProfileDependent()) {
- item[0].setCompoundButtonColorId(getAppMode().getIconColorInfo().getColor(nightMode));
+ item[0].setCompoundButtonColor(getAppMode().getProfileColor(nightMode));
}
items.add(item[0]);
}
diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java
index c270ea0ed8..7bde0e8034 100644
--- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java
@@ -84,8 +84,7 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot
entryValues = new Float[]{9.1f, 18.3f, 30.5f, 45.7f, 91.5f, 183.0f, 482.0f, 965.0f, 1609.0f};
}
- final int appModeColorId = appMode.getIconColorInfo().getColor(nightMode);
- final int appModeColor = ContextCompat.getColor(themedCtx, appModeColorId);
+ final int appModeColor = appMode.getProfileColor(nightMode);
final int activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic);
final int disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary);
@@ -108,7 +107,7 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot
final BottomSheetItemWithCompoundButton[] preferenceBtn = new BottomSheetItemWithCompoundButton[1];
preferenceBtn[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(enabled)
- .setCompoundButtonColorId(appModeColorId)
+ .setCompoundButtonColor(appModeColor)
.setTitle(enabled ? on : off)
.setTitleColorId(enabled ? activeColor : disabledColor)
.setCustomView(getCustomButtonView(app, getAppMode(), enabled, nightMode))
diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ResetProfilePrefsBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ResetProfilePrefsBottomSheet.java
index e9317533bc..69e225b4c0 100644
--- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ResetProfilePrefsBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ResetProfilePrefsBottomSheet.java
@@ -38,18 +38,17 @@ public class ResetProfilePrefsBottomSheet extends BasePreferenceBottomSheet {
String title = getString(customProfile ? R.string.restore_all_profile_settings : R.string.reset_all_profile_settings);
items.add(new TitleItem(title));
- int profileColor = mode.getIconColorInfo().getColor(nightMode);
- int colorNoAlpha = ContextCompat.getColor(ctx, profileColor);
+ int colorNoAlpha = mode.getProfileColor(nightMode);
Drawable backgroundIcon = UiUtilities.getColoredSelectableDrawable(ctx, colorNoAlpha, 0.3f);
Drawable[] layers = {new ColorDrawable(UiUtilities.getColorWithAlpha(colorNoAlpha, 0.10f)), backgroundIcon};
BaseBottomSheetItem profileItem = new BottomSheetItemWithCompoundButton.Builder()
.setChecked(true)
- .setCompoundButtonColorId(profileColor)
- .setButtonTintList(ColorStateList.valueOf(getResolvedColor(profileColor)))
+ .setCompoundButtonColor(colorNoAlpha)
+ .setButtonTintList(ColorStateList.valueOf(colorNoAlpha))
.setDescription(ProfileDataUtils.getAppModeDescription(ctx, mode))
- .setIcon(getIcon(mode.getIconRes(), profileColor))
+ .setIcon(getPaintedIcon(mode.getIconRes(), colorNoAlpha))
.setTitle(mode.toHumanString())
.setBackground(new LayerDrawable(layers))
.setLayoutId(R.layout.preference_profile_item_with_radio_btn)
diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SingleSelectPreferenceBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SingleSelectPreferenceBottomSheet.java
index dc673207b2..2a214cdbe3 100644
--- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SingleSelectPreferenceBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SingleSelectPreferenceBottomSheet.java
@@ -6,6 +6,7 @@ import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@@ -69,8 +70,11 @@ public class SingleSelectPreferenceBottomSheet extends BasePreferenceBottomSheet
final BaseBottomSheetItem[] preferenceItem = new BottomSheetItemWithCompoundButton[1];
preferenceItem[0] = new BottomSheetItemWithCompoundButton.Builder()
.setChecked(i == selectedEntryIndex)
- .setButtonTintList(AndroidUtils.createCheckedColorStateList(ctx, R.color.icon_color_default_light,
- isProfileDependent() ? getAppMode().getIconColorInfo().getColor(nightMode) : getActiveColorId()))
+ .setButtonTintList(AndroidUtils.createCheckedColorIntStateList(
+ ContextCompat.getColor(ctx,R.color.icon_color_default_light),
+ isProfileDependent() ?
+ getAppMode().getProfileColor(nightMode) :
+ ContextCompat.getColor(ctx, getActiveColorId())))
.setTitle(entries[i])
.setTag(i)
.setLayoutId(R.layout.bottom_sheet_item_with_radio_btn_left)
diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/WakeTimeBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/WakeTimeBottomSheet.java
index 149aa5b0a4..13dff97c94 100644
--- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/WakeTimeBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/WakeTimeBottomSheet.java
@@ -118,8 +118,7 @@ public class WakeTimeBottomSheet extends BasePreferenceBottomSheet {
}
});
- int appModeColorId = getAppMode().getIconColorInfo().getColor(nightMode);
- int appModeColor = ContextCompat.getColor(themedCtx, appModeColorId);
+ int appModeColor = getAppMode().getProfileColor(nightMode);
UiUtilities.setupSlider(slider, nightMode, appModeColor, true);
items.add(new BaseBottomSheetItem.Builder()
diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java
index 63dab74fd4..e6d39cade8 100644
--- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java
@@ -680,12 +680,9 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
@ColorInt
protected int getActiveProfileColor() {
- return ContextCompat.getColor(app, getActiveProfileColorRes());
- }
-
- @ColorRes
- protected int getActiveProfileColorRes() {
- return isProfileDependent() ? getSelectedAppMode().getIconColorInfo().getColor(isNightMode()) : R.color.icon_color_active_light;
+ return isProfileDependent() ?
+ getSelectedAppMode().getProfileColor(isNightMode()) :
+ ContextCompat.getColor(app, nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light);
}
@ColorRes
@@ -801,7 +798,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
protected Drawable getActiveIcon(@DrawableRes int id) {
UiUtilities cache = getIconsCache();
- return cache != null ? cache.getIcon(id, getActiveProfileColorRes()) : null;
+ return cache != null ? cache.getPaintedIcon(id, getActiveProfileColor()) : null;
}
protected Drawable getIcon(@DrawableRes int id, @ColorRes int colorId) {
@@ -829,7 +826,8 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
Drawable icon = AndroidUtils.createEnabledStateListDrawable(disabled, enabled);
if (Build.VERSION.SDK_INT < 21) {
- ColorStateList colorStateList = AndroidUtils.createEnabledColorStateList(app, R.color.icon_color_default_light, getActiveProfileColorRes());
+ int defaultColor = ContextCompat.getColor(app, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light);
+ ColorStateList colorStateList = AndroidUtils.createEnabledColorIntStateList(defaultColor, getActiveProfileColor());
icon = DrawableCompat.wrap(icon);
DrawableCompat.setTintList(icon, colorStateList);
return icon;
diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java
index 078197da4f..4b8e40f1a0 100644
--- a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java
@@ -6,9 +6,6 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
-import androidx.annotation.NonNull;
-import androidx.recyclerview.widget.RecyclerView;
-
import net.osmand.AndroidUtils;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
@@ -33,12 +30,16 @@ import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
import net.osmand.util.Algorithms;
-import org.apache.commons.logging.Log;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
import java.io.File;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.core.content.ContextCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
import static net.osmand.plus.settings.backend.backup.FileSettingsItem.FileSubtype;
public class DuplicatesSettingsAdapter extends RecyclerView.Adapter {
@@ -121,7 +122,10 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter 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);
+ colorsCardContainer.addView(colorsCard.build(app));
+ updateColorName();
}
private void updateProfileNameAppearance() {
if (profileName != null) {
if (profileName.isFocusable() && profileName.isFocusableInTouchMode()) {
- int selectedColor = ContextCompat.getColor(app, changedProfile.color.getColor(isNightMode()));
+ int selectedColor = changedProfile.getActualColor();
profileNameOtfb.setPrimaryColor(selectedColor);
profileName.getBackground().mutate().setColorFilter(selectedColor, PorterDuff.Mode.SRC_ATOP);
}
@@ -560,8 +538,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
private View createLocationIconView(final LocationIcon locationIcon, ViewGroup rootView) {
FrameLayout locationIconView = (FrameLayout) UiUtilities.getInflater(getContext(), isNightMode())
.inflate(R.layout.preference_select_icon_button, rootView, false);
- int changedProfileColor = ContextCompat.getColor(app, changedProfile.color.getColor(
- app.getDaynightHelper().isNightModeForMapControls()));
+ int changedProfileColor = changedProfile.getActualColor();
LayerDrawable locationIconDrawable = (LayerDrawable) AppCompatResources.getDrawable(app, locationIcon.getIconId());
if (locationIconDrawable != null) {
DrawableCompat.setTint(DrawableCompat.wrap(locationIconDrawable.getDrawable(1)), changedProfileColor);
@@ -609,7 +586,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
LayerDrawable navigationIconDrawable = (LayerDrawable) AppCompatResources.getDrawable(app, navigationIcon.getIconId());
if (navigationIconDrawable != null) {
DrawableCompat.setTint(DrawableCompat.wrap(navigationIconDrawable.getDrawable(1)),
- ContextCompat.getColor(app, changedProfile.color.getColor(app.getDaynightHelper().isNightModeForMapControls())));
+ changedProfile.getActualColor());
}
ImageView imageView = navigationIconView.findViewById(R.id.icon);
imageView.setImageDrawable(navigationIconDrawable);
@@ -634,8 +611,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
});
ImageView outlineRect = navigationIconView.findViewById(R.id.outlineRect);
GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_icon_button_outline);
- int changedProfileColor = ContextCompat.getColor(app, changedProfile.color.getColor(
- app.getDaynightHelper().isNightModeForMapControls()));
+ int changedProfileColor = changedProfile.getActualColor();
if (rectContourDrawable != null) {
rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 2), changedProfileColor);
}
@@ -660,13 +636,13 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
}
private void setIconColor(int iconRes) {
- int changedProfileColor = ContextCompat.getColor(app, changedProfile.color.getColor(
- app.getDaynightHelper().isNightModeForMapControls()));
+ int changedProfileColor = changedProfile.getActualColor();
View iconItem = iconItems.findViewWithTag(iconRes);
if (iconItem != null) {
+ int newColor = changedProfile.getActualColor();
AndroidUtils.setBackground(iconItem.findViewById(R.id.background),
UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, R.drawable.circle_background_light),
- UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, changedProfile.color.getColor(isNightMode())), 0.1f)));
+ UiUtilities.getColorWithAlpha(newColor, 0.1f)));
ImageView outlineCircle = iconItem.findViewById(R.id.outline);
GradientDrawable circleContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.circle_contour_bg_light);
if (circleContourDrawable != null) {
@@ -775,6 +751,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
mode.setRoutingProfile(changedProfile.routingProfile);
mode.setRouteService(changedProfile.routeService);
mode.setIconColor(changedProfile.color);
+ mode.setCustomIconColor(changedProfile.customColor);
mode.setLocationIcon(changedProfile.locationIcon);
mode.setNavigationIcon(changedProfile.navigationIcon);
@@ -795,6 +772,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
.setRoutingProfile(changedProfile.routingProfile)
.setRouteService(changedProfile.routeService)
.setIconColor(changedProfile.color)
+ .setCustomIconColor(changedProfile.customColor)
.setLocationIcon(changedProfile.locationIcon)
.setNavigationIcon(changedProfile.navigationIcon);
@@ -931,6 +909,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);
@@ -938,6 +928,53 @@ 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.customColor = null;
+ changedProfile.color = changedProfile.getProfileColorByColorValue(color);
+ } else {
+ changedProfile.customColor = cardOfColors.getSelectedColor();
+ 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);
@@ -963,12 +1000,29 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
ApplicationMode parent = null;
String name;
ProfileIconColors color;
+ Integer customColor = null;
int iconRes;
String routingProfile;
RouteProvider.RouteService routeService;
NavigationIcon navigationIcon;
LocationIcon locationIcon;
+ @ColorInt
+ public int getActualColor() {
+ return customColor != null ?
+ customColor : ContextCompat.getColor(app, color.getColor(isNightMode()));
+ }
+
+ public ProfileIconColors getProfileColorByColorValue(int colorValue) {
+ for (ProfileIconColors color : ProfileIconColors.values()) {
+ if (ContextCompat.getColor(app, color.getColor(true)) == colorValue
+ || ContextCompat.getColor(app, color.getColor(false)) == colorValue) {
+ return color;
+ }
+ }
+ return ProfileIconColors.DEFAULT;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -982,6 +1036,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
if (parent != null ? !parent.equals(that.parent) : that.parent != null) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (color != that.color) return false;
+ if (customColor != null ? !customColor.equals(that.customColor) : that.customColor != null) return false;
if (routingProfile != null ? !routingProfile.equals(that.routingProfile) : that.routingProfile != null)
return false;
if (routeService != that.routeService) return false;
@@ -995,6 +1050,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
result = 31 * result + (parent != null ? parent.hashCode() : 0);
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (color != null ? color.hashCode() : 0);
+ result = 31 * result + (customColor != null ? customColor.hashCode() : 0);
result = 31 * result + iconRes;
result = 31 * result + (routingProfile != null ? routingProfile.hashCode() : 0);
result = 31 * result + (routeService != null ? routeService.hashCode() : 0);
diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java
index 4ec93b68ef..d9290bdcbe 100644
--- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java
@@ -443,7 +443,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
});
builder.setNegativeButton(R.string.shared_string_cancel, null);
- int selectedModeColor = ContextCompat.getColor(app, mode.getIconColorInfo().getColor(nightMode));
+ int selectedModeColor = mode.getProfileColor(nightMode);
setupAngleSlider(angleValue, sliderView, nightMode, selectedModeColor);
builder.show();
}
diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java
index 7885a6700b..3972b61c20 100644
--- a/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java
@@ -280,7 +280,7 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
}
});
- int selectedModeColor = ContextCompat.getColor(app, mode.getIconColorInfo().getColor(nightMode));
+ int selectedModeColor = mode.getProfileColor(nightMode);
if (!defaultSpeedOnly) {
setupSpeedSlider(SpeedSliderType.DEFAULT_SPEED, speedUnits, defaultValue, minValue, maxValue, min, max, seekbarView, selectedModeColor);
setupSpeedSlider(SpeedSliderType.MIN_SPEED, speedUnits, defaultValue, minValue, maxValue, min, max, seekbarView, selectedModeColor);
diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java
index 86abdee880..0b4f6d831c 100644
--- a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java
+++ b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java
@@ -184,7 +184,7 @@ public class ContourLinesMenu {
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(toggleActionStringId, mapActivity)
.setIcon(toggleIconId)
- .setColor(toggleIconColorId)
+ .setColor(app, toggleIconColorId)
.setListener(l)
.setSelected(selected).createItem());
if (selected) {
@@ -225,7 +225,7 @@ public class ContourLinesMenu {
.setTitleId(R.string.srtm_plugin_name, mapActivity)
.setLayout(R.layout.list_item_icon_and_right_btn)
.setIcon(R.drawable.ic_plugin_srtm)
- .setColor(R.color.osmand_orange)
+ .setColor(app, R.color.osmand_orange)
.setDescription(app.getString(R.string.shared_string_plugin))
.setListener(l).createItem());
} else {
diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java
index e58bf4ef89..bf070b158a 100644
--- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java
@@ -10,7 +10,6 @@ import android.widget.ArrayAdapter;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
-import androidx.core.content.ContextCompat;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
@@ -303,7 +302,7 @@ public class SRTMPlugin extends OsmandPlugin {
if (item != null) {
item.setDescription(app.getString(R.string.display_zoom_level,
getPrefDescription(app, contourLinesProp, pref)));
- item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ item.setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
item.setSelected(selected);
adapter.notifyDataSetChanged();
}
@@ -322,7 +321,7 @@ public class SRTMPlugin extends OsmandPlugin {
}
ContextMenuItem item = adapter.getItem(position);
if (item != null) {
- item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ item.setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
item.setSelected(selected);
adapter.notifyDataSetChanged();
}
@@ -346,7 +345,7 @@ public class SRTMPlugin extends OsmandPlugin {
.setSelected(contourLinesSelected)
.setIcon(R.drawable.ic_plugin_srtm)
.setDescription(app.getString(R.string.display_zoom_level, descr))
- .setColor(contourLinesSelected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, contourLinesSelected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setItemDeleteAction(makeDeleteAction(settings.CONTOUR_LINES_ZOOM))
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(listener).createItem());
@@ -360,7 +359,7 @@ public class SRTMPlugin extends OsmandPlugin {
? R.string.shared_string_hillshade
: R.string.download_slope_maps))
.setSelected(terrainEnabled)
- .setColor(terrainEnabled ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, terrainEnabled ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_action_hillshade_dark)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setItemDeleteAction(makeDeleteAction(settings.TERRAIN, settings.TERRAIN_MODE))
@@ -473,7 +472,7 @@ public class SRTMPlugin extends OsmandPlugin {
possibleValues[j]);
}
- int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode));
+ int selectedModeColor = settings.getApplicationMode().getProfileColor(nightMode);
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
possibleValuesString, nightMode, i, app, selectedModeColor, themeRes, new View.OnClickListener() {
diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java
index c142ebcf5c..1475a0a7fd 100644
--- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java
+++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java
@@ -75,7 +75,6 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
private boolean nightMode;
private boolean terrainEnabled;
- private int colorProfileRes;
private int colorProfile;
private TextView downloadDescriptionTv;
@@ -144,8 +143,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
uiUtilities = app.getUIUtilities();
nightMode = app.getDaynightHelper().isNightModeForMapControls();
srtmPlugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
- colorProfileRes = settings.getApplicationMode().getIconColorInfo().getColor(nightMode);
- colorProfile = ContextCompat.getColor(app, colorProfileRes);
+ colorProfile = settings.getApplicationMode().getProfileColor(nightMode);
terrainEnabled = srtmPlugin.isTerrainLayerEnabled();
super.onCreate(savedInstanceState);
}
@@ -238,7 +236,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
String transparency = transparencyValue + "%";
int minZoom = Math.max(srtmPlugin.getTerrainMinZoom(), TERRAIN_MIN_ZOOM);
int maxZoom = Math.min(srtmPlugin.getTerrainMaxZoom(), TERRAIN_MAX_ZOOM);
- iconIv.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_hillshade_dark, colorProfileRes));
+ iconIv.setImageDrawable(uiUtilities.getPaintedIcon(R.drawable.ic_action_hillshade_dark, colorProfile));
stateTv.setText(R.string.shared_string_enabled);
transparencySlider.setValue(transparencyValue);
transparencyValueTv.setText(transparency);
diff --git a/OsmAnd/src/net/osmand/plus/track/ColorsCard.java b/OsmAnd/src/net/osmand/plus/track/ColorsCard.java
index 9fee9408c4..5f83dfc6c8 100644
--- a/OsmAnd/src/net/osmand/plus/track/ColorsCard.java
+++ b/OsmAnd/src/net/osmand/plus/track/ColorsCard.java
@@ -7,12 +7,6 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
-import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.core.content.ContextCompat;
-import androidx.core.graphics.ColorUtils;
-import androidx.fragment.app.Fragment;
-
import com.google.android.material.internal.FlowLayout;
import net.osmand.AndroidUtils;
@@ -22,6 +16,8 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
+import net.osmand.plus.settings.backend.ApplicationMode;
+import net.osmand.plus.settings.backend.ListStringPreference;
import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
import net.osmand.util.Algorithms;
@@ -30,6 +26,11 @@ import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.ColorInt;
+import androidx.core.content.ContextCompat;
+import androidx.core.graphics.ColorUtils;
+import androidx.fragment.app.Fragment;
+
public class ColorsCard extends BaseCard implements ColorPickerListener {
public static final int MAX_CUSTOM_COLORS = 6;
@@ -41,6 +42,9 @@ public class ColorsCard extends BaseCard implements ColorPickerListener {
private Fragment targetFragment;
+ private ApplicationMode appMode;
+ private ListStringPreference colorsListPreference;
+
private List colors;
private List customColors;
@@ -51,12 +55,14 @@ public class ColorsCard extends BaseCard implements ColorPickerListener {
return R.layout.colors_card;
}
- public ColorsCard(MapActivity mapActivity, int selectedColor, Fragment targetFragment, List colors) {
+ public ColorsCard(MapActivity mapActivity, int selectedColor, Fragment targetFragment, List colors, ListStringPreference colorsListPreference, ApplicationMode appMode) {
super(mapActivity);
this.targetFragment = targetFragment;
this.selectedColor = selectedColor;
this.colors = colors;
- customColors = getCustomColors(app);
+ this.colorsListPreference = colorsListPreference;
+ this.customColors = getCustomColors(colorsListPreference, appMode);
+ this.appMode = appMode;
}
public int getSelectedColor() {
@@ -215,9 +221,18 @@ public class ColorsCard extends BaseCard implements ColorPickerListener {
return app.getUIUtilities().getPaintedIcon(R.drawable.ic_bg_transparency, transparencyColor);
}
- public static List getCustomColors(@NonNull OsmandApplication app) {
+ public static List getCustomColors(ListStringPreference colorsListPreference) {
+ return getCustomColors(colorsListPreference, null);
+ }
+
+ public static List getCustomColors(ListStringPreference colorsListPreference, ApplicationMode appMode) {
List colors = new ArrayList<>();
- List colorNames = app.getSettings().CUSTOM_TRACK_COLORS.getStringsList();
+ List colorNames;
+ if (appMode == null) {
+ colorNames = colorsListPreference.getStringsList();
+ } else {
+ colorNames = colorsListPreference.getStringsListForProfile(appMode);
+ }
if (colorNames != null) {
for (String colorHex : colorNames) {
try {
@@ -233,12 +248,24 @@ public class ColorsCard extends BaseCard implements ColorPickerListener {
return colors;
}
+ public int getIndexOfSelectedColor() {
+ return customColors.indexOf(selectedColor);
+ }
+
+ public boolean isBaseColor(int color) {
+ return colors.contains(color);
+ }
+
private void saveCustomColors() {
List colorNames = new ArrayList<>();
for (Integer color : customColors) {
String colorHex = Algorithms.colorToString(color);
colorNames.add(colorHex);
}
- app.getSettings().CUSTOM_TRACK_COLORS.setStringsList(colorNames);
+ if (appMode == null) {
+ colorsListPreference.setStringsList(colorNames);
+ } else {
+ colorsListPreference.setStringsListForProfile(appMode, colorNames);
+ }
}
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java
index f586700ef2..4642175b09 100644
--- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java
+++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java
@@ -360,7 +360,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
@Override
public void onColorSelected(Integer prevColor, int newColor) {
if (prevColor != null) {
- List customColors = ColorsCard.getCustomColors(app);
+ List customColors = ColorsCard.getCustomColors(app.getSettings().CUSTOM_TRACK_COLORS);
int index = customColors.indexOf(prevColor);
if (index != ColorsCard.INVALID_VALUE) {
saveCustomColorsToTracks(prevColor, newColor);
@@ -670,7 +670,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
List colors = getTrackColors();
- colorsCard = new ColorsCard(mapActivity, trackDrawInfo.getColor(), this, colors);
+ colorsCard = new ColorsCard(mapActivity, trackDrawInfo.getColor(), this, colors, app.getSettings().CUSTOM_TRACK_COLORS, null);
colorsCard.setListener(this);
cardsContainer.addView(colorsCard.build(mapActivity));
}
diff --git a/OsmAnd/src/net/osmand/plus/transport/TransportLinesMenu.java b/OsmAnd/src/net/osmand/plus/transport/TransportLinesMenu.java
index 4e91d5700e..5ccac24296 100644
--- a/OsmAnd/src/net/osmand/plus/transport/TransportLinesMenu.java
+++ b/OsmAnd/src/net/osmand/plus/transport/TransportLinesMenu.java
@@ -80,8 +80,7 @@ public class TransportLinesMenu {
final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
final Context themedCtx = UiUtilities.getThemedContext(mapActivity, nightMode);
- final int profileColorResId = appMode.getIconColorInfo().getColor(nightMode);
- final int profileColor = ContextCompat.getColor(themedCtx, profileColorResId);
+ final int profileColor = appMode.getProfileColor(nightMode);
final AlertDialog.Builder b = new AlertDialog.Builder(themedCtx);
b.setTitle(themedCtx.getString(R.string.rendering_category_transport));
@@ -123,7 +122,7 @@ public class TransportLinesMenu {
View v = super.getView(position, convertView, parent);
final ImageView icon = (ImageView) v.findViewById(R.id.icon);
if (checkedItems[position]) {
- icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], profileColorResId));
+ icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(iconIds[position], profileColor));
} else {
icon.setImageDrawable(app.getUIUtilities().getThemedIcon(iconIds[position]));
}
@@ -138,7 +137,7 @@ public class TransportLinesMenu {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
checkedItems[position] = isChecked;
if (checkedItems[position]) {
- icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], profileColorResId));
+ icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(iconIds[position], profileColor));
} else {
icon.setImageDrawable(app.getUIUtilities().getThemedIcon(iconIds[position]));
}
diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java
index 8fa3f2bf50..945796a726 100644
--- a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java
@@ -20,6 +20,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.content.res.AppCompatResources;
@@ -888,7 +889,7 @@ public class MapControlsLayer extends OsmandMapLayer {
compassHud.updateVisibility(!forceHideCompass && shouldShowCompass());
ApplicationMode appMode = settings.getApplicationMode();
- layersHud.setIconColorId(appMode.getIconColorInfo().getColor(isNight));
+ layersHud.setIconColor(appMode.getProfileColor(isNight));
if (layersHud.setIconResId(appMode.getIconRes())) {
layersHud.update(app, isNight);
}
@@ -1095,8 +1096,7 @@ public class MapControlsLayer extends OsmandMapLayer {
transparencyBarLayout.setVisibility(View.GONE);
}
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
- int selectedModeColor = ContextCompat.getColor(app,
- appMode.getIconColorInfo().getColor(nightMode));
+ int selectedModeColor = appMode.getProfileColor(nightMode);
UiUtilities.setupSlider(transparencySlider, nightMode, selectedModeColor);
}
@@ -1115,6 +1115,10 @@ public class MapControlsLayer extends OsmandMapLayer {
private int resDarkId;
private int resClrLight = R.color.map_button_icon_color_light;
private int resClrDark = R.color.map_button_icon_color_dark;
+ @ColorInt
+ private Integer clrIntLight = null;
+ @ColorInt
+ private Integer clrIntDark = null;
private String id;
private boolean flipIconForRtl;
@@ -1223,11 +1227,14 @@ public class MapControlsLayer extends OsmandMapLayer {
}
public boolean resetIconColors() {
- if (resClrLight == R.color.map_button_icon_color_light && resClrDark == R.color.map_button_icon_color_dark) {
+ if (resClrLight == R.color.map_button_icon_color_light && resClrDark == R.color.map_button_icon_color_dark
+ && clrIntLight == null && clrIntDark == null) {
return false;
}
resClrLight = R.color.map_button_icon_color_light;
resClrDark = R.color.map_button_icon_color_dark;
+ clrIntLight = null;
+ clrIntDark = null;
f = true;
return true;
}
@@ -1242,6 +1249,16 @@ public class MapControlsLayer extends OsmandMapLayer {
return this;
}
+ public MapHudButton setIconColor(@ColorInt Integer clr) {
+ if (clrIntLight == clr && clrIntDark == clr) {
+ return this;
+ }
+ clrIntLight = clr;
+ clrIntDark = clr;
+ f = true;
+ return this;
+ }
+
public MapHudButton setIconsId(int icnLight, int icnDark) {
if (resLightId == icnLight && resDarkId == icnDark) {
return this;
@@ -1262,6 +1279,17 @@ public class MapControlsLayer extends OsmandMapLayer {
return this;
}
+ public MapHudButton setIconColor(@ColorInt int clrLight, @ColorInt int clrDark) {
+ if (clrIntLight == clrLight && clrIntDark == clrDark) {
+ return this;
+ }
+ clrIntLight = clrLight;
+ clrIntDark = clrDark;
+ f = true;
+ return this;
+
+ }
+
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public void update(OsmandApplication ctx, boolean night) {
@@ -1283,7 +1311,11 @@ public class MapControlsLayer extends OsmandMapLayer {
} else if (resLightId != 0 && !nightMode) {
d = ctx.getUIUtilities().getIcon(resLightId);
} else if (resId != 0) {
- d = ctx.getUIUtilities().getIcon(resId, nightMode ? resClrDark : resClrLight);
+ if (clrIntLight != null && clrIntDark != null) {
+ d = ctx.getUIUtilities().getPaintedIcon(resId, nightMode ? clrIntDark : clrIntLight);
+ } else {
+ d = ctx.getUIUtilities().getIcon(resId, nightMode ? resClrDark : resClrLight);
+ }
if (flipIconForRtl) {
d = AndroidUtils.getDrawableForDirection(ctx, d);
}
diff --git a/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java
index 16952876a8..3c60b1af49 100644
--- a/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java
@@ -1,5 +1,6 @@
package net.osmand.plus.views.layers;
+import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
@@ -11,6 +12,7 @@ import android.graphics.PorterDuffColorFilter;
import android.graphics.RectF;
import android.graphics.drawable.LayerDrawable;
+import androidx.annotation.ColorInt;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
@@ -48,7 +50,8 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
private OsmandMapTileView view;
private ApplicationMode appMode;
- private int colorId;
+ @ColorInt
+ private int color;
private LayerDrawable navigationIcon;
private int navigationIconId;
private LayerDrawable locationIcon;
@@ -160,30 +163,32 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
}
private void updateIcons(ApplicationMode appMode, boolean nighMode, boolean locationOutdated) {
- int colorId = locationOutdated ? ProfileIconColors.getOutdatedLocationColor(nighMode) : appMode.getIconColorInfo().getColor(nighMode);
+ Context ctx = view.getContext();
+ int color = locationOutdated ?
+ ContextCompat.getColor(ctx, ProfileIconColors.getOutdatedLocationColor(nighMode)) :
+ appMode.getProfileColor(nighMode);
int locationIconId = appMode.getLocationIcon().getIconId();
int navigationIconId = appMode.getNavigationIcon().getIconId();
int headingIconId = appMode.getLocationIcon().getHeadingIconId();
if (appMode != this.appMode || this.nm != nighMode || this.locationOutdated != locationOutdated
- || this.colorId != colorId
+ || this.color != color
|| this.locationIconId != locationIconId
|| this.headingIconId != headingIconId
|| this.navigationIconId != navigationIconId) {
this.appMode = appMode;
- this.colorId = colorId;
+ this.color = color;
this.nm = nighMode;
this.locationOutdated = locationOutdated;
this.locationIconId = locationIconId;
this.headingIconId = headingIconId;
this.navigationIconId = navigationIconId;
- int color = ContextCompat.getColor(view.getContext(), colorId);
- navigationIcon = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), navigationIconId);
+ navigationIcon = (LayerDrawable) AppCompatResources.getDrawable(ctx, navigationIconId);
if (navigationIcon != null) {
DrawableCompat.setTint(navigationIcon.getDrawable(1), color);
}
headingIcon = BitmapFactory.decodeResource(view.getResources(), headingIconId);
headingPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
- locationIcon = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), locationIconId);
+ locationIcon = (LayerDrawable) AppCompatResources.getDrawable(ctx, locationIconId);
if (locationIcon != null) {
DrawableCompat.setTint(DrawableCompat.wrap(locationIcon.getDrawable(1)), color);
}
diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java
index 2c9d6af19d..a64fb19f02 100644
--- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java
+++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java
@@ -9,7 +9,6 @@ import android.widget.LinearLayout;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
-import androidx.core.content.ContextCompat;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
@@ -468,7 +467,7 @@ public class MapWidgetRegistry {
.setTitleId(R.string.configure_screen_quick_action, mapActivity)
.setIcon(R.drawable.ic_quick_action)
.setSelected(selected)
- .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(new ContextMenuAdapter.OnRowItemClick() {
@Override
@@ -504,7 +503,7 @@ public class MapWidgetRegistry {
}
ContextMenuItem item = adapter.getItem(position);
item.setSelected(visible);
- item.setColorRes(visible ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ item.setColor(app, visible ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
}
@@ -522,12 +521,11 @@ public class MapWidgetRegistry {
final boolean selected = r.visibleCollapsed(mode) || r.visible(mode);
final String desc = mapActivity.getString(R.string.shared_string_collapse);
final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
- final int currentModeColorRes = mode.getIconColorInfo().getColor(nightMode);
- final int currentModeColor = ContextCompat.getColor(app, currentModeColorRes);
+ final int currentModeColor = mode.getProfileColor(nightMode);
ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder()
.setIcon(r.getDrawableMenu())
.setSelected(selected)
- .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setSecondaryIcon(r.widget != null ? R.drawable.ic_action_additional_option : ContextMenuItem.INVALID_ID)
.setDescription(r.visibleCollapsed(mode) ? desc : null)
.setListener(new ContextMenuAdapter.OnRowItemClick() {
@@ -557,7 +555,7 @@ public class MapWidgetRegistry {
final int id = menuItemIds[i];
boolean isChecked = id == checkedId;
String title = app.getString(titleId);
- Drawable icon = isChecked && selected ? ic.getIcon(iconId, currentModeColorRes) : ic.getThemedIcon(iconId);
+ Drawable icon = isChecked && selected ? ic.getPaintedIcon(iconId, currentModeColor) : ic.getThemedIcon(iconId);
items.add(new PopUpMenuItem.Builder(app)
.setTitle(title)
.setIcon(icon)
@@ -646,7 +644,7 @@ public class MapWidgetRegistry {
}
ContextMenuItem item = adapter.getItem(position);
item.setSelected(visible);
- item.setColorRes(visible ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
+ item.setColor(app, visible ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
item.setDescription(visible && collapsed ? desc : null);
adapter.notifyDataSetChanged();
}
diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java b/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java
index 2fdf57b9be..e9534e55e4 100644
--- a/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java
@@ -71,7 +71,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
public void createMenuItems(Bundle savedInstanceState) {
final int activeColorResId = nightMode ?
R.color.active_color_primary_dark : R.color.active_color_primary_light;
- final int profileColorResId = appMode.getIconColorInfo().getColor(nightMode);
+ final int profileColor = appMode.getProfileColor(nightMode);
final int contentPadding = app.getResources().getDimensionPixelSize(R.dimen.content_padding);
final int contentPaddingSmall = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
@@ -86,7 +86,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
final BottomSheetItemWithCompoundButton[] btnSelectAll = new BottomSheetItemWithCompoundButton[1];
btnSelectAll[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(this.isGlobalWikiPoiEnabled)
- .setCompoundButtonColorId(profileColorResId)
+ .setCompoundButtonColor(profileColor)
.setTitle(getString(R.string.shared_string_all_languages))
.setTitleColorId(activeColorResId)
.setCustomView(getCustomButtonView())
@@ -174,15 +174,15 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
int disableColorId = nightMode ?
R.color.active_buttons_and_links_text_disabled_dark :
R.color.active_buttons_and_links_text_disabled_light;
- int profileColorId = appMode.getIconColorInfo().getColor(nightMode);
+ int profileColor = appMode.getProfileColor(nightMode);
+ int disableColor = ContextCompat.getColor(app, disableColorId);
for (BottomSheetItemWithCompoundButton item : languageItems) {
item.getView().setEnabled(enable);
item.setTitleColorId(enable ? textColorPrimaryId : disableColorId);
CompoundButton cb = item.getCompoundButton();
if (cb != null) {
cb.setEnabled(enable);
- UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(app, enable ?
- profileColorId : disableColorId), cb);
+ UiUtilities.setupCompoundButton(nightMode, enable ? profileColor : disableColor, cb);
}
}
}
@@ -254,7 +254,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
Drawable bgDrawable = app.getUIUtilities().getPaintedIcon(bgResId, bgColor);
AndroidUtils.setBackground(buttonView, bgDrawable);
- int selectedModeColorId = appMode.getIconColorInfo().getColor(nightMode);
+ int selectedModeColorId = appMode.getProfileColor(nightMode);
UiUtilities.setupCompoundButton(nightMode, selectedModeColorId, cb);
return buttonView;
diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java
index 1b97f6df1c..f08f02966e 100644
--- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java
@@ -141,7 +141,7 @@ public class WikipediaPlugin extends OsmandPlugin {
ContextMenuItem item = adapter.getItem(pos);
if (item != null) {
item.setSelected(selected);
- item.setColorRes(selected ?
+ item.setColor(app, selected ?
R.color.osmand_orange : ContextMenuItem.INVALID_ID);
item.setDescription(selected ? getLanguagesSummary() : null);
adapter.notifyDataSetChanged();
@@ -160,7 +160,7 @@ public class WikipediaPlugin extends OsmandPlugin {
.setTitleId(R.string.shared_string_wikipedia, mapActivity)
.setDescription(selected ? getLanguagesSummary() : null)
.setSelected(selected)
- .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
+ .setColor(app, selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_plugin_wikipedia)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(listener).createItem());
diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPoiMenu.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPoiMenu.java
index 28c2639a35..a2cb6b5b71 100644
--- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPoiMenu.java
+++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPoiMenu.java
@@ -74,7 +74,7 @@ public class WikipediaPoiMenu {
.setTitleId(toggleActionStringId, mapActivity)
.setDescription(summary)
.setIcon(toggleIconId)
- .setColor(toggleIconColorId)
+ .setColor(app, toggleIconColorId)
.setListener(l)
.setSelected(enabled).createItem());