From a69e44a7c158e065aaf2d1728728b642136a8f06 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Fri, 12 Jan 2018 15:07:56 +0200 Subject: [PATCH] Change button icon color on tap in map data context menu --- .../net/osmand/plus/mapcontextmenu/MenuController.java | 10 ++++++++++ .../controllers/MapDataMenuController.java | 10 +++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 385b600190..4bda4d120e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -583,6 +583,16 @@ public abstract class MenuController extends BaseMenuController { return null; } + public void clearIcon(boolean left) { + if (left) { + leftIcon = null; + leftIconId = 0; + } else { + rightIcon = null; + rightIconId = 0; + } + } + public void updateStateListDrawableIcon(@DrawableRes int resId, boolean left) { if (left) { leftIcon = enabled ? getStateListDrawable(resId) : null; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java index a0735a80b2..c46251e66c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java @@ -115,7 +115,7 @@ public class MapDataMenuController extends MenuController { } }; leftDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_download); - leftDownloadButtonController.leftIconId = R.drawable.ic_action_import; + leftDownloadButtonController.updateStateListDrawableIcon(R.drawable.ic_action_import, true); rightDownloadButtonController = new TitleButtonController() { @Override @@ -142,7 +142,7 @@ public class MapDataMenuController extends MenuController { } }; rightDownloadButtonController.caption = getMapActivity().getString(R.string.download_select_map_types); - rightDownloadButtonController.leftIconId = R.drawable.ic_plugin_srtm; + rightDownloadButtonController.updateStateListDrawableIcon(R.drawable.ic_plugin_srtm, true); bottomTitleButtonController = new TitleButtonController() { @Override @@ -159,7 +159,7 @@ public class MapDataMenuController extends MenuController { } }; bottomTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_delete); - bottomTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark; + bottomTitleButtonController.updateStateListDrawableIcon(R.drawable.ic_action_delete_dark, true); titleProgressController = new TitleProgressController() { @Override @@ -367,7 +367,7 @@ public class MapDataMenuController extends MenuController { } leftDownloadButtonController.visible = true; - leftDownloadButtonController.leftIconId = R.drawable.ic_action_import; + leftDownloadButtonController.updateStateListDrawableIcon(R.drawable.ic_action_import, true); if (backuped) { leftDownloadButtonController.caption = getMapActivity().getString(R.string.local_index_mi_restore); } else if (indexItem != null) { @@ -375,7 +375,7 @@ public class MapDataMenuController extends MenuController { || indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) { leftDownloadButtonController.caption = getMapActivity().getString(R.string.get_plugin); - leftDownloadButtonController.leftIconId = 0; + leftDownloadButtonController.clearIcon(true); } else if (indexItem.isOutdated()) { leftDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_update); } else if (!downloaded) {