diff --git a/OsmAnd/res/layout/map_marker_item_new.xml b/OsmAnd/res/layout/map_marker_item_new.xml
index 3bdea75231..3f1f1d6c38 100644
--- a/OsmAnd/res/layout/map_marker_item_new.xml
+++ b/OsmAnd/res/layout/map_marker_item_new.xml
@@ -149,17 +149,23 @@
tools:background="@drawable/marker_circle_background_dark_with_inset"
tools:src="@drawable/ic_action_marker_passed"/>
-
+ android:layout_height="wrap_content">
+
+
+
+
+ Route is calculated: Show map
+ You must add at least one marker to use this function.
Exception occurred: note was not modified
Modify note
Modify OSM note
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
index 65be7d5e27..92382b26a8 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
@@ -16,6 +16,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
+import android.widget.Toast;
import net.osmand.plus.LockableViewPager;
import net.osmand.plus.MapMarkersHelper;
@@ -193,54 +194,70 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
@Override
public void sortByOnClick() {
- OrderByBottomSheetDialogFragment fragment = new OrderByBottomSheetDialogFragment();
- fragment.setListener(createOrderByFragmentListener());
- fragment.show(mapActivity.getSupportFragmentManager(), OrderByBottomSheetDialogFragment.TAG);
+ if (mapActivity != null) {
+ OrderByBottomSheetDialogFragment fragment = new OrderByBottomSheetDialogFragment();
+ fragment.setListener(createOrderByFragmentListener());
+ fragment.show(mapActivity.getSupportFragmentManager(), OrderByBottomSheetDialogFragment.TAG);
+ }
}
@Override
public void showDirectionOnClick() {
- ShowDirectionBottomSheetDialogFragment fragment = new ShowDirectionBottomSheetDialogFragment();
- fragment.setListener(createShowDirectionFragmentListener());
- fragment.show(mapActivity.getSupportFragmentManager(), ShowDirectionBottomSheetDialogFragment.TAG);
+ if (mapActivity != null) {
+ ShowDirectionBottomSheetDialogFragment fragment = new ShowDirectionBottomSheetDialogFragment();
+ fragment.setListener(createShowDirectionFragmentListener());
+ fragment.show(mapActivity.getSupportFragmentManager(), ShowDirectionBottomSheetDialogFragment.TAG);
+ }
}
@Override
public void coordinateInputOnClick() {
- CoordinateInputDialogFragment.showInstance(mapActivity);
+ if (mapActivity != null) {
+ CoordinateInputDialogFragment.showInstance(mapActivity);
+ }
}
@Override
public void buildRouteOnClick() {
- PlanRouteFragment.showInstance(mapActivity);
- dismiss();
+ if (mapActivity != null) {
+ if (mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers().isEmpty()) {
+ Toast.makeText(mapActivity, getString(R.string.plan_route_no_markers_toast), Toast.LENGTH_SHORT).show();
+ } else {
+ PlanRouteFragment.showInstance(mapActivity);
+ dismiss();
+ }
+ }
}
@Override
public void saveAsNewTrackOnClick() {
- SaveAsTrackBottomSheetDialogFragment fragment = new SaveAsTrackBottomSheetDialogFragment();
- fragment.setListener(createSaveAsTrackFragmentListener());
- fragment.show(mapActivity.getSupportFragmentManager(), SaveAsTrackBottomSheetDialogFragment.TAG);
+ if (mapActivity != null) {
+ SaveAsTrackBottomSheetDialogFragment fragment = new SaveAsTrackBottomSheetDialogFragment();
+ fragment.setListener(createSaveAsTrackFragmentListener());
+ fragment.show(mapActivity.getSupportFragmentManager(), SaveAsTrackBottomSheetDialogFragment.TAG);
+ }
}
@Override
public void moveAllToHistoryOnClick() {
- final MapMarkersHelper helper = mapActivity.getMyApplication().getMapMarkersHelper();
- final List markers = new ArrayList<>(helper.getMapMarkers());
- helper.moveAllActiveMarkersToHistory();
- activeFragment.updateAdapter();
- snackbar = Snackbar.make(viewPager, R.string.all_markers_moved_to_history, Snackbar.LENGTH_LONG)
- .setAction(R.string.shared_string_undo, new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- helper.restoreMarkersFromHistory(markers);
- activeFragment.updateAdapter();
- }
- });
- View snackBarView = snackbar.getView();
- TextView tv = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_action);
- tv.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_dialog_buttons_dark));
- snackbar.show();
+ if (mapActivity != null) {
+ final MapMarkersHelper helper = mapActivity.getMyApplication().getMapMarkersHelper();
+ final List markers = new ArrayList<>(helper.getMapMarkers());
+ helper.moveAllActiveMarkersToHistory();
+ activeFragment.updateAdapter();
+ snackbar = Snackbar.make(viewPager, R.string.all_markers_moved_to_history, Snackbar.LENGTH_LONG)
+ .setAction(R.string.shared_string_undo, new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ helper.restoreMarkersFromHistory(markers);
+ activeFragment.updateAdapter();
+ }
+ });
+ View snackBarView = snackbar.getView();
+ TextView tv = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_action);
+ tv.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_dialog_buttons_dark));
+ snackbar.show();
+ }
}
};
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkersPlanRouteContext.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkersPlanRouteContext.java
index 65f53ea2ab..3c27d84d67 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkersPlanRouteContext.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkersPlanRouteContext.java
@@ -41,6 +41,7 @@ public class MarkersPlanRouteContext {
private boolean progressBarVisible;
private boolean fragmentVisible;
private boolean markersListOpened;
+ private boolean adjustMapOnStart = true;
Map, List> getSnappedToRoadPoints() {
return snappedToRoadPoints;
@@ -90,12 +91,20 @@ public class MarkersPlanRouteContext {
this.markersListOpened = markersListOpened;
}
+ public boolean isAdjustMapOnStart() {
+ return adjustMapOnStart;
+ }
+
+ public void setAdjustMapOnStart(boolean adjustMapOnStart) {
+ this.adjustMapOnStart = adjustMapOnStart;
+ }
+
public MarkersPlanRouteContext(OsmandApplication app) {
this.app = app;
}
void cancelSnapToRoad() {
- listener.hideProgressBar();
+ listener.hideProgressBar(true);
snapToRoadPairsToCalculate.clear();
if (calculationProgress != null) {
calculationProgress.isCancelled = true;
@@ -245,7 +254,7 @@ public class MarkersPlanRouteContext {
app.runInUIThread(new Runnable() {
@Override
public void run() {
- listener.hideProgressBar();
+ listener.hideProgressBar(false);
}
});
}
@@ -261,7 +270,7 @@ public class MarkersPlanRouteContext {
void updateProgress(int progress);
- void hideProgressBar();
+ void hideProgressBar(boolean canceled);
void refresh();
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java
index b9825a7785..262f7487be 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java
@@ -24,6 +24,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
+import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.Location;
@@ -62,6 +63,7 @@ import java.util.ArrayList;
import java.util.List;
import static net.osmand.plus.OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT;
+import static net.osmand.plus.OsmandSettings.MIDDLE_TOP_CONSTANT;
public class PlanRouteFragment extends Fragment implements OsmAndLocationListener {
@@ -108,9 +110,13 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
}
@Override
- public void hideProgressBar() {
+ public void hideProgressBar(boolean canceled) {
mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE);
planRouteContext.setProgressBarVisible(false);
+ if (!canceled && portrait && planRouteContext.isMarkersListOpened()) {
+ Toast.makeText(mapActivity, getString(R.string.route_calculated_toast), Toast.LENGTH_SHORT).show();
+ showHideMarkersList();
+ }
}
@Override
@@ -268,7 +274,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
private int toPosition;
@Override
- public void onItemClick(View view) {
+ public void onCheckBoxClick(View view) {
int pos = markersRv.getChildAdapterPosition(view);
if (pos == RecyclerView.NO_POSITION) {
return;
@@ -288,6 +294,22 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
planRouteContext.recreateSnapTrkSegment(false);
}
+ @Override
+ public void onItemClick(View v) {
+ int pos = markersRv.getChildAdapterPosition(v);
+ if (pos == RecyclerView.NO_POSITION) {
+ return;
+ }
+ Object item = adapter.getItem(pos);
+ if (item instanceof Location) {
+ Location loc = (Location) item;
+ moveMapToPosition(loc.getLatitude(), loc.getLongitude());
+ } else if (item instanceof MapMarker) {
+ MapMarker marker = (MapMarker) item;
+ moveMapToPosition(marker.getLatitude(), marker.getLongitude());
+ }
+ }
+
@Override
public void onDragStarted(RecyclerView.ViewHolder holder) {
fromPosition = holder.getAdapterPosition();
@@ -398,6 +420,18 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
return iconsCache.getIcon(id, nightMode ? R.color.osmand_orange : R.color.color_myloc_distance);
}
+ private void moveMapToPosition(double lat, double lon) {
+ MapActivity mapActivity = getMapActivity();
+ if (mapActivity != null) {
+ OsmandMapTileView view = mapActivity.getMapView();
+ view.getAnimatedDraggingThread().startMoving(lat, lon, view.getZoom(), true);
+ if (planRouteContext.isMarkersListOpened()) {
+ planRouteContext.setAdjustMapOnStart(false);
+ showHideMarkersList();
+ }
+ }
+ }
+
private SnapToRoadFragmentListener createSnapToRoadFragmentListener() {
return new SnapToRoadFragmentListener() {
@Override
@@ -581,12 +615,11 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
OsmandMapTileView tileView = mapActivity.getMapView();
previousMapPosition = tileView.getMapPosition();
- if (!portrait) {
- tileView.setMapPosition(LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
- }
+ tileView.setMapPosition(portrait ? MIDDLE_TOP_CONSTANT : LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
selectedCount = mapActivity.getMyApplication().getMapMarkersHelper().getSelectedMarkersCount();
- planRouteContext.recreateSnapTrkSegment(true);
+ planRouteContext.recreateSnapTrkSegment(planRouteContext.isAdjustMapOnStart());
+ planRouteContext.setAdjustMapOnStart(true);
mapActivity.refreshMap();
updateSelectButton();
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkerItemViewHolder.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkerItemViewHolder.java
index 975b0ec541..2366d9f3c6 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkerItemViewHolder.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkerItemViewHolder.java
@@ -25,6 +25,7 @@ public class MapMarkerItemViewHolder extends RecyclerView.ViewHolder {
final View rightPointSpace;
final TextView description;
public final ImageButton optionsBtn;
+ final View checkBoxContainer;
final CheckBox checkBox;
final View divider;
final View bottomShadow;
@@ -45,6 +46,7 @@ public class MapMarkerItemViewHolder extends RecyclerView.ViewHolder {
rightPointSpace = view.findViewById(R.id.map_marker_right_point_space);
description = (TextView) view.findViewById(R.id.map_marker_description);
optionsBtn = (ImageButton) view.findViewById(R.id.map_marker_options_button);
+ checkBoxContainer = view.findViewById(R.id.check_box_container);
checkBox = (CheckBox) view.findViewById(R.id.map_marker_check_box);
divider = view.findViewById(R.id.divider);
bottomShadow = view.findViewById(R.id.bottom_shadow);
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java
index 92bfb3d868..ee3c224dc9 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java
@@ -106,7 +106,13 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter