Add "New map markers" item to drawer; move method
This commit is contained in:
parent
a64f4d1d3f
commit
915d5d516b
5 changed files with 48 additions and 36 deletions
|
@ -105,6 +105,36 @@ public class MapMarkersHelper {
|
|||
result = 31 * result + colorIndex;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int getColorId(int colorIndex) {
|
||||
int colorId;
|
||||
switch (colorIndex) {
|
||||
case 0:
|
||||
colorId = R.color.marker_blue;
|
||||
break;
|
||||
case 1:
|
||||
colorId = R.color.marker_green;
|
||||
break;
|
||||
case 2:
|
||||
colorId = R.color.marker_orange;
|
||||
break;
|
||||
case 3:
|
||||
colorId = R.color.marker_red;
|
||||
break;
|
||||
case 4:
|
||||
colorId = R.color.marker_yellow;
|
||||
break;
|
||||
case 5:
|
||||
colorId = R.color.marker_teal;
|
||||
break;
|
||||
case 6:
|
||||
colorId = R.color.marker_purple;
|
||||
break;
|
||||
default:
|
||||
colorId = R.color.marker_blue;
|
||||
}
|
||||
return colorId;
|
||||
}
|
||||
}
|
||||
|
||||
public MapMarkersHelper(OsmandApplication ctx) {
|
||||
|
@ -463,34 +493,4 @@ public class MapMarkersHelper {
|
|||
ctx.getGeocodingLookupService().cancel(latLon);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getMapMarkerColorId(int colorIndex) {
|
||||
int colorId;
|
||||
switch (colorIndex) {
|
||||
case 0:
|
||||
colorId = R.color.marker_blue;
|
||||
break;
|
||||
case 1:
|
||||
colorId = R.color.marker_green;
|
||||
break;
|
||||
case 2:
|
||||
colorId = R.color.marker_orange;
|
||||
break;
|
||||
case 3:
|
||||
colorId = R.color.marker_red;
|
||||
break;
|
||||
case 4:
|
||||
colorId = R.color.marker_yellow;
|
||||
break;
|
||||
case 5:
|
||||
colorId = R.color.marker_teal;
|
||||
break;
|
||||
case 6:
|
||||
colorId = R.color.marker_purple;
|
||||
break;
|
||||
default:
|
||||
colorId = R.color.marker_blue;
|
||||
}
|
||||
return colorId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
|||
import net.osmand.plus.dialogs.FavoriteDialogs;
|
||||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.liveupdates.OsmLiveActivity;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
|
||||
|
@ -623,6 +624,18 @@ public class MapActivityActions implements DialogProvider {
|
|||
return false;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitle("New map markers")
|
||||
.setIcon(R.drawable.ic_action_flag_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_markers_open");
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
MapMarkersDialogFragment.showInstance(mapActivity);
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
} else {
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.waypoints, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_intermediate)
|
||||
|
|
|
@ -783,7 +783,7 @@ public class MapMarkerDialogHelper {
|
|||
}
|
||||
|
||||
public static Drawable getMapMarkerIcon(OsmandApplication app, int colorIndex) {
|
||||
return app.getIconsCache().getIcon(R.drawable.ic_action_flag_dark, MapMarkersHelper.getMapMarkerColorId(colorIndex));
|
||||
return app.getIconsCache().getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(colorIndex));
|
||||
}
|
||||
|
||||
public void updateLocation(ListView listView, boolean compassChanged) {
|
||||
|
@ -865,7 +865,7 @@ public class MapMarkerDialogHelper {
|
|||
WptPt wpt = new WptPt();
|
||||
wpt.lat = marker.getLatitude();
|
||||
wpt.lon = marker.getLongitude();
|
||||
wpt.setColor(mapActivity.getResources().getColor(MapMarkersHelper.getMapMarkerColorId(marker.colorIndex)));
|
||||
wpt.setColor(mapActivity.getResources().getColor(MapMarker.getColorId(marker.colorIndex)));
|
||||
wpt.name = marker.getOnlyName();
|
||||
//wpt.link = r.getFileName();
|
||||
//wpt.time = r.getFile().lastModified();
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.view.ViewGroup;
|
|||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -63,7 +62,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
|
|||
}
|
||||
});
|
||||
|
||||
int color = MapMarkersHelper.getMapMarkerColorId(marker.colorIndex);
|
||||
int color = MapMarker.getColorId(marker.colorIndex);
|
||||
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
|
||||
|
||||
holder.title.setText(marker.getName(mapActivity));
|
||||
|
|
|
@ -250,7 +250,7 @@ public class MapMarkersWidgetsFactory {
|
|||
} else {
|
||||
dd = (DirectionDrawable) arrowImg.getDrawable();
|
||||
}
|
||||
dd.setImage(R.drawable.ic_arrow_marker_diretion, MapMarkersHelper.getMapMarkerColorId(marker.colorIndex));
|
||||
dd.setImage(R.drawable.ic_arrow_marker_diretion, MapMarker.getColorId(marker.colorIndex));
|
||||
if (heading != null && loc != null) {
|
||||
dd.setAngle(mes[1] - heading + 180 + screenOrientation);
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ public class MapMarkersWidgetsFactory {
|
|||
setImageDrawable(map.getMyApplication().getIconsCache()
|
||||
.getIcon(isNight() ? R.drawable.widget_marker_night : R.drawable.widget_marker_day,
|
||||
R.drawable.widget_marker_triangle,
|
||||
MapMarkersHelper.getMapMarkerColorId(marker.colorIndex)));
|
||||
MapMarker.getColorId(marker.colorIndex)));
|
||||
cachedMarkerColorIndex = marker.colorIndex;
|
||||
cachedNightMode = isNight();
|
||||
res = true;
|
||||
|
|
Loading…
Reference in a new issue