diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index ab03574f92..1cdddd794c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -565,6 +565,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { boolean needMapAdjust = oldMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN; if (newMenuState != oldMenuState) { + restoreCustomMapRatio(); menu.updateControlsVisibility(true); doBeforeMenuStateChange(oldMenuState, newMenuState); } @@ -572,20 +573,39 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { applyPosY(currentY, needCloseMenu, needMapAdjust, oldMenuState, newMenuState, 0); } - public void doZoomIn() { - if (!centered) { - centered = true; - calculateCenterLatLon(menu.getLatLon(), getZoom() + 1, true); + private void restoreCustomMapRatio() { + if (map.hasCustomMapRatio()) { + map.restoreMapRatio(); + } + } + + private void setCustomMapRatio() { + LatLon latLon = menu.getLatLon(); + RotatedTileBox tb = map.getCurrentRotatedTileBox().copy(); + float px = tb.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude()); + float py = tb.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude()); + float ratioX = px / tb.getPixWidth(); + float ratioY = py / tb.getPixHeight(); + map.setCustomMapRatio(ratioX, ratioY); + map.setLatLon(latLon.getLatitude(), latLon.getLongitude()); + } + + public void doZoomIn() { + if (map.isZooming() && map.hasCustomMapRatio()) { + getMapActivity().changeZoom(2, System.currentTimeMillis()); + } else { + if (!map.hasCustomMapRatio()) { + setCustomMapRatio(); + } + getMapActivity().changeZoom(1, System.currentTimeMillis()); } - applyPosY(getViewY(), false, true, 0, 0, 1); } public void doZoomOut() { - if (!centered) { - centered = true; - calculateCenterLatLon(menu.getLatLon(), getZoom() - 1, true); + if (!map.hasCustomMapRatio()) { + setCustomMapRatio(); } - applyPosY(getViewY(), false, true, 0, 0, -1); + getMapActivity().changeZoom(-1, System.currentTimeMillis()); } private void applyPosY(final int currentY, final boolean needCloseMenu, boolean needMapAdjust, @@ -859,6 +879,8 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { @Override public void onPause() { + restoreCustomMapRatio(); + ViewParent parent = view.getParent(); if (parent != null && containerLayoutListener != null) { ((View) parent).removeOnLayoutChangeListener(containerLayoutListener); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java index 91a8c769d7..606798e3e5 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java @@ -79,7 +79,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment ((ImageView) mainView.findViewById(R.id.coordinate_input_icon)) .setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_longitude)); ((ImageView) mainView.findViewById(R.id.build_route_icon)) - .setImageDrawable(getContentIcon(R.drawable.map_directions)); + .setImageDrawable(getContentIcon(R.drawable.ic_action_gdirections_dark)); ((ImageView) mainView.findViewById(R.id.save_as_new_track_icon)) .setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark)); ((ImageView) mainView.findViewById(R.id.move_all_to_history_icon)) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java index 42e3ed58f0..4ef91ecfd6 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java @@ -55,7 +55,7 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog ((TextView) mainView.findViewById(R.id.title)).setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark)); } - ((ImageView) mainView.findViewById(R.id.navigate_icon)).setImageDrawable(getContentIcon(R.drawable.map_directions)); + ((ImageView) mainView.findViewById(R.id.navigate_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_gdirections_dark)); ((ImageView) mainView.findViewById(R.id.make_round_trip_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_trip_round)); ((ImageView) mainView.findViewById(R.id.door_to_door_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_door_to_door)); ((ImageView) mainView.findViewById(R.id.reverse_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_reverse_order)); diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java index 79aa23f434..230ff660c7 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -124,9 +124,12 @@ public class OsmandMapTileView implements IMapDownloaderCallback { private float rotate; // accumulate private int mapPosition; - private int mapPositionX; + private float mapRatioX; + private float mapRatioY; + private LatLon originalRatioCenterLatLon; + private boolean showMapPosition = true; private IMapLocationListener locationListener; @@ -488,6 +491,25 @@ public class OsmandMapTileView implements IMapDownloaderCallback { this.mapPositionX = type; } + public void setCustomMapRatio(float ratioX, float ratioY) { + this.mapRatioX = ratioX; + this.mapRatioY = ratioY; + originalRatioCenterLatLon = currentViewport.getCenterLatLon(); + } + + public void restoreMapRatio() { + mapRatioX = 0; + mapRatioY = 0; + if (originalRatioCenterLatLon != null) { + setLatLon(originalRatioCenterLatLon.getLatitude(), originalRatioCenterLatLon.getLongitude()); + originalRatioCenterLatLon = null; + } + } + + public boolean hasCustomMapRatio() { + return mapRatioX != 0 && mapRatioY != 0; + } + public OsmandSettings getSettings() { return settings; } @@ -576,7 +598,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback { return; } final float ratioy; - if (mapPosition == OsmandSettings.BOTTOM_CONSTANT) { + if (mapRatioY != 0) { + ratioy = mapRatioY; + } else if (mapPosition == OsmandSettings.BOTTOM_CONSTANT) { ratioy = 0.85f; } else if (mapPosition == OsmandSettings.MIDDLE_BOTTOM_CONSTANT) { ratioy = 0.70f; @@ -586,7 +610,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback { ratioy = 0.5f; } final float ratiox; - if (mapPosition == OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT) { + if (mapRatioX != 0) { + ratiox = mapRatioX; + } else if (mapPosition == OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT) { ratiox = 0.7f; } else { ratiox = mapPositionX == 0 ? 0.5f : 0.75f;