diff --git a/OsmAnd/res/layout-land/empty_state_markers_history.xml b/OsmAnd/res/layout-land/empty_state_markers_history.xml
index c423a8ee80..2c45d0d8a8 100644
--- a/OsmAnd/res/layout-land/empty_state_markers_history.xml
+++ b/OsmAnd/res/layout-land/empty_state_markers_history.xml
@@ -33,7 +33,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/empty_state_text_interval"
android:background="@null"
- android:text="@string/empty_state_markers_history"
+ android:text="@string/shared_string_history"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/empty_state_text_size"
osmand:typeface="@string/font_roboto_medium"/>
diff --git a/OsmAnd/res/layout/empty_state_markers_history.xml b/OsmAnd/res/layout/empty_state_markers_history.xml
index 94ab69e18b..7af867b962 100644
--- a/OsmAnd/res/layout/empty_state_markers_history.xml
+++ b/OsmAnd/res/layout/empty_state_markers_history.xml
@@ -21,7 +21,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/empty_state_text_interval"
android:background="@null"
- android:text="@string/empty_state_markers_history"
+ android:text="@string/shared_string_history"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/empty_state_text_size"/>
diff --git a/OsmAnd/res/values-be-rBY/strings.xml b/OsmAnd/res/values-be-rBY/strings.xml
index d84486e645..ae5d5e25d4 100644
--- a/OsmAnd/res/values-be-rBY/strings.xml
+++ b/OsmAnd/res/values-be-rBY/strings.xml
@@ -2917,7 +2917,6 @@ U vypadku, kali vy lubіcie OsmAnd і OSM і chočacie padtrymać jaho, heta іd
Pierajmienavać markier
Źniešni vyhlad na mapie
Abiarycie trek, kab dadać šlachavyja kropki da markieraŭ. (Pieraličanyja tolki treki z šlachavymi kropkami.)
- \@string/shared_string_history
Naprava
Nalieva
Bolš
diff --git a/OsmAnd/res/values-be/strings.xml b/OsmAnd/res/values-be/strings.xml
index e494fcb9e5..72cffaf28f 100644
--- a/OsmAnd/res/values-be/strings.xml
+++ b/OsmAnd/res/values-be/strings.xml
@@ -2966,7 +2966,6 @@
Выберыце, колькі індыкатараў накірунку будзе адлюстравана.
Зьнешні выгляд на мапе
Абярыце трэк, каб дадаць шляхавые кропкі да маркераў. (Пералічаныя толькі трэкі з шляхавымі кропкамі.)
- \@string/shared_string_history
Направа
Налева
Больш
diff --git a/OsmAnd/res/values-ca/strings.xml b/OsmAnd/res/values-ca/strings.xml
index 3ff78b63da..e28e68330e 100644
--- a/OsmAnd/res/values-ca/strings.xml
+++ b/OsmAnd/res/values-ca/strings.xml
@@ -2714,7 +2714,6 @@ Abasta l\'àrea: %1$s x %2$s
Premeu més o menys temps sobre els llocs i després el botó tipus bandera del marcador.
Importa grups
Podeu importar com marcadors a grups de preferits o a fites de la traça.
- \@string/shared_string_history
Els marcadors marcats com a aprovats apareixeran en aquesta pantalla.
Dos
Un
diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml
index 35fba6ccfb..32472df2a9 100644
--- a/OsmAnd/res/values-da/strings.xml
+++ b/OsmAnd/res/values-da/strings.xml
@@ -2966,7 +2966,6 @@ Repræsenterer område: %1$s x %2$s
Langt eller kort tryk på steder, og tryk derefter på markørflag knappen.
Importer grupper
Importer favoritgrupper eller et spor af rutepunkter som markører.
- \@string/shared_string_history
Markører, der er markeret som passeret vises på denne skærm.
Udseende på kortet
Find spor med rutepunkter
diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml
index 799b215fc1..74f7366d03 100644
--- a/OsmAnd/res/values-de/strings.xml
+++ b/OsmAnd/res/values-de/strings.xml
@@ -2900,7 +2900,6 @@ Abgedeckte Fläche: %1$s x %2$s
Gruppe hinzufügen
Kartenmarkierungen erstellen!
Gruppen importieren
- \@string/shared_string_history
Markierungen, die als passiert gekennzeichnet sind, werden auf diesem Bildschirm angezeigt.
Anzahl der Dezimalstellen
Nummernblock anzeigen
diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml
index 1d2d8b9659..135344611d 100644
--- a/OsmAnd/res/values-es-rAR/strings.xml
+++ b/OsmAnd/res/values-es-rAR/strings.xml
@@ -2846,7 +2846,6 @@ Proporciona un código completo
Elige cómo mostrar la distancia a los marcadores activos.
Elige cuántos indicadores de dirección mostrar.
Aspecto en el mapa
-
Búsqueda de trazas con puntos de referencia
Más
Crear o modificar objetos OSM
diff --git a/OsmAnd/res/values-es-rUS/strings.xml b/OsmAnd/res/values-es-rUS/strings.xml
index 6d858cd8f2..041830b4b8 100644
--- a/OsmAnd/res/values-es-rUS/strings.xml
+++ b/OsmAnd/res/values-es-rUS/strings.xml
@@ -2849,7 +2849,6 @@ Proporciona un código completo
Aspecto en el mapa
Búsqueda de trazas con puntos de referencia
Más
-
Crear o modificar objetos OSM
Crea o modifica puntos de interés (OSM), abre o comenta problemas del mapa (OSM), y contribuye con archivos de grabaciones GPX.
Borrado
diff --git a/OsmAnd/res/values-es/strings.xml b/OsmAnd/res/values-es/strings.xml
index 8ce58a9c42..e338ce98ae 100644
--- a/OsmAnd/res/values-es/strings.xml
+++ b/OsmAnd/res/values-es/strings.xml
@@ -2782,6 +2782,5 @@ Por favor proporciona un código completo
Elige cómo mostrar la distancia hasta los marcadores activos.
Elige cuántos indicadores de dirección se muestran.
Más
- \@string/shared_string_history
Buscando trazas con puntos de referencia
diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml
index 1a5e9d5a25..16d1173e9a 100644
--- a/OsmAnd/res/values-fr/strings.xml
+++ b/OsmAnd/res/values-fr/strings.xml
@@ -3012,7 +3012,6 @@ représentant la zone : %1$s x %2$s
Sélectionnez des emplacements sur la carte puis appuyez sur le drapeau de marque.
Importer des groupes
Vous pouvez importer des groupes de favoris ou des points de passage comme marques.
- \@string/shared_string_history
Les marques visitées s\'afficheront sur cet écran.
Deux
Une
diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml
index 6d10aff29d..e87a92b031 100644
--- a/OsmAnd/res/values-it/strings.xml
+++ b/OsmAnd/res/values-it/strings.xml
@@ -2970,7 +2970,6 @@ Rappresenta l\'area: %1$s x %2$s
Tap lungo o breve nel luogo, poi tappa il pulsante bandiera del marcatore.
Importa gruppi
Puoi importare, come marcatori, gruppi di luoghi preferiti o punti intermedi di tracce.
- \@string/shared_string_history
Marcatori indicati come passati appariranno su questa schermata.
Due
Uno
diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml
index 61d4383a8a..2a4cc4dfc5 100644
--- a/OsmAnd/res/values-ru/strings.xml
+++ b/OsmAnd/res/values-ru/strings.xml
@@ -2634,7 +2634,6 @@
Файл %1$s не содержит путевых точек, импортировать его как трек?
Выберите трек для добавления путевых точек. (Показаны только треки с путевыми точками.)
Трек путевых точек
- \@string/shared_string_history
Направо
Налево
Показать цифровую панель
diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml
index b57e318c70..9d4492965c 100644
--- a/OsmAnd/res/values-sc/strings.xml
+++ b/OsmAnd/res/values-sc/strings.xml
@@ -2861,7 +2861,6 @@ Pro praghere iscrie su còdighe intreu
Marca logos in sa mapa cun un\'incarcu curtzu o longu e, a pustis, incarchende su butone cun sa bandera de sos marcadores.
Importa grupos
Podes importare grupos de preferidos o puntos de coladòrgiu de una rasta comente marcadores.
- \@string/shared_string_history
Sos marcadores sinnados comente colados ant a aparire in custu ischermu.
Duos
Unu
diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml
index b5832b33f2..b28a8a6d77 100644
--- a/OsmAnd/res/values-uk/strings.xml
+++ b/OsmAnd/res/values-uk/strings.xml
@@ -3089,7 +3089,6 @@
Відзначити місце на мапі дотиком.
Імпортувати групи
Ви можете імпортувати групи закладок або шляхові точки треку як маркери.
- \@string/shared_string_history
Маркери, позначені як пройдені, з\'являться на цьому екрані.
Два
Один
diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml
index 89cd87db88..e9d6a5e352 100644
--- a/OsmAnd/res/values-zh-rTW/strings.xml
+++ b/OsmAnd/res/values-zh-rTW/strings.xml
@@ -2945,7 +2945,6 @@ OsmAnd (Automated Navigation Directions) 是一個地圖和導航的應用程式
長按或點一下地點,然後點擊標記標誌按鈕。
匯入群組
您可以匯入我的收藏群組或軌跡航點作為標記。
- \@string/shared_string_history
二
一
選擇如何顯示現行標記的距離。
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 74bd2dc17a..22e52f9f59 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -35,7 +35,6 @@
Long or short tap places, then tap the marker flag button.
Import groups
You can import favorite groups or track waypoints as markers.
- @string/shared_string_history
Markers marked as passed will appear on this screen.
Two
One
diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
index 7336268266..6b27448356 100644
--- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
+++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
@@ -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 markers, LatLon latLon, String name, boolean enabled) {
+ public boolean isSynced(SelectedGpxFile gpxFile) {
+ GPXFile gpx = gpxFile.getGpxFile();
+ List 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 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)) {
+ 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 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 points, List historyNames, @Nullable MarkersSyncGroup group) {
+ public void addMapMarkers(@NonNull List points, @NonNull List historyNames, @Nullable MarkersSyncGroup group) {
addMarkers(points, historyNames, group, true);
}
- private void addMarkers(List points, List historyNames, @Nullable MarkersSyncGroup group, boolean enabled) {
+ private void addMarkers(@NonNull List points, @NonNull List historyNames, @Nullable MarkersSyncGroup group, boolean enabled) {
+ addMarkers(points, historyNames, group, enabled, null, null);
+ }
+
+ private void addMarkers(@NonNull List points, @NonNull List historyNames, @Nullable MarkersSyncGroup group,
+ boolean enabled, @Nullable List favouritePoints, @Nullable List wptPts) {
if (points.size() > 0) {
int colorIndex = -1;
List 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 markers, boolean enabled) {
+ private void addMarkersToGroups(@NonNull List markers, boolean enabled) {
List 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();
diff --git a/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java b/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java
index 8bf83028d5..2a67b177b7 100644
--- a/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java
+++ b/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java
@@ -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 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);
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
index b33f1f56ef..5a3c16fcc1 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
@@ -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) {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
index 6abbc09581..cde5b3f35b 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
@@ -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);
- buttonWaypoint.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- menu.buttonWaypointPressed();
- }
- });
+ 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())) {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java
index 2b58f58a98..63b4c05240 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java
@@ -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 "";
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java
index 5c317790d2..e430ac5a0c 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java
@@ -111,4 +111,4 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
}
return null;
}
-}
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java
index 2bd01a0222..94de99c006 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java
@@ -76,4 +76,3 @@ public class WptPtMenuBuilder extends MenuBuilder {
buildPlainMenuItems(view);
}
}
-
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java
index 1e34bb140a..aab6b6b0f1 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java
@@ -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);
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java
index 7977446d9f..4a07a96155 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java
@@ -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);
+ }
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java
index 09095c5452..73c82ab902 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java
@@ -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 : "";
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java
index 497b276212..0d3a289064 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java
@@ -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();
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java
index 375ccd8d84..0a4a68f539 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java
@@ -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;
- mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
- 15, marker.getPointDescription(mapActivity), true, marker);
- MapActivity.launchMapActivityMoveToTop(mapActivity);
- ((DialogFragment) getParentFragment()).dismiss();
+ 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, 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;
}
diff --git a/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java b/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java
index 9efc9f1054..ed5dac297a 100644
--- a/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java
@@ -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 cache = new ArrayList<>();
private MapTextLayer textLayer;
private Paint paintIcon;
@@ -54,7 +56,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
protected List extends FavouritePoint> getPoints() {
return favorites.getFavouritePoints();
}
-
+
@Override
public void initLayer(OsmandMapTileView view) {
this.view = view;
@@ -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(),
- objectInMotion.getColor(), true);
+ 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);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java
index be7921a76d..bbb117b321 100644
--- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java
@@ -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 cache = new ArrayList<>();
private Map 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));
}
}
diff --git a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java
index 44194aff2a..38efc761ff 100644
--- a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java
@@ -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,14 +521,16 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
int r = getRadiusPoi(tileBox);
for (int i = 0; i < markers.size(); i++) {
MapMarker marker = markers.get(i);
- LatLon latLon = marker.point;
- if (latLon != null) {
- int ex = (int) point.x;
- int ey = (int) point.y;
- int x = (int) tileBox.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
- int y = (int) tileBox.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
- if (calculateBelongs(ex, ey, x, y, r)) {
- o.add(marker);
+ if (!isSynced(marker)) {
+ LatLon latLon = marker.point;
+ if (latLon != null) {
+ int ex = (int) point.x;
+ int ey = (int) point.y;
+ int x = (int) tileBox.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
+ int y = (int) tileBox.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
+ if (calculateBelongs(ex, ey, x, y, r)) {
+ o.add(marker);
+ }
}
}
}