Add icon to "Show on Top Bar" button

This commit is contained in:
Alexander Sytnyk 2017-11-01 12:05:51 +02:00
parent 3903ed14c0
commit 9b06da353e
3 changed files with 15 additions and 3 deletions

View file

@ -222,9 +222,7 @@
android:id="@+id/title_divider" android:id="@+id/title_divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top"
android:background="?attr/dashboard_divider" android:background="?attr/dashboard_divider"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"/> tools:visibility="visible"/>

View file

@ -502,8 +502,12 @@ public abstract class MenuController extends BaseMenuController {
public String rightTextCaption = ""; public String rightTextCaption = "";
public boolean visible = true; public boolean visible = true;
public boolean needColorizeIcon = true; public boolean needColorizeIcon = true;
public Drawable leftIcon;
public Drawable getLeftIcon() { public Drawable getLeftIcon() {
if (leftIcon != null) {
return leftIcon;
}
if (leftIconId != 0) { if (leftIconId != 0) {
if (needColorizeIcon) { if (needColorizeIcon) {
return getIcon(leftIconId, isLight() ? R.color.map_widget_blue : R.color.osmand_orange); return getIcon(leftIconId, isLight() ? R.color.map_widget_blue : R.color.osmand_orange);

View file

@ -1,8 +1,10 @@
package net.osmand.plus.mapcontextmenu.controllers; package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -40,8 +42,16 @@ public class MapMarkerMenuController extends MenuController {
getMapActivity().getContextMenu().close(); getMapActivity().getContextMenu().close();
} }
}; };
leftSubtitleButtonController.needColorizeIcon = false;
leftSubtitleButtonController.caption = getMapActivity().getString(R.string.show_on_top_bar); 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 @Override