Easy replaсement of color from @ColorRes to @ColorInt

This commit is contained in:
cepprice 2021-02-23 13:45:16 +05:00
parent 7c22585d43
commit f75a8f8b58
37 changed files with 67 additions and 76 deletions

View file

@ -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);

View file

@ -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;

View file

@ -490,7 +490,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

View file

@ -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);

View file

@ -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);

View file

@ -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)
@ -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 : ContextMenuItem.INVALID_ID)
.setListener(l).createItem());
selected = app.getSelectedGpxHelper().isShowingAnyGpxFiles();
@ -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)

View file

@ -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);

View file

@ -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);

View file

@ -1338,7 +1338,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);
}

View file

@ -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

View file

@ -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));
}
}

View file

@ -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());
}

View file

@ -544,7 +544,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);

View file

@ -115,8 +115,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() {

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -67,10 +67,9 @@ public class SelectCopyProfilesMenuAdapter extends AbstractProfileMenuAdapter<Se
if (iconRes == 0 || iconRes == -1) {
iconRes = R.drawable.ic_action_world_globe;
}
int iconColor = appMode.getIconColorInfo().getColor(nightMode);
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, iconColor));
int colorNoAlpha = appMode.getProfileColor(nightMode);
int colorNoAlpha = ContextCompat.getColor(app, iconColor);
holder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(iconRes, colorNoAlpha));
Drawable drawable = UiUtilities.getColoredSelectableDrawable(app, colorNoAlpha, 0.3f);
if (selected) {

View file

@ -100,11 +100,10 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
holder.title.setText(item.toHumanString());
holder.descr.setText(ProfileDataUtils.getAppModeDescription(app, item));
int profileColorResId = item.getIconColorInfo().getColor(nightMode);
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(profileColorResId, selectedIconColorRes));
int colorNoAlpha = item.getProfileColor(nightMode);
holder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(selectedIconColorRes, colorNoAlpha));
//set up cell color
int colorNoAlpha = ContextCompat.getColor(app, profileColorResId);
boolean selectedMode = appMode == item;
Drawable drawable = UiUtilities.getColoredSelectableDrawable(app, colorNoAlpha, 0.3f);

View file

@ -372,8 +372,7 @@ public class QuickActionListFragment extends BaseOsmAndFragment
private void updateToolbarSwitch(final boolean isChecked) {
OsmandApplication app = requireMyApplication();
ApplicationMode appMode = app.getSettings().getApplicationMode();
int profileColor = appMode.getIconColorInfo().getColor(nightMode);
int color = ContextCompat.getColor(app, isChecked ? profileColor : R.color.preference_top_switch_off);
int color = isChecked ? appMode.getProfileColor(nightMode) : ContextCompat.getColor(app, R.color.preference_top_switch_off);
AndroidUtils.setBackground(toolbarSwitchContainer, new ColorDrawable(color));
SwitchCompat switchView = toolbarSwitchContainer.findViewById(R.id.switchWidget);

View file

@ -483,7 +483,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

View file

@ -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;

View file

@ -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

View file

@ -1,6 +1,7 @@
package net.osmand.plus.settings.backend;
import androidx.annotation.DrawableRes;
import androidx.core.content.ContextCompat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@ -463,6 +464,14 @@ public class ApplicationMode {
return app.getSettings().LOCATION_ICON.getModeValue(this);
}
public int getProfileColor(boolean nightMode) {
int index = getCustomIconColorIndex();
if (index == -1) {
return ContextCompat.getColor(app, getIconColorInfo().getColor(nightMode));
}
return Integer.parseInt(getCustomIconColors().get(index));
}
public void setLocationIcon(LocationIcon locationIcon) {
if (locationIcon != null) {
app.getSettings().LOCATION_ICON.setModeValue(this, locationIcon);

View file

@ -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);

View file

@ -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);

View file

@ -38,8 +38,7 @@ 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};

View file

@ -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()

View file

@ -142,7 +142,6 @@ public class GlobalSettingsFragment extends BaseSettingsFragment
private void setupDefaultAppModePref() {
Preference defaultApplicationMode = (Preference) findPreference(settings.DEFAULT_APPLICATION_MODE.getId());
int iconColor = settings.getApplicationMode().getIconColorInfo().getColor(isNightMode());
String summary;
int iconId;
if (settings.USE_LAST_APPLICATION_MODE_BY_DEFAULT.get()) {
@ -153,7 +152,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment
summary = appMode.toHumanString();
iconId = appMode.getIconRes();
}
defaultApplicationMode.setIcon(getIcon(iconId, iconColor));
defaultApplicationMode.setIcon(getPaintedIcon(iconId, settings.getApplicationMode().getProfileColor(isNightMode())));
defaultApplicationMode.setSummary(summary);
}

View file

@ -87,8 +87,7 @@ public class MainSettingsFragment extends BaseSettingsFragment implements OnSele
if (CONFIGURE_PROFILE.equals(key)) {
View selectedProfile = holder.itemView.findViewById(R.id.selectable_list_item);
if (selectedProfile != null) {
int activeProfileColorId = getSelectedAppMode().getIconColorInfo().getColor(isNightMode());
int activeProfileColor = ContextCompat.getColor(app, activeProfileColorId);
int activeProfileColor = getSelectedAppMode().getProfileColor(isNightMode());
Drawable backgroundDrawable = new ColorDrawable(UiUtilities.getColorWithAlpha(activeProfileColor, 0.15f));
AndroidUtils.setBackground(selectedProfile, backgroundDrawable);
}
@ -212,7 +211,7 @@ public class MainSettingsFragment extends BaseSettingsFragment implements OnSele
private Drawable getAppProfilesIcon(ApplicationMode applicationMode, boolean appProfileEnabled) {
int iconResId = applicationMode.getIconRes();
return appProfileEnabled ? app.getUIUtilities().getIcon(applicationMode.getIconRes(), applicationMode.getIconColorInfo().getColor(isNightMode()))
return appProfileEnabled ? app.getUIUtilities().getPaintedIcon(applicationMode.getIconRes(), applicationMode.getProfileColor(isNightMode()))
: getIcon(iconResId, isNightMode() ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light);
}

View file

@ -434,7 +434,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();
}

View file

@ -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);

View file

@ -473,7 +473,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() {

View file

@ -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);

View file

@ -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]));
}

View file

@ -1095,8 +1095,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);
}

View file

@ -515,8 +515,7 @@ 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)
@ -550,7 +549,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)