From 5330409b5eea8bc9462f916aaaedc23358643ddb Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 19 Apr 2016 23:36:06 +0300 Subject: [PATCH] Switching widgets mode on Configure screen in progress --- OsmAnd/res/menu/vidget_visibility_menu.xml | 15 -- OsmAnd/res/menu/widget_visibility_menu.xml | 27 +++ OsmAnd/res/values/ids.xml | 8 + OsmAnd/res/values/strings.xml | 1 + .../src/net/osmand/plus/ContextMenuItem.java | 6 +- OsmAnd/src/net/osmand/plus/IconsCache.java | 8 - .../osmand/plus/dashboard/DashboardOnMap.java | 7 +- .../net/osmand/plus/views/MapInfoLayer.java | 12 +- .../views/mapwidgets/MapWidgetRegistry.java | 192 ++++++++++++++++-- .../mapwidgets/RouteInfoWidgetsFactory.java | 112 +++++++++- 10 files changed, 330 insertions(+), 58 deletions(-) delete mode 100644 OsmAnd/res/menu/vidget_visibility_menu.xml create mode 100644 OsmAnd/res/menu/widget_visibility_menu.xml diff --git a/OsmAnd/res/menu/vidget_visibility_menu.xml b/OsmAnd/res/menu/vidget_visibility_menu.xml deleted file mode 100644 index 9974a9d044..0000000000 --- a/OsmAnd/res/menu/vidget_visibility_menu.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/menu/widget_visibility_menu.xml b/OsmAnd/res/menu/widget_visibility_menu.xml new file mode 100644 index 0000000000..ee110585a9 --- /dev/null +++ b/OsmAnd/res/menu/widget_visibility_menu.xml @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/ids.xml b/OsmAnd/res/values/ids.xml index e27aa4f93a..ca2120f6bb 100644 --- a/OsmAnd/res/values/ids.xml +++ b/OsmAnd/res/values/ids.xml @@ -1,4 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index cc71f116b6..1bbebedb1e 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -10,6 +10,7 @@ PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Magnetic bearing Relative bearing Don\'t change route when you are off the way Prevent automatic route recalculation when you are quite far from the right way diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java index 16fdafe17e..ff3eb0c45a 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java @@ -16,7 +16,7 @@ public class ContextMenuItem { private final int titleId; private String title; @DrawableRes - private final int mIcon; + private int mIcon; @ColorRes private int colorRes; @DrawableRes @@ -150,6 +150,10 @@ public class ContextMenuItem { this.title = title; } + public void setIcon(int iconId) { + this.mIcon = iconId; + } + public void setColorRes(int colorRes) { this.colorRes = colorRes; } diff --git a/OsmAnd/src/net/osmand/plus/IconsCache.java b/OsmAnd/src/net/osmand/plus/IconsCache.java index 97d0b1a0cd..b483d14b17 100644 --- a/OsmAnd/src/net/osmand/plus/IconsCache.java +++ b/OsmAnd/src/net/osmand/plus/IconsCache.java @@ -79,14 +79,6 @@ public class IconsCache { return getDrawable(id, light ? R.color.icon_color : 0); } - public void paintMenuItem(MenuItem menuItem) { - Drawable drawable = menuItem.getIcon(); - drawable = DrawableCompat.wrap(drawable); - drawable.mutate(); - int color = ContextCompat.getColor(app, getDefaultColorRes(app)); - DrawableCompat.setTint(drawable, color); - } - @ColorRes public static int getDefaultColorRes(Context context) { final OsmandApplication app = (OsmandApplication) context.getApplicationContext(); diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 784eada357..9df9ed3f24 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -965,8 +965,11 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis } public void refreshContent(boolean force) { - if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.MAP_MARKERS - || visibleType == DashboardType.MAP_MARKERS_SELECTION || force) { + if (visibleType == DashboardType.WAYPOINTS + || visibleType == DashboardType.MAP_MARKERS + || visibleType == DashboardType.MAP_MARKERS_SELECTION + || visibleType == DashboardType.CONFIGURE_SCREEN + || force) { updateListAdapter(); } else if (visibleType == DashboardType.CONFIGURE_MAP || visibleType == DashboardType.ROUTE_PREFERENCES) { int index = listView.getFirstVisiblePosition(); diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index 05f81bca06..e22d02b086 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -21,11 +21,14 @@ import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView; import net.osmand.plus.views.mapwidgets.MapMarkersWidgetsFactory; import net.osmand.plus.views.mapwidgets.MapWidgetRegistry; import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo; +import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WidgetState; import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget; import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory; import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.AlarmWidget; +import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.BearingWidgetState; import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.LanesControl; import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.RulerWidget; +import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.TimeControlWidgetState; import net.osmand.plus.views.mapwidgets.TextInfoWidget; import java.lang.reflect.Field; @@ -82,6 +85,11 @@ public class MapInfoLayer extends OsmandMapLayer { updateReg(calculateTextState(), reg); } + public void registerSideWidget(TextInfoWidget widget, WidgetState widgetState, String key, boolean left, int priorityOrder) { + MapWidgetRegInfo reg = mapInfoControls.registerSideWidgetInternal(widget, widgetState, key, left, priorityOrder); + updateReg(calculateTextState(), reg); + } + public T getSideWidget(Class cl) { return mapInfoControls.getSideWidget(cl); } @@ -120,9 +128,9 @@ public class MapInfoLayer extends OsmandMapLayer { TextInfoWidget dist = ric.createDistanceControl(map); registerSideWidget(dist, R.drawable.ic_action_target, R.string.map_widget_distance, "distance", false, 5); TextInfoWidget time = ric.createTimeControl(map); - registerSideWidget(time, R.drawable.ic_action_time, R.string.map_widget_time, "time", false, 10); + registerSideWidget(time, new TimeControlWidgetState(app), "time", false, 10); TextInfoWidget bearing = ric.createBearingControl(map); - registerSideWidget(bearing, R.drawable.ic_action_bearing, R.string.map_widget_bearing, "bearing", false, 11); + registerSideWidget(bearing, new BearingWidgetState(app), "bearing", false, 11); if (settings.USE_MAP_MARKERS.get()) { TextInfoWidget marker = mwf.createMapMarkerControl(map, true); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java index c24d99d7fa..d4c085e71d 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java @@ -6,6 +6,7 @@ import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; import android.support.annotation.StringRes; import android.support.v7.app.AlertDialog; +import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; @@ -16,6 +17,7 @@ import net.osmand.plus.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuItem; import net.osmand.plus.IconsCache; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings.MapMarkersMode; import net.osmand.plus.OsmandSettings.OsmandPreference; @@ -140,12 +142,42 @@ public class MapWidgetRegistry { return null; } + public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget, + WidgetState widgetState, + String key, boolean left, int priorityOrder) { + MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, widgetState, priorityOrder, left); + processVisibleModes(key, ii); + if (widget != null) { + widget.setContentTitle(widgetState.getMenuTitleId()); + } + if (left) { + this.leftWidgetSet.add(ii); + } else { + this.rightWidgetSet.add(ii); + } + return ii; + } + + public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget, @DrawableRes int drawableMenu, @StringRes int messageId, String key, boolean left, int priorityOrder) { MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu, messageId, priorityOrder, left); + processVisibleModes(key, ii); + if (widget != null) { + widget.setContentTitle(messageId); + } + if (left) { + this.leftWidgetSet.add(ii); + } else { + this.rightWidgetSet.add(ii); + } + return ii; + } + + private void processVisibleModes(String key, MapWidgetRegInfo ii) { for (ApplicationMode ms : ApplicationMode.values(settings)) { boolean collapse = ms.isWidgetCollapsible(key); boolean def = ms.isWidgetVisible(key); @@ -168,15 +200,6 @@ public class MapWidgetRegistry { ii.visibleCollapsible.add(ms); } } - if (widget != null) { - widget.setContentTitle(messageId); - } - if (left) { - this.leftWidgetSet.add(ii); - } else { - this.rightWidgetSet.add(ii); - } - return ii; } private void restoreModes(Set set, Set mi, ApplicationMode mode) { @@ -343,7 +366,7 @@ public class MapWidgetRegistry { } public String getText(Context ctx, final ApplicationMode mode, final MapWidgetRegInfo r) { - return (r.visibleCollapsed(mode) ? " + " : " ") + ctx.getString(r.messageId); + return (r.visibleCollapsed(mode) ? " + " : " ") + ctx.getString(r.getMessageId()); } public Set getRightWidgetSet() { @@ -370,8 +393,8 @@ public class MapWidgetRegistry { final boolean selected = r.visibleCollapsed(mode) || r.visible(mode); final String desc = mapActivity.getString(R.string.shared_string_collapse); - contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(r.messageId, mapActivity) - .setIcon(r.drawableMenu) + contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(r.getMessageId(), mapActivity) + .setIcon(r.getDrawableMenu()) .setSelected(selected) .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setSecondaryIcon(R.drawable.ic_action_additional_option) @@ -385,11 +408,32 @@ public class MapWidgetRegistry { View textWrapper = view.findViewById(R.id.text_wrapper); IconPopupMenu popup = new IconPopupMenu(view.getContext(), textWrapper); MenuInflater inflater = popup.getMenuInflater(); - inflater.inflate(R.menu.vidget_visibility_menu, popup.getMenu()); + final Menu menu = popup.getMenu(); + inflater.inflate(R.menu.widget_visibility_menu, menu); IconsCache ic = mapActivity.getMyApplication().getIconsCache(); - ic.paintMenuItem(popup.getMenu().findItem(R.id.action_show)); - ic.paintMenuItem(popup.getMenu().findItem(R.id.action_hide)); - ic.paintMenuItem(popup.getMenu().findItem(R.id.action_collapse)); + menu.findItem(R.id.action_show).setIcon(ic.getThemedIcon(R.drawable.ic_action_view)); + menu.findItem(R.id.action_hide).setIcon(ic.getThemedIcon(R.drawable.ic_action_hide)); + menu.findItem(R.id.action_collapse).setIcon(ic.getThemedIcon(R.drawable.ic_action_widget_collapse)); + + final int[] menuIconIds = r.getDrawableMenuIds(); + final int[] menuTitleIds = r.getMessageIds(); + final int[] menuItemIds = r.getItemIds(); + int checkedId = r.getItemId(); + if (menuIconIds != null && menuTitleIds != null && menuItemIds != null + && menuIconIds.length == menuTitleIds.length && menuIconIds.length == menuItemIds.length) { + for (int i = 0; i < menuIconIds.length; i++) { + int iconId = menuIconIds[i]; + int titleId = menuTitleIds[i]; + int id = menuItemIds[i]; + MenuItem menuItem = menu.add(R.id.single_selection_group, id, i, titleId) + .setChecked(id == checkedId); + menuItem.setIcon(menuItem.isChecked() + ? ic.getIcon(iconId, R.color.osmand_orange) : ic.getThemedIcon(iconId)); + } + menu.setGroupCheckable(R.id.single_selection_group, true, true); + menu.setGroupVisible(R.id.single_selection_group, true); + } + popup.setOnMenuItemClickListener( new IconPopupMenu.OnMenuItemClickListener() { @Override @@ -405,6 +449,23 @@ public class MapWidgetRegistry { case R.id.action_collapse: setVisibility(adapter, pos, true, true); return true; + default: + if (menuItemIds != null) { + for (int menuItemId : menuItemIds) { + if (menuItem.getItemId() == menuItemId) { + r.changeState(menuItemId); + MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer(); + if (mil != null) { + mil.recreateControls(); + } + ContextMenuItem item = adapter.getItem(pos); + item.setIcon(r.getDrawableMenu()); + item.setTitle(mapActivity.getResources().getString(r.getMessageId())); + adapter.notifyDataSetChanged(); + return true; + } + } + } } return false; } @@ -443,9 +504,10 @@ public class MapWidgetRegistry { public static class MapWidgetRegInfo implements Comparable { public final TextInfoWidget widget; @DrawableRes - public final int drawableMenu; + private int drawableMenu; @StringRes - public final int messageId; + private int messageId; + private WidgetState widgetState; public final String key; public final boolean left; public final int priorityOrder; @@ -463,6 +525,69 @@ public class MapWidgetRegistry { this.left = left; } + public MapWidgetRegInfo(String key, TextInfoWidget widget, WidgetState widgetState, + int priorityOrder, boolean left) { + this.key = key; + this.widget = widget; + this.widgetState = widgetState; + this.priorityOrder = priorityOrder; + this.left = left; + } + + public int getDrawableMenu() { + if (widgetState != null) { + return widgetState.getMenuIconId(); + } else { + return drawableMenu; + } + } + + public int getMessageId() { + if (widgetState != null) { + return widgetState.getMenuTitleId(); + } else { + return messageId; + } + } + + public int getItemId() { + if (widgetState != null) { + return widgetState.getMenuItemId(); + } else { + return messageId; + } + } + + public int[] getDrawableMenuIds() { + if (widgetState != null) { + return widgetState.getMenuIconIds(); + } else { + return null; + } + } + + public int[] getMessageIds() { + if (widgetState != null) { + return widgetState.getMenuTitleIds(); + } else { + return null; + } + } + + public int[] getItemIds() { + if (widgetState != null) { + return widgetState.getMenuItemIds(); + } else { + return null; + } + } + + public void changeState(int stateId) { + if (widgetState != null) { + widgetState.changeState(stateId); + } + } + public boolean visibleCollapsed(ApplicationMode mode) { return visibleCollapsible.contains(mode); } @@ -483,7 +608,7 @@ public class MapWidgetRegistry { @Override public int hashCode() { - return messageId; + return getMessageId(); } @Override @@ -496,16 +621,16 @@ public class MapWidgetRegistry { return false; } MapWidgetRegInfo other = (MapWidgetRegInfo) obj; - return messageId == other.messageId; + return getMessageId() == other.getMessageId(); } @Override public int compareTo(@NonNull MapWidgetRegInfo another) { - if (messageId == another.messageId) { + if (getMessageId() == another.getMessageId()) { return 0; } if (priorityOrder == another.priorityOrder) { - return messageId - another.messageId; + return getMessageId() - another.getMessageId(); } return priorityOrder - another.priorityOrder; } @@ -546,4 +671,27 @@ public class MapWidgetRegistry { return false; } } + + public static abstract class WidgetState { + + private OsmandApplication ctx; + + public OsmandApplication getCtx() { + return ctx; + } + + public WidgetState(OsmandApplication ctx) { + this.ctx = ctx; + } + + public abstract int getMenuTitleId(); + public abstract int getMenuIconId(); + public abstract int getMenuItemId(); + + public abstract int[] getMenuTitleIds(); + public abstract int[] getMenuIconIds(); + public abstract int[] getMenuItemIds(); + + public abstract void changeState(int stateId); + } } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index c0e098574f..166203433f 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java @@ -27,7 +27,6 @@ import net.osmand.Location; import net.osmand.binary.RouteDataObject; import net.osmand.data.LatLon; import net.osmand.data.RotatedTileBox; -import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndLocationProvider; @@ -51,6 +50,7 @@ import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.TurnPathHelper; +import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WidgetState; import net.osmand.router.RouteResultPreparation; import net.osmand.router.TurnType; import net.osmand.util.Algorithms; @@ -196,11 +196,56 @@ public class RouteInfoWidgetsFactory { // initial state return nextTurnInfo; } - - + public static class TimeControlWidgetState extends WidgetState { + + public static final int TIME_CONTROL_WIDGET_STATE_ARRIVAL_TIME = R.id.time_control_widget_state_arrival_time; + public static final int TIME_CONTROL_WIDGET_STATE_TIME_TO_GO = R.id.time_control_widget_state_time_to_go; + + private final OsmandPreference showArrival; + + public TimeControlWidgetState(OsmandApplication ctx) { + super(ctx); + showArrival = ctx.getSettings().SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME; + } + + @Override + public int getMenuTitleId() { + return showArrival.get() ? R.string.access_arrival_time : R.string.map_widget_time; + } + + @Override + public int getMenuIconId() { + return showArrival.get() ? R.drawable.ic_action_time : R.drawable.ic_action_time_to_distance; + } + + @Override + public int getMenuItemId() { + return showArrival.get() ? TIME_CONTROL_WIDGET_STATE_ARRIVAL_TIME : TIME_CONTROL_WIDGET_STATE_TIME_TO_GO; + } + + @Override + public int[] getMenuTitleIds() { + return new int[]{R.string.access_arrival_time, R.string.map_widget_time}; + } + + @Override + public int[] getMenuIconIds() { + return new int[]{R.drawable.ic_action_time, R.drawable.ic_action_time_to_distance}; + } + + @Override + public int[] getMenuItemIds() { + return new int[]{TIME_CONTROL_WIDGET_STATE_ARRIVAL_TIME, TIME_CONTROL_WIDGET_STATE_TIME_TO_GO}; + } + + @Override + public void changeState(int stateId) { + showArrival.set(stateId == TIME_CONTROL_WIDGET_STATE_ARRIVAL_TIME); + } + } public TextInfoWidget createTimeControl(final MapActivity map){ final RoutingHelper routingHelper = map.getRoutingHelper(); @@ -508,6 +553,55 @@ public class RouteInfoWidgetsFactory { return distanceControl; } + + public static class BearingWidgetState extends WidgetState { + + public static final int BEARING_WIDGET_STATE_RELATIVE_BEARING = R.id.bearing_widget_state_relative_bearing; + public static final int BEARING_WIDGET_STATE_MAGNETIC_BEARING = R.id.bearing_widget_state_magnetic_bearing; + + private final OsmandPreference showRelativeBearing; + + public BearingWidgetState(OsmandApplication ctx) { + super(ctx); + showRelativeBearing = ctx.getSettings().SHOW_RELATIVE_BEARING_OTHERWISE_REGULAR_BEARING; + } + + @Override + public int getMenuTitleId() { + return showRelativeBearing.get() ? R.string.map_widget_bearing : R.string.map_widget_magnetic_bearing; + } + + @Override + public int getMenuIconId() { + return showRelativeBearing.get() ? R.drawable.ic_action_relative_bearing : R.drawable.ic_action_bearing; + } + + @Override + public int getMenuItemId() { + return showRelativeBearing.get() ? BEARING_WIDGET_STATE_RELATIVE_BEARING : BEARING_WIDGET_STATE_MAGNETIC_BEARING; + } + + @Override + public int[] getMenuTitleIds() { + return new int[]{R.string.map_widget_magnetic_bearing, R.string.map_widget_bearing}; + } + + @Override + public int[] getMenuIconIds() { + return new int[]{R.drawable.ic_action_bearing, R.drawable.ic_action_relative_bearing}; + } + + @Override + public int[] getMenuItemIds() { + return new int[]{BEARING_WIDGET_STATE_MAGNETIC_BEARING, BEARING_WIDGET_STATE_RELATIVE_BEARING}; + } + + @Override + public void changeState(int stateId) { + showRelativeBearing.set(stateId == BEARING_WIDGET_STATE_RELATIVE_BEARING); + } + } + public TextInfoWidget createBearingControl(final MapActivity map) { final int bearingResId = R.drawable.widget_bearing_day; final int bearingNightResId = R.drawable.widget_bearing_night; @@ -526,7 +620,9 @@ public class RouteInfoWidgetsFactory { @Override public boolean updateInfo(DrawSettings drawSettings) { - int b = getBearing(showRelativeBearing.get()); + boolean relative = showRelativeBearing.get(); + setContentTitle(relative ? R.string.map_widget_bearing : R.string.map_widget_magnetic_bearing); + int b = getBearing(relative); if (distChanged(cachedDegrees, b)) { cachedDegrees = b; if (b != -1000) { @@ -590,15 +686,15 @@ public class RouteInfoWidgetsFactory { @Override public void onClick(View v) { showRelativeBearing.set(!showRelativeBearing.get()); - bearingControl.setIcons(showRelativeBearing.get() ? bearingResId : relativeBearingResId, - showRelativeBearing.get() ? bearingNightResId : relativeBearingNightResId); + bearingControl.setIcons(!showRelativeBearing.get() ? bearingResId : relativeBearingResId, + !showRelativeBearing.get() ? bearingNightResId : relativeBearingNightResId); map.getMapView().refreshMap(); } }); bearingControl.setText(null, null); - bearingControl.setIcons(showRelativeBearing.get() ? bearingResId : relativeBearingResId, - showRelativeBearing.get() ? bearingNightResId : relativeBearingNightResId); + bearingControl.setIcons(!showRelativeBearing.get() ? bearingResId : relativeBearingResId, + !showRelativeBearing.get() ? bearingNightResId : relativeBearingNightResId); return bearingControl; }