Merge pull request #4794 from osmandapp/markers_empty_states
Markers icons and context menu
This commit is contained in:
commit
08122c430f
15 changed files with 356 additions and 94 deletions
|
@ -74,6 +74,8 @@ public class MapMarkersHelper {
|
|||
public String nextKey;
|
||||
public String groupKey;
|
||||
public String groupName;
|
||||
public WptPt wptPt;
|
||||
public FavouritePoint favouritePoint;
|
||||
|
||||
public MapMarker(LatLon point, PointDescription name, int colorIndex,
|
||||
boolean selected, int index) {
|
||||
|
@ -455,19 +457,19 @@ public class MapMarkersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public void syncGroupAsync(MarkersSyncGroup group) {
|
||||
public void syncGroupAsync(@NonNull MarkersSyncGroup group) {
|
||||
syncGroupAsync(group, true, null);
|
||||
}
|
||||
|
||||
public void syncGroupAsync(MarkersSyncGroup group, boolean enabled) {
|
||||
public void syncGroupAsync(@NonNull MarkersSyncGroup group, boolean enabled) {
|
||||
syncGroupAsync(group, enabled, null);
|
||||
}
|
||||
|
||||
public void syncGroupAsync(MarkersSyncGroup group, OnGroupSyncedListener groupSyncedListener) {
|
||||
public void syncGroupAsync(@NonNull MarkersSyncGroup group, @Nullable OnGroupSyncedListener groupSyncedListener) {
|
||||
syncGroupAsync(group, true, groupSyncedListener);
|
||||
}
|
||||
|
||||
private void syncGroupAsync(final MarkersSyncGroup group, final boolean enabled, final OnGroupSyncedListener groupSyncedListener) {
|
||||
private void syncGroupAsync(@NonNull final MarkersSyncGroup group, final boolean enabled, @Nullable final OnGroupSyncedListener groupSyncedListener) {
|
||||
ctx.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -517,7 +519,7 @@ public class MapMarkersHelper {
|
|||
}
|
||||
|
||||
for (FavouritePoint fp : favGroup.points) {
|
||||
addNewMarkerIfNeeded(group, dbMarkers, new LatLon(fp.getLatitude(), fp.getLongitude()), fp.getName(), enabled);
|
||||
addNewMarkerIfNeeded(group, dbMarkers, new LatLon(fp.getLatitude(), fp.getLongitude()), fp.getName(), enabled, fp, null);
|
||||
}
|
||||
|
||||
removeOldMarkersIfNeeded(dbMarkers);
|
||||
|
@ -540,7 +542,7 @@ public class MapMarkersHelper {
|
|||
int defColor = ContextCompat.getColor(ctx, R.color.marker_red);
|
||||
for (WptPt pt : gpxPoints) {
|
||||
group.setColor(pt.getColor(defColor));
|
||||
addNewMarkerIfNeeded(group, dbMarkers, new LatLon(pt.lat, pt.lon), pt.name, enabled);
|
||||
addNewMarkerIfNeeded(group, dbMarkers, new LatLon(pt.lat, pt.lon), pt.name, enabled, null, pt);
|
||||
}
|
||||
|
||||
removeOldMarkersIfNeeded(dbMarkers);
|
||||
|
@ -560,19 +562,62 @@ public class MapMarkersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private void addNewMarkerIfNeeded(MarkersSyncGroup group, List<MapMarker> markers, LatLon latLon, String name, boolean enabled) {
|
||||
public boolean isSynced(SelectedGpxFile gpxFile) {
|
||||
GPXFile gpx = gpxFile.getGpxFile();
|
||||
List<WptPt> gpxPoints = gpx.getPoints();
|
||||
for (WptPt wptPt : gpxPoints) {
|
||||
MapMarker mapMarker = getMapMarker(wptPt);
|
||||
if (mapMarker != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSynced(FavouritePoint favouritePoint) {
|
||||
MapMarker mapMarker = getMapMarker(favouritePoint);
|
||||
return mapMarker != null;
|
||||
}
|
||||
|
||||
public MapMarker getMapMarker(WptPt wptPt) {
|
||||
for (MapMarker marker : mapMarkers) {
|
||||
if (marker.wptPt == wptPt) {
|
||||
return marker;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public MapMarker getMapMarker(FavouritePoint favouritePoint) {
|
||||
for (MapMarker marker : mapMarkers) {
|
||||
if (marker.favouritePoint == favouritePoint) {
|
||||
return marker;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addNewMarkerIfNeeded(@NonNull MarkersSyncGroup group,
|
||||
@NonNull List<MapMarker> markers,
|
||||
@NonNull LatLon latLon,
|
||||
@NonNull String name,
|
||||
boolean enabled,
|
||||
@Nullable FavouritePoint favouritePoint,
|
||||
@Nullable WptPt wptPt) {
|
||||
boolean exists = false;
|
||||
|
||||
for (MapMarker marker : markers) {
|
||||
if (marker.id.equals(group.getId() + name)) {
|
||||
exists = true;
|
||||
if (!marker.history && (!marker.point.equals(latLon))) {
|
||||
for (MapMarker m : mapMarkers) {
|
||||
if (m.id.equals(marker.id)) {
|
||||
m.favouritePoint = favouritePoint;
|
||||
m.wptPt = wptPt;
|
||||
if (!marker.history && !marker.point.equals(latLon)) {
|
||||
m.point = latLon;
|
||||
updateMapMarker(m, true);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
markers.remove(marker);
|
||||
|
@ -582,7 +627,8 @@ public class MapMarkersHelper {
|
|||
|
||||
if (!exists) {
|
||||
addMarkers(Collections.singletonList(latLon),
|
||||
Collections.singletonList(new PointDescription(POINT_TYPE_MAP_MARKER, name)), group, enabled);
|
||||
Collections.singletonList(new PointDescription(POINT_TYPE_MAP_MARKER, name)),
|
||||
group, enabled, Collections.singletonList(favouritePoint), Collections.singletonList(wptPt));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -840,7 +886,7 @@ public class MapMarkersHelper {
|
|||
markersDbHelper.removeDisabledGroups();
|
||||
}
|
||||
|
||||
public void updateGroupDisabled(MapMarkersGroup group, boolean disabled) {
|
||||
public void updateGroupDisabled(@NonNull MapMarkersGroup group, boolean disabled) {
|
||||
String id = group.getGroupKey();
|
||||
if (id != null) {
|
||||
markersDbHelper.updateSyncGroupDisabled(id, disabled);
|
||||
|
@ -848,7 +894,7 @@ public class MapMarkersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateSyncGroupDisabled(MapMarkersGroup group, boolean disabled) {
|
||||
private void updateSyncGroupDisabled(@NonNull MapMarkersGroup group, boolean disabled) {
|
||||
List<MapMarker> groupMarkers = group.getMarkers();
|
||||
for (MapMarker marker : groupMarkers) {
|
||||
if (marker.history) {
|
||||
|
@ -886,21 +932,28 @@ public class MapMarkersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public void addMapMarker(LatLon point, PointDescription historyName) {
|
||||
public void addMapMarker(@NonNull LatLon point, @Nullable PointDescription historyName) {
|
||||
addMarkers(Collections.singletonList(point), Collections.singletonList(historyName), null, true);
|
||||
}
|
||||
|
||||
public void addMapMarkers(List<LatLon> points, List<PointDescription> historyNames, @Nullable MarkersSyncGroup group) {
|
||||
public void addMapMarkers(@NonNull List<LatLon> points, @NonNull List<PointDescription> historyNames, @Nullable MarkersSyncGroup group) {
|
||||
addMarkers(points, historyNames, group, true);
|
||||
}
|
||||
|
||||
private void addMarkers(List<LatLon> points, List<PointDescription> historyNames, @Nullable MarkersSyncGroup group, boolean enabled) {
|
||||
private void addMarkers(@NonNull List<LatLon> points, @NonNull List<PointDescription> historyNames, @Nullable MarkersSyncGroup group, boolean enabled) {
|
||||
addMarkers(points, historyNames, group, enabled, null, null);
|
||||
}
|
||||
|
||||
private void addMarkers(@NonNull List<LatLon> points, @NonNull List<PointDescription> historyNames, @Nullable MarkersSyncGroup group,
|
||||
boolean enabled, @Nullable List<FavouritePoint> favouritePoints, @Nullable List<WptPt> wptPts) {
|
||||
if (points.size() > 0) {
|
||||
int colorIndex = -1;
|
||||
List<MapMarker> addedMarkers = new ArrayList<>();
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
LatLon point = points.get(i);
|
||||
PointDescription historyName = historyNames.get(i);
|
||||
FavouritePoint favouritePoint = favouritePoints == null ? null : favouritePoints.get(i);
|
||||
WptPt wptPt = wptPts == null ? null : wptPts.get(i);
|
||||
final PointDescription pointDescription;
|
||||
if (historyName == null) {
|
||||
pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
|
||||
|
@ -931,6 +984,8 @@ public class MapMarkersHelper {
|
|||
}
|
||||
marker.history = false;
|
||||
marker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE;
|
||||
marker.favouritePoint = favouritePoint;
|
||||
marker.wptPt = wptPt;
|
||||
markersDbHelper.addMarker(marker);
|
||||
if (enabled) {
|
||||
addToMapMarkersList(0, marker);
|
||||
|
@ -1143,7 +1198,7 @@ public class MapMarkersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private void addMarkersToGroups(List<MapMarker> markers, boolean enabled) {
|
||||
private void addMarkersToGroups(@NonNull List<MapMarker> markers, boolean enabled) {
|
||||
List<MapMarkersGroup> groups = new ArrayList<>();
|
||||
for (int i = 0; i < markers.size(); i++) {
|
||||
MapMarkersGroup group = addMarkerToGroup(markers.get(i));
|
||||
|
@ -1178,7 +1233,7 @@ public class MapMarkersHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
private MapMarkersGroup createMapMarkerGroup(MapMarker marker) {
|
||||
private MapMarkersGroup createMapMarkerGroup(@NonNull MapMarker marker) {
|
||||
MapMarkersGroup group = new MapMarkersGroup();
|
||||
if (marker.groupName != null) {
|
||||
group.setName(marker.groupName);
|
||||
|
@ -1197,7 +1252,7 @@ public class MapMarkersHelper {
|
|||
return group;
|
||||
}
|
||||
|
||||
private void createHeaderAndHistoryButtonInGroup(MapMarkersGroup group) {
|
||||
private void createHeaderAndHistoryButtonInGroup(@NonNull MapMarkersGroup group) {
|
||||
if (group.getName() != null) {
|
||||
GroupHeader header = new GroupHeader();
|
||||
int type = group.getType();
|
||||
|
|
|
@ -25,14 +25,20 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
private Paint paintBackground;
|
||||
private Bitmap favIcon;
|
||||
private Bitmap favBackground;
|
||||
private Bitmap syncedStroke;
|
||||
private Bitmap syncedColor;
|
||||
private Bitmap syncedShadow;
|
||||
private Bitmap syncedIcon;
|
||||
private Resources resources;
|
||||
private boolean withShadow;
|
||||
private boolean synced;
|
||||
private Paint paintOuter;
|
||||
private Paint paintInnerCircle;
|
||||
private Drawable listDrawable;
|
||||
|
||||
public FavoriteImageDrawable(Context ctx, int color, boolean withShadow) {
|
||||
public FavoriteImageDrawable(Context ctx, int color, boolean withShadow, boolean synced) {
|
||||
this.withShadow = withShadow;
|
||||
this.synced = synced;
|
||||
this.resources = ctx.getResources();
|
||||
this.color = color;
|
||||
paintBackground = new Paint();
|
||||
|
@ -41,6 +47,10 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
paintIcon = new Paint();
|
||||
favIcon = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.map_favorite);
|
||||
favBackground = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.map_white_favorite_shield);
|
||||
syncedStroke = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.map_shield_marker_point_stroke);
|
||||
syncedColor = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.map_shield_marker_point_color);
|
||||
syncedShadow = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.map_shield_marker_point_shadow);
|
||||
syncedIcon = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.map_marker_point_14dp);
|
||||
listDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_action_fav_dark, null).mutate();
|
||||
|
||||
paintOuter = new Paint();
|
||||
|
@ -58,7 +68,7 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
protected void onBoundsChange(Rect bounds) {
|
||||
super.onBoundsChange(bounds);
|
||||
|
||||
if (!withShadow) {
|
||||
if (!withShadow && !synced) {
|
||||
Rect bs = new Rect(bounds);
|
||||
//bs.inset((int) (4 * density), (int) (4 * density));
|
||||
bs.inset(bs.width() / 4, bs.height() / 4);
|
||||
|
@ -68,12 +78,12 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return favBackground.getHeight();
|
||||
return synced ? syncedShadow.getHeight() : favBackground.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return favBackground.getWidth();
|
||||
return synced ? syncedShadow.getWidth() : favBackground.getWidth();
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
|
@ -87,7 +97,12 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
Rect bs = getBounds();
|
||||
if(withShadow) {
|
||||
if (synced) {
|
||||
canvas.drawBitmap(syncedShadow, bs.exactCenterX() - syncedShadow.getWidth() / 2f, bs.exactCenterY() - syncedShadow.getHeight() / 2f, paintBackground);
|
||||
canvas.drawBitmap(syncedColor, bs.exactCenterX() - syncedColor.getWidth() / 2f, bs.exactCenterY() - syncedColor.getHeight() / 2f, paintBackground);
|
||||
canvas.drawBitmap(syncedStroke, bs.exactCenterX() - syncedStroke.getWidth() / 2f, bs.exactCenterY() - syncedStroke.getHeight() / 2f, paintBackground);
|
||||
canvas.drawBitmap(syncedIcon, bs.exactCenterX() - syncedIcon.getWidth() / 2f, bs.exactCenterY() - syncedIcon.getHeight() / 2f, paintIcon);
|
||||
} else if (withShadow) {
|
||||
canvas.drawBitmap(favBackground, bs.exactCenterX() - favBackground.getWidth() / 2f, bs.exactCenterY() - favBackground.getHeight() / 2f, paintBackground);
|
||||
canvas.drawBitmap(favIcon, bs.exactCenterX() - favIcon.getWidth() / 2f, bs.exactCenterY() - favIcon.getHeight() / 2f, paintIcon);
|
||||
} else {
|
||||
|
@ -133,15 +148,23 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
|
||||
private static TreeMap<Integer, FavoriteImageDrawable> cache = new TreeMap<>();
|
||||
|
||||
public static FavoriteImageDrawable getOrCreate(Context a, int color, boolean withShadow) {
|
||||
private static FavoriteImageDrawable getOrCreate(Context a, int color, boolean withShadow, boolean synced) {
|
||||
color = color | 0xff000000;
|
||||
int hash = (color << 2) + (withShadow ? 1 : 0);
|
||||
int hash = (color << 2) + (withShadow ? 1 : 0) + (synced ? 3 : 0);
|
||||
FavoriteImageDrawable drawable = cache.get(hash);
|
||||
if (drawable == null) {
|
||||
drawable = new FavoriteImageDrawable(a, color, withShadow);
|
||||
drawable = new FavoriteImageDrawable(a, color, withShadow, synced);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
cache.put(hash, drawable);
|
||||
}
|
||||
return drawable;
|
||||
}
|
||||
|
||||
public static FavoriteImageDrawable getOrCreate(Context a, int color, boolean withShadow) {
|
||||
return getOrCreate(a, color, withShadow, false);
|
||||
}
|
||||
|
||||
public static FavoriteImageDrawable getOrCreateSyncedIcon(Context a, int color) {
|
||||
return getOrCreate(a, color, false, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -718,6 +718,13 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
? R.string.shared_string_add_to_map_markers : R.string.context_menu_item_destination_point;
|
||||
}
|
||||
|
||||
public boolean isButtonWaypointEnabled() {
|
||||
if (menuController != null) {
|
||||
return menuController.isWaypointButtonEnabled();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void acquireIcons() {
|
||||
super.acquireIcons();
|
||||
if (menuController != null) {
|
||||
|
|
|
@ -30,9 +30,12 @@ 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.QuadPoint;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -459,12 +462,16 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
|
||||
buttonWaypoint.setContentDescription(getString(menu.getWaypointActionStringId()));
|
||||
AndroidUtils.setDashButtonBackground(getMapActivity(), buttonWaypoint, nightMode);
|
||||
if (menu.isButtonWaypointEnabled()) {
|
||||
buttonWaypoint.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
menu.buttonWaypointPressed();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
deactivate(buttonWaypoint);
|
||||
}
|
||||
|
||||
final ImageButton buttonShare = (ImageButton) view.findViewById(R.id.context_menu_share_button);
|
||||
buttonShare.setImageDrawable(getIcon(R.drawable.map_action_gshare_dark,
|
||||
|
@ -514,6 +521,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
return view;
|
||||
}
|
||||
|
||||
private void deactivate(View view) {
|
||||
view.setEnabled(false);
|
||||
view.setAlpha(0.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusBarColorId() {
|
||||
if (menu != null && (menu.getCurrentMenuState() == MenuState.FULL_SCREEN || menu.isLandscapeLayout())) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.mapcontextmenu;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
@ -23,6 +24,7 @@ import net.osmand.map.OsmandRegions;
|
|||
import net.osmand.map.WorldRegion;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
@ -95,6 +97,7 @@ public abstract class MenuController extends BaseMenuController {
|
|||
private PointDescription pointDescription;
|
||||
private LatLon latLon;
|
||||
private boolean active;
|
||||
private Drawable showOnTopBarIcon;
|
||||
|
||||
protected TitleButtonController leftTitleButtonController;
|
||||
protected TitleButtonController rightTitleButtonController;
|
||||
|
@ -311,6 +314,10 @@ public abstract class MenuController extends BaseMenuController {
|
|||
this.currentMenuState = currentMenuState;
|
||||
}
|
||||
|
||||
public void setLeftTitleButtonController(TitleButtonController leftDownloadButtonController) {
|
||||
this.leftTitleButtonController = leftDownloadButtonController;
|
||||
}
|
||||
|
||||
public TitleButtonController getLeftTitleButtonController() {
|
||||
return leftTitleButtonController;
|
||||
}
|
||||
|
@ -323,6 +330,10 @@ public abstract class MenuController extends BaseMenuController {
|
|||
return topRightTitleButtonController;
|
||||
}
|
||||
|
||||
public void setLeftSubtitleButtonController(TitleButtonController leftSubtitleButtonController) {
|
||||
this.leftSubtitleButtonController = leftSubtitleButtonController;
|
||||
}
|
||||
|
||||
public TitleButtonController getLeftSubtitleButtonController() {
|
||||
return leftSubtitleButtonController;
|
||||
}
|
||||
|
@ -421,6 +432,21 @@ public abstract class MenuController extends BaseMenuController {
|
|||
? R.string.shared_string_add_to_map_markers : R.string.context_menu_item_destination_point;
|
||||
}
|
||||
|
||||
public boolean isWaypointButtonEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Drawable getShowOnTopBarIcon() {
|
||||
if (showOnTopBarIcon == null) {
|
||||
IconsCache ic = getMapActivity().getMyApplication().getIconsCache();
|
||||
Drawable background = ic.getIcon(R.drawable.ic_action_device_top,
|
||||
isLight() ? R.color.on_map_icon_color : R.color.ctx_menu_info_text_dark);
|
||||
Drawable topbar = ic.getIcon(R.drawable.ic_action_device_topbar, R.color.dashboard_blue);
|
||||
showOnTopBarIcon = new LayerDrawable(new Drawable[]{background, topbar});
|
||||
}
|
||||
return showOnTopBarIcon;
|
||||
}
|
||||
|
||||
public String getTypeStr() {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -76,4 +76,3 @@ public class WptPtMenuBuilder extends MenuBuilder {
|
|||
buildPlainMenuItems(view);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.mapcontextmenu.controllers;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import net.osmand.data.Amenity;
|
||||
|
@ -8,6 +9,9 @@ import net.osmand.data.FavouritePoint;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
|
@ -24,6 +28,13 @@ public class FavouritePointMenuController extends MenuController {
|
|||
public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) {
|
||||
super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity);
|
||||
this.fav = fav;
|
||||
|
||||
final MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
||||
final MapMarker mapMarker = markersHelper.getMapMarker(fav);
|
||||
|
||||
if (mapMarker != null) {
|
||||
MapMarkerMenuController.createMarkerButtons(this, mapActivity, mapMarker);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,6 +79,11 @@ public class FavouritePointMenuController extends MenuController {
|
|||
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), fav.getColor(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWaypointButtonEnabled() {
|
||||
return getMapActivity().getMyApplication().getMapMarkersHelper().getMapMarker(fav) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getSecondLineTypeIcon() {
|
||||
return getIcon(R.drawable.map_small_group);
|
||||
|
|
|
@ -22,36 +22,7 @@ public class MapMarkerMenuController extends MenuController {
|
|||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.mapMarker = mapMarker;
|
||||
builder.setShowNearestWiki(true);
|
||||
final MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
||||
|
||||
leftTitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
markersHelper.moveMapMarkerToHistory(getMapMarker());
|
||||
getMapActivity().getContextMenu().close();
|
||||
}
|
||||
};
|
||||
leftTitleButtonController.needColorizeIcon = false;
|
||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.mark_passed);
|
||||
leftTitleButtonController.leftIconId = isLight() ? R.drawable.passed_icon_light : R.drawable.passed_icon_dark;
|
||||
|
||||
leftSubtitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
markersHelper.moveMarkerToTop(getMapMarker());
|
||||
getMapActivity().getContextMenu().close();
|
||||
}
|
||||
};
|
||||
leftSubtitleButtonController.caption = getMapActivity().getString(R.string.show_on_top_bar);
|
||||
leftSubtitleButtonController.leftIcon = createShowOnTopbarIcon();
|
||||
}
|
||||
|
||||
private Drawable createShowOnTopbarIcon() {
|
||||
IconsCache ic = getMapActivity().getMyApplication().getIconsCache();
|
||||
Drawable background = ic.getIcon(R.drawable.ic_action_device_top,
|
||||
isLight() ? R.color.on_map_icon_color : R.color.ctx_menu_info_text_dark);
|
||||
Drawable topbar = ic.getIcon(R.drawable.ic_action_device_topbar, R.color.dashboard_blue);
|
||||
return new LayerDrawable(new Drawable[]{background, topbar});
|
||||
createMarkerButtons(this, mapActivity, mapMarker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,4 +75,31 @@ public class MapMarkerMenuController extends MenuController {
|
|||
public int getWaypointActionStringId() {
|
||||
return R.string.rename_marker;
|
||||
}
|
||||
|
||||
public static void createMarkerButtons(MenuController menuController, final MapActivity mapActivity, final MapMarker mapMarker) {
|
||||
final MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
||||
|
||||
TitleButtonController leftTitleButtonController = menuController.new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
markersHelper.moveMapMarkerToHistory(mapMarker);
|
||||
mapActivity.getContextMenu().close();
|
||||
}
|
||||
};
|
||||
leftTitleButtonController.needColorizeIcon = false;
|
||||
leftTitleButtonController.caption = mapActivity.getString(R.string.mark_passed);
|
||||
leftTitleButtonController.leftIconId = menuController.isLight() ? R.drawable.passed_icon_light : R.drawable.passed_icon_dark;
|
||||
menuController.setLeftTitleButtonController(leftTitleButtonController);
|
||||
|
||||
TitleButtonController leftSubtitleButtonController = menuController.new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
markersHelper.moveMarkerToTop(mapMarker);
|
||||
mapActivity.getContextMenu().close();
|
||||
}
|
||||
};
|
||||
leftSubtitleButtonController.caption = mapActivity.getString(R.string.show_on_top_bar);
|
||||
leftSubtitleButtonController.leftIcon = menuController.getShowOnTopBarIcon();
|
||||
menuController.setLeftSubtitleButtonController(leftSubtitleButtonController);
|
||||
}
|
||||
}
|
|
@ -1,10 +1,14 @@
|
|||
package net.osmand.plus.mapcontextmenu.controllers;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
|
@ -19,6 +23,13 @@ public class WptPtMenuController extends MenuController {
|
|||
public WptPtMenuController(MapActivity mapActivity, PointDescription pointDescription, WptPt wpt) {
|
||||
super(new WptPtMenuBuilder(mapActivity, wpt), pointDescription, mapActivity);
|
||||
this.wpt = wpt;
|
||||
|
||||
final MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
||||
final MapMarker mapMarker = markersHelper.getMapMarker(wpt);
|
||||
|
||||
if (mapMarker != null) {
|
||||
MapMarkerMenuController.createMarkerButtons(this, mapActivity, mapMarker);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,6 +81,11 @@ public class WptPtMenuController extends MenuController {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWaypointButtonEnabled() {
|
||||
return getMapActivity().getMyApplication().getMapMarkersHelper().getMapMarker(wpt) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
return wpt.category != null ? wpt.category : "";
|
||||
|
|
|
@ -13,7 +13,10 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||
|
@ -60,8 +63,22 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
|
|||
return;
|
||||
}
|
||||
MapMarker marker = adapter.getItem(pos);
|
||||
WptPt wptPt = marker.wptPt;
|
||||
FavouritePoint favouritePoint = marker.favouritePoint;
|
||||
Object objectToShow;
|
||||
PointDescription pointDescription;
|
||||
if (wptPt != null) {
|
||||
pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, wptPt.name);
|
||||
objectToShow = wptPt;
|
||||
} else if (favouritePoint != null) {
|
||||
pointDescription = new PointDescription(PointDescription.POINT_TYPE_FAVORITE, favouritePoint.getName());
|
||||
objectToShow = favouritePoint;
|
||||
} else {
|
||||
pointDescription = marker.getPointDescription(mapActivity);
|
||||
objectToShow = marker;
|
||||
}
|
||||
mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
|
||||
15, marker.getPointDescription(mapActivity), true, marker);
|
||||
15, pointDescription, true, objectToShow);
|
||||
MapActivity.launchMapActivityMoveToTop(mapActivity);
|
||||
((DialogFragment) getParentFragment()).dismiss();
|
||||
}
|
||||
|
|
|
@ -23,8 +23,10 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||
|
@ -70,6 +72,10 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
|
|||
if (addGroupFragment != null) {
|
||||
((AddGroupBottomSheetDialogFragment) addGroupFragment).setListener(createAddGroupListener());
|
||||
}
|
||||
Fragment historyMarkerMenuFragment = getChildFragmentManager().findFragmentByTag(HistoryMarkerMenuBottomSheetDialogFragment.TAG);
|
||||
if (historyMarkerMenuFragment != null) {
|
||||
((HistoryMarkerMenuBottomSheetDialogFragment) historyMarkerMenuFragment).setListener(createHistoryMarkerMenuListener());
|
||||
}
|
||||
|
||||
final EmptyStateRecyclerView recyclerView = (EmptyStateRecyclerView) mainView.findViewById(R.id.list);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
@ -224,10 +230,37 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
|
|||
Object item = adapter.getItem(pos);
|
||||
if (item instanceof MapMarker) {
|
||||
MapMarker marker = (MapMarker) item;
|
||||
if (!marker.history) {
|
||||
WptPt wptPt = marker.wptPt;
|
||||
FavouritePoint favouritePoint = marker.favouritePoint;
|
||||
Object objectToShow;
|
||||
PointDescription pointDescription;
|
||||
if (wptPt != null) {
|
||||
pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, wptPt.name);
|
||||
objectToShow = wptPt;
|
||||
} else if (favouritePoint != null) {
|
||||
pointDescription = new PointDescription(PointDescription.POINT_TYPE_FAVORITE, favouritePoint.getName());
|
||||
objectToShow = favouritePoint;
|
||||
} else {
|
||||
pointDescription = marker.getPointDescription(mapActivity);
|
||||
objectToShow = marker;
|
||||
}
|
||||
mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
|
||||
15, marker.getPointDescription(mapActivity), true, marker);
|
||||
15, pointDescription, true, objectToShow);
|
||||
MapActivity.launchMapActivityMoveToTop(mapActivity);
|
||||
((DialogFragment) getParentFragment()).dismiss();
|
||||
} else {
|
||||
HistoryMarkerMenuBottomSheetDialogFragment fragment = new HistoryMarkerMenuBottomSheetDialogFragment();
|
||||
fragment.setUsedOnMap(false);
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putInt(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_POSITION, pos);
|
||||
arguments.putString(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_NAME, marker.getName(mapActivity));
|
||||
arguments.putInt(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_COLOR_INDEX, marker.colorIndex);
|
||||
arguments.putLong(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_VISITED_DATE, marker.visitedDate);
|
||||
fragment.setArguments(arguments);
|
||||
fragment.setListener(createHistoryMarkerMenuListener());
|
||||
fragment.show(getChildFragmentManager(), HistoryMarkerMenuBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -277,6 +310,32 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
|
|||
return mainView;
|
||||
}
|
||||
|
||||
private HistoryMarkerMenuBottomSheetDialogFragment.HistoryMarkerMenuFragmentListener createHistoryMarkerMenuListener() {
|
||||
return new HistoryMarkerMenuBottomSheetDialogFragment.HistoryMarkerMenuFragmentListener() {
|
||||
@Override
|
||||
public void onMakeMarkerActive(int pos) {
|
||||
Object item = adapter.getItem(pos);
|
||||
if (item instanceof MapMarker) {
|
||||
if (getMyApplication() != null) {
|
||||
getMyApplication().getMapMarkersHelper().restoreMarkerFromHistory((MapMarker) item, 0);
|
||||
}
|
||||
updateAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteMarker(int pos) {
|
||||
Object item = adapter.getItem(pos);
|
||||
if (item instanceof MapMarker) {
|
||||
if (getMyApplication() != null) {
|
||||
getMyApplication().getMapMarkersHelper().removeMarker((MapMarker) item);
|
||||
}
|
||||
updateAdapter();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void setGroupIdToOpen(String groupIdToOpen) {
|
||||
this.groupIdToOpen = groupIdToOpen;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.osmand.data.QuadRect;
|
|||
import net.osmand.data.QuadTree;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
|
@ -37,6 +38,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
protected OsmandMapTileView view;
|
||||
private Paint paint;
|
||||
private FavouritesDbHelper favorites;
|
||||
private MapMarkersHelper mapMarkersHelper;
|
||||
protected List<FavouritePoint> cache = new ArrayList<>();
|
||||
private MapTextLayer textLayer;
|
||||
private Paint paintIcon;
|
||||
|
@ -64,6 +66,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
paint.setDither(true);
|
||||
settings = view.getApplication().getSettings();
|
||||
favorites = view.getApplication().getFavorites();
|
||||
mapMarkersHelper = view.getApplication().getMapMarkersHelper();
|
||||
textLayer = view.getLayerByClass(MapTextLayer.class);
|
||||
paintIcon = new Paint();
|
||||
pointSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small);
|
||||
|
@ -93,8 +96,13 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||
if (contextMenuLayer.getMoveableObject() instanceof FavouritePoint) {
|
||||
FavouritePoint objectInMotion = (FavouritePoint) contextMenuLayer.getMoveableObject();
|
||||
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(),
|
||||
FavoriteImageDrawable fid;
|
||||
if (mapMarkersHelper.isSynced(objectInMotion)) {
|
||||
fid = FavoriteImageDrawable.getOrCreateSyncedIcon(view.getContext(), objectInMotion.getColor());
|
||||
} else {
|
||||
fid = FavoriteImageDrawable.getOrCreate(view.getContext(),
|
||||
objectInMotion.getColor(), true);
|
||||
}
|
||||
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
|
||||
fid.drawBitmapInCenter(canvas, pf.x, pf.y);
|
||||
}
|
||||
|
@ -134,7 +142,8 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
}
|
||||
for (FavouritePoint o : fullObjects) {
|
||||
if (o != contextMenuLayer.getMoveableObject()) {
|
||||
drawPoint(canvas, tileBox, latLonBounds, o);
|
||||
boolean syncedPoint = mapMarkersHelper.isSynced(o);
|
||||
drawPoint(canvas, tileBox, latLonBounds, o, syncedPoint);
|
||||
}
|
||||
}
|
||||
this.fullObjectsLatLon = fullObjectsLatLon;
|
||||
|
@ -147,14 +156,18 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
|
||||
}
|
||||
|
||||
|
||||
private void drawPoint(Canvas canvas, RotatedTileBox tileBox, final QuadRect latLonBounds, FavouritePoint o) {
|
||||
private void drawPoint(Canvas canvas, RotatedTileBox tileBox, final QuadRect latLonBounds, FavouritePoint o, boolean synced) {
|
||||
if (o.isVisible() && o.getLatitude() >= latLonBounds.bottom && o.getLatitude() <= latLonBounds.top && o.getLongitude() >= latLonBounds.left
|
||||
&& o.getLongitude() <= latLonBounds.right ) {
|
||||
cache.add(o);
|
||||
int x = (int) tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
int y = (int) tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), o.getColor(), true);
|
||||
FavoriteImageDrawable fid;
|
||||
if (synced) {
|
||||
fid = FavoriteImageDrawable.getOrCreateSyncedIcon(view.getContext(), o.getColor());
|
||||
} else {
|
||||
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), o.getColor(), true);
|
||||
}
|
||||
fid.drawBitmapInCenter(canvas, x, y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import net.osmand.plus.GpxSelectionHelper;
|
|||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
|
@ -80,6 +81,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
|
||||
|
||||
private GpxSelectionHelper selectedGpxHelper;
|
||||
private MapMarkersHelper mapMarkersHelper;
|
||||
private Paint paintBmp;
|
||||
private List<WptPt> cache = new ArrayList<>();
|
||||
private Map<WptPt, SelectedGpxFile> pointFileMap = new HashMap<>();
|
||||
|
@ -108,6 +110,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
public void initLayer(OsmandMapTileView view) {
|
||||
this.view = view;
|
||||
selectedGpxHelper = view.getApplication().getSelectedGpxHelper();
|
||||
mapMarkersHelper = view.getApplication().getMapMarkersHelper();
|
||||
osmandRenderer = view.getApplication().getResourceManager().getRenderer().getRenderer();
|
||||
initUI();
|
||||
}
|
||||
|
@ -179,7 +182,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
|
||||
SelectedGpxFile gpxFile = pointFileMap.get(objectInMotion);
|
||||
if (gpxFile != null) {
|
||||
drawBigPoint(canvas, objectInMotion, getFileColor(gpxFile), pf.x, pf.y);
|
||||
drawBigPoint(canvas, objectInMotion, getFileColor(gpxFile), pf.x, pf.y, isSynced(gpxFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -382,10 +385,11 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
}
|
||||
pointFileMap.put(o, g);
|
||||
}
|
||||
boolean synced = isSynced(g);
|
||||
for (WptPt o : fullObjects) {
|
||||
float x = tileBox.getPixXFromLatLon(o.lat, o.lon);
|
||||
float y = tileBox.getPixYFromLatLon(o.lat, o.lon);
|
||||
drawBigPoint(canvas, o, fileColor, x, y);
|
||||
drawBigPoint(canvas, o, fileColor, x, y, synced);
|
||||
}
|
||||
}
|
||||
if (trackChartPoints != null) {
|
||||
|
@ -450,9 +454,14 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
return g.getColor() == 0 ? defPointColor : g.getColor();
|
||||
}
|
||||
|
||||
private void drawBigPoint(Canvas canvas, WptPt o, int fileColor, float x, float y) {
|
||||
private void drawBigPoint(Canvas canvas, WptPt o, int fileColor, float x, float y, boolean synced) {
|
||||
int pointColor = getPointColor(o, fileColor);
|
||||
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor, true);
|
||||
FavoriteImageDrawable fid;
|
||||
if (synced) {
|
||||
fid = FavoriteImageDrawable.getOrCreateSyncedIcon(view.getContext(), pointColor);
|
||||
} else {
|
||||
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor, true);
|
||||
}
|
||||
fid.drawBitmapInCenter(canvas, x, y);
|
||||
}
|
||||
|
||||
|
@ -519,6 +528,10 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
return g.getGpxFile().getPoints();
|
||||
}
|
||||
|
||||
private boolean isSynced(SelectedGpxFile g) {
|
||||
return mapMarkersHelper.isSynced(g);
|
||||
}
|
||||
|
||||
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {
|
||||
return (Math.abs(objx - ex) <= radius * 2 && Math.abs(objy - ey) <= radius * 2);
|
||||
// return Math.abs(objx - ex) <= radius && (ey - objy) <= radius / 2 && (objy - ey) <= 3 * radius ;
|
||||
|
@ -648,7 +661,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
private void syncGpx(GPXFile gpxFile) {
|
||||
File gpx = new File(gpxFile.path);
|
||||
if (gpx.exists()) {
|
||||
view.getApplication().getMapMarkersHelper().syncGroupAsync(new MarkersSyncGroup(gpx.getAbsolutePath(),
|
||||
mapMarkersHelper.syncGroupAsync(new MarkersSyncGroup(gpx.getAbsolutePath(),
|
||||
AndroidUtils.trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||
import net.osmand.plus.views.ContextMenuLayer.ApplyMovedObjectCallback;
|
||||
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
||||
|
@ -326,7 +327,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
|
||||
for (MapMarker marker : markersHelper.getMapMarkers()) {
|
||||
if (isLocationVisible(tileBox, marker) && !overlappedByWaypoint(marker)
|
||||
&& !isInMotion(marker)) {
|
||||
&& !isInMotion(marker) && !isSynced(marker)) {
|
||||
Bitmap bmp = getMapMarkerBitmap(marker.colorIndex);
|
||||
int marginX = bmp.getWidth() / 6;
|
||||
int marginY = bmp.getHeight();
|
||||
|
@ -365,17 +366,22 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
|
||||
if (contextMenuLayer.getMoveableObject() instanceof MapMarker) {
|
||||
MapMarker objectInMotion = (MapMarker) contextMenuLayer.getMoveableObject();
|
||||
Bitmap bitmap = getMapMarkerBitmap(objectInMotion.colorIndex);
|
||||
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
|
||||
Bitmap bitmap = getMapMarkerBitmap(objectInMotion.colorIndex);
|
||||
int marginX = bitmap.getWidth() / 6;
|
||||
int marginY = bitmap.getHeight();
|
||||
float locationX = pf.x;
|
||||
float locationY = pf.y;
|
||||
canvas.rotate(-tileBox.getRotate(), locationX, locationY);
|
||||
canvas.drawBitmap(bitmap, locationX - marginX, locationY - marginY, bitmapPaint);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSynced(@NonNull MapMarker marker) {
|
||||
return marker.wptPt != null || marker.favouritePoint != null;
|
||||
}
|
||||
|
||||
private boolean isInMotion(@NonNull MapMarker marker) {
|
||||
return marker.equals(contextMenuLayer.getMoveableObject());
|
||||
}
|
||||
|
@ -515,6 +521,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
int r = getRadiusPoi(tileBox);
|
||||
for (int i = 0; i < markers.size(); i++) {
|
||||
MapMarker marker = markers.get(i);
|
||||
if (!isSynced(marker)) {
|
||||
LatLon latLon = marker.point;
|
||||
if (latLon != null) {
|
||||
int ex = (int) point.x;
|
||||
|
@ -527,6 +534,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {
|
||||
return Math.abs(objx - ex) <= radius && (ey - objy) <= radius && (objy - ey) <= 2.5 * radius;
|
||||
|
|
Loading…
Reference in a new issue