Merge pull request #4352 from osmandapp/sasha_pasha_branch
Sasha pasha branch
This commit is contained in:
commit
829b6c5bec
3 changed files with 167 additions and 29 deletions
122
OsmAnd/res/layout/map_marker_item_new.xml
Normal file
122
OsmAnd/res/layout/map_marker_item_new.xml
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:descendantFocusability="blocksDescendants">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/bg_color">
|
||||||
|
|
||||||
|
<android.support.v7.widget.AppCompatImageView
|
||||||
|
android:id="@+id/marker_reorder_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:tint="?attr/secondary_icon_color"
|
||||||
|
tools:src="@drawable/ic_action_reorder"/>
|
||||||
|
|
||||||
|
<android.support.v7.widget.AppCompatImageView
|
||||||
|
android:id="@+id/marker_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:layout_toEndOf="@id/marker_reorder_icon"
|
||||||
|
android:layout_toRightOf="@id/marker_reorder_icon"
|
||||||
|
tools:src="@drawable/ic_action_flag_dark"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/marker_options_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:layout_marginLeft="14dp"
|
||||||
|
android:layout_marginRight="14dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
tools:src="@drawable/ic_overflow_menu_white"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_toEndOf="@+id/marker_icon"
|
||||||
|
android:layout_toLeftOf="@id/marker_options_button"
|
||||||
|
android:layout_toRightOf="@+id/marker_icon"
|
||||||
|
android:layout_toStartOf="@id/marker_options_button"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<android.support.v7.widget.AppCompatTextView
|
||||||
|
android:id="@+id/measure_point_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
tools:text="Van Gogh Museum"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/direction_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:src="@drawable/ic_direction_arrow"/>
|
||||||
|
|
||||||
|
<android.support.v7.widget.AppCompatTextView
|
||||||
|
android:id="@+id/marker_distance"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="4dp"
|
||||||
|
android:layout_marginRight="4dp"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="@color/marker_blue"
|
||||||
|
android:textSize="@dimen/default_sub_text_size"
|
||||||
|
tools:text="213 m"/>
|
||||||
|
|
||||||
|
<android.support.v7.widget.AppCompatTextView
|
||||||
|
android:id="@+id/point_icon_text_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="•"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_sub_text_size"/>
|
||||||
|
|
||||||
|
<android.support.v7.widget.AppCompatTextView
|
||||||
|
android:id="@+id/marker_description"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="4dp"
|
||||||
|
android:layout_marginRight="4dp"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_sub_text_size"
|
||||||
|
tools:text="Amsterdam Weekend"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/points_divider"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_toEndOf="@+id/marker_reorder_icon"
|
||||||
|
android:layout_toRightOf="@+id/marker_reorder_icon"
|
||||||
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
|
@ -112,7 +112,8 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
|
|
||||||
private enum SaveType {
|
private enum SaveType {
|
||||||
ROUTE_POINT,
|
ROUTE_POINT,
|
||||||
LINE
|
LINE,
|
||||||
|
SNAP_TO_ROAD
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEditingCtx(MeasurementEditingContext editingCtx) {
|
private void setEditingCtx(MeasurementEditingContext editingCtx) {
|
||||||
|
@ -459,12 +460,12 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
cancelModes();
|
||||||
exitMeasurementMode();
|
exitMeasurementMode();
|
||||||
adapter.setAdapterListener(null);
|
adapter.setAdapterListener(null);
|
||||||
if (pointsListOpened) {
|
if (pointsListOpened) {
|
||||||
hidePointsList();
|
hidePointsList();
|
||||||
}
|
}
|
||||||
closeModes();
|
|
||||||
MeasurementToolLayer layer = getMeasurementLayer();
|
MeasurementToolLayer layer = getMeasurementLayer();
|
||||||
if (layer != null) {
|
if (layer != null) {
|
||||||
layer.setOnSingleTapListener(null);
|
layer.setOnSingleTapListener(null);
|
||||||
|
@ -837,7 +838,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
int position = editingCtx.getSelectedPointPosition();
|
int position = editingCtx.getSelectedPointPosition();
|
||||||
editingCtx.getCommandManager().execute(new MovePointCommand(measurementLayer, oldPoint, newPoint, position));
|
editingCtx.getCommandManager().execute(new MovePointCommand(measurementLayer, oldPoint, newPoint, position));
|
||||||
editingCtx.addPoint(newPoint);
|
editingCtx.addPoint(newPoint);
|
||||||
measurementLayer.exitMovePointMode(false);
|
exitMovePointMode(false);
|
||||||
doAddOrMovePointCommonStuff();
|
doAddOrMovePointCommonStuff();
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
}
|
}
|
||||||
|
@ -845,22 +846,28 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
|
|
||||||
private void cancelMovePointMode() {
|
private void cancelMovePointMode() {
|
||||||
switchMovePointMode(false);
|
switchMovePointMode(false);
|
||||||
MeasurementToolLayer measurementToolLayer = getMeasurementLayer();
|
exitMovePointMode(true);
|
||||||
if (measurementToolLayer != null) {
|
MapActivity mapActivity = getMapActivity();
|
||||||
measurementToolLayer.exitMovePointMode(true);
|
if (mapActivity != null) {
|
||||||
measurementToolLayer.refreshMap();
|
mapActivity.refreshMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeModes() {
|
void exitMovePointMode(boolean saveOriginalPoint) {
|
||||||
if (editingCtx.getOriginalPointToMove() != null) {
|
if (saveOriginalPoint) {
|
||||||
switchMovePointMode(false);
|
WptPt pt = editingCtx.getOriginalPointToMove();
|
||||||
} else if (editingCtx.getSelectedPointPosition() != -1) {
|
editingCtx.addPoint(pt);
|
||||||
switchAddPointBeforeAfterMode(false);
|
|
||||||
}
|
}
|
||||||
MeasurementToolLayer layer = getMeasurementLayer();
|
editingCtx.setOriginalPointToMove(null);
|
||||||
if (layer != null && editingCtx.getOriginalPointToMove() != null) {
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
layer.exitMovePointMode(true);
|
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelModes() {
|
||||||
|
if (editingCtx.getOriginalPointToMove() != null) {
|
||||||
|
cancelMovePointMode();
|
||||||
|
} else if (editingCtx.getSelectedPointPosition() != -1) {
|
||||||
|
cancelAddPointBeforeOrAfterMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1074,7 +1081,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
final SwitchCompat showOnMapToggle = (SwitchCompat) view.findViewById(R.id.toggle_show_on_map);
|
final SwitchCompat showOnMapToggle = (SwitchCompat) view.findViewById(R.id.toggle_show_on_map);
|
||||||
showOnMapToggle.setChecked(true);
|
showOnMapToggle.setChecked(true);
|
||||||
|
|
||||||
final String suggestedName = new SimpleDateFormat("yyyy-M-dd_HH-mm_EEE", Locale.US).format(new Date());
|
final String suggestedName = new SimpleDateFormat("yyyy-MM-dd_HH-mm_EEE", Locale.US).format(new Date());
|
||||||
String displayedName = suggestedName;
|
String displayedName = suggestedName;
|
||||||
File fout = new File(dir, suggestedName + GPX_SUFFIX);
|
File fout = new File(dir, suggestedName + GPX_SUFFIX);
|
||||||
int ind = 1;
|
int ind = 1;
|
||||||
|
@ -1156,7 +1163,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
closeModes();
|
cancelModes();
|
||||||
MapActivity activity = getMapActivity();
|
MapActivity activity = getMapActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
progressDialog = new ProgressDialog(activity);
|
progressDialog = new ProgressDialog(activity);
|
||||||
|
@ -1184,6 +1191,19 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
Route rt = new Route();
|
Route rt = new Route();
|
||||||
gpx.routes.add(rt);
|
gpx.routes.add(rt);
|
||||||
rt.points.addAll(points);
|
rt.points.addAll(points);
|
||||||
|
} else if (saveType == SaveType.SNAP_TO_ROAD) {
|
||||||
|
TrkSegment segmentToSave = new TrkSegment();
|
||||||
|
TrkSegment before = editingCtx.getBeforeTrkSegmentLine();
|
||||||
|
TrkSegment after = editingCtx.getAfterTrkSegmentLine();
|
||||||
|
segmentToSave.points.addAll(before.points);
|
||||||
|
segmentToSave.points.addAll(after.points);
|
||||||
|
Track track = new Track();
|
||||||
|
track.segments.add(segmentToSave);
|
||||||
|
gpx.tracks.add(track);
|
||||||
|
|
||||||
|
Route rt = new Route();
|
||||||
|
rt.points.addAll(points);
|
||||||
|
gpx.routes.add(rt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
|
@ -1390,7 +1410,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
final String name = new SimpleDateFormat("yyyy-M-dd_HH-mm_EEE", Locale.US).format(new Date());
|
final String name = new SimpleDateFormat("yyyy-MM-dd_HH-mm_EEE", Locale.US).format(new Date());
|
||||||
String fileName = name + GPX_SUFFIX;
|
String fileName = name + GPX_SUFFIX;
|
||||||
File fout = new File(dir, fileName);
|
File fout = new File(dir, fileName);
|
||||||
int ind = 1;
|
int ind = 1;
|
||||||
|
@ -1398,7 +1418,13 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
fileName = name + "_" + (++ind) + GPX_SUFFIX;
|
fileName = name + "_" + (++ind) + GPX_SUFFIX;
|
||||||
fout = new File(dir, fileName);
|
fout = new File(dir, fileName);
|
||||||
}
|
}
|
||||||
saveNewGpx(dir, fileName, showOnMapToggle.isChecked(), SaveType.LINE, true);
|
SaveType saveType;
|
||||||
|
if (editingCtx.isInSnapToRoadMode()) {
|
||||||
|
saveType = SaveType.SNAP_TO_ROAD;
|
||||||
|
} else {
|
||||||
|
saveType = SaveType.LINE;
|
||||||
|
}
|
||||||
|
saveNewGpx(dir, fileName, showOnMapToggle.isChecked(), saveType, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -300,16 +300,6 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void exitMovePointMode(boolean saveOriginalPoint) {
|
|
||||||
if (saveOriginalPoint) {
|
|
||||||
WptPt pt = editingCtx.getOriginalPointToMove();
|
|
||||||
editingCtx.addPoint(pt);
|
|
||||||
}
|
|
||||||
editingCtx.setOriginalPointToMove(null);
|
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
|
||||||
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawCenterIcon(Canvas canvas, RotatedTileBox tb, QuadPoint center, boolean nightMode) {
|
private void drawCenterIcon(Canvas canvas, RotatedTileBox tb, QuadPoint center, boolean nightMode) {
|
||||||
canvas.rotate(-tb.getRotate(), center.x, center.y);
|
canvas.rotate(-tb.getRotate(), center.x, center.y);
|
||||||
if (nightMode) {
|
if (nightMode) {
|
||||||
|
|
Loading…
Reference in a new issue