From a60e97b18f3bb60379bc3a0f120ad8bf79ca429e Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 16 Nov 2015 01:40:43 +0100 Subject: [PATCH] Add direction from as extra item / revert fab as 1 action --- .../plus/activities/MapActivityActions.java | 56 +++++++++++-------- .../plus/mapcontextmenu/MapContextMenu.java | 6 +- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index cc2b30fe8e..6d5575819d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -1,24 +1,10 @@ package net.osmand.plus.activities; -import android.app.Activity; -import android.app.Dialog; -import android.content.DialogInterface; -import android.content.Intent; -import android.graphics.drawable.Drawable; -import android.os.AsyncTask; -import android.os.Bundle; -import android.support.v7.app.AlertDialog; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.EditText; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; +import java.io.File; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import net.londatiga.android.ActionItem; import net.londatiga.android.QuickAction; @@ -58,11 +44,25 @@ import net.osmand.util.MapUtils; import org.apache.commons.logging.Log; -import java.io.File; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import android.app.Activity; +import android.app.Dialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.v7.app.AlertDialog; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.view.WindowManager; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; public class MapActivityActions implements DialogProvider { private static final Log LOG = PlatformUtil.getLog(MapActivityActions.class); @@ -335,6 +335,10 @@ public class MapActivityActions implements DialogProvider { public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) { final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter(mapActivity) : iadapter; adapter.item(R.string.context_menu_item_search).iconColor(R.drawable.ic_action_search_dark).reg(); + if (!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) { + adapter.item(R.string.context_menu_item_directions_from).iconColor( + R.drawable.ic_action_gdirections_dark).reg(); + } OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj); getMyApplication().getAppCustomization().prepareLocationMenu(mapActivity, adapter); @@ -355,6 +359,10 @@ public class MapActivityActions implements DialogProvider { intent.putExtra(SearchActivity.SEARCH_LON, longitude); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); mapActivity.startActivity(intent); + } else if (standardId == R.string.context_menu_item_directions_to) { + final TargetPointsHelper targets = getMyApplication().getTargetPointsHelper(); + targets.navigateToPoint(new LatLon(latitude, longitude), true, -1, null); + enterRoutePlanningMode(null, null, false); } } }); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index b773adf54f..ee83db7c9c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -336,7 +336,6 @@ public class MapContextMenu extends MenuTitleController { protected void acquireIcons() { super.acquireIcons(); - if (menuController != null) { favActionIconId = menuController.getFavActionIconId(); } else { @@ -345,10 +344,9 @@ public class MapContextMenu extends MenuTitleController { } public void fabPressed() { - mapActivity.getMapActions().showNavigationContextMenuPoint(latLon.getLatitude(), latLon.getLongitude()); - //mapActivity.getMapActions().directionTo(latLon.getLatitude(), latLon.getLongitude()); + mapActivity.getMapActions().directionTo(latLon.getLatitude(), latLon.getLongitude(), getPointDescription()); hide(); - //mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog(); + mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog(); } public void buttonWaypointPressed() {