From 9b06da353e2ecf9fc5a1f62b6d86b34e7157f265 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 1 Nov 2017 12:05:51 +0200 Subject: [PATCH] Add icon to "Show on Top Bar" button --- OsmAnd/res/layout/map_context_menu_fragment.xml | 2 -- .../osmand/plus/mapcontextmenu/MenuController.java | 4 ++++ .../controllers/MapMarkerMenuController.java | 12 +++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index c55c77ca81..bf1a78ede6 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -222,9 +222,7 @@ android:id="@+id/title_divider" android:layout_width="match_parent" android:layout_height="1dp" - android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom" android:layout_marginLeft="10dp" - android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top" android:background="?attr/dashboard_divider" android:visibility="gone" tools:visibility="visible"/> diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 69a05d95ab..b5828dc67b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -502,8 +502,12 @@ public abstract class MenuController extends BaseMenuController { public String rightTextCaption = ""; public boolean visible = true; public boolean needColorizeIcon = true; + public Drawable leftIcon; public Drawable getLeftIcon() { + if (leftIcon != null) { + return leftIcon; + } if (leftIconId != 0) { if (needColorizeIcon) { return getIcon(leftIconId, isLight() ? R.color.map_widget_blue : R.color.osmand_orange); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java index fcda2dcae1..3eeaca8c90 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java @@ -1,8 +1,10 @@ package net.osmand.plus.mapcontextmenu.controllers; import android.graphics.drawable.Drawable; +import android.graphics.drawable.LayerDrawable; 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.R; @@ -40,8 +42,16 @@ public class MapMarkerMenuController extends MenuController { getMapActivity().getContextMenu().close(); } }; - leftSubtitleButtonController.needColorizeIcon = false; leftSubtitleButtonController.caption = getMapActivity().getString(R.string.show_on_top_bar); + leftSubtitleButtonController.leftIcon = createShowOnTopbarIcon(); + } + + 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); + return new LayerDrawable(new Drawable[]{background, topbar}); } @Override