From b8ec9b1dfdb6d2e6200e4309838874a99fc5d635 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Mon, 15 Jan 2018 13:05:24 +0200 Subject: [PATCH] Change button icon color on tap in map markers context menu --- OsmAnd/res/drawable/passed_icon_dark.xml | 11 ----- OsmAnd/res/drawable/passed_icon_light.xml | 11 ----- OsmAnd/res/values/colors.xml | 4 +- .../controllers/MapMarkerMenuController.java | 45 +++++++++++++++---- 4 files changed, 38 insertions(+), 33 deletions(-) delete mode 100644 OsmAnd/res/drawable/passed_icon_dark.xml delete mode 100644 OsmAnd/res/drawable/passed_icon_light.xml diff --git a/OsmAnd/res/drawable/passed_icon_dark.xml b/OsmAnd/res/drawable/passed_icon_dark.xml deleted file mode 100644 index 99997007bd..0000000000 --- a/OsmAnd/res/drawable/passed_icon_dark.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/drawable/passed_icon_light.xml b/OsmAnd/res/drawable/passed_icon_light.xml deleted file mode 100644 index ac91b37dec..0000000000 --- a/OsmAnd/res/drawable/passed_icon_light.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index 4dc952ec36..bc57720393 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -325,11 +325,11 @@ #e6e6e6 #4c63e6 #2d3133 - #b36a0b + #d28521 #fafafa #6d82fc #222526 - #d28521 + #b36a0b #f2f2f2 #222526 #e6e6e6 diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java index c8247d34e5..89c5474b7b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java @@ -2,9 +2,13 @@ package net.osmand.plus.mapcontextmenu.controllers; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; +import android.graphics.drawable.ShapeDrawable; +import android.graphics.drawable.StateListDrawable; +import android.graphics.drawable.shapes.OvalShape; +import android.support.v4.content.ContextCompat; +import net.osmand.AndroidUtils; import net.osmand.data.PointDescription; -import net.osmand.plus.IconsCache; import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmandApplication; @@ -34,9 +38,8 @@ public class MapMarkerMenuController extends MenuController { getMapActivity().getContextMenu().close(); } }; - leftTitleButtonController.needColorizeIcon = false; leftTitleButtonController.caption = getMapActivity().getString(R.string.mark_passed); - leftTitleButtonController.leftIconId = isLight() ? R.drawable.passed_icon_light : R.drawable.passed_icon_dark; + leftTitleButtonController.leftIcon = createStateListPassedIcon(); rightTitleButtonController = new TitleButtonController() { @Override @@ -51,14 +54,38 @@ public class MapMarkerMenuController extends MenuController { } }; rightTitleButtonController.caption = getMapActivity().getString(R.string.make_active); - rightTitleButtonController.leftIcon = createShowOnTopbarIcon(); + rightTitleButtonController.leftIcon = createStateListShowOnTopbarIcon(); } - private Drawable createShowOnTopbarIcon() { - IconsCache ic = getMapActivity().getMyApplication().getIconsCache(); - Drawable background = ic.getIcon(R.drawable.ic_action_device_top, - isLight() ? R.color.on_map_icon_color : R.color.ctx_menu_info_text_dark); - Drawable topbar = ic.getIcon(R.drawable.ic_action_device_topbar, R.color.dashboard_blue); + private StateListDrawable createStateListPassedIcon() { + int bgNormal = isLight() ? R.color.map_widget_blue : R.color.osmand_orange; + int bgPressed = isLight() ? R.color.ctx_menu_controller_button_text_color_light_p + : R.color.ctx_menu_controller_button_text_color_dark_p; + int icPressed = isLight() ? R.color.ctx_menu_controller_button_text_color_light_n + : R.color.ctx_menu_controller_button_bg_color_dark_p; + return AndroidUtils.createStateListDrawable(createPassedIcon(bgNormal, 0), + createPassedIcon(bgPressed, icPressed)); + } + + private LayerDrawable createPassedIcon(int bgColorRes, int icColorRes) { + ShapeDrawable bg = new ShapeDrawable(new OvalShape()); + bg.getPaint().setColor(ContextCompat.getColor(getMapActivity(), bgColorRes)); + Drawable ic = getIcon(R.drawable.ic_action_marker_passed, icColorRes); + return new LayerDrawable(new Drawable[]{bg, ic}); + } + + private StateListDrawable createStateListShowOnTopbarIcon() { + int bgNormal = isLight() ? R.color.on_map_icon_color : R.color.ctx_menu_info_text_dark; + int bgPressed = isLight() ? R.color.ctx_menu_controller_button_text_color_light_p + : R.color.ctx_menu_controller_button_text_color_dark_p; + int icPressed = isLight() ? R.color.osmand_orange : R.color.route_info_go_btn_bg_dark_p; + return AndroidUtils.createStateListDrawable(createShowOnTopbarIcon(bgNormal, R.color.dashboard_blue), + createShowOnTopbarIcon(bgPressed, icPressed)); + } + + private LayerDrawable createShowOnTopbarIcon(int bgColorRes, int icColorRes) { + Drawable background = getIcon(R.drawable.ic_action_device_top, bgColorRes); + Drawable topbar = getIcon(R.drawable.ic_action_device_topbar, icColorRes); return new LayerDrawable(new Drawable[]{background, topbar}); }