diff --git a/OsmAnd/src/net/londatiga/android/QuickAction.java b/OsmAnd/src/net/londatiga/android/QuickAction.java index 70166587dc..1bdf7424f5 100644 --- a/OsmAnd/src/net/londatiga/android/QuickAction.java +++ b/OsmAnd/src/net/londatiga/android/QuickAction.java @@ -117,6 +117,15 @@ public class QuickAction extends CustomPopupWindow { actionList.add(action); } + /** + * Add action item + * + * @param action {@link ActionItem} + */ + public void addActionItem(ActionItem action, int pos) { + actionList.add(pos, action); + } + /** * Show popup window */ diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 5dc7a06e33..54d1302f09 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -966,6 +966,7 @@ public class OsmandSettings { public final static String POINT_NAVIGATE_LAT = "point_navigate_lat"; //$NON-NLS-1$ public final static String POINT_NAVIGATE_LON = "point_navigate_lon"; //$NON-NLS-1$ + public final static String POINT_NAVIGATE_ROUTE = "point_navigate_route"; //$NON-NLS-1$ public LatLon getPointToNavigate() { float lat = globalPreferences.getFloat(POINT_NAVIGATE_LAT, 0); @@ -975,13 +976,27 @@ public class OsmandSettings { } return new LatLon(lat, lon); } - + + public boolean isRouteToPointNavigateAndClear(){ + boolean t = globalPreferences.contains(POINT_NAVIGATE_ROUTE); + globalPreferences.edit().remove(POINT_NAVIGATE_ROUTE).commit(); + return t; + } + public boolean clearPointToNavigate() { - return globalPreferences.edit().remove(POINT_NAVIGATE_LAT).remove(POINT_NAVIGATE_LON).commit(); + return globalPreferences.edit().remove(POINT_NAVIGATE_LAT).remove(POINT_NAVIGATE_LON). + remove(POINT_NAVIGATE_ROUTE).commit(); + } + + public boolean setPointToNavigate(double latitude, double longitude, String historyDescription) { + return setPointToNavigate(latitude, longitude, false, historyDescription); } - public boolean setPointToNavigate(double latitude, double longitude, String historyDescription) { + public boolean setPointToNavigate(double latitude, double longitude, boolean navigate, String historyDescription) { boolean add = globalPreferences.edit().putFloat(POINT_NAVIGATE_LAT, (float) latitude).putFloat(POINT_NAVIGATE_LON, (float) longitude).commit(); + if(navigate) { + globalPreferences.edit().putString(POINT_NAVIGATE_ROUTE, "true").commit(); + } if(add){ if(historyDescription != null){ SearchHistoryHelper.getInstance().addNewItemToHistory(latitude, longitude, historyDescription, ctx); diff --git a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java index 7ecbe2315d..b1ab85fd3c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java @@ -16,6 +16,8 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; +import net.londatiga.android.ActionItem; +import net.londatiga.android.QuickAction; import net.osmand.FavouritePoint; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; @@ -36,6 +38,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; +import android.view.View.OnClickListener; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -227,12 +230,42 @@ public class FavouritesActivity extends OsmandExpandableListActivity { favoritesToDelete.remove(model); } } else { - FavouritePoint point = (FavouritePoint) favouritesAdapter.getChild(groupPosition, childPosition); - OsmandSettings settings = getMyApplication().getSettings(); - settings.SHOW_FAVORITES.set(true); - settings.setMapLocationToShow(point.getLatitude(), point.getLongitude(), - Math.max(12, settings.getLastKnownMapZoom()), null, getString(R.string.favorite)+":\n " + point.getName(), point); - MapActivity.launchMapActivityMoveToTop(FavouritesActivity.this); + QuickAction qa = new QuickAction(v); + final OsmandSettings settings = getMyApplication().getSettings(); + final FavouritePoint point = (FavouritePoint) favouritesAdapter.getChild(groupPosition, childPosition); + String name = getString(R.string.favorite) + ": " + point.getName(); + LatLon location = new LatLon(point.getLatitude(), point.getLongitude()); + OnClickListener onshow = new OnClickListener() { + @Override + public void onClick(View v) { + settings.SHOW_FAVORITES.set(true); + } + }; + MapActivityActions.createDirectionsActions(qa, location, point, name, settings.getLastKnownMapZoom(), this, + true, onshow); + if (point.isStored()) { + ActionItem edit = new ActionItem(); + edit.setTitle(getString(R.string.favourites_context_menu_edit)); + edit.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + editPoint(point); + } + }); + qa.addActionItem(edit); + + ActionItem delete = new ActionItem(); + delete.setTitle(getString(R.string.favourites_context_menu_delete)); + delete.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + deletePoint(point); + } + }); + qa.addActionItem(delete); + } + + qa.show(); } return true; } @@ -253,56 +286,64 @@ public class FavouritesActivity extends OsmandExpandableListActivity { getMyApplication().getSettings().setPointToNavigate(point.getLatitude(), point.getLongitude(), getString(R.string.favorite)+" : " + point.getName()); MapActivity.launchMapActivityMoveToTop(this); } else if (aItem.getItemId() == EDIT_ITEM) { - Builder builder = new AlertDialog.Builder(this); - builder.setTitle(R.string.favourites_context_menu_edit); - final View v = getLayoutInflater().inflate(R.layout.favourite_edit_dialog, getExpandableListView(), false); - final AutoCompleteTextView cat = (AutoCompleteTextView) v.findViewById(R.id.Category); - final EditText editText = (EditText) v.findViewById(R.id.Name); - builder.setView(v); - editText.setText(point.getName()); - cat.setText(point.getCategory()); - cat.setThreshold(1); - cat.setAdapter(new ArrayAdapter(this, R.layout.list_textview, helper.getFavoriteGroups().keySet().toArray(new String[] {}))); - builder.setNegativeButton(R.string.default_buttons_cancel, null); - builder.setPositiveButton(R.string.default_buttons_apply, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - boolean editied = helper.editFavouriteName(point, editText.getText().toString(), cat.getText().toString()); - if (editied) { - favouritesAdapter.synchronizeGroups(); - favouritesAdapter.sort(favoritesComparator); - } - - } - }); - builder.create().show(); - editText.requestFocus(); - return true; + return editPoint(point); } if (aItem.getItemId() == DELETE_ITEM) { - final Resources resources = this.getResources(); - Builder builder = new AlertDialog.Builder(this); - builder.setMessage(getString(R.string.favourites_remove_dialog_msg, point.getName())); - builder.setNegativeButton(R.string.default_buttons_no, null); - builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - boolean deleted = helper.deleteFavourite(point); - if (deleted) { - AccessibleToast.makeText(FavouritesActivity.this, - MessageFormat.format(resources.getString(R.string.favourites_remove_dialog_success), point.getName()), - Toast.LENGTH_SHORT).show(); - favouritesAdapter.synchronizeGroups(); - favouritesAdapter.sort(favoritesComparator); - } - - } - }); - builder.create().show(); - return true; + return deletePoint(point); } return false; } + + private boolean editPoint(final FavouritePoint point) { + Builder builder = new AlertDialog.Builder(this); + builder.setTitle(R.string.favourites_context_menu_edit); + final View v = getLayoutInflater().inflate(R.layout.favourite_edit_dialog, getExpandableListView(), false); + final AutoCompleteTextView cat = (AutoCompleteTextView) v.findViewById(R.id.Category); + final EditText editText = (EditText) v.findViewById(R.id.Name); + builder.setView(v); + editText.setText(point.getName()); + cat.setText(point.getCategory()); + cat.setThreshold(1); + cat.setAdapter(new ArrayAdapter(this, R.layout.list_textview, helper.getFavoriteGroups().keySet().toArray(new String[] {}))); + builder.setNegativeButton(R.string.default_buttons_cancel, null); + builder.setPositiveButton(R.string.default_buttons_apply, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + boolean editied = helper.editFavouriteName(point, editText.getText().toString(), cat.getText().toString()); + if (editied) { + favouritesAdapter.synchronizeGroups(); + favouritesAdapter.sort(favoritesComparator); + } + + } + }); + builder.create().show(); + editText.requestFocus(); + return true; + } + + private boolean deletePoint(final FavouritePoint point) { + final Resources resources = this.getResources(); + Builder builder = new AlertDialog.Builder(this); + builder.setMessage(getString(R.string.favourites_remove_dialog_msg, point.getName())); + builder.setNegativeButton(R.string.default_buttons_no, null); + builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + boolean deleted = helper.deleteFavourite(point); + if (deleted) { + AccessibleToast.makeText(FavouritesActivity.this, + MessageFormat.format(resources.getString(R.string.favourites_remove_dialog_success), point.getName()), + Toast.LENGTH_SHORT).show(); + favouritesAdapter.synchronizeGroups(); + favouritesAdapter.sort(favoritesComparator); + } + + } + }); + builder.create().show(); + return true; + } @Override public boolean onCreateOptionsMenu(Menu menu) { diff --git a/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java b/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java index 7cfc417b0d..dece0e2de9 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java @@ -6,6 +6,7 @@ package net.osmand.plus.activities; import java.util.Comparator; import java.util.List; +import net.londatiga.android.QuickAction; import net.osmand.FavouritePoint; import net.osmand.OsmAndFormatter; import net.osmand.osm.LatLon; @@ -24,7 +25,6 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.ImageView; @@ -85,12 +85,13 @@ public class FavouritesListActivity extends ListActivity implements SearchActivi locationUpdate(location); if (!isSelectFavoriteMode()) { - getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { - @Override - public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { - return FavouritesListActivity.this.onItemLongClick(position); - } - }); + // TODO remove if not needed +// getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { +// @Override +// public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { +// return FavouritesListActivity.this.onItemLongClick(position); +// } +// }); } } @@ -147,11 +148,20 @@ public class FavouritesListActivity extends ListActivity implements SearchActivi protected void onListItemClick(ListView l, View v, int position, long id) { if (!isSelectFavoriteMode()) { + QuickAction qa = new QuickAction(v); FavouritePoint point = favouritesAdapter.getItem(position); - settings.SHOW_FAVORITES.set(true); - settings.setMapLocationToShow(point.getLatitude(), point.getLongitude(), settings.getLastKnownMapZoom(), null, - getString(R.string.favorite) + ": \n " + point.getName(), point); //$NON-NLS-1$ - MapActivity.launchMapActivityMoveToTop(FavouritesListActivity.this); + String name = getString(R.string.favorite) + ": " + point.getName(); + LatLon location = new LatLon(point.getLatitude(), point.getLongitude()); + View.OnClickListener onshow = new View.OnClickListener() { + + @Override + public void onClick(View v) { + settings.SHOW_FAVORITES.set(true); + } + }; + MapActivityActions.createDirectionsActions(qa, location, point, name, settings.getLastKnownMapZoom(), this, + true, onshow); + qa.show(); } else { Intent intent = getIntent(); intent.putExtra(SELECT_FAVORITE_POINT_INTENT_KEY, favouritesAdapter.getItem(position)); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 718f0cf597..51822acbc0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -297,6 +297,10 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe LatLon latLonToShow = settings.getAndClearMapLocationToShow(); String mapLabelToShow = settings.getAndClearMapLabelToShow(); Object toShow = settings.getAndClearObjectToShow(); + if(settings.isRouteToPointNavigateAndClear()){ + // always enable and follow and let calculate it (GPS is not accessible in garage) + mapActions.getDirections(getLastKnownLocation(), true); + } if(mapLabelToShow != null && latLonToShow != null){ mapLayers.getContextMenuLayer().setSelectedObject(toShow); mapLayers.getContextMenuLayer().setLocation(latLonToShow, mapLabelToShow); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index bc1ef65b2d..68c7f01ace 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -9,6 +9,8 @@ import java.util.Date; import java.util.Iterator; import java.util.List; +import net.londatiga.android.ActionItem; +import net.londatiga.android.QuickAction; import net.osmand.AndroidUtils; import net.osmand.CallbackWithObject; import net.osmand.FavouritePoint; @@ -66,6 +68,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.Button; @@ -394,7 +397,7 @@ public class MapActivityActions implements DialogProvider { } - protected void getDirections(final Location from, boolean followEnabled) { + public void getDirections(final Location from, boolean followEnabled) { final RoutingHelper routingHelper = mapActivity.getRoutingHelper(); @@ -1066,4 +1069,53 @@ public class MapActivityActions implements DialogProvider { }); menu.show(); } + + public static void createDirectionsActions(QuickAction qa , final LatLon location, final Object obj, final String name, final int z, final Activity activity, + final boolean saveHistory, final OnClickListener onShow){ + ActionItem showOnMap = new ActionItem(); + final OsmandApplication app = ((OsmandApplication) activity.getApplication()); + showOnMap.setIcon(activity.getResources().getDrawable(android.R.drawable.ic_dialog_map)); + showOnMap.setTitle(activity.getString(R.string.show_poi_on_map)); + showOnMap.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if(onShow != null) { + onShow.onClick(v); + } + app.getSettings().setMapLocationToShow( location.getLatitude(), location.getLongitude(), + z, saveHistory ? name : null, name, obj); //$NON-NLS-1$ + MapActivity.launchMapActivityMoveToTop(activity); + } + }); + qa.addActionItem(showOnMap); + ActionItem setAsDestination = new ActionItem(); + setAsDestination.setIcon(activity.getResources().getDrawable(R.drawable.list_view_set_destination)); + setAsDestination.setTitle(activity.getString(R.string.navigate_to)); + setAsDestination.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if(onShow != null) { + onShow.onClick(v); + } + app.getSettings().setPointToNavigate(location.getLatitude(), location.getLongitude(), name); + MapActivity.launchMapActivityMoveToTop(activity); + } + }); + qa.addActionItem(setAsDestination); + + ActionItem directionsTo = new ActionItem(); + directionsTo.setIcon(activity.getResources().getDrawable(R.drawable.list_view_directions_to_here)); + directionsTo.setTitle(activity.getString(R.string.context_menu_item_directions)); + directionsTo.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if(onShow != null) { + onShow.onClick(v); + } + app.getSettings().setPointToNavigate(location.getLatitude(), location.getLongitude(), true, name); + MapActivity.launchMapActivityMoveToTop(activity); + } + }); + qa.addActionItem(directionsTo); + } } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryActivity.java index 557b49ce14..36970c22fb 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryActivity.java @@ -2,6 +2,8 @@ package net.osmand.plus.activities.search; import java.util.List; +import net.londatiga.android.QuickAction; +import net.osmand.FavouritePoint; import net.osmand.OsmAndFormatter; import net.osmand.osm.LatLon; import net.osmand.osm.MapUtils; @@ -9,6 +11,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.activities.MapActivityActions; import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild; import net.osmand.plus.activities.search.SearchHistoryHelper.HistoryEntry; import android.app.AlertDialog; @@ -18,6 +21,7 @@ import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; @@ -123,14 +127,22 @@ public class SearchHistoryActivity extends ListActivity implements SearchActivi @Override protected void onListItemClick(ListView l, View v, int position, long id) { HistoryEntry model = ((HistoryAdapter) getListAdapter()).getItem(position); - selectModel(model); + selectModel(model, v); } - private void selectModel(HistoryEntry model) { - helper.selectEntry(model, this); + private void selectModel(final HistoryEntry model, View v) { + QuickAction qa = new QuickAction(v); + String name = model.getName(); OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings(); - settings.setMapLocationToShow(model.getLat(), model.getLon(), settings.getLastKnownMapZoom(), null, model.getName(), null); - MapActivity.launchMapActivityMoveToTop(this); + OnClickListener onShow = new View.OnClickListener() { + @Override + public void onClick(View v) { + helper.selectEntry(model, SearchHistoryActivity.this); + } + }; + MapActivityActions.createDirectionsActions(qa, new LatLon(model.getLat(), model.getLon()), + model, name, settings.getLastKnownMapZoom(), this, false, onShow); + qa.show(); } class HistoryAdapter extends ArrayAdapter { @@ -168,18 +180,18 @@ public class SearchHistoryActivity extends ListActivity implements SearchActivi View.OnClickListener clickListener = new View.OnClickListener() { @Override public void onClick(View v) { - selectModel(model); + selectModel(model, v); } }; - View.OnLongClickListener longClickListener = new View.OnLongClickListener() { - @Override - public boolean onLongClick(View v) { - return onItemLongClick(position); - } - }; - distanceLabel.setOnLongClickListener(longClickListener); - label.setOnLongClickListener(longClickListener); +// View.OnLongClickListener longClickListener = new View.OnLongClickListener() { +// @Override +// public boolean onLongClick(View v) { +// return onItemLongClick(position); +// } +// }; +// distanceLabel.setOnLongClickListener(longClickListener); +// label.setOnLongClickListener(longClickListener); distanceLabel.setOnClickListener(clickListener); label.setOnClickListener(clickListener); return row; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index d3d0bfd6ac..b9c85740c6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -15,6 +15,8 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import net.londatiga.android.ActionItem; +import net.londatiga.android.QuickAction; import net.osmand.Algoritms; import net.osmand.LogUtil; import net.osmand.OsmAndFormatter; @@ -26,7 +28,6 @@ import net.osmand.data.AmenityType; import net.osmand.osm.LatLon; import net.osmand.osm.OpeningHoursParser; import net.osmand.osm.OpeningHoursParser.OpeningHours; -import net.osmand.osm.OpeningHoursParser.OpeningHoursRule; import net.osmand.plus.NameFinderPoiFilter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; @@ -36,8 +37,10 @@ import net.osmand.plus.SearchByNameFilter; import net.osmand.plus.activities.CustomTitleBar; import net.osmand.plus.activities.EditPOIFilterActivity; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.activities.MapActivityActions; import net.osmand.plus.activities.OsmandListActivity; import android.app.AlertDialog; +import android.app.AlertDialog.Builder; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -68,9 +71,9 @@ import android.util.DisplayMetrics; import android.util.Log; import android.view.LayoutInflater; import android.view.View; -import android.view.WindowManager; 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; @@ -230,14 +233,15 @@ public class SearchPOIActivity extends OsmandListActivity implements SensorEvent // ListActivity has a ListView, which you can get with: ListView lv = getListView(); - lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { - @Override - public boolean onItemLongClick(AdapterView av, View v, int pos, long id) { - final Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(pos); - onLongClick(amenity); - return true; - } - }); + // TODO remove if not needed +// lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { +// @Override +// public boolean onItemLongClick(AdapterView av, View v, int pos, long id) { +// final Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(pos); +// onLongClick(amenity); +// return true; +// } +// }); } private Path createDirectionPath() { @@ -559,16 +563,58 @@ public class SearchPOIActivity extends OsmandListActivity implements SensorEvent currentLocationProvider = null; } } + + @Override public void onListItemClick(ListView parent, View v, int position, long id) { - int z = settings.getLastKnownMapZoom(); - Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(position); - String poiSimpleFormat = OsmAndFormatter.getPoiSimpleFormat(amenity, this, settings.usingEnglishNames()); + final Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(position); + QuickAction qa = new QuickAction(v); + String poiSimpleFormat = OsmAndFormatter.getPoiSimpleFormat(amenity, SearchPOIActivity.this, settings.usingEnglishNames()); String name = getString(R.string.poi)+" : " + poiSimpleFormat; - settings.setMapLocationToShow( amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), - Math.max(16, z), name, name, amenity); //$NON-NLS-1$ - MapActivity.launchMapActivityMoveToTop(SearchPOIActivity.this); + int z = Math.max(16, settings.getLastKnownMapZoom()); + MapActivityActions.createDirectionsActions(qa, amenity.getLocation(), amenity, name, z, this, true , null); + ActionItem poiDescription = new ActionItem(); + poiDescription.setTitle(getString(R.string.poi_context_menu_showdescription)); + poiDescription.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + Builder bs = new AlertDialog.Builder(v.getContext()); + bs.setTitle(OsmAndFormatter.getPoiSimpleFormat(amenity, v.getContext(), settings.USE_ENGLISH_NAMES.get())); + StringBuilder d = new StringBuilder(); + if(amenity.getOpeningHours() != null) { + d.append(getString(R.string.opening_hours) + " : ").append(amenity.getOpeningHours()).append("\n"); + } + if(amenity.getPhone() != null) { + d.append(getString(R.string.phone) + " : ").append(amenity.getPhone()).append("\n"); + } + if(amenity.getSite() != null) { + d.append(getString(R.string.website) + " : ").append(amenity.getSite()).append("\n"); + } + if(amenity.getDescription() != null) { + d.append(amenity.getDescription()); + } + bs.setMessage(d.toString()); + bs.show(); + } + }); + qa.addActionItem(poiDescription, 2); + if (((OsmandApplication)getApplication()).accessibilityEnabled()) { + ActionItem showDetails = new ActionItem(); + showDetails.setTitle(getString(R.string.show_details)); + showDetails.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + showPOIDetails(amenity, settings.usingEnglishNames()); + } + }); + qa.addActionItem(showDetails); + } + qa.show(); + + }