commit
10a99a3b4e
13 changed files with 437 additions and 17 deletions
66
OsmAnd/res/layout-land/add_gpx_waypoint_bottom_sheet.xml
Normal file
66
OsmAnd/res/layout-land/add_gpx_waypoint_bottom_sheet.xml
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
android:id="@+id/add_gpx_waypoint_bottom_sheet"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="?attr/bottom_menu_view_bg"
|
||||
android:clickable="true"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_action_photo_dark"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/add_gpx_waypoint_bottom_sheet_title"
|
||||
style="@style/TextAppearance.ContextMenuTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/add_gpx_waypoint_bottom_sheet_title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
style="@style/TextAppearance.ContextMenuSubtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
tools:text="Lat: 50.45375 Lon: 30.48693"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/create_button"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/shared_string_create"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/cancel_button"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/shared_string_cancel"/>
|
||||
</LinearLayout>
|
|
@ -261,4 +261,11 @@
|
|||
android:layout_gravity="bottom|left"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<include
|
||||
layout="@layout/add_gpx_waypoint_bottom_sheet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|left"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
</LinearLayout>
|
68
OsmAnd/res/layout/add_gpx_waypoint_bottom_sheet.xml
Normal file
68
OsmAnd/res/layout/add_gpx_waypoint_bottom_sheet.xml
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
android:id="@+id/add_gpx_waypoint_bottom_sheet"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="?attr/bottom_menu_view_bg"
|
||||
android:clickable="true"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_action_photo_dark"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/add_gpx_waypoint_bottom_sheet_title"
|
||||
style="@style/TextAppearance.ContextMenuTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/add_gpx_waypoint_bottom_sheet_title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
style="@style/TextAppearance.ContextMenuSubtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
tools:text="Lat: 50.45375\nLon: 30.48693"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginRight="12dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/create_button"
|
||||
style="@style/DialogActionButton"
|
||||
android:layout_marginRight="8dp"
|
||||
android:text="@string/shared_string_create"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel_button"
|
||||
style="@style/DialogCancelButton"
|
||||
android:text="@string/shared_string_cancel"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -223,6 +223,9 @@
|
|||
<include layout="@layout/move_marker_bottom_sheet"
|
||||
tools:visibility="gone"/>
|
||||
|
||||
<include layout="@layout/add_gpx_waypoint_bottom_sheet"
|
||||
tools:visibility="gone"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/bottomFragmentContainer"
|
||||
android:layout_width="match_parent"
|
||||
|
|
32
OsmAnd/res/layout/points_tree.xml
Normal file
32
OsmAnd/res/layout/points_tree.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?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">
|
||||
|
||||
<ExpandableListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="0dp"
|
||||
android:layout_marginRight="0dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:divider="@null"
|
||||
android:dividerHeight="0dp"
|
||||
android:drawSelectorOnTop="false"
|
||||
android:groupIndicator="@android:color/transparent" />
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fabButton"
|
||||
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"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -2660,4 +2660,6 @@
|
|||
<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="shared_string_create">Create</string>
|
||||
</resources>
|
||||
|
|
|
@ -102,6 +102,18 @@ 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;
|
||||
|
|
|
@ -57,6 +57,8 @@ 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;
|
||||
|
@ -916,6 +918,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 {
|
||||
mapContextMenu.show(latLonToShow, mapLabelToShow, toShow);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.view.ActionMode;
|
||||
|
@ -29,13 +30,16 @@ 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;
|
||||
|
@ -89,6 +93,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
private Set<Integer> selectedGroups = new LinkedHashSet<>();
|
||||
private ActionMode actionMode;
|
||||
private SearchView searchView;
|
||||
private FloatingActionButton fab;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
|
@ -106,10 +111,30 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.favorites_tree, container, false);
|
||||
View view = inflater.inflate(R.layout.points_tree, container, false);
|
||||
ExpandableListView listView = (ExpandableListView) view.findViewById(android.R.id.list);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
fab = (FloatingActionButton) view.findViewById(R.id.fabButton);
|
||||
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
GPXFile gpx = getGpx();
|
||||
Location location = app.getLocationProvider().getLastKnownLocation();
|
||||
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());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
TextView tv = new TextView(getActivity());
|
||||
tv.setText(R.string.none_selected_gpx);
|
||||
tv.setTextSize(24);
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
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 {
|
||||
private final View view;
|
||||
private final TextView title;
|
||||
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;
|
||||
|
||||
public AddWaypointBottomSheetHelper(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);
|
||||
description = (TextView) view.findViewById(R.id.description);
|
||||
context = activity;
|
||||
contextMenu = activity.getContextMenu();
|
||||
ImageView icon = (ImageView) view.findViewById(R.id.icon);
|
||||
|
||||
IconsCache iconsCache = activity.getMyApplication().getIconsCache();
|
||||
icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_photo_dark, R.color.marker_green));
|
||||
view.findViewById(R.id.create_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
contextMenuLayer.createGpxWaypoint();
|
||||
GPXFile gpx = newGpxWaypoint.getGpx();
|
||||
LatLon latLon = contextMenu.getLatLon();
|
||||
activity.getContextMenu().getWptPtPointEditor().add(gpx, latLon, titleText);
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.cancel_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
hide();
|
||||
contextMenuLayer.cancelAddGpxWaypoint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onDraw(RotatedTileBox rt) {
|
||||
PointF point = contextMenuLayer.getMovableCenterPoint(rt);
|
||||
double lat = rt.getLatFromPixel(point.x, point.y);
|
||||
double lon = rt.getLonFromPixel(point.x, point.y);
|
||||
description.setText(PointDescription.getLocationName(context, lat, lon, true));
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
titleText = title;
|
||||
this.title.setText(titleText);
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return view.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
public void show(Drawable drawable, NewGpxWaypoint newGpxWaypoint) {
|
||||
this.newGpxWaypoint = newGpxWaypoint;
|
||||
exitApplyPositionMode();
|
||||
view.setVisibility(View.VISIBLE);
|
||||
((ImageView) view.findViewById(R.id.icon)).setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
exitApplyPositionMode();
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void enterApplyPositionMode() {
|
||||
if (!applyingPositionMode) {
|
||||
applyingPositionMode = true;
|
||||
view.findViewById(R.id.create_button).setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void exitApplyPositionMode() {
|
||||
if (applyingPositionMode) {
|
||||
applyingPositionMode = false;
|
||||
view.findViewById(R.id.create_button).setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@ 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;
|
||||
|
@ -75,12 +76,14 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
private GestureDetector movementListener;
|
||||
|
||||
private final MoveMarkerBottomSheetHelper mMoveMarkerBottomSheetHelper;
|
||||
private final AddWaypointBottomSheetHelper mAddWaypointBottomSheetHelper;
|
||||
private boolean mInChangeMarkerPositionMode;
|
||||
private IContextMenuProvider selectedObjectContextMenuProvider;
|
||||
private boolean cancelApplyingNewMarkerPosition;
|
||||
private LatLon applyingMarkerLatLon;
|
||||
private boolean wasCollapseButtonVisible;
|
||||
private boolean mInGpxDetailsMode;
|
||||
private boolean mInAddGpxWaypointMode;
|
||||
|
||||
private List<String> publicTransportTypes;
|
||||
private Object selectedObject;
|
||||
|
@ -91,6 +94,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
multiSelectionMenu = menu.getMultiSelectionMenu();
|
||||
movementListener = new GestureDetector(activity, new MenuLayerOnGestureListener());
|
||||
mMoveMarkerBottomSheetHelper = new MoveMarkerBottomSheetHelper(activity, this);
|
||||
mAddWaypointBottomSheetHelper = new AddWaypointBottomSheetHelper(activity, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -194,7 +198,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
canvas.drawBitmap(pressedBitmap, x - pressedBitmap.getWidth() / 2, y - pressedBitmap.getHeight() / 2, paint);
|
||||
}
|
||||
|
||||
if (mapQuickActionLayer!= null && mapQuickActionLayer.isInChangeMarkerPositionMode())
|
||||
if (mapQuickActionLayer!= null && mapQuickActionLayer.isInMovingMarkerMode())
|
||||
return;
|
||||
|
||||
if (mInChangeMarkerPositionMode) {
|
||||
|
@ -203,6 +207,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
contextMarker.draw(canvas);
|
||||
}
|
||||
mMoveMarkerBottomSheetHelper.onDraw(box);
|
||||
} else if (mInAddGpxWaypointMode) {
|
||||
canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight());
|
||||
contextMarker.draw(canvas);
|
||||
mAddWaypointBottomSheetHelper.onDraw(box);
|
||||
} else if (menu.isActive()) {
|
||||
LatLon latLon = menu.getLatLon();
|
||||
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
|
@ -281,7 +289,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public Object getMoveableObject() {
|
||||
return mInChangeMarkerPositionMode ? menu.getObject() : null;
|
||||
return mInChangeMarkerPositionMode || mInAddGpxWaypointMode ? menu.getObject() : null;
|
||||
}
|
||||
|
||||
public boolean isInChangeMarkerPositionMode() {
|
||||
|
@ -292,6 +300,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
return mInGpxDetailsMode;
|
||||
}
|
||||
|
||||
public boolean isInAddGpxWaypointMode() {
|
||||
return mInAddGpxWaypointMode;
|
||||
}
|
||||
|
||||
public boolean isObjectMoveable(Object o) {
|
||||
if (o == null) {
|
||||
return true;
|
||||
|
@ -313,7 +325,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
l.applyNewObjectPosition(o, position, callback);
|
||||
}
|
||||
}
|
||||
} else if (mInChangeMarkerPositionMode) {
|
||||
} else if (mInChangeMarkerPositionMode || mInAddGpxWaypointMode) {
|
||||
callback.onApplyMovedObject(true, null);
|
||||
}
|
||||
}
|
||||
|
@ -357,6 +369,45 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
});
|
||||
}
|
||||
|
||||
public void createGpxWaypoint() {
|
||||
if (!mInAddGpxWaypointMode) {
|
||||
throw new IllegalStateException("Not in add gpx waypoint mode");
|
||||
}
|
||||
|
||||
RotatedTileBox tileBox = activity.getMapView().getCurrentRotatedTileBox();
|
||||
PointF newMarkerPosition = getMovableCenterPoint(tileBox);
|
||||
final LatLon ll = tileBox.getLatLonFromPixel(newMarkerPosition.x, newMarkerPosition.y);
|
||||
applyingMarkerLatLon = ll;
|
||||
|
||||
Object obj = getMoveableObject();
|
||||
cancelApplyingNewMarkerPosition = false;
|
||||
mAddWaypointBottomSheetHelper.enterApplyPositionMode();
|
||||
applyMovedObject(obj, ll, new ApplyMovedObjectCallback() {
|
||||
@Override
|
||||
public void onApplyMovedObject(boolean success, @Nullable Object newObject) {
|
||||
mAddWaypointBottomSheetHelper.exitApplyPositionMode();
|
||||
if (success && !cancelApplyingNewMarkerPosition) {
|
||||
mAddWaypointBottomSheetHelper.hide();
|
||||
quitAddGpxWaipoint();
|
||||
|
||||
PointDescription pointDescription = null;
|
||||
if (selectedObjectContextMenuProvider != null) {
|
||||
pointDescription = selectedObjectContextMenuProvider.getObjectName(newObject);
|
||||
}
|
||||
menu.show(ll, pointDescription, newObject);
|
||||
view.refreshMap();
|
||||
}
|
||||
selectedObjectContextMenuProvider = null;
|
||||
applyingMarkerLatLon = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelApplyingNewMarkerPosition;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void enterGpxDetailsMode() {
|
||||
menu.updateMapCenter(null);
|
||||
menu.hide();
|
||||
|
@ -398,6 +449,39 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
|
||||
private void quitAddGpxWaipoint() {
|
||||
mInAddGpxWaypointMode = 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);
|
||||
|
||||
View collapseButton = activity.findViewById(R.id.map_collapse_button);
|
||||
if (collapseButton != null && wasCollapseButtonVisible) {
|
||||
collapseButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void enterAddGpxWaypointMode(NewGpxWaypoint newGpxWaypoint) {
|
||||
menu.updateMapCenter(null);
|
||||
menu.hide();
|
||||
|
||||
activity.disableDrawer();
|
||||
|
||||
mInAddGpxWaypointMode = true;
|
||||
mAddWaypointBottomSheetHelper.show(menu.getLeftIcon(), newGpxWaypoint);
|
||||
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);
|
||||
|
||||
View collapseButton = activity.findViewById(R.id.map_collapse_button);
|
||||
if (collapseButton != null && collapseButton.getVisibility() == View.VISIBLE) {
|
||||
wasCollapseButtonVisible = true;
|
||||
collapseButton.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
wasCollapseButtonVisible = false;
|
||||
}
|
||||
|
||||
view.refreshMap();
|
||||
}
|
||||
|
||||
private void enterMovingMode(RotatedTileBox tileBox) {
|
||||
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
vibrator.vibrate(VIBRATE_SHORT);
|
||||
|
@ -445,6 +529,13 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
applyingMarkerLatLon = null;
|
||||
}
|
||||
|
||||
public void cancelAddGpxWaypoint() {
|
||||
cancelApplyingNewMarkerPosition = true;
|
||||
quitAddGpxWaipoint();
|
||||
activity.getContextMenu().show();
|
||||
applyingMarkerLatLon = null;
|
||||
}
|
||||
|
||||
public boolean showContextMenu(double latitude, double longitude, boolean showUnknownLocation) {
|
||||
RotatedTileBox cp = activity.getMapView().getCurrentRotatedTileBox();
|
||||
float x = cp.getPixXFromLatLon(latitude, longitude);
|
||||
|
@ -550,7 +641,14 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
if (latLon == null) {
|
||||
latLon = getLatLon(point, tileBox);
|
||||
}
|
||||
showContextMenu(latLon, pointDescription, selectedObj, provider);
|
||||
if (mInAddGpxWaypointMode) {
|
||||
if (pointDescription != null) {
|
||||
mAddWaypointBottomSheetHelper.setTitle(pointDescription.getName());
|
||||
}
|
||||
view.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), view.getZoom(), true);
|
||||
} else {
|
||||
showContextMenu(latLon, pointDescription, selectedObj, provider);
|
||||
}
|
||||
return true;
|
||||
|
||||
} else if (selectedObjects.size() > 1) {
|
||||
|
@ -592,7 +690,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public boolean disableLongPressOnMap() {
|
||||
if (mInChangeMarkerPositionMode || mInGpxDetailsMode) {
|
||||
if (mInChangeMarkerPositionMode || mInGpxDetailsMode || mInAddGpxWaypointMode) {
|
||||
return true;
|
||||
}
|
||||
boolean res = false;
|
||||
|
|
|
@ -712,7 +712,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
|
||||
updateMyLocation(rh, routeDialogOpened || trackDialogOpened);
|
||||
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode)
|
||||
&& !isInChangeMarkerPositionMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode();
|
||||
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode();
|
||||
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
|
||||
if (rh.isFollowingMode()) {
|
||||
routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
|
||||
|
@ -1119,9 +1119,9 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
this.mapQuickActionLayer = mapQuickActionLayer;
|
||||
}
|
||||
|
||||
private boolean isInChangeMarkerPositionMode(){
|
||||
return mapQuickActionLayer == null ? contextMenuLayer.isInChangeMarkerPositionMode() :
|
||||
mapQuickActionLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInChangeMarkerPositionMode();
|
||||
private boolean isInMovingMarkerMode(){
|
||||
return mapQuickActionLayer == null ? contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxWaypointMode():
|
||||
mapQuickActionLayer.isInMovingMarkerMode() || contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxWaypointMode();
|
||||
}
|
||||
|
||||
private boolean isInGpxDetailsMode() {
|
||||
|
|
|
@ -54,7 +54,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
private boolean wasCollapseButtonVisible;
|
||||
private int previousMapPosition;
|
||||
|
||||
private boolean inChangeMarkerPositionMode;
|
||||
private boolean inMovingMarkerMode;
|
||||
private boolean isLayerOn;
|
||||
|
||||
private boolean nightMode;
|
||||
|
@ -236,7 +236,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
double lon = rb.getLonFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
||||
view.setLatLon(lat, lon);
|
||||
|
||||
inChangeMarkerPositionMode = true;
|
||||
inMovingMarkerMode = true;
|
||||
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);
|
||||
|
||||
|
@ -271,7 +271,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
}
|
||||
view.setMapPosition(previousMapPosition);
|
||||
|
||||
inChangeMarkerPositionMode = false;
|
||||
inMovingMarkerMode = 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);
|
||||
|
||||
|
@ -293,7 +293,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
|
||||
@Override
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
if (isInChangeMarkerPositionMode() && !pressedQuickActionWidget(point.x, point.y)) {
|
||||
if (isInMovingMarkerMode() && !pressedQuickActionWidget(point.x, point.y)) {
|
||||
setLayerState(false);
|
||||
return true;
|
||||
} else
|
||||
|
@ -307,7 +307,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings settings) {
|
||||
boolean nightMode = settings != null && settings.isNightMode();
|
||||
if (isInChangeMarkerPositionMode()) {
|
||||
if (isInMovingMarkerMode()) {
|
||||
canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight());
|
||||
contextMarker.draw(canvas);
|
||||
}
|
||||
|
@ -356,8 +356,8 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
return new PointF(tb.getPixWidth() / 2, tb.getPixHeight() / 2);
|
||||
}
|
||||
|
||||
public boolean isInChangeMarkerPositionMode() {
|
||||
return isLayerOn && inChangeMarkerPositionMode;
|
||||
public boolean isInMovingMarkerMode() {
|
||||
return isLayerOn && inMovingMarkerMode;
|
||||
}
|
||||
|
||||
public boolean isLayerOn() {
|
||||
|
|
Loading…
Reference in a new issue