Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ced78d70e3
4 changed files with 62 additions and 14 deletions
|
@ -565,6 +565,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
boolean needMapAdjust = oldMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN;
|
boolean needMapAdjust = oldMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN;
|
||||||
|
|
||||||
if (newMenuState != oldMenuState) {
|
if (newMenuState != oldMenuState) {
|
||||||
|
restoreCustomMapRatio();
|
||||||
menu.updateControlsVisibility(true);
|
menu.updateControlsVisibility(true);
|
||||||
doBeforeMenuStateChange(oldMenuState, newMenuState);
|
doBeforeMenuStateChange(oldMenuState, newMenuState);
|
||||||
}
|
}
|
||||||
|
@ -572,20 +573,39 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
applyPosY(currentY, needCloseMenu, needMapAdjust, oldMenuState, newMenuState, 0);
|
applyPosY(currentY, needCloseMenu, needMapAdjust, oldMenuState, newMenuState, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doZoomIn() {
|
private void restoreCustomMapRatio() {
|
||||||
if (!centered) {
|
if (map.hasCustomMapRatio()) {
|
||||||
centered = true;
|
map.restoreMapRatio();
|
||||||
calculateCenterLatLon(menu.getLatLon(), getZoom() + 1, true);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
public void doZoomOut() {
|
||||||
if (!centered) {
|
if (!map.hasCustomMapRatio()) {
|
||||||
centered = true;
|
setCustomMapRatio();
|
||||||
calculateCenterLatLon(menu.getLatLon(), getZoom() - 1, true);
|
|
||||||
}
|
}
|
||||||
applyPosY(getViewY(), false, true, 0, 0, -1);
|
getMapActivity().changeZoom(-1, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyPosY(final int currentY, final boolean needCloseMenu, boolean needMapAdjust,
|
private void applyPosY(final int currentY, final boolean needCloseMenu, boolean needMapAdjust,
|
||||||
|
@ -859,6 +879,8 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
|
restoreCustomMapRatio();
|
||||||
|
|
||||||
ViewParent parent = view.getParent();
|
ViewParent parent = view.getParent();
|
||||||
if (parent != null && containerLayoutListener != null) {
|
if (parent != null && containerLayoutListener != null) {
|
||||||
((View) parent).removeOnLayoutChangeListener(containerLayoutListener);
|
((View) parent).removeOnLayoutChangeListener(containerLayoutListener);
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
((ImageView) mainView.findViewById(R.id.coordinate_input_icon))
|
((ImageView) mainView.findViewById(R.id.coordinate_input_icon))
|
||||||
.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_longitude));
|
.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_longitude));
|
||||||
((ImageView) mainView.findViewById(R.id.build_route_icon))
|
((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))
|
((ImageView) mainView.findViewById(R.id.save_as_new_track_icon))
|
||||||
.setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
|
.setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
|
||||||
((ImageView) mainView.findViewById(R.id.move_all_to_history_icon))
|
((ImageView) mainView.findViewById(R.id.move_all_to_history_icon))
|
||||||
|
|
|
@ -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));
|
((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.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.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));
|
((ImageView) mainView.findViewById(R.id.reverse_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_reverse_order));
|
||||||
|
|
|
@ -124,9 +124,12 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
||||||
private float rotate; // accumulate
|
private float rotate; // accumulate
|
||||||
|
|
||||||
private int mapPosition;
|
private int mapPosition;
|
||||||
|
|
||||||
private int mapPositionX;
|
private int mapPositionX;
|
||||||
|
|
||||||
|
private float mapRatioX;
|
||||||
|
private float mapRatioY;
|
||||||
|
private LatLon originalRatioCenterLatLon;
|
||||||
|
|
||||||
private boolean showMapPosition = true;
|
private boolean showMapPosition = true;
|
||||||
|
|
||||||
private IMapLocationListener locationListener;
|
private IMapLocationListener locationListener;
|
||||||
|
@ -488,6 +491,25 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
||||||
this.mapPositionX = type;
|
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() {
|
public OsmandSettings getSettings() {
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
@ -576,7 +598,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final float ratioy;
|
final float ratioy;
|
||||||
if (mapPosition == OsmandSettings.BOTTOM_CONSTANT) {
|
if (mapRatioY != 0) {
|
||||||
|
ratioy = mapRatioY;
|
||||||
|
} else if (mapPosition == OsmandSettings.BOTTOM_CONSTANT) {
|
||||||
ratioy = 0.85f;
|
ratioy = 0.85f;
|
||||||
} else if (mapPosition == OsmandSettings.MIDDLE_BOTTOM_CONSTANT) {
|
} else if (mapPosition == OsmandSettings.MIDDLE_BOTTOM_CONSTANT) {
|
||||||
ratioy = 0.70f;
|
ratioy = 0.70f;
|
||||||
|
@ -586,7 +610,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
||||||
ratioy = 0.5f;
|
ratioy = 0.5f;
|
||||||
}
|
}
|
||||||
final float ratiox;
|
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;
|
ratiox = 0.7f;
|
||||||
} else {
|
} else {
|
||||||
ratiox = mapPositionX == 0 ? 0.5f : 0.75f;
|
ratiox = mapPositionX == 0 ? 0.5f : 0.75f;
|
||||||
|
|
Loading…
Reference in a new issue