Add route points and styling
This commit is contained in:
parent
2ad0fe821d
commit
0122d0faa1
15 changed files with 295 additions and 101 deletions
|
@ -32,7 +32,7 @@
|
|||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/add_gpx_waypoint_bottom_sheet_title"/>
|
||||
android:text="@string/add_gpx_waypoint"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
|
@ -262,7 +262,7 @@
|
|||
tools:visibility="visible"/>
|
||||
|
||||
<include
|
||||
layout="@layout/add_gpx_waypoint_bottom_sheet"
|
||||
layout="@layout/add_gpx_point_bottom_sheet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|left"
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/add_gpx_waypoint_bottom_sheet_title"/>
|
||||
tools:text="@string/add_gpx_waypoint"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
|
@ -223,7 +223,7 @@
|
|||
<include layout="@layout/move_marker_bottom_sheet"
|
||||
tools:visibility="gone"/>
|
||||
|
||||
<include layout="@layout/add_gpx_waypoint_bottom_sheet"
|
||||
<include layout="@layout/add_gpx_point_bottom_sheet"
|
||||
tools:visibility="gone"/>
|
||||
|
||||
<FrameLayout
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/MainLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/MainLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ExpandableListView
|
||||
android:id="@android:id/list"
|
||||
|
@ -16,17 +18,96 @@
|
|||
android:divider="@null"
|
||||
android:dividerHeight="0dp"
|
||||
android:drawSelectorOnTop="false"
|
||||
android:groupIndicator="@android:color/transparent" />
|
||||
android:groupIndicator="@android:color/transparent"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fabButton"
|
||||
android:id="@+id/menu_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_action_plus"
|
||||
android:contentDescription="@string/quick_action_new_action"
|
||||
app:backgroundTint="@color/dashboard_blue"/>
|
||||
android:src="@drawable/ic_action_plus"
|
||||
app:backgroundTint="@color/dashboard_blue"
|
||||
app:fabSize="normal"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/waypoint_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/menu_fab"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="24dp"
|
||||
android:contentDescription="@string/quick_action_new_action"
|
||||
android:src="@drawable/ic_action_marker_dark"
|
||||
android:visibility="gone"
|
||||
app:backgroundTint="@color/dashboard_blue"
|
||||
app:fabSize="mini"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/waypoint_text_layout"
|
||||
android:layout_toLeftOf="@id/waypoint_fab"
|
||||
android:layout_toStartOf="@id/waypoint_fab"
|
||||
android:layout_above="@id/menu_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/waypoint_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/gpx_wpt"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/route_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/waypoint_fab"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginRight="24dp"
|
||||
android:contentDescription="@string/quick_action_new_action"
|
||||
android:src="@drawable/ic_action_markers_dark"
|
||||
android:visibility="gone"
|
||||
app:backgroundTint="@color/dashboard_blue"
|
||||
app:fabSize="mini"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/route_text_layout"
|
||||
android:layout_toLeftOf="@id/route_fab"
|
||||
android:layout_toStartOf="@id/route_fab"
|
||||
android:layout_above="@id/waypoint_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/route_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/route_point"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -2659,6 +2659,8 @@
|
|||
<string name="shared_string_action_name">Action name</string>
|
||||
<string name="mappilary_no_internet_desc">You need internet to view photos from Mapillary</string>
|
||||
<string name="retry">Retry</string>
|
||||
<string name="add_gpx_waypoint_bottom_sheet_title">Add gpx waypoint</string>
|
||||
<string name="add_gpx_waypoint">Add GPX waypoint</string>
|
||||
<string name="shared_string_create">Create</string>
|
||||
<string name="route_point">Route point</string>
|
||||
<string name="add_route_point">Add route point</string>
|
||||
</resources>
|
||||
|
|
|
@ -24,6 +24,7 @@ public class PointDescription {
|
|||
|
||||
public static final String POINT_TYPE_FAVORITE = "favorite";
|
||||
public static final String POINT_TYPE_WPT = "wpt";
|
||||
public static final String POINT_TYPE_ROUTE = "route_point";
|
||||
public static final String POINT_TYPE_POI = "poi";
|
||||
public static final String POINT_TYPE_ADDRESS = "address";
|
||||
public static final String POINT_TYPE_OSM_NOTE= "osm_note";
|
||||
|
@ -211,6 +212,10 @@ public class PointDescription {
|
|||
public boolean isWpt() {
|
||||
return POINT_TYPE_WPT.equals(type);
|
||||
}
|
||||
|
||||
public boolean isRoutePoint() {
|
||||
return POINT_TYPE_ROUTE.equals(type);
|
||||
}
|
||||
|
||||
public boolean isPoi() {
|
||||
return POINT_TYPE_POI.equals(type);
|
||||
|
|
|
@ -102,18 +102,6 @@ public class GPXUtilities {
|
|||
public float speed;
|
||||
}
|
||||
|
||||
public static class NewGpxWaypoint {
|
||||
private GPXFile gpx;
|
||||
|
||||
public NewGpxWaypoint(GPXFile gpx) {
|
||||
this.gpx = gpx;
|
||||
}
|
||||
|
||||
public GPXFile getGpx() {
|
||||
return gpx;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WptPt extends GPXExtensions implements LocationPoint {
|
||||
public boolean firstPoint = false;
|
||||
public boolean lastPoint = false;
|
||||
|
@ -860,7 +848,7 @@ public class GPXUtilities {
|
|||
return false;
|
||||
}
|
||||
|
||||
public WptPt addWptPt(double lat, double lon, long time, String description, String name, String category, int color) {
|
||||
public WptPt addWptPt(double lat, double lon, long time, String description, String name, String category, int color, PointDescription pointDescription) {
|
||||
double latAdjusted = Double.parseDouble(latLonFormat.format(lat));
|
||||
double lonAdjusted = Double.parseDouble(latLonFormat.format(lon));
|
||||
final WptPt pt = new WptPt(latAdjusted, lonAdjusted, time, Double.NaN, 0, Double.NaN);
|
||||
|
@ -871,7 +859,15 @@ public class GPXUtilities {
|
|||
pt.setColor(color);
|
||||
}
|
||||
|
||||
points.add(pt);
|
||||
if (pointDescription.isWpt()) {
|
||||
points.add(pt);
|
||||
} else if (pointDescription.isRoutePoint()) {
|
||||
if (routes.size() == 0) {
|
||||
routes.add(new Route());
|
||||
}
|
||||
Route currentRoute = routes.get(routes.size() -1);
|
||||
currentRoute.points.add(pt);
|
||||
}
|
||||
modifiedTime = System.currentTimeMillis();
|
||||
|
||||
return pt;
|
||||
|
|
|
@ -57,8 +57,6 @@ import net.osmand.plus.AppInitializer;
|
|||
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
||||
import net.osmand.plus.AppInitializer.InitEvents;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.NewGpxWaypoint;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
||||
|
@ -105,6 +103,7 @@ import net.osmand.plus.routing.RoutingHelper.RouteCalculationProgressCallback;
|
|||
import net.osmand.plus.search.QuickSearchDialogFragment;
|
||||
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab;
|
||||
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
|
||||
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewPoint;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.MapControlsLayer;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
|
@ -918,9 +917,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
} else if (toShow instanceof QuadRect) {
|
||||
QuadRect qr = (QuadRect) toShow;
|
||||
mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0);
|
||||
} else if (toShow instanceof NewGpxWaypoint) {
|
||||
NewGpxWaypoint newGpxWaypoint = (NewGpxWaypoint) toShow;
|
||||
getMapLayers().getContextMenuLayer().enterAddGpxWaypointMode(newGpxWaypoint);
|
||||
} else if (toShow instanceof NewPoint) {
|
||||
NewPoint newPoint = (NewPoint) toShow;
|
||||
getMapLayers().getContextMenuLayer().enterAddGpxPointMode(newPoint);
|
||||
} else {
|
||||
mapContextMenu.show(latLonToShow, mapLabelToShow, toShow);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.mapcontextmenu.editors;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
|
@ -12,6 +13,7 @@ public class WptPtEditor extends PointEditor {
|
|||
private GPXFile gpxFile;
|
||||
private WptPt wpt;
|
||||
private boolean gpxSelected;
|
||||
private PointDescription pointDescription;
|
||||
|
||||
public static final String TAG = "WptPtEditorFragment";
|
||||
|
||||
|
@ -28,6 +30,10 @@ public class WptPtEditor extends PointEditor {
|
|||
return gpxFile;
|
||||
}
|
||||
|
||||
public PointDescription getPointDescription() {
|
||||
return pointDescription;
|
||||
}
|
||||
|
||||
public boolean isGpxSelected() {
|
||||
return gpxSelected;
|
||||
}
|
||||
|
@ -53,6 +59,24 @@ public class WptPtEditor extends PointEditor {
|
|||
WptPtEditorFragment.showInstance(mapActivity);
|
||||
}
|
||||
|
||||
public void add(GPXFile gpxFile, LatLon latLon, String title, PointDescription pointDescription) {
|
||||
if (latLon == null) {
|
||||
return;
|
||||
}
|
||||
isNew = true;
|
||||
this.pointDescription = pointDescription;
|
||||
|
||||
this.gpxFile = gpxFile;
|
||||
SelectedGpxFile selectedGpxFile =
|
||||
mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path);
|
||||
gpxSelected = selectedGpxFile != null;
|
||||
|
||||
wpt = new WptPt(latLon.getLatitude(), latLon.getLongitude(),
|
||||
System.currentTimeMillis(), Double.NaN, 0, Double.NaN);
|
||||
wpt.name = title;
|
||||
WptPtEditorFragment.showInstance(mapActivity);
|
||||
}
|
||||
|
||||
public void add(GPXFile gpxFile, LatLon latLon, String title, String categoryName, int categoryColor, boolean skipDialog) {
|
||||
if (latLon == null) {
|
||||
return;
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.support.annotation.Nullable;
|
|||
import android.view.View;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
|
@ -152,6 +153,7 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
}
|
||||
|
||||
GPXFile gpx = editor.getGpxFile();
|
||||
PointDescription pointDescription = editor.getPointDescription();
|
||||
if (gpx != null) {
|
||||
if (gpx.showCurrentTrack) {
|
||||
wpt = savingTrackHelper.insertPointData(wpt.getLatitude(), wpt.getLongitude(),
|
||||
|
@ -161,7 +163,7 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
}
|
||||
} else {
|
||||
wpt = gpx.addWptPt(wpt.getLatitude(), wpt.getLongitude(),
|
||||
System.currentTimeMillis(), description, name, category, color);
|
||||
System.currentTimeMillis(), description, name, category, color, pointDescription);
|
||||
new SaveGpxAsyncTask(getMyApplication(), gpx, editor.isGpxSelected()).execute();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.plus.mapcontextmenu.MenuController.MenuType;
|
|||
import net.osmand.plus.mapcontextmenu.MenuTitleController;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -194,8 +195,16 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
|||
public void openContextMenu(@NonNull MenuObject menuObject) {
|
||||
IContextMenuProvider provider = selectedObjects.remove(menuObject.getObject());
|
||||
hide();
|
||||
getMapActivity().getMapLayers().getContextMenuLayer().showContextMenu(
|
||||
menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject(), provider);
|
||||
ContextMenuLayer contextMenuLayer = getMapActivity().getMapLayers().getContextMenuLayer();
|
||||
if (contextMenuLayer.isInAddGpxWaypointMode()) {
|
||||
PointDescription pointDescription = menuObject.getPointDescription();
|
||||
String title = pointDescription == null ? "" : pointDescription.getName();
|
||||
contextMenuLayer.getAddGpxPointBottomSheetHelper().setTitle(title);
|
||||
OsmandMapTileView view = menuObject.getMapActivity().getMapView();
|
||||
view.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), view.getZoom(), true);
|
||||
} else {
|
||||
contextMenuLayer.showContextMenu(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject(), provider);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearSelectedObjects() {
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.os.Handler;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.view.ActionMode;
|
||||
|
@ -30,16 +31,13 @@ import android.widget.ListView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.NewGpxWaypoint;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||
|
@ -58,6 +56,7 @@ import net.osmand.plus.activities.TrackActivity;
|
|||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.base.OsmandExpandableListFragment;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewPoint;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -93,7 +92,12 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
private Set<Integer> selectedGroups = new LinkedHashSet<>();
|
||||
private ActionMode actionMode;
|
||||
private SearchView searchView;
|
||||
private FloatingActionButton fab;
|
||||
private boolean menuOpened = false;
|
||||
private FloatingActionButton menuFab;
|
||||
private FloatingActionButton waypointFab;
|
||||
private View waypointTextLayout;
|
||||
private FloatingActionButton routePointFab;
|
||||
private View routePointTextLayout;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
|
@ -115,26 +119,38 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
ExpandableListView listView = (ExpandableListView) view.findViewById(android.R.id.list);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
fab = (FloatingActionButton) view.findViewById(R.id.fabButton);
|
||||
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
menuFab = (FloatingActionButton) view.findViewById(R.id.menu_fab);
|
||||
menuFab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
GPXFile gpx = getGpx();
|
||||
LatLon location = settings.getLastKnownMapLocation();
|
||||
if (location != null) {
|
||||
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(),
|
||||
settings.getLastKnownMapZoom(),
|
||||
new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.context_menu_item_add_waypoint)),
|
||||
false,
|
||||
new NewGpxWaypoint(gpx));
|
||||
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
if (menuOpened) {
|
||||
closeMenu();
|
||||
} else {
|
||||
openMenu();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
waypointFab = (FloatingActionButton) view.findViewById(R.id.waypoint_fab);
|
||||
waypointFab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.context_menu_item_add_waypoint));
|
||||
addPoint(pointDescription);
|
||||
}
|
||||
});
|
||||
waypointTextLayout = view.findViewById(R.id.waypoint_text_layout);
|
||||
|
||||
routePointFab = (FloatingActionButton) view.findViewById(R.id.route_fab);
|
||||
routePointFab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_ROUTE, getString(R.string.add_route_point));
|
||||
addPoint(pointDescription);
|
||||
}
|
||||
});
|
||||
routePointTextLayout = view.findViewById(R.id.route_text_layout);
|
||||
|
||||
TextView tv = new TextView(getActivity());
|
||||
tv.setText(R.string.none_selected_gpx);
|
||||
tv.setTextSize(24);
|
||||
|
@ -146,6 +162,39 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
private void addPoint(PointDescription pointDescription) {
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
GPXFile gpx = getGpx();
|
||||
LatLon location = settings.getLastKnownMapLocation();
|
||||
if (gpx != null && location != null) {
|
||||
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(),
|
||||
settings.getLastKnownMapZoom(),
|
||||
pointDescription,
|
||||
false,
|
||||
new NewPoint(gpx, pointDescription));
|
||||
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
}
|
||||
|
||||
private void openMenu() {
|
||||
menuFab.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_action_remove_dark));
|
||||
waypointFab.setVisibility(View.VISIBLE);
|
||||
waypointTextLayout.setVisibility(View.VISIBLE);
|
||||
routePointFab.setVisibility(View.VISIBLE);
|
||||
routePointTextLayout.setVisibility(View.VISIBLE);
|
||||
menuOpened = true;
|
||||
}
|
||||
|
||||
private void closeMenu() {
|
||||
menuFab.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_action_plus));
|
||||
waypointFab.setVisibility(View.GONE);
|
||||
waypointTextLayout.setVisibility(View.GONE);
|
||||
routePointFab.setVisibility(View.GONE);
|
||||
routePointTextLayout.setVisibility(View.GONE);
|
||||
menuOpened = false;
|
||||
}
|
||||
|
||||
public TrackActivity getTrackActivity() {
|
||||
return (TrackActivity) getActivity();
|
||||
}
|
||||
|
|
|
@ -10,26 +10,25 @@ import android.widget.TextView;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.NewGpxWaypoint;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
|
||||
public class AddWaypointBottomSheetHelper {
|
||||
public class AddGpxPointBottomSheetHelper {
|
||||
private final View view;
|
||||
private final TextView title;
|
||||
private String titleText = "";
|
||||
private String titleText;
|
||||
private final TextView description;
|
||||
private final Context context;
|
||||
private final MapContextMenu contextMenu;
|
||||
private final ContextMenuLayer contextMenuLayer;
|
||||
private boolean applyingPositionMode;
|
||||
private NewGpxWaypoint newGpxWaypoint;
|
||||
private NewPoint newPoint;
|
||||
private PointDescription pointDescription;
|
||||
|
||||
public AddWaypointBottomSheetHelper(final MapActivity activity, ContextMenuLayer ctxMenuLayer) {
|
||||
public AddGpxPointBottomSheetHelper(final MapActivity activity, ContextMenuLayer ctxMenuLayer) {
|
||||
this.contextMenuLayer = ctxMenuLayer;
|
||||
view = activity.findViewById(R.id.add_gpx_waypoint_bottom_sheet);
|
||||
title = (TextView) view.findViewById(R.id.add_gpx_waypoint_bottom_sheet_title);
|
||||
|
@ -43,17 +42,17 @@ public class AddWaypointBottomSheetHelper {
|
|||
view.findViewById(R.id.create_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
contextMenuLayer.createGpxWaypoint();
|
||||
GPXFile gpx = newGpxWaypoint.getGpx();
|
||||
contextMenuLayer.createGpxPoint();
|
||||
GPXFile gpx = newPoint.getGpx();
|
||||
LatLon latLon = contextMenu.getLatLon();
|
||||
activity.getContextMenu().getWptPtPointEditor().add(gpx, latLon, titleText);
|
||||
activity.getContextMenu().getWptPtPointEditor().add(gpx, latLon, titleText, pointDescription);
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.cancel_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
hide();
|
||||
contextMenuLayer.cancelAddGpxWaypoint();
|
||||
contextMenuLayer.cancelAddGpxPoint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -74,8 +73,14 @@ public class AddWaypointBottomSheetHelper {
|
|||
return view.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
public void show(Drawable drawable, NewGpxWaypoint newGpxWaypoint) {
|
||||
this.newGpxWaypoint = newGpxWaypoint;
|
||||
public void show(Drawable drawable, NewPoint newPoint) {
|
||||
this.newPoint = newPoint;
|
||||
pointDescription = newPoint.getPointDescription();
|
||||
if (pointDescription.isWpt()) {
|
||||
setTitle(context.getString(R.string.add_gpx_waypoint));
|
||||
} else if (pointDescription.isRoutePoint()) {
|
||||
setTitle(context.getString(R.string.add_route_point));
|
||||
}
|
||||
exitApplyPositionMode();
|
||||
view.setVisibility(View.VISIBLE);
|
||||
((ImageView) view.findViewById(R.id.icon)).setImageDrawable(drawable);
|
||||
|
@ -99,4 +104,22 @@ public class AddWaypointBottomSheetHelper {
|
|||
view.findViewById(R.id.create_button).setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static class NewPoint {
|
||||
private PointDescription pointDescription;
|
||||
private GPXFile gpx;
|
||||
|
||||
public NewPoint(GPXFile gpx, PointDescription pointDescription) {
|
||||
this.gpx = gpx;
|
||||
this.pointDescription = pointDescription;
|
||||
}
|
||||
|
||||
public GPXFile getGpx() {
|
||||
return gpx;
|
||||
}
|
||||
|
||||
public PointDescription getPointDescription() {
|
||||
return pointDescription;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,13 +35,13 @@ import net.osmand.osm.PoiFilter;
|
|||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities.NewGpxWaypoint;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
||||
import net.osmand.plus.render.MapRenderRepositories;
|
||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewPoint;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -76,14 +76,14 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
private GestureDetector movementListener;
|
||||
|
||||
private final MoveMarkerBottomSheetHelper mMoveMarkerBottomSheetHelper;
|
||||
private final AddWaypointBottomSheetHelper mAddWaypointBottomSheetHelper;
|
||||
private final AddGpxPointBottomSheetHelper mAddGpxPointBottomSheetHelper;
|
||||
private boolean mInChangeMarkerPositionMode;
|
||||
private IContextMenuProvider selectedObjectContextMenuProvider;
|
||||
private boolean cancelApplyingNewMarkerPosition;
|
||||
private LatLon applyingMarkerLatLon;
|
||||
private boolean wasCollapseButtonVisible;
|
||||
private boolean mInGpxDetailsMode;
|
||||
private boolean mInAddGpxWaypointMode;
|
||||
private boolean mInAddGpxPointMode;
|
||||
|
||||
private List<String> publicTransportTypes;
|
||||
private Object selectedObject;
|
||||
|
@ -94,7 +94,11 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
multiSelectionMenu = menu.getMultiSelectionMenu();
|
||||
movementListener = new GestureDetector(activity, new MenuLayerOnGestureListener());
|
||||
mMoveMarkerBottomSheetHelper = new MoveMarkerBottomSheetHelper(activity, this);
|
||||
mAddWaypointBottomSheetHelper = new AddWaypointBottomSheetHelper(activity, this);
|
||||
mAddGpxPointBottomSheetHelper = new AddGpxPointBottomSheetHelper(activity, this);
|
||||
}
|
||||
|
||||
public AddGpxPointBottomSheetHelper getAddGpxPointBottomSheetHelper() {
|
||||
return mAddGpxPointBottomSheetHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -207,10 +211,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
contextMarker.draw(canvas);
|
||||
}
|
||||
mMoveMarkerBottomSheetHelper.onDraw(box);
|
||||
} else if (mInAddGpxWaypointMode) {
|
||||
} else if (mInAddGpxPointMode) {
|
||||
canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight());
|
||||
contextMarker.draw(canvas);
|
||||
mAddWaypointBottomSheetHelper.onDraw(box);
|
||||
mAddGpxPointBottomSheetHelper.onDraw(box);
|
||||
} else if (menu.isActive()) {
|
||||
LatLon latLon = menu.getLatLon();
|
||||
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
|
@ -289,7 +293,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public Object getMoveableObject() {
|
||||
return mInChangeMarkerPositionMode || mInAddGpxWaypointMode ? menu.getObject() : null;
|
||||
return mInChangeMarkerPositionMode ? menu.getObject() : null;
|
||||
}
|
||||
|
||||
public boolean isInChangeMarkerPositionMode() {
|
||||
|
@ -301,7 +305,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public boolean isInAddGpxWaypointMode() {
|
||||
return mInAddGpxWaypointMode;
|
||||
return mInAddGpxPointMode;
|
||||
}
|
||||
|
||||
public boolean isObjectMoveable(Object o) {
|
||||
|
@ -318,14 +322,14 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public void applyMovedObject(Object o, LatLon position, ApplyMovedObjectCallback callback) {
|
||||
if (selectedObjectContextMenuProvider != null) {
|
||||
if (selectedObjectContextMenuProvider != null && !isInAddGpxWaypointMode()) {
|
||||
if (selectedObjectContextMenuProvider instanceof IMoveObjectProvider) {
|
||||
final IMoveObjectProvider l = (IMoveObjectProvider) selectedObjectContextMenuProvider;
|
||||
if (l.isObjectMovable(o)) {
|
||||
l.applyNewObjectPosition(o, position, callback);
|
||||
}
|
||||
}
|
||||
} else if (mInChangeMarkerPositionMode || mInAddGpxWaypointMode) {
|
||||
} else if (mInChangeMarkerPositionMode || mInAddGpxPointMode) {
|
||||
callback.onApplyMovedObject(true, null);
|
||||
}
|
||||
}
|
||||
|
@ -351,11 +355,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
mMoveMarkerBottomSheetHelper.hide();
|
||||
quitMovingMarker();
|
||||
|
||||
PointDescription pointDescription = null;
|
||||
if (selectedObjectContextMenuProvider != null) {
|
||||
pointDescription = selectedObjectContextMenuProvider.getObjectName(newObject);
|
||||
}
|
||||
menu.show(ll, pointDescription, newObject);
|
||||
|
||||
view.refreshMap();
|
||||
}
|
||||
selectedObjectContextMenuProvider = null;
|
||||
|
@ -369,9 +369,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
});
|
||||
}
|
||||
|
||||
public void createGpxWaypoint() {
|
||||
if (!mInAddGpxWaypointMode) {
|
||||
throw new IllegalStateException("Not in add gpx waypoint mode");
|
||||
public void createGpxPoint() {
|
||||
if (!mInAddGpxPointMode) {
|
||||
throw new IllegalStateException("Not in add gpx point mode");
|
||||
}
|
||||
|
||||
RotatedTileBox tileBox = activity.getMapView().getCurrentRotatedTileBox();
|
||||
|
@ -381,14 +381,14 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
|
||||
Object obj = getMoveableObject();
|
||||
cancelApplyingNewMarkerPosition = false;
|
||||
mAddWaypointBottomSheetHelper.enterApplyPositionMode();
|
||||
mAddGpxPointBottomSheetHelper.enterApplyPositionMode();
|
||||
applyMovedObject(obj, ll, new ApplyMovedObjectCallback() {
|
||||
@Override
|
||||
public void onApplyMovedObject(boolean success, @Nullable Object newObject) {
|
||||
mAddWaypointBottomSheetHelper.exitApplyPositionMode();
|
||||
mAddGpxPointBottomSheetHelper.exitApplyPositionMode();
|
||||
if (success && !cancelApplyingNewMarkerPosition) {
|
||||
mAddWaypointBottomSheetHelper.hide();
|
||||
quitAddGpxWaipoint();
|
||||
mAddGpxPointBottomSheetHelper.hide();
|
||||
quitAddGpxPoint();
|
||||
|
||||
PointDescription pointDescription = null;
|
||||
if (selectedObjectContextMenuProvider != null) {
|
||||
|
@ -449,8 +449,8 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
|
||||
private void quitAddGpxWaipoint() {
|
||||
mInAddGpxWaypointMode = false;
|
||||
private void quitAddGpxPoint() {
|
||||
mInAddGpxPointMode = false;
|
||||
mark(View.VISIBLE, R.id.map_ruler_layout,
|
||||
R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
|
||||
|
||||
|
@ -460,14 +460,14 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
|
||||
public void enterAddGpxWaypointMode(NewGpxWaypoint newGpxWaypoint) {
|
||||
public void enterAddGpxPointMode(NewPoint newPoint) {
|
||||
menu.updateMapCenter(null);
|
||||
menu.hide();
|
||||
|
||||
activity.disableDrawer();
|
||||
|
||||
mInAddGpxWaypointMode = true;
|
||||
mAddWaypointBottomSheetHelper.show(menu.getLeftIcon(), newGpxWaypoint);
|
||||
mInAddGpxPointMode = true;
|
||||
mAddGpxPointBottomSheetHelper.show(menu.getLeftIcon(), newPoint);
|
||||
mark(View.INVISIBLE, R.id.map_ruler_layout,
|
||||
R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
|
||||
|
||||
|
@ -529,9 +529,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
applyingMarkerLatLon = null;
|
||||
}
|
||||
|
||||
public void cancelAddGpxWaypoint() {
|
||||
public void cancelAddGpxPoint() {
|
||||
cancelApplyingNewMarkerPosition = true;
|
||||
quitAddGpxWaipoint();
|
||||
quitAddGpxPoint();
|
||||
activity.getContextMenu().show();
|
||||
applyingMarkerLatLon = null;
|
||||
}
|
||||
|
@ -648,10 +648,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
if (latLon == null) {
|
||||
latLon = getLatLon(point, tileBox);
|
||||
}
|
||||
if (mInAddGpxWaypointMode) {
|
||||
if (pointDescription != null) {
|
||||
mAddWaypointBottomSheetHelper.setTitle(pointDescription.getName());
|
||||
}
|
||||
if (mInAddGpxPointMode) {
|
||||
String title = pointDescription == null ? "" : pointDescription.getName();
|
||||
mAddGpxPointBottomSheetHelper.setTitle(title);
|
||||
view.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), view.getZoom(), true);
|
||||
} else {
|
||||
showContextMenu(latLon, pointDescription, selectedObj, provider);
|
||||
|
@ -668,7 +667,12 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
selectedObjectContextMenuProvider = null;
|
||||
LatLon latLon = getLatLon(point, tileBox);
|
||||
activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||
menu.show(latLon, null, null);
|
||||
if (mInAddGpxPointMode) {
|
||||
mAddGpxPointBottomSheetHelper.setTitle("");
|
||||
view.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), view.getZoom(), true);
|
||||
} else {
|
||||
menu.show(latLon, null, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -697,7 +701,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public boolean disableLongPressOnMap() {
|
||||
if (mInChangeMarkerPositionMode || mInGpxDetailsMode || mInAddGpxWaypointMode) {
|
||||
if (mInChangeMarkerPositionMode || mInGpxDetailsMode || mInAddGpxPointMode) {
|
||||
return true;
|
||||
}
|
||||
boolean res = false;
|
||||
|
|
Loading…
Reference in a new issue