Convert Markers to dashboard. Add sorting

This commit is contained in:
Alexey Kulish 2016-02-08 20:15:17 +03:00
parent 1456b5e328
commit ac4d6b16a4
8 changed files with 229 additions and 252 deletions

View file

@ -166,7 +166,6 @@
<activity android:name="net.osmand.plus.activities.PluginsActivity" /> <activity android:name="net.osmand.plus.activities.PluginsActivity" />
<activity android:name="net.osmand.plus.activities.PluginActivity" /> <activity android:name="net.osmand.plus.activities.PluginActivity" />
<activity android:name="net.osmand.plus.activities.ContributionVersionActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/contribution_activity" /> <activity android:name="net.osmand.plus.activities.ContributionVersionActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/contribution_activity" />
<activity android:name="net.osmand.plus.activities.MapMarkersActivity"/>
<activity android:name="net.osmand.plus.osmo.SettingsOsMoActivity" android:configChanges="keyboardHidden|orientation" /> <activity android:name="net.osmand.plus.osmo.SettingsOsMoActivity" android:configChanges="keyboardHidden|orientation" />

View file

@ -30,6 +30,7 @@ public class MapMarkersHelper {
public int colorIndex; public int colorIndex;
public int index; public int index;
public boolean history; public boolean history;
public int dist;
public MapMarker(LatLon point, PointDescription name, int colorIndex, int index) { public MapMarker(LatLon point, PointDescription name, int colorIndex, int index) {
this.point = point; this.point = point;

View file

@ -1,15 +1,11 @@
package net.osmand.plus; package net.osmand.plus;
import java.io.File; import android.app.Activity;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import net.osmand.IProgress; import net.osmand.IProgress;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.data.LocationPoint; import net.osmand.data.LocationPoint;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapMarkersActivity;
import net.osmand.plus.activities.PluginsActivity; import net.osmand.plus.activities.PluginsActivity;
import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.activities.TrackActivity;
@ -20,7 +16,11 @@ import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.routing.RouteCalculationResult;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import android.app.Activity;
import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public class OsmAndAppCustomization { public class OsmAndAppCustomization {
@ -68,10 +68,6 @@ public class OsmAndAppCustomization {
return FavoritesActivity.class; return FavoritesActivity.class;
} }
public Class<MapMarkersActivity> getMapMarkersActivity(){
return MapMarkersActivity.class;
}
public Class<? extends Activity> getDownloadIndexActivity() { public Class<? extends Activity> getDownloadIndexActivity() {
return DownloadActivity.class; return DownloadActivity.class;
} }

View file

@ -577,8 +577,8 @@ public class MapActivityActions implements DialogProvider {
@Override @Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent(); MapActivity.clearPrevActivityIntent();
openMapMarkersActivity(); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.MAP_MARKERS);
return true; return false;
} }
}).reg(); }).reg();
optionsMenuHelper.item(R.string.get_directions).iconColor(R.drawable.ic_action_gdirections_dark) optionsMenuHelper.item(R.string.get_directions).iconColor(R.drawable.ic_action_gdirections_dark)
@ -746,13 +746,6 @@ public class MapActivityActions implements DialogProvider {
return optionsMenuHelper; return optionsMenuHelper;
} }
public void openMapMarkersActivity() {
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getMapMarkersActivity());
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
}
public void openIntermediatePointsDialog() { public void openIntermediatePointsDialog() {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
} }

View file

@ -41,6 +41,8 @@ import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick; import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -54,6 +56,7 @@ import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.dialogs.RasterMapMenu; import net.osmand.plus.dialogs.RasterMapMenu;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.MapMarkerDialogHelper;
import net.osmand.plus.helpers.WaypointDialogHelper; import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointDialogHelper.WaypointDialogHelperCallbacks; import net.osmand.plus.helpers.WaypointDialogHelper.WaypointDialogHelperCallbacks;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
@ -68,6 +71,7 @@ import net.osmand.plus.views.controls.DynamicListView;
import net.osmand.plus.views.controls.DynamicListViewCallbacks; import net.osmand.plus.views.controls.DynamicListViewCallbacks;
import net.osmand.plus.views.controls.StableArrayAdapter; import net.osmand.plus.views.controls.StableArrayAdapter;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener; import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.DismissCallbacks;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.Undoable; import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.Undoable;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
@ -141,6 +145,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
int baseColor; int baseColor;
private WaypointDialogHelper waypointDialogHelper; private WaypointDialogHelper waypointDialogHelper;
private MapMarkerDialogHelper mapMarkerDialogHelper;
private final int[] running = new int[]{-1}; private final int[] running = new int[]{-1};
private List<LocationPointWrapper> deletedPoints = new ArrayList<>(); private List<LocationPointWrapper> deletedPoints = new ArrayList<>();
private Drawable gradientToolbar; private Drawable gradientToolbar;
@ -159,7 +164,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
ROUTE_PREFERENCES, ROUTE_PREFERENCES,
DASHBOARD, DASHBOARD,
OVERLAY_MAP, OVERLAY_MAP,
UNDERLAY_MAP UNDERLAY_MAP,
MAP_MARKERS
} }
private Map<DashboardActionButtonType, DashboardActionButton> actionButtons = new HashMap<>(); private Map<DashboardActionButtonType, DashboardActionButton> actionButtons = new HashMap<>();
@ -184,6 +190,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
baseColor = mapActivity.getResources().getColor(R.color.osmand_orange) & 0x00ffffff; baseColor = mapActivity.getResources().getColor(R.color.osmand_orange) & 0x00ffffff;
waypointDialogHelper = new WaypointDialogHelper(mapActivity); waypointDialogHelper = new WaypointDialogHelper(mapActivity);
waypointDialogHelper.setWaypointDialogHelperCallbacks(this); waypointDialogHelper.setWaypointDialogHelperCallbacks(this);
mapMarkerDialogHelper = new MapMarkerDialogHelper(mapActivity);
landscape = !AndroidUiHelper.isOrientationPortrait(mapActivity); landscape = !AndroidUiHelper.isOrientationPortrait(mapActivity);
dashboardView = (FrameLayout) mapActivity.findViewById(R.id.dashboard); dashboardView = (FrameLayout) mapActivity.findViewById(R.id.dashboard);
final View.OnClickListener listener = new View.OnClickListener() { final View.OnClickListener listener = new View.OnClickListener() {
@ -204,11 +211,14 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
// the pressed state (the list selector), handling list item clicks, etc. // the pressed state (the list selector), handling list item clicks, etc.
swipeDismissListener = new SwipeDismissListViewTouchListener( swipeDismissListener = new SwipeDismissListViewTouchListener(
listView, listView,
new SwipeDismissListViewTouchListener.DismissCallbacks() { new DismissCallbacks() {
private List<Object> deletedMarkers = new ArrayList<>();
@Override @Override
public boolean canDismiss(int position) { public boolean canDismiss(int position) {
boolean res = false; boolean res = false;
if (visibleType == DashboardType.WAYPOINTS && listAdapter instanceof StableArrayAdapter) { if (listAdapter instanceof StableArrayAdapter) {
List<Object> activeObjects = ((StableArrayAdapter) listAdapter).getActiveObjects(); List<Object> activeObjects = ((StableArrayAdapter) listAdapter).getActiveObjects();
Object obj = listAdapter.getItem(position); Object obj = listAdapter.getItem(position);
res = activeObjects.contains(obj); res = activeObjects.contains(obj);
@ -225,6 +235,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
stableAdapter = (StableArrayAdapter) listAdapter; stableAdapter = (StableArrayAdapter) listAdapter;
item = stableAdapter.getItem(position); item = stableAdapter.getItem(position);
if (visibleType == DashboardType.MAP_MARKERS) {
if (!((MapMarker) item).history) {
deletedMarkers.add(item);
}
}
stableAdapter.setNotifyOnChange(false); stableAdapter.setNotifyOnChange(false);
stableAdapter.remove(item); stableAdapter.remove(item);
stableAdapter.getObjects().remove(item); stableAdapter.getObjects().remove(item);
@ -247,13 +263,19 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
stableAdapter.getObjects().add(position, item); stableAdapter.getObjects().add(position, item);
stableAdapter.getActiveObjects().add(activeObjPos, item); stableAdapter.getActiveObjects().add(activeObjPos, item);
stableAdapter.refreshData(); stableAdapter.refreshData();
onItemsSwapped(stableAdapter.getActiveObjects()); if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
onItemsSwapped(stableAdapter.getActiveObjects());
} else if (visibleType == DashboardType.MAP_MARKERS) {
deletedMarkers.remove(item);
updateMapMarkers(stableAdapter.getActiveObjects());
reloadAdapter();
}
} }
} }
@Override @Override
public String getTitle() { public String getTitle() {
if (visibleType == DashboardType.WAYPOINTS if ((visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT)
&& (getMyApplication().getRoutingHelper().isRoutePlanningMode() || getMyApplication().getRoutingHelper().isFollowingMode()) && (getMyApplication().getRoutingHelper().isRoutePlanningMode() || getMyApplication().getRoutingHelper().isFollowingMode())
&& item != null && item != null
&& stableAdapter.getActiveObjects().size() == 0) { && stableAdapter.getActiveObjects().size() == 0) {
@ -270,14 +292,45 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
if (listAdapter instanceof StableArrayAdapter) { if (listAdapter instanceof StableArrayAdapter) {
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter; StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
stableAdapter.refreshData(); stableAdapter.refreshData();
onItemsSwapped(stableAdapter.getActiveObjects()); if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
onItemsSwapped(stableAdapter.getActiveObjects());
} else if (visibleType == DashboardType.MAP_MARKERS) {
updateMapMarkers(stableAdapter.getActiveObjects());
}
if (stableAdapter.getActiveObjects().size() == 0) { if (stableAdapter.getActiveObjects().size() == 0) {
hideDashboard(); hideDashboard();
mapActivity.getMapActions().stopNavigationWithoutConfirm(); if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide(); mapActivity.getMapActions().stopNavigationWithoutConfirm();
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide();
}
} else {
if (visibleType == DashboardType.MAP_MARKERS) {
reloadAdapter();
}
} }
} }
} }
private void updateMapMarkers(List<Object> objects) {
List<MapMarker> markers = new ArrayList<>();
List<MapMarker> markersHistory = new ArrayList<>();
for (Object obj : objects) {
MapMarker marker = (MapMarker) obj;
if (!marker.history) {
markers.add(marker);
} else {
markersHistory.add(marker);
}
}
for (int i = deletedMarkers.size() - 1; i >= 0; i--) {
markersHistory.add(0, (MapMarker) deletedMarkers.get(i));
}
deletedMarkers.clear();
getMyApplication().getMapMarkersHelper().saveMapMarkers(markers, markersHistory);
}
}); });
gradientToolbar = mapActivity.getResources().getDrawable(R.drawable.gradient_toolbar).mutate(); gradientToolbar = mapActivity.getResources().getDrawable(R.drawable.gradient_toolbar).mutate();
@ -358,6 +411,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
tv.setText(R.string.map_underlay); tv.setText(R.string.map_underlay);
} else if (visibleType == DashboardType.OVERLAY_MAP) { } else if (visibleType == DashboardType.OVERLAY_MAP) {
tv.setText(R.string.map_overlay); tv.setText(R.string.map_overlay);
} else if (visibleType == DashboardType.MAP_MARKERS) {
tv.setText(R.string.map_markers);
} }
ImageView edit = (ImageView) dashboardView.findViewById(R.id.toolbar_edit); ImageView edit = (ImageView) dashboardView.findViewById(R.id.toolbar_edit);
edit.setVisibility(View.GONE); edit.setVisibility(View.GONE);
@ -399,17 +454,19 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}); });
} }
} }
// if (waypointsEdit) {
// ok.setVisibility(View.VISIBLE); if (visibleType == DashboardType.MAP_MARKERS
// ok.setOnClickListener(new View.OnClickListener() { && getMyApplication().getMapMarkersHelper().getActiveMapMarkers().size() > 0) {
// sort.setVisibility(View.VISIBLE);
// @Override sort.setOnClickListener(new View.OnClickListener() {
// public void onClick(View v) { @Override
// mapActivity.getMyApplication().getWaypointHelper().removeVisibleLocationPoint(deletedPoints); public void onClick(View v) {
// hideDashboard(); mapMarkerDialogHelper.setSorted(!mapMarkerDialogHelper.isSorted());
// } reloadAdapter();
// }); }
// } });
}
if (visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.LIST_MENU) { if (visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.LIST_MENU) {
settingsButton.setVisibility(View.VISIBLE); settingsButton.setVisibility(View.VISIBLE);
settingsButton.setOnClickListener(new View.OnClickListener() { settingsButton.setOnClickListener(new View.OnClickListener() {
@ -672,7 +729,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} else { } else {
listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark)); listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
} }
if (visibleType != DashboardType.WAYPOINTS) { if (visibleType != DashboardType.WAYPOINTS && visibleType != DashboardType.MAP_MARKERS) {
Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_dark)); Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_dark));
listView.setDivider(d); listView.setDivider(d);
listView.setDividerHeight(dpToPx(1f)); listView.setDividerHeight(dpToPx(1f));
@ -685,7 +742,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} else { } else {
listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light)); listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light));
} }
if (visibleType != DashboardType.WAYPOINTS) { if (visibleType != DashboardType.WAYPOINTS && visibleType != DashboardType.MAP_MARKERS) {
Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_light)); Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_light));
listView.setDivider(d); listView.setDivider(d);
listView.setDividerHeight(dpToPx(1f)); listView.setDividerHeight(dpToPx(1f));
@ -703,6 +760,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
private void updateListAdapter() { private void updateListAdapter() {
ContextMenuAdapter cm = null; ContextMenuAdapter cm = null;
if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) { if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
StableArrayAdapter listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running, StableArrayAdapter listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running,
DashboardType.WAYPOINTS_FLAT == visibleType, nightMode); DashboardType.WAYPOINTS_FLAT == visibleType, nightMode);
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running, OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
@ -714,7 +772,20 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
updateListAdapter(listAdapter, listener); updateListAdapter(listAdapter, listener);
} else if (DashboardType.MAP_MARKERS == visibleType) {
mapMarkerDialogHelper.setNightMode(nightMode);
StableArrayAdapter listAdapter = mapMarkerDialogHelper.getMapMarkersListAdapter();
OnItemClickListener listener = mapMarkerDialogHelper.getItemClickListener(listAdapter);
DynamicListView dynamicListView = (DynamicListView) listView;
dynamicListView.setItemsList(listAdapter.getObjects());
dynamicListView.setActiveItemsList(listAdapter.getActiveObjects());
updateListAdapter(listAdapter, listener);
} else { } else {
if (DashboardType.CONFIGURE_SCREEN == visibleType) { if (DashboardType.CONFIGURE_SCREEN == visibleType) {
cm = mapActivity.getMapLayers().getMapWidgetRegistry().getViewConfigureMenuAdapter(mapActivity); cm = mapActivity.getMapLayers().getMapWidgetRegistry().getViewConfigureMenuAdapter(mapActivity);
} else if (DashboardType.CONFIGURE_MAP == visibleType) { } else if (DashboardType.CONFIGURE_MAP == visibleType) {
@ -749,7 +820,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} }
public void refreshContent(boolean force) { public void refreshContent(boolean force) {
if (visibleType == DashboardType.WAYPOINTS || force) { if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.MAP_MARKERS || force) {
updateListAdapter(); updateListAdapter();
} else if (visibleType == DashboardType.CONFIGURE_MAP || visibleType == DashboardType.ROUTE_PREFERENCES) { } else if (visibleType == DashboardType.CONFIGURE_MAP || visibleType == DashboardType.ROUTE_PREFERENCES) {
int index = listView.getFirstVisiblePosition(); int index = listView.getFirstVisiblePosition();
@ -1254,10 +1325,13 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
@Override @Override
public void reloadAdapter() { public void reloadAdapter() {
if ((DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) if (listAdapter != null && listAdapter instanceof StableArrayAdapter) {
&& listAdapter != null && listAdapter instanceof StableArrayAdapter) {
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter; StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
waypointDialogHelper.reloadListAdapter(stableAdapter); if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
waypointDialogHelper.reloadListAdapter(stableAdapter);
} else if (DashboardType.MAP_MARKERS == visibleType) {
mapMarkerDialogHelper.reloadListAdapter(stableAdapter);
}
if (listView instanceof DynamicListView) { if (listView instanceof DynamicListView) {
DynamicListView dynamicListView = (DynamicListView) listView; DynamicListView dynamicListView = (DynamicListView) listView;
dynamicListView.setItemsList(stableAdapter.getObjects()); dynamicListView.setItemsList(stableAdapter.getObjects());

View file

@ -1,14 +1,14 @@
package net.osmand.plus.activities; package net.osmand.plus.helpers;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.Shape; import android.graphics.drawable.shapes.Shape;
import android.os.Bundle;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -23,152 +23,62 @@ import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.views.controls.DynamicListView; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.controls.DynamicListViewCallbacks;
import net.osmand.plus.views.controls.ListDividerShape; import net.osmand.plus.views.controls.ListDividerShape;
import net.osmand.plus.views.controls.StableArrayAdapter; import net.osmand.plus.views.controls.StableArrayAdapter;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
public class MapMarkersActivity extends OsmandListActivity implements DynamicListViewCallbacks { public class MapMarkerDialogHelper {
public static final int ACTIVE_MARKERS = 0; public static final int ACTIVE_MARKERS = 0;
public static final int MARKERS_HISTORY = 1; public static final int MARKERS_HISTORY = 1;
private SwipeDismissListViewTouchListener swipeDismissListener; private MapActivity mapActivity;
private OsmandApplication app;
private boolean sorted;
private boolean nightMode; private boolean nightMode;
@Override public MapMarkerDialogHelper(MapActivity mapActivity) {
protected void onCreate(Bundle savedInstanceState) { this.mapActivity = mapActivity;
getMyApplication().applyTheme(this); app = mapActivity.getMyApplication();
super.onCreate(savedInstanceState);
setContentView(R.layout.map_markers);
getSupportActionBar().setTitle(R.string.map_markers);
((DynamicListView) getListView()).setDynamicListViewCallbacks(this);
swipeDismissListener = new SwipeDismissListViewTouchListener(getListView(),
new SwipeDismissListViewTouchListener.DismissCallbacks() {
private List<Object> deletedMarkers = new ArrayList<>();
@Override
public boolean canDismiss(int position) {
List<Object> activeObjects = getListAdapter().getActiveObjects();
Object obj = getListAdapter().getItem(position);
return activeObjects.contains(obj);
}
@Override
public SwipeDismissListViewTouchListener.Undoable onDismiss(final int position) {
final StableArrayAdapter stableAdapter = getListAdapter();
final int activeObjPos;
final Object item = stableAdapter.getItem(position);
if (item != null) {
if (!((MapMarker) item).history) {
deletedMarkers.add(item);
}
stableAdapter.setNotifyOnChange(false);
stableAdapter.remove(item);
stableAdapter.getObjects().remove(item);
activeObjPos = stableAdapter.getActiveObjects().indexOf(item);
stableAdapter.getActiveObjects().remove(item);
stableAdapter.refreshData();
stableAdapter.notifyDataSetChanged();
return new SwipeDismissListViewTouchListener.Undoable() {
@Override
public void undo() {
stableAdapter.setNotifyOnChange(false);
stableAdapter.insert(item, position);
stableAdapter.getObjects().add(position, item);
stableAdapter.getActiveObjects().add(activeObjPos, item);
stableAdapter.refreshData();
deletedMarkers.remove(item);
updateMapMarkers(stableAdapter.getActiveObjects());
reloadListAdapter();
}
};
} else {
return null;
}
}
@Override
public void onHidePopup() {
StableArrayAdapter stableAdapter = getListAdapter();
stableAdapter.refreshData();
updateMapMarkers(stableAdapter.getActiveObjects());
if (stableAdapter.getActiveObjects().size() == 0) {
finish();
} else {
reloadListAdapter();
}
}
private void updateMapMarkers(List<Object> objects) {
List<MapMarker> markers = new ArrayList<>();
List<MapMarker> markersHistory = new ArrayList<>();
for (Object obj : objects) {
MapMarker marker = (MapMarker) obj;
if (!marker.history) {
markers.add(marker);
} else {
markersHistory.add(marker);
}
}
for (int i = deletedMarkers.size() - 1; i >= 0; i--) {
markersHistory.add(0, (MapMarker) deletedMarkers.get(i));
}
deletedMarkers.clear();
getMyApplication().getMapMarkersHelper().saveMapMarkers(markers, markersHistory);
}
});
//nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
nightMode = !getMyApplication().getSettings().isLightContent();
setListAdapter(getMapMarkersListAdapter());
} }
@Override public boolean isNightMode() {
protected void onStart() { return nightMode;
super.onStart();
if (nightMode) {
getListView().setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
} else {
getListView().setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_light));
}
} }
@Override public void setNightMode(boolean nightMode) {
public StableArrayAdapter getListAdapter() { this.nightMode = nightMode;
return (StableArrayAdapter) super.getListAdapter();
} }
@Override public boolean isSorted() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { return sorted;
Object obj = getListAdapter().getItem(position); }
if (obj instanceof MapMarker) {
MapMarker marker = (MapMarker) obj; public void setSorted(boolean sorted) {
if (!marker.history) { this.sorted = sorted;
showOnMap(marker); }
} else {
showHistoryOnMap(marker); public AdapterView.OnItemClickListener getItemClickListener(final ArrayAdapter<Object> listAdapter) {
return new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
Object obj = listAdapter.getItem(item);
if (obj instanceof MapMarker) {
MapMarker marker = (MapMarker) obj;
if (!marker.history) {
showOnMap(marker);
} else {
showHistoryOnMap(marker);
}
}
} }
} };
}
@Override
protected void onResume() {
super.onResume();
getListAdapter().notifyDataSetChanged();
} }
public StableArrayAdapter getMapMarkersListAdapter() { public StableArrayAdapter getMapMarkersListAdapter() {
@ -176,7 +86,7 @@ public class MapMarkersActivity extends OsmandListActivity implements DynamicLis
final List<Object> objects = getListObjects(); final List<Object> objects = getListObjects();
List<Object> activeObjects = getActiveObjects(objects); List<Object> activeObjects = getActiveObjects(objects);
final StableArrayAdapter listAdapter = new StableArrayAdapter(getMyApplication(), final StableArrayAdapter listAdapter = new StableArrayAdapter(mapActivity,
R.layout.waypoint_reached, R.id.title, objects, activeObjects) { R.layout.waypoint_reached, R.id.title, objects, activeObjects) {
@Override @Override
@ -199,16 +109,16 @@ public class MapMarkersActivity extends OsmandListActivity implements DynamicLis
boolean topDividerView = (obj instanceof Boolean) && ((Boolean) obj); boolean topDividerView = (obj instanceof Boolean) && ((Boolean) obj);
boolean bottomDividerView = (obj instanceof Boolean) && !((Boolean) obj); boolean bottomDividerView = (obj instanceof Boolean) && !((Boolean) obj);
if (labelView) { if (labelView) {
v = createItemForCategory((Integer) obj); v = createItemForCategory(this, (Integer) obj);
AndroidUtils.setListItemBackground(MapMarkersActivity.this, v, nightMode); AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
} else if (topDividerView) { } else if (topDividerView) {
v = getLayoutInflater().inflate(R.layout.card_top_divider, null); v = mapActivity.getLayoutInflater().inflate(R.layout.card_top_divider, null);
} else if (bottomDividerView) { } else if (bottomDividerView) {
v = getLayoutInflater().inflate(R.layout.card_bottom_divider, null); v = mapActivity.getLayoutInflater().inflate(R.layout.card_bottom_divider, null);
} else if (obj instanceof MapMarker) { } else if (obj instanceof MapMarker) {
MapMarker marker = (MapMarker) obj; MapMarker marker = (MapMarker) obj;
v = updateMapMarkerItemView(v, marker); v = updateMapMarkerItemView(v, marker);
AndroidUtils.setListItemBackground(MapMarkersActivity.this, v, nightMode); AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
} }
return v; return v;
} }
@ -218,15 +128,15 @@ public class MapMarkersActivity extends OsmandListActivity implements DynamicLis
if (p instanceof MapMarker) { if (p instanceof MapMarker) {
final MapMarker marker = (MapMarker) p; final MapMarker marker = (MapMarker) p;
if (marker.getOriginalPointDescription() != null if (marker.getOriginalPointDescription() != null
&& marker.getOriginalPointDescription().isSearchingAddress(this)) { && marker.getOriginalPointDescription().isSearchingAddress(mapActivity)) {
GeocodingLookupService.AddressLookupRequest lookupRequest GeocodingLookupService.AddressLookupRequest lookupRequest
= new GeocodingLookupService.AddressLookupRequest(marker.point, new GeocodingLookupService.OnAddressLookupResult() { = new GeocodingLookupService.AddressLookupRequest(marker.point, new GeocodingLookupService.OnAddressLookupResult() {
@Override @Override
public void geocodingDone(String address) { public void geocodingDone(String address) {
reloadListAdapter(); reloadListAdapter(listAdapter);
} }
}, null); }, null);
getMyApplication().getGeocodingLookupService().lookupAddress(lookupRequest); app.getGeocodingLookupService().lookupAddress(lookupRequest);
} }
} }
} }
@ -237,18 +147,18 @@ public class MapMarkersActivity extends OsmandListActivity implements DynamicLis
private List<Drawable> getCustomDividers(List<Object> points) { private List<Drawable> getCustomDividers(List<Object> points) {
int color; int color;
if (nightMode) { if (nightMode) {
color = getResources().getColor(R.color.dashboard_divider_dark); color = mapActivity.getResources().getColor(R.color.dashboard_divider_dark);
} else { } else {
color = getResources().getColor(R.color.dashboard_divider_light); color = mapActivity.getResources().getColor(R.color.dashboard_divider_light);
} }
Shape fullDividerShape = new ListDividerShape(color, 0); Shape fullDividerShape = new ListDividerShape(color, 0);
Shape halfDividerShape = new ListDividerShape(color, AndroidUtils.dpToPx(this, 56f)); Shape halfDividerShape = new ListDividerShape(color, AndroidUtils.dpToPx(mapActivity, 56f));
final ShapeDrawable fullDivider = new ShapeDrawable(fullDividerShape); final ShapeDrawable fullDivider = new ShapeDrawable(fullDividerShape);
final ShapeDrawable halfDivider = new ShapeDrawable(halfDividerShape); final ShapeDrawable halfDivider = new ShapeDrawable(halfDividerShape);
int divHeight = AndroidUtils.dpToPx(this, 1f); int divHeight = AndroidUtils.dpToPx(mapActivity, 1f);
fullDivider.setIntrinsicHeight(divHeight); fullDivider.setIntrinsicHeight(divHeight);
halfDivider.setIntrinsicHeight(divHeight); halfDivider.setIntrinsicHeight(divHeight);
@ -283,41 +193,41 @@ public class MapMarkersActivity extends OsmandListActivity implements DynamicLis
return res; return res;
} }
protected View createItemForCategory(final int type) { protected View createItemForCategory(final ArrayAdapter<Object> listAdapter, final int type) {
View v = getLayoutInflater().inflate(R.layout.waypoint_header, null); View v = mapActivity.getLayoutInflater().inflate(R.layout.waypoint_header, null);
v.findViewById(R.id.check_item).setVisibility(View.GONE); v.findViewById(R.id.check_item).setVisibility(View.GONE);
v.findViewById(R.id.ProgressBar).setVisibility(View.GONE); v.findViewById(R.id.ProgressBar).setVisibility(View.GONE);
final Button btn = (Button) v.findViewById(R.id.header_button); final Button btn = (Button) v.findViewById(R.id.header_button);
btn.setTextColor(!nightMode ? getResources().getColor(R.color.map_widget_blue) btn.setTextColor(!nightMode ? mapActivity.getResources().getColor(R.color.map_widget_blue)
: getResources().getColor(R.color.osmand_orange)); : mapActivity.getResources().getColor(R.color.osmand_orange));
btn.setText(getString(R.string.shared_string_clear)); btn.setText(mapActivity.getString(R.string.shared_string_clear));
btn.setVisibility(View.VISIBLE); btn.setVisibility(View.VISIBLE);
btn.setOnClickListener(new View.OnClickListener() { btn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (type == MARKERS_HISTORY) { if (type == MARKERS_HISTORY) {
AlertDialog.Builder builder = new AlertDialog.Builder(MapMarkersActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
builder.setMessage(getString(R.string.clear_markers_history_q)) builder.setMessage(mapActivity.getString(R.string.clear_markers_history_q))
.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
getListAdapter().notifyDataSetInvalidated(); listAdapter.notifyDataSetInvalidated();
getMyApplication().getMapMarkersHelper().removeMarkersHistory(); app.getMapMarkersHelper().removeMarkersHistory();
reloadListAdapter(); reloadListAdapter(listAdapter);
} }
}) })
.setNegativeButton(R.string.shared_string_no, null) .setNegativeButton(R.string.shared_string_no, null)
.show(); .show();
} else if (type == ACTIVE_MARKERS) { } else if (type == ACTIVE_MARKERS) {
AlertDialog.Builder builder = new AlertDialog.Builder(MapMarkersActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
builder.setMessage(getString(R.string.clear_active_markers_q)) builder.setMessage(mapActivity.getString(R.string.clear_active_markers_q))
.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
getListAdapter().notifyDataSetInvalidated(); listAdapter.notifyDataSetInvalidated();
getMyApplication().getMapMarkersHelper().removeActiveMarkers(); app.getMapMarkersHelper().removeActiveMarkers();
reloadListAdapter(); reloadListAdapter(listAdapter);
} }
}) })
.setNegativeButton(R.string.shared_string_no, null) .setNegativeButton(R.string.shared_string_no, null)
@ -327,14 +237,14 @@ public class MapMarkersActivity extends OsmandListActivity implements DynamicLis
}); });
TextView tv = (TextView) v.findViewById(R.id.header_text); TextView tv = (TextView) v.findViewById(R.id.header_text);
AndroidUtils.setTextPrimaryColor(this, tv, nightMode); AndroidUtils.setTextPrimaryColor(mapActivity, tv, nightMode);
tv.setText(getHeader(type)); tv.setText(getHeader(type));
return v; return v;
} }
protected View updateMapMarkerItemView(View v, final MapMarker marker) { protected View updateMapMarkerItemView(View v, final MapMarker marker) {
if (v == null || v.findViewById(R.id.info_close) == null) { if (v == null || v.findViewById(R.id.info_close) == null) {
v = getLayoutInflater().inflate(R.layout.waypoint_reached, null); v = mapActivity.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
} }
updateMapMarkerInfoView(v, marker); updateMapMarkerInfoView(v, marker);
final View more = v.findViewById(R.id.all_points); final View more = v.findViewById(R.id.all_points);
@ -347,26 +257,23 @@ public class MapMarkersActivity extends OsmandListActivity implements DynamicLis
} }
protected void updateMapMarkerInfoView(View localView, final MapMarker marker) { protected void updateMapMarkerInfoView(View localView, final MapMarker marker) {
OsmandApplication app = getMyApplication();
TextView text = (TextView) localView.findViewById(R.id.waypoint_text); TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow); TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow);
TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist); TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist);
if (!marker.history) { if (!marker.history) {
((ImageView) localView.findViewById(R.id.waypoint_icon)) ((ImageView) localView.findViewById(R.id.waypoint_icon))
.setImageDrawable(getMapMarkerIcon(app, marker.colorIndex)); .setImageDrawable(getMapMarkerIcon(app, marker.colorIndex));
AndroidUtils.setTextPrimaryColor(this, text, nightMode); AndroidUtils.setTextPrimaryColor(mapActivity, text, nightMode);
textDist.setTextColor(getResources().getColor(R.color.color_myloc_distance)); textDist.setTextColor(mapActivity.getResources().getColor(R.color.color_myloc_distance));
} else { } else {
((ImageView) localView.findViewById(R.id.waypoint_icon)) ((ImageView) localView.findViewById(R.id.waypoint_icon))
.setImageDrawable(getMyApplication().getIconsCache() .setImageDrawable(app.getIconsCache()
.getContentIcon(R.drawable.ic_action_flag_dark, !nightMode)); .getContentIcon(R.drawable.ic_action_flag_dark, !nightMode));
AndroidUtils.setTextSecondaryColor(this, text, nightMode); AndroidUtils.setTextSecondaryColor(mapActivity, text, nightMode);
AndroidUtils.setTextSecondaryColor(this, textDist, nightMode); AndroidUtils.setTextSecondaryColor(mapActivity, textDist, nightMode);
} }
LatLon lastKnownMapLocation = app.getSettings().getLastKnownMapLocation(); int dist = marker.dist;
int dist = (int) (MapUtils.getDistance(marker.getLatitude(), marker.getLongitude(),
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
//if (dist > 0) { //if (dist > 0) {
textDist.setText(OsmAndFormatter.getFormattedDistance(dist, app)); textDist.setText(OsmAndFormatter.getFormattedDistance(dist, app));
@ -411,62 +318,81 @@ public class MapMarkersActivity extends OsmandListActivity implements DynamicLis
} }
public void showOnMap(MapMarker marker) { public void showOnMap(MapMarker marker) {
getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(), app.getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
15, marker.getPointDescription(this), true, marker); 15, marker.getPointDescription(mapActivity), true, marker);
MapActivity.launchMapActivityMoveToTop(this); MapActivity.launchMapActivityMoveToTop(mapActivity);
} }
public void showHistoryOnMap(MapMarker marker) { public void showHistoryOnMap(MapMarker marker) {
getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(), app.getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
15, new PointDescription(PointDescription.POINT_TYPE_LOCATION, marker.getPointDescription(this).getName()), 15, new PointDescription(PointDescription.POINT_TYPE_LOCATION,
marker.getPointDescription(mapActivity).getName()),
false, null); false, null);
MapActivity.launchMapActivityMoveToTop(this); MapActivity.launchMapActivityMoveToTop(mapActivity);
} }
protected String getHeader(int type) { protected String getHeader(int type) {
String str = getString(R.string.map_markers); String str = mapActivity.getString(R.string.map_markers);
switch (type) { switch (type) {
case ACTIVE_MARKERS: case ACTIVE_MARKERS:
str = getString(R.string.active_markers); str = mapActivity.getString(R.string.active_markers);
break; break;
case MARKERS_HISTORY: case MARKERS_HISTORY:
str = getString(R.string.shared_string_history); str = mapActivity.getString(R.string.shared_string_history);
break; break;
} }
return str; return str;
} }
public void reloadListAdapter() { public void reloadListAdapter(ArrayAdapter<Object> listAdapter) {
StableArrayAdapter listAdapter = getListAdapter();
listAdapter.setNotifyOnChange(false); listAdapter.setNotifyOnChange(false);
listAdapter.clear(); listAdapter.clear();
List<Object> objects = getListObjects(); List<Object> objects = getListObjects();
for (Object point : objects) { for (Object point : objects) {
listAdapter.add(point); listAdapter.add(point);
} }
listAdapter.updateObjects(objects, getActiveObjects(objects)); if (listAdapter instanceof StableArrayAdapter) {
((StableArrayAdapter) listAdapter).updateObjects(objects, getActiveObjects(objects));
}
listAdapter.notifyDataSetChanged(); listAdapter.notifyDataSetChanged();
}
DynamicListView dynamicListView = (DynamicListView) getListView(); public void calcDistance(LatLon anchor, List<MapMarker> markers) {
dynamicListView.setItemsList(listAdapter.getObjects()); for (MapMarker m : markers) {
dynamicListView.setActiveItemsList(listAdapter.getActiveObjects()); m.dist = (int) (MapUtils.getDistance(m.getLatitude(), m.getLongitude(),
anchor.getLatitude(), anchor.getLongitude()));
}
} }
protected List<Object> getListObjects() { protected List<Object> getListObjects() {
final List<Object> objects = new ArrayList<>(); final List<Object> objects = new ArrayList<>();
final MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper(); final MapMarkersHelper markersHelper = app.getMapMarkersHelper();
List<MapMarker> activeMarkers = markersHelper.getActiveMapMarkers(); LatLon mapLocation =
new LatLon(mapActivity.getMapView().getLatitude(), mapActivity.getMapView().getLongitude());
List<MapMarker> activeMarkers = new ArrayList<>(markersHelper.getActiveMapMarkers());
calcDistance(mapLocation, activeMarkers);
if (sorted) {
Collections.sort(activeMarkers, new Comparator<MapMarker>() {
@Override
public int compare(MapMarker lhs, MapMarker rhs) {
return lhs.dist < rhs.dist ? -1 : (lhs.dist == rhs.dist ? 0 : 1);
}
});
}
if (activeMarkers.size() > 0) { if (activeMarkers.size() > 0) {
objects.add(true);
objects.add(ACTIVE_MARKERS); objects.add(ACTIVE_MARKERS);
objects.addAll(activeMarkers); objects.addAll(activeMarkers);
objects.add(false); objects.add(false);
} }
List<MapMarker> markersHistory = markersHelper.getMapMarkersHistory(); List<MapMarker> markersHistory = new ArrayList<>(markersHelper.getMapMarkersHistory());
calcDistance(mapLocation, markersHistory);
if (markersHistory.size() > 0) { if (markersHistory.size() > 0) {
objects.add(true); if (activeMarkers.size() > 0) {
objects.add(true);
}
objects.add(MARKERS_HISTORY); objects.add(MARKERS_HISTORY);
objects.addAll(markersHistory); objects.addAll(markersHistory);
objects.add(false); objects.add(false);
@ -502,19 +428,4 @@ public class MapMarkersActivity extends OsmandListActivity implements DynamicLis
return iconsCache.getIcon(R.drawable.map_marker_blue); return iconsCache.getIcon(R.drawable.map_marker_blue);
} }
} }
}
@Override
public void onWindowVisibilityChanged(int visibility) {
if (visibility != View.VISIBLE && swipeDismissListener != null) {
swipeDismissListener.discardUndo();
}
}
@Override
public void onItemsSwapped(List<Object> items) {
}
@Override
public void onItemSwapping(int position) {
}
}

View file

@ -22,6 +22,7 @@ import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.mapcontextmenu.MenuController.MenuState; import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
@ -471,7 +472,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
if (pointDescription.isDestination()) { if (pointDescription.isDestination()) {
mapActivity.getMapActions().editWaypoints(); mapActivity.getMapActions().editWaypoints();
} else if (pointDescription.isMapMarker()) { } else if (pointDescription.isMapMarker()) {
mapActivity.getMapActions().openMapMarkersActivity(); hide();
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAP_MARKERS);
} else { } else {
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(), mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(),
pointDescription); pointDescription);

View file

@ -8,7 +8,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapMarkersActivity; import net.osmand.plus.helpers.MapMarkerDialogHelper;
import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -61,7 +61,7 @@ public class MapMarkerMenuController extends MenuController {
@Override @Override
public Drawable getLeftIcon() { public Drawable getLeftIcon() {
return MapMarkersActivity.getMapMarkerIcon(getMapActivity().getMyApplication(), mapMarker.colorIndex); return MapMarkerDialogHelper.getMapMarkerIcon(getMapActivity().getMyApplication(), mapMarker.colorIndex);
} }
@Override @Override