diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index 52ab9f268b..b916c25337 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -310,6 +310,7 @@ public class MapMarkersHelper { public void syncWithMarkers(@NonNull MapMarkersGroup group) { if (!isGroupSynced(group.getId())) { markersDbHelper.addGroup(group); + addHistoryMarkersToGroup(group); addToGroupsList(group); } else if (group.wptCategories != null) { markersDbHelper.updateGroupCategories(group.getId(), group.getWptCategoriesString()); @@ -317,6 +318,15 @@ public class MapMarkersHelper { runSynchronization(group); } + private void addHistoryMarkersToGroup(@NonNull MapMarkersGroup group) { + List historyMarkers = new ArrayList<>(mapMarkersHistory); + for (MapMarker m : historyMarkers) { + if (m.groupKey != null && group.getId() != null && m.groupKey.equals(group.getId())) { + group.getMarkers().add(m); + } + } + } + public void removeMarkersGroup(MapMarkersGroup group) { if (group != null) { markersDbHelper.removeMarkersGroup(group.getId()); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java index 7219c5f73f..1399dd0f48 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java @@ -300,7 +300,8 @@ public class MapMarkersDbHelper { if (db != null) { try { db.execSQL("DELETE FROM " + GROUPS_TABLE_NAME + " WHERE " + GROUPS_COL_DISABLED + " = ? ", new Object[]{1}); - db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME + " WHERE " + MARKERS_COL_DISABLED + " = ? ", new Object[]{1}); + db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME + + " WHERE " + MARKERS_COL_DISABLED + " = ? AND " + MARKERS_COL_ACTIVE + " = ?", new Object[]{1, 1}); } finally { db.close(); } @@ -408,8 +409,8 @@ public class MapMarkersDbHelper { SQLiteConnection db = openConnection(true); if (db != null) { try { - SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ? " + "AND " + MARKERS_COL_DISABLED + " = ?", - new String[]{String.valueOf(1), String.valueOf(0)}); + SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?", + new String[]{String.valueOf(1)}); if (query.moveToFirst()) { do { MapMarker marker = readItem(query); @@ -567,8 +568,8 @@ public class MapMarkersDbHelper { SQLiteConnection db = openConnection(true); if (db != null) { try { - SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ? " + "AND " + MARKERS_COL_DISABLED + " = ?", - new String[]{String.valueOf(0), String.valueOf(0)}); + SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?", + new String[]{String.valueOf(0)}); if (query.moveToFirst()) { do { markers.add(readItem(query)); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java index 626a37b348..ded5753518 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java @@ -51,6 +51,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee final BottomSheetItemWithCompoundButton[] selectAllItem = new BottomSheetItemWithCompoundButton[1]; selectAllItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() + .setChecked(true) .setDescription(getString(R.string.shared_string_total) + ": " + gpxFile.getPoints().size()) .setIcon(getContentIcon(R.drawable.ic_action_group_select_all)) .setTitle(getString(R.string.shared_string_select_all)) @@ -75,6 +76,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee for (String category : pointsByCategories.keySet()) { final BottomSheetItemWithCompoundButton[] categoryItem = new BottomSheetItemWithCompoundButton[1]; categoryItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() + .setChecked(true) .setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { @@ -100,6 +102,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee .create(); items.add(categoryItem[0]); categoryItems.add(categoryItem[0]); + selectedCategories.add(category); } }