From 4923723adef9feb1716d6030d2e0c02ec8ab0f3b Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 3 Nov 2020 18:11:38 +0200 Subject: [PATCH 1/7] Add MarkersSettingsItem initial commit --- .../settings/backend/ExportSettingsType.java | 3 +- .../backend/backup/MarkersSettingsItem.java | 152 ++++++++++++++++++ .../backend/backup/SettingsHelper.java | 19 +++ .../backend/backup/SettingsItemType.java | 3 +- .../backend/backup/SettingsItemsFactory.java | 3 + .../fragments/DuplicatesSettingsAdapter.java | 20 ++- .../ExportImportSettingsAdapter.java | 12 ++ .../ImportedSettingsItemsAdapter.java | 4 + 8 files changed, 209 insertions(+), 7 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java index 91d5493217..a530ef5dcf 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java @@ -16,5 +16,6 @@ public enum ExportSettingsType { OFFLINE_MAPS, FAVORITES, TTS_VOICE, - VOICE + VOICE, + MARKERS } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java new file mode 100644 index 0000000000..0d1f9d6bb8 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java @@ -0,0 +1,152 @@ +package net.osmand.plus.settings.backend.backup; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.GPXUtilities; +import net.osmand.GPXUtilities.GPXFile; +import net.osmand.plus.MapMarkersHelper; +import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import static net.osmand.IndexConstants.GPX_FILE_EXT; + +public class MarkersSettingsItem extends CollectionSettingsItem { + + private MapMarkersHelper markersHelper; + + public MarkersSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { + super(app, null, items); + } + + public MarkersSettingsItem(@NonNull OsmandApplication app, @Nullable MarkersSettingsItem baseItem, @NonNull List items) { + super(app, baseItem, items); + } + + MarkersSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { + super(app, json); + } + + @Override + protected void init() { + super.init(); + markersHelper = app.getMapMarkersHelper(); + existingItems = new ArrayList<>(markersHelper.getMapMarkersGroups()); + } + + @NonNull + @Override + public SettingsItemType getType() { + return SettingsItemType.MARKERS; + } + + @NonNull + @Override + public String getName() { + return "markers"; + } + + @NonNull + @Override + public String getPublicName(@NonNull Context ctx) { + return ctx.getString(R.string.map_markers); + } + + @NonNull + public String getDefaultFileName() { + return getName() + getDefaultFileExtension(); + } + + @NonNull + public String getDefaultFileExtension() { + return GPX_FILE_EXT; + } + + @Override + public void apply() { + List newItems = getNewItems(); + if (!newItems.isEmpty() || !duplicateItems.isEmpty()) { + appliedItems = new ArrayList<>(newItems); + + for (MapMarkersGroup duplicate : duplicateItems) { + if (shouldReplace) { + + } + appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate)); + } + } + } + + @Override + public boolean isDuplicate(@NonNull MapMarkersGroup markersGroup) { + String name = markersGroup.getName(); + for (MapMarkersGroup group : existingItems) { + if (group.getName().equals(name)) { + return true; + } + } + return false; + } + + @Override + public boolean shouldReadOnCollecting() { + return true; + } + + @NonNull + @Override + public MapMarkersGroup renameItem(@NonNull MapMarkersGroup item) { + return item; + } + + @Nullable + @Override + SettingsItemReader getReader() { + return new SettingsItemReader(this) { + + @Override + public void readFromStream(@NonNull InputStream inputStream, File destination) throws IOException, IllegalArgumentException { + GPXFile gpxFile = GPXUtilities.loadGPXFile(inputStream); + if (gpxFile.error != null) { + warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType()))); + SettingsHelper.LOG.error("Failed read gpx file", gpxFile.error); + } else { + Map flatGroups = new LinkedHashMap<>(); + } + } + }; + } + + @Nullable + @Override + SettingsItemWriter getWriter() { + return new SettingsItemWriter(this) { + + @Override + public boolean writeToStream(@NonNull OutputStream outputStream) throws IOException { +// Exception error = GPXUtilities.writeGpx(new OutputStreamWriter(outputStream, "UTF-8"), gpxFile); +// if (error != null) { +// warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType()))); +// SettingsHelper.LOG.error("Failed write to gpx file", error); +// return false; +// } + return true; + } + }; + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java index f3821505a2..43e8fe22c2 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java @@ -14,6 +14,7 @@ import net.osmand.map.ITileSource; import net.osmand.map.TileSourceManager; import net.osmand.map.TileSourceManager.TileSourceTemplate; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; +import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.SQLiteTileSource; @@ -552,6 +553,10 @@ public class SettingsHelper { if (!files.isEmpty()) { dataList.put(ExportSettingsType.VOICE, files); } + List markersGroups = app.getMapMarkersHelper().getMapMarkersGroups(); + if (!markersGroups.isEmpty()) { + dataList.put(ExportSettingsType.MARKERS, markersGroups); + } return dataList; } @@ -591,6 +596,7 @@ public class SettingsHelper { List favoriteGroups = new ArrayList<>(); List osmNotesPointList = new ArrayList<>(); List osmEditsPointList = new ArrayList<>(); + List markersGroups = new ArrayList<>(); for (Object object : data) { if (object instanceof QuickAction) { @@ -615,6 +621,8 @@ public class SettingsHelper { osmEditsPointList.add((OpenstreetmapPoint) object); } else if (object instanceof FavoriteGroup) { favoriteGroups.add((FavoriteGroup) object); + } else if (object instanceof MapMarkersGroup) { + markersGroups.add((MapMarkersGroup) object); } } if (!quickActions.isEmpty()) { @@ -646,6 +654,9 @@ public class SettingsHelper { if (!favoriteGroups.isEmpty()) { settingsItems.add(new FavoritesSettingsItem(app, favoriteGroups)); } + if (!markersGroups.isEmpty()) { + settingsItems.add(new MarkersSettingsItem(app, markersGroups)); + } return settingsItems; } @@ -667,6 +678,7 @@ public class SettingsHelper { List notesPointList = new ArrayList<>(); List editsPointList = new ArrayList<>(); List favoriteGroups = new ArrayList<>(); + List markersGroups = new ArrayList<>(); for (SettingsItem item : settingsItems) { switch (item.getType()) { @@ -746,6 +758,10 @@ public class SettingsHelper { FavoritesSettingsItem favoritesSettingsItem = (FavoritesSettingsItem) item; favoriteGroups.addAll(favoritesSettingsItem.getItems()); break; + case MARKERS: + MarkersSettingsItem markersSettingsItem = (MarkersSettingsItem) item; + markersGroups.addAll(markersSettingsItem.getItems()); + break; default: break; } @@ -799,6 +815,9 @@ public class SettingsHelper { if (!voiceFilesList.isEmpty()) { settingsToOperate.put(ExportSettingsType.VOICE, voiceFilesList); } + if (!markersGroups.isEmpty()) { + settingsToOperate.put(ExportSettingsType.MARKERS, markersGroups); + } return settingsToOperate; } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java index bb6b68b3ce..bc254e28ca 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java @@ -15,5 +15,6 @@ public enum SettingsItemType { DOWNLOADS, OSM_NOTES, OSM_EDITS, - FAVOURITES + FAVOURITES, + MARKERS } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java index 9669099003..3012cc3dd8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java @@ -134,6 +134,9 @@ class SettingsItemsFactory { case FAVOURITES: item = new FavoritesSettingsItem(app, json); break; + case MARKERS: + item = new MarkersSettingsItem(app, json); + break; } return item; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java index d90f4b7429..58af347031 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java @@ -14,19 +14,20 @@ import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.map.ITileSource; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; -import net.osmand.plus.audionotes.AudioVideoNotesPlugin; -import net.osmand.plus.helpers.GpxUiHelper; -import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean; +import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; +import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; +import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.profiles.ProfileIconColors; import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources; import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.render.RenderingIcons; +import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; @@ -134,7 +135,7 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter Date: Tue, 3 Nov 2020 18:34:49 +0200 Subject: [PATCH 2/7] Move MapMarkersHelper to mapmarkers package --- OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 4 ++-- OsmAnd/src/net/osmand/plus/AppInitializer.java | 1 + OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java | 3 ++- OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java | 3 ++- OsmAnd/src/net/osmand/plus/OsmandApplication.java | 1 + .../activities/EditFavoriteGroupDialogFragment.java | 4 ++-- .../osmand/plus/activities/FavoritesTreeFragment.java | 2 +- OsmAnd/src/net/osmand/plus/activities/MapActivity.java | 4 ++-- .../net/osmand/plus/activities/MapActivityActions.java | 4 ++-- .../net/osmand/plus/base/MapViewTrackingUtilities.java | 4 ++-- .../src/net/osmand/plus/helpers/ExternalApiHelper.java | 4 ++-- OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java | 2 +- .../net/osmand/plus/helpers/MapMarkerDialogHelper.java | 2 +- .../net/osmand/plus/mapcontextmenu/MapContextMenu.java | 4 ++-- .../net/osmand/plus/mapcontextmenu/MenuController.java | 2 +- .../controllers/AmenityMenuController.java | 2 +- .../controllers/FavouritePointMenuController.java | 4 ++-- .../controllers/MapMarkerMenuController.java | 4 ++-- .../controllers/WptPtMenuController.java | 4 ++-- .../plus/mapcontextmenu/editors/MapMarkerEditor.java | 2 +- .../editors/MapMarkerEditorFragment.java | 2 +- .../mapcontextmenu/editors/WptPtEditorFragment.java | 4 ++-- .../mapcontextmenu/editors/WptPtEditorFragmentNew.java | 4 ++-- .../plus/mapmarkers/CoordinateInputDialogFragment.java | 2 -- .../HistoryMarkerMenuBottomSheetDialogFragment.java | 2 +- .../plus/mapmarkers/MapMarkerSelectionFragment.java | 2 +- .../plus/mapmarkers/MapMarkersActiveFragment.java | 2 +- .../net/osmand/plus/mapmarkers/MapMarkersDbHelper.java | 5 ++--- .../plus/mapmarkers/MapMarkersDialogFragment.java | 5 ++--- .../plus/mapmarkers/MapMarkersGroupsFragment.java | 2 +- .../osmand/plus/{ => mapmarkers}/MapMarkersHelper.java | 10 +++++++--- .../plus/mapmarkers/MapMarkersHistoryFragment.java | 3 +-- .../plus/mapmarkers/MarkersPlanRouteContext.java | 1 - .../mapmarkers/OrderByBottomSheetDialogFragment.java | 3 +-- .../net/osmand/plus/mapmarkers/PlanRouteFragment.java | 3 +-- .../SelectWptCategoriesBottomSheetDialogFragment.java | 3 +-- .../mapmarkers/adapters/MapMarkersActiveAdapter.java | 6 +++--- .../mapmarkers/adapters/MapMarkersGroupsAdapter.java | 10 +++++----- .../mapmarkers/adapters/MapMarkersHistoryAdapter.java | 2 +- .../mapmarkers/adapters/MapMarkersListAdapter.java | 2 +- .../plus/myplaces/EditTrackGroupDialogFragment.java | 4 ++-- .../net/osmand/plus/myplaces/TrackPointFragment.java | 4 ++-- .../AddPointBottomSheetDialog.java | 4 ++-- .../plus/routepreparationmenu/MapRouteInfoMenu.java | 2 +- .../routepreparationmenu/cards/MapMarkersCard.java | 2 +- .../settings/backend/backup/MarkersSettingsItem.java | 4 ++-- .../plus/settings/backend/backup/SettingsHelper.java | 2 +- .../settings/fragments/DuplicatesSettingsAdapter.java | 2 +- .../fragments/ExportImportSettingsAdapter.java | 2 +- .../net/osmand/plus/views/layers/FavouritesLayer.java | 4 ++-- OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java | 6 +++--- .../net/osmand/plus/views/layers/MapMarkersLayer.java | 4 ++-- .../views/mapwidgets/MapMarkersWidgetsFactory.java | 4 ++-- .../plus/views/mapwidgets/RouteInfoWidgetsFactory.java | 2 +- 54 files changed, 89 insertions(+), 90 deletions(-) rename OsmAnd/src/net/osmand/plus/{ => mapmarkers}/MapMarkersHelper.java (99%) diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index ec3a9c1e10..89b5c95828 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -55,8 +55,8 @@ import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.SQLiteTileSource; diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 58690a9a3b..b172d08242 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -41,6 +41,7 @@ import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.inapp.InAppPurchaseHelperImpl; import net.osmand.plus.liveupdates.LiveUpdatesHelper; import net.osmand.plus.mapmarkers.MapMarkersDbHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper; import net.osmand.plus.monitoring.LiveMonitoringHelper; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.poi.PoiFiltersHelper; diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 22beca7cbe..0e79b30e5b 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -16,7 +16,8 @@ import net.osmand.PlatformUtil; import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.plus.GeocodingLookupService.AddressLookupRequest; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; import net.osmand.plus.api.SQLiteAPI.SQLiteCursor; import net.osmand.util.Algorithms; diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 923bbe646a..b4d4fa0c3b 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -23,7 +23,8 @@ import net.osmand.PlatformUtil; import net.osmand.StateChangedListener; import net.osmand.data.LatLon; import net.osmand.plus.GPXDatabase.GpxDataItem; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType; diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index b57d94dc3a..539db520ae 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -63,6 +63,7 @@ import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.mapmarkers.MapMarkersDbHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper; import net.osmand.plus.monitoring.LiveMonitoringHelper; import net.osmand.plus.poi.PoiFiltersHelper; import net.osmand.plus.quickaction.QuickActionRegistry; diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index 4b2079a573..63c84274c6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -27,8 +27,8 @@ import androidx.fragment.app.FragmentManager; import net.osmand.AndroidUtils; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index b1a625d27e..866503f477 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -41,7 +41,7 @@ import net.osmand.data.PointDescription; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; import net.osmand.plus.FavouritesDbHelper.FavoritesListener; -import net.osmand.plus.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper; import net.osmand.plus.OsmandApplication; import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.settings.backend.OsmandSettings; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 8cb6e832c5..f9f8a81726 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -67,8 +67,8 @@ import net.osmand.plus.AppInitializer; import net.osmand.plus.AppInitializer.AppInitializeListener; import net.osmand.plus.AppInitializer.InitEvents; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; -import net.osmand.plus.MapMarkersHelper.MapMarker; -import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener; import net.osmand.plus.OnDismissDialogFragmentListener; import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmAndLocationSimulation; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 294b382ca4..ba13014b8f 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -39,8 +39,8 @@ import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.ItemClickListener; import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem.ItemBuilder; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java index 601fb62909..a0a3ef4edb 100644 --- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java +++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java @@ -13,8 +13,8 @@ import net.osmand.data.LatLon; import net.osmand.data.RotatedTileBox; import net.osmand.map.IMapLocationListener; import net.osmand.map.WorldRegion; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener; import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; diff --git a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java index 91d9a6f255..f6aa0f9526 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java @@ -31,8 +31,8 @@ import net.osmand.data.PointDescription; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; diff --git a/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java b/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java index 19748b100c..baadd43208 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java @@ -11,7 +11,7 @@ import net.osmand.PlatformUtil; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.map.TileSourceManager; -import net.osmand.plus.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java index 37bbbfda1a..a46e490635 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java @@ -10,7 +10,7 @@ import android.widget.TextView; import net.osmand.AndroidUtils; import net.osmand.Location; import net.osmand.data.LatLon; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 226216be06..6d99c3cad1 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -25,8 +25,8 @@ import net.osmand.data.TransportStop; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.MapMarkersHelper.MapMarker; -import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 55fc56b3b8..55f6063a87 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -32,7 +32,7 @@ import net.osmand.data.TransportStop; import net.osmand.map.OsmandRegions; import net.osmand.map.WorldRegion; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index 06ade3cc26..4f39b41773 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -12,7 +12,7 @@ import net.osmand.data.TransportStop; import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiFilter; import net.osmand.osm.PoiType; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java index 9659ecd40b..4c53ded466 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java @@ -14,8 +14,8 @@ import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.TransportStop; import net.osmand.plus.FavouritesDbHelper; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java index b8f5789d47..6ea4e701e1 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java @@ -11,8 +11,8 @@ import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import net.osmand.data.PointDescription; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java index 3c1ce7d9f4..ddf3cecb9c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java @@ -11,8 +11,8 @@ import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.PointImageDrawable; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditor.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditor.java index b90cd2c334..f75c71ca4c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditor.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditor.java @@ -2,7 +2,7 @@ package net.osmand.plus.mapcontextmenu.editors; import androidx.annotation.NonNull; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.activities.MapActivity; public class MapMarkerEditor extends PointEditor { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditorFragment.java index ac0f69e37f..c925f95d4b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditorFragment.java @@ -14,7 +14,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import net.osmand.data.PointDescription; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java index 26062bafc4..80a937087f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java @@ -17,8 +17,8 @@ import net.osmand.GPXUtilities.WptPt; import net.osmand.data.LatLon; import net.osmand.data.WptLocationPoint; import net.osmand.plus.GpxSelectionHelper; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java index 92d6368a04..30da85d0bb 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java @@ -20,8 +20,8 @@ import net.osmand.data.FavouritePoint.BackgroundType; import net.osmand.data.LatLon; import net.osmand.data.WptLocationPoint; import net.osmand.plus.GpxSelectionHelper; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index aef217f347..89ffdd389c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -63,7 +63,6 @@ import net.osmand.GPXUtilities.WptPt; import net.osmand.IndexConstants; import net.osmand.Location; import net.osmand.plus.GpxSelectionHelper; -import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmandApplication; @@ -79,7 +78,6 @@ import net.osmand.plus.mapmarkers.CoordinateInputFormats.DDM; import net.osmand.plus.mapmarkers.CoordinateInputFormats.DMS; import net.osmand.plus.mapmarkers.CoordinateInputFormats.Format; import net.osmand.plus.mapmarkers.adapters.CoordinateInputAdapter; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.widgets.EditTextEx; import net.osmand.util.Algorithms; import net.osmand.util.LocationParser; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java index a1a3eaf82b..dc1e39bd92 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java @@ -3,7 +3,7 @@ package net.osmand.plus.mapmarkers; import android.os.Bundle; import android.view.View; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.R; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java index 993c5c1d93..e18a54c802 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java @@ -15,7 +15,7 @@ import androidx.annotation.Nullable; import net.osmand.AndroidUtils; import net.osmand.data.LatLon; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java index b893fbe5c8..69ec8af5a5 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java @@ -21,7 +21,7 @@ import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.WptLocationPoint; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmandApplication; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java index d3c1c37705..1bdf8701b4 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java @@ -4,8 +4,8 @@ import androidx.annotation.Nullable; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; -import net.osmand.plus.MapMarkersHelper.MapMarker; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; import net.osmand.plus.api.SQLiteAPI.SQLiteCursor; @@ -13,7 +13,6 @@ import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.util.Algorithms; import java.util.ArrayList; -import java.util.Calendar; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index e84f7cbfc4..6d729c4ce2 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -29,9 +29,8 @@ import net.osmand.AndroidUtils; import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.plus.LockableViewPager; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarkersSortByDef; -import net.osmand.plus.MapMarkersHelper.OnGroupSyncedListener; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersSortByDef; +import net.osmand.plus.mapmarkers.MapMarkersHelper.OnGroupSyncedListener; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java index 5d368b7580..98b9128151 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java @@ -28,7 +28,7 @@ import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.WptLocationPoint; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmandApplication; diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java similarity index 99% rename from OsmAnd/src/net/osmand/plus/MapMarkersHelper.java rename to OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java index c168047ba9..c2615538a4 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java @@ -1,4 +1,4 @@ -package net.osmand.plus; +package net.osmand.plus.mapmarkers; import android.content.Context; import android.os.AsyncTask; @@ -19,10 +19,14 @@ import net.osmand.data.LatLon; import net.osmand.data.LocationPoint; import net.osmand.data.PointDescription; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; +import net.osmand.plus.GPXDatabase; +import net.osmand.plus.GeocodingLookupService; import net.osmand.plus.GeocodingLookupService.AddressLookupRequest; +import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.mapmarkers.MapMarkersDbHelper; -import net.osmand.plus.mapmarkers.MarkersPlanRouteContext; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.Version; import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.TravelDbHelper; import net.osmand.util.Algorithms; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java index a472dbf3a7..5cc2b081ab 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java @@ -20,8 +20,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.snackbar.Snackbar; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkersPlanRouteContext.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkersPlanRouteContext.java index 025205cbca..622fa39542 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkersPlanRouteContext.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkersPlanRouteContext.java @@ -7,7 +7,6 @@ import net.osmand.data.LatLon; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.GPXUtilities.TrkSegment; import net.osmand.GPXUtilities.WptPt; -import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.OsmandApplication; import net.osmand.plus.routing.RouteCalculationParams; import net.osmand.plus.routing.RouteCalculationResult; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java index 7239b76fcc..8e16b708b1 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java @@ -4,8 +4,7 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.view.View; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarkersSortByDef; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersSortByDef; import net.osmand.plus.R; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java index 60399c3872..8a891f7a11 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java @@ -39,8 +39,7 @@ import net.osmand.TspAnt; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.RotatedTileBox; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmandApplication; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java index 0052bf655e..305d9a6b5b 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java @@ -13,8 +13,7 @@ import net.osmand.GPXUtilities.WptPt; import net.osmand.IndexConstants; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.base.MenuBottomSheetDialogFragment; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java index 4b6eee036b..c81dffbf63 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java @@ -13,9 +13,9 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.snackbar.Snackbar; import net.osmand.data.LatLon; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarker; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java index 6b8a1b9dcd..650fb9e9e5 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java @@ -21,11 +21,11 @@ import net.osmand.IndexConstants; import net.osmand.data.LatLon; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.GroupHeader; -import net.osmand.plus.MapMarkersHelper.MapMarker; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; -import net.osmand.plus.MapMarkersHelper.ShowHideHistoryButton; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.GroupHeader; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper.ShowHideHistoryButton; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java index 024651d819..2278d0412d 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java @@ -10,7 +10,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.snackbar.Snackbar; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java index 31695a085a..d01a845f68 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java @@ -17,7 +17,7 @@ import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.plus.GeocodingLookupService.AddressLookupRequest; import net.osmand.plus.GeocodingLookupService.OnAddressLookupResult; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; diff --git a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java index a08674368f..7a6c117058 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java @@ -28,8 +28,8 @@ import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.WptPt; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.EditFavoriteGroupDialogFragment.FavoriteColorAdapter; diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java index 72526e92ba..5c2f48f7e4 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java @@ -54,8 +54,8 @@ import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java index 4b2bfd6665..39ca914b7b 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java @@ -27,8 +27,8 @@ import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.plus.FavouritesDbHelper; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index 4e16226026..b070f59264 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -51,7 +51,7 @@ import net.osmand.plus.GeocodingLookupService; import net.osmand.plus.GeocodingLookupService.AddressLookupRequest; import net.osmand.plus.GeocodingLookupService.OnAddressLookupResult; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmandApplication; import net.osmand.plus.settings.backend.OsmandSettings; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/MapMarkersCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/MapMarkersCard.java index f4bbd99d8c..15bdb9af01 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/MapMarkersCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/MapMarkersCard.java @@ -14,7 +14,7 @@ import androidx.appcompat.view.ContextThemeWrapper; import net.osmand.AndroidUtils; import net.osmand.data.LatLon; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MapViewTrackingUtilities; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java index 0d1f9d6bb8..e0ee6b758e 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java @@ -7,8 +7,8 @@ import androidx.annotation.Nullable; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java index 43e8fe22c2..176303632d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java @@ -14,7 +14,7 @@ import net.osmand.map.ITileSource; import net.osmand.map.TileSourceManager; import net.osmand.map.TileSourceManager.TileSourceTemplate; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.SQLiteTileSource; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java index 58af347031..25d5ca9503 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java @@ -14,7 +14,7 @@ import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.map.ITileSource; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java index b695395673..eec6cde0f9 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java @@ -17,7 +17,7 @@ import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.map.ITileSource; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; diff --git a/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java index d0a1b91d8b..1093d02e0f 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java @@ -17,8 +17,8 @@ import net.osmand.data.QuadTree; import net.osmand.data.RotatedTileBox; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.base.PointImageDrawable; diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index 46d51bca33..4169e8da0a 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -37,9 +37,9 @@ 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.MapMarker; -import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java index 244a9efc17..a8b992ddde 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java @@ -31,8 +31,8 @@ import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadPoint; import net.osmand.data.RotatedTileBox; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java index 799490d949..733d23308b 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java @@ -9,8 +9,8 @@ import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.plus.UiUtilities; -import net.osmand.plus.MapMarkersHelper; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index f77bc27f36..b8e9c9e8f0 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java @@ -12,7 +12,7 @@ import android.view.View; import net.osmand.Location; import net.osmand.binary.RouteDataObject; import net.osmand.data.LatLon; -import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmandApplication; From 7c4b28613c11633eee7212a76ec188e3ba91212f Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 3 Nov 2020 23:21:33 +0200 Subject: [PATCH 3/7] Move inner classes from MapMarkersHelper --- OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 2 +- .../net/osmand/plus/FavouritesDbHelper.java | 2 +- .../net/osmand/plus/GpxSelectionHelper.java | 2 +- .../EditFavoriteGroupDialogFragment.java | 2 +- .../osmand/plus/activities/MapActivity.java | 2 +- .../plus/activities/MapActivityActions.java | 2 +- .../plus/base/MapViewTrackingUtilities.java | 4 +- .../plus/helpers/ExternalApiHelper.java | 2 +- .../net/osmand/plus/helpers/IntentHelper.java | 4 +- .../plus/helpers/MapMarkerDialogHelper.java | 2 +- .../plus/mapcontextmenu/MapContextMenu.java | 2 +- .../plus/mapcontextmenu/MenuController.java | 2 +- .../controllers/AmenityMenuController.java | 2 +- .../FavouritePointMenuController.java | 2 +- .../controllers/MapMarkerMenuController.java | 2 +- .../controllers/WptPtMenuController.java | 2 +- .../editors/MapMarkerEditor.java | 2 +- .../editors/MapMarkerEditorFragment.java | 2 +- .../editors/WptPtEditorFragment.java | 2 +- .../editors/WptPtEditorFragmentNew.java | 2 +- .../plus/mapmarkers/CategoriesSubHeader.java | 24 ++ .../CoordinateInputDialogFragment.java | 2 +- .../osmand/plus/mapmarkers/GroupHeader.java | 24 ++ ...ryMarkerMenuBottomSheetDialogFragment.java | 1 - .../net/osmand/plus/mapmarkers/MapMarker.java | 137 +++++++ .../MapMarkerSelectionFragment.java | 1 - .../mapmarkers/MapMarkersActiveFragment.java | 1 - .../plus/mapmarkers/MapMarkersDbHelper.java | 2 - .../mapmarkers/MapMarkersDialogFragment.java | 2 +- .../plus/mapmarkers/MapMarkersGroup.java | 183 +++++++++ .../mapmarkers/MapMarkersGroupsFragment.java | 1 - .../plus/mapmarkers/MapMarkersHelper.java | 380 ++---------------- .../mapmarkers/MapMarkersHistoryFragment.java | 1 - .../plus/mapmarkers/PlanRouteFragment.java | 1 - ...ptCategoriesBottomSheetDialogFragment.java | 1 - .../mapmarkers/ShowHideHistoryButton.java | 5 + .../adapters/MapMarkersActiveAdapter.java | 7 +- .../adapters/MapMarkersGroupsAdapter.java | 17 +- .../adapters/MapMarkersHistoryAdapter.java | 2 +- .../adapters/MapMarkersListAdapter.java | 2 +- .../EditTrackGroupDialogFragment.java | 2 +- .../plus/myplaces/TrackPointFragment.java | 2 +- .../AddPointBottomSheetDialog.java | 2 +- .../MapRouteInfoMenu.java | 2 +- .../cards/MapMarkersCard.java | 2 +- .../backend/backup/MarkersSettingsItem.java | 2 +- .../backend/backup/SettingsHelper.java | 2 +- .../fragments/DuplicatesSettingsAdapter.java | 2 +- .../ExportImportSettingsAdapter.java | 2 +- .../plus/views/layers/FavouritesLayer.java | 2 +- .../osmand/plus/views/layers/GPXLayer.java | 4 +- .../plus/views/layers/MapMarkersLayer.java | 2 +- .../mapwidgets/MapMarkersWidgetsFactory.java | 2 +- .../mapwidgets/RouteInfoWidgetsFactory.java | 2 +- 54 files changed, 467 insertions(+), 401 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/mapmarkers/CategoriesSubHeader.java create mode 100644 OsmAnd/src/net/osmand/plus/mapmarkers/GroupHeader.java create mode 100644 OsmAnd/src/net/osmand/plus/mapmarkers/MapMarker.java create mode 100644 OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroup.java create mode 100644 OsmAnd/src/net/osmand/plus/mapmarkers/ShowHideHistoryButton.java diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 89b5c95828..de3f073bdc 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -56,7 +56,7 @@ import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.SQLiteTileSource; diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 0e79b30e5b..c1db6114bc 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -17,7 +17,7 @@ import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.plus.GeocodingLookupService.AddressLookupRequest; import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; import net.osmand.plus.api.SQLiteAPI.SQLiteCursor; import net.osmand.util.Algorithms; diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index b4d4fa0c3b..2651e7b988 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -24,7 +24,7 @@ import net.osmand.StateChangedListener; import net.osmand.data.LatLon; import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType; diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index 63c84274c6..001868e7b4 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -28,7 +28,7 @@ import net.osmand.AndroidUtils; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index f9f8a81726..f38012a987 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -67,7 +67,7 @@ import net.osmand.plus.AppInitializer; import net.osmand.plus.AppInitializer.AppInitializeListener; import net.osmand.plus.AppInitializer.InitEvents; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener; import net.osmand.plus.OnDismissDialogFragmentListener; import net.osmand.plus.OsmAndConstants; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index ba13014b8f..08fef7dd77 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -40,7 +40,7 @@ import net.osmand.plus.ContextMenuAdapter.ItemClickListener; import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem.ItemBuilder; import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java index a0a3ef4edb..9c6c6c2e7e 100644 --- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java +++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java @@ -13,7 +13,7 @@ import net.osmand.data.LatLon; import net.osmand.data.RotatedTileBox; import net.osmand.map.IMapLocationListener; import net.osmand.map.WorldRegion; -import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener; import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmAndLocationProvider; @@ -88,7 +88,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc } @Override - public void onMapMarkerChanged(MapMarkersHelper.MapMarker mapMarker) { + public void onMapMarkerChanged(MapMarker mapMarker) { } @Override diff --git a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java index f6aa0f9526..6222663a00 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java @@ -32,7 +32,7 @@ import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; diff --git a/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java b/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java index baadd43208..d0d74badfe 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java @@ -11,7 +11,7 @@ import net.osmand.PlatformUtil; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.map.TileSourceManager; -import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; @@ -207,7 +207,7 @@ public class IntentHelper { if (intent.hasExtra(MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS)) { Bundle openMapMarkersGroupsExtra = intent.getBundleExtra(MapMarkersDialogFragment.OPEN_MAP_MARKERS_GROUPS); if (openMapMarkersGroupsExtra != null) { - MapMarkersDialogFragment.showInstance(mapActivity, openMapMarkersGroupsExtra.getString(MapMarkersHelper.MapMarkersGroup.MARKERS_SYNC_GROUP_ID)); + MapMarkersDialogFragment.showInstance(mapActivity, openMapMarkersGroupsExtra.getString(MapMarkersGroup.MARKERS_SYNC_GROUP_ID)); } mapActivity.setIntent(null); } diff --git a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java index a46e490635..a90247e644 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java @@ -10,7 +10,7 @@ import android.widget.TextView; import net.osmand.AndroidUtils; import net.osmand.Location; import net.osmand.data.LatLon; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 6d99c3cad1..1bb1e1146e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -25,7 +25,7 @@ import net.osmand.data.TransportStop; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 55f6063a87..d2c1cf155a 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -32,7 +32,7 @@ import net.osmand.data.TransportStop; import net.osmand.map.OsmandRegions; import net.osmand.map.WorldRegion; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index 4f39b41773..aa65a39e90 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -12,7 +12,7 @@ import net.osmand.data.TransportStop; import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiFilter; import net.osmand.osm.PoiType; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java index 4c53ded466..84ced6c613 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java @@ -15,7 +15,7 @@ import net.osmand.data.PointDescription; import net.osmand.data.TransportStop; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java index 6ea4e701e1..29bc7c01aa 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java @@ -12,7 +12,7 @@ import androidx.core.content.ContextCompat; import net.osmand.data.PointDescription; import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java index ddf3cecb9c..f436fb03fb 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java @@ -12,7 +12,7 @@ import net.osmand.data.PointDescription; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.PointImageDrawable; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditor.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditor.java index f75c71ca4c..ca97d1679f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditor.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditor.java @@ -2,7 +2,7 @@ package net.osmand.plus.mapcontextmenu.editors; import androidx.annotation.NonNull; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.activities.MapActivity; public class MapMarkerEditor extends PointEditor { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditorFragment.java index c925f95d4b..e580edd6eb 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/MapMarkerEditorFragment.java @@ -14,7 +14,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import net.osmand.data.PointDescription; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java index 80a937087f..eaf3cc994b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java @@ -18,7 +18,7 @@ import net.osmand.data.LatLon; import net.osmand.data.WptLocationPoint; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java index 30da85d0bb..c973009798 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java @@ -21,7 +21,7 @@ import net.osmand.data.LatLon; import net.osmand.data.WptLocationPoint; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CategoriesSubHeader.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CategoriesSubHeader.java new file mode 100644 index 0000000000..aef2f28afd --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CategoriesSubHeader.java @@ -0,0 +1,24 @@ +package net.osmand.plus.mapmarkers; + +import androidx.annotation.DrawableRes; + +public class CategoriesSubHeader { + + @DrawableRes + private int iconRes; + private MapMarkersGroup group; + + public CategoriesSubHeader(int iconRes, MapMarkersGroup group) { + this.iconRes = iconRes; + this.group = group; + } + + @DrawableRes + public int getIconRes() { + return iconRes; + } + + public MapMarkersGroup getGroup() { + return group; + } +} diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 89ffdd389c..09eef3d06c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -169,7 +169,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm private void syncGpx(GPXFile gpxFile) { MapMarkersHelper helper = getMyApplication().getMapMarkersHelper(); - MapMarkersHelper.MapMarkersGroup group = helper.getMarkersGroup(gpxFile); + MapMarkersGroup group = helper.getMarkersGroup(gpxFile); if (group != null) { helper.runSynchronization(group); } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/GroupHeader.java b/OsmAnd/src/net/osmand/plus/mapmarkers/GroupHeader.java new file mode 100644 index 0000000000..c5c97a1c2e --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/GroupHeader.java @@ -0,0 +1,24 @@ +package net.osmand.plus.mapmarkers; + +import androidx.annotation.DrawableRes; + +public class GroupHeader { + + @DrawableRes + private int iconRes; + private MapMarkersGroup group; + + public GroupHeader(int iconRes, MapMarkersGroup group) { + this.iconRes = iconRes; + this.group = group; + } + + @DrawableRes + public int getIconRes() { + return iconRes; + } + + public MapMarkersGroup getGroup() { + return group; + } +} diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java index dc1e39bd92..a1cb1cafe6 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java @@ -3,7 +3,6 @@ package net.osmand.plus.mapmarkers; import android.os.Bundle; import android.view.View; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.R; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarker.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarker.java new file mode 100644 index 0000000000..172aea8a46 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarker.java @@ -0,0 +1,137 @@ +package net.osmand.plus.mapmarkers; + +import android.content.Context; + +import androidx.core.content.ContextCompat; + +import net.osmand.GPXUtilities; +import net.osmand.data.FavouritePoint; +import net.osmand.data.LatLon; +import net.osmand.data.LocationPoint; +import net.osmand.data.PointDescription; +import net.osmand.plus.R; +import net.osmand.util.Algorithms; + +import static net.osmand.data.PointDescription.POINT_TYPE_MAP_MARKER; + +public class MapMarker implements LocationPoint { + private static int[] colors; + + public String id; + public LatLon point; + private PointDescription pointDescription; + public int colorIndex; + public int index; + public boolean history; + public boolean selected; + public int dist; + public long creationDate; + public long visitedDate; + public String nextKey; + public String groupKey; + public String groupName; + public GPXUtilities.WptPt wptPt; + public FavouritePoint favouritePoint; + public String mapObjectName; + + public MapMarker(LatLon point, PointDescription name, int colorIndex, boolean selected, int index) { + this.point = point; + this.pointDescription = name; + this.colorIndex = colorIndex; + this.selected = selected; + this.index = index; + } + + public int getType() { + return favouritePoint == null ? + (wptPt == null ? MapMarkersGroup.ANY_TYPE : MapMarkersGroup.GPX_TYPE) : + MapMarkersGroup.FAVORITES_TYPE; + } + + public PointDescription getPointDescription(Context ctx) { + return new PointDescription(POINT_TYPE_MAP_MARKER, ctx.getString(R.string.map_marker), getOnlyName()); + } + + public String getName(Context ctx) { + String name; + PointDescription pd = getPointDescription(ctx); + if (Algorithms.isEmpty(pd.getName())) { + name = pd.getTypeName(); + } else { + name = pd.getName(); + } + return name; + } + + public PointDescription getOriginalPointDescription() { + return pointDescription; + } + + public void setOriginalPointDescription(PointDescription pointDescription) { + this.pointDescription = pointDescription; + } + + public String getOnlyName() { + return pointDescription == null ? "" : pointDescription.getName(); + } + + public double getLatitude() { + return point.getLatitude(); + } + + public double getLongitude() { + return point.getLongitude(); + } + + @Override + public int getColor() { + return 0; + } + + @Override + public boolean isVisible() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + MapMarker mapMarker = (MapMarker) o; + + return colorIndex == mapMarker.colorIndex && point.equals(mapMarker.point); + } + + @Override + public int hashCode() { + int result = point.hashCode(); + result = 31 * result + colorIndex; + return result; + } + + private static final int[] colorsIds = new int[]{ + R.color.marker_blue, + R.color.marker_green, + R.color.marker_orange, + R.color.marker_red, + R.color.marker_yellow, + R.color.marker_teal, + R.color.marker_purple + }; + + public static int[] getColors(Context context) { + if (colors != null) { + return colors; + } + colors = new int[colorsIds.length]; + for (int i = 0; i < colorsIds.length; i++) { + colors[i] = ContextCompat.getColor(context, colorsIds[i]); + } + return colors; + } + + public static int getColorId(int colorIndex) { + return (colorIndex >= 0 && colorIndex < colorsIds.length) ? colorsIds[colorIndex] : colorsIds[0]; + } +} diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java index e18a54c802..cd723e7d7c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java @@ -15,7 +15,6 @@ import androidx.annotation.Nullable; import net.osmand.AndroidUtils; import net.osmand.data.LatLon; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java index 69ec8af5a5..d59dad4346 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java @@ -21,7 +21,6 @@ import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.WptLocationPoint; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmandApplication; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java index 1bdf8701b4..0b2ba5ab0c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java @@ -4,8 +4,6 @@ import androidx.annotation.Nullable; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; import net.osmand.plus.api.SQLiteAPI.SQLiteCursor; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index 6d729c4ce2..fd9f100c4b 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -429,7 +429,7 @@ public class MapMarkersDialogFragment extends DialogFragment implements OnGroupS public void moveAllToHistoryOnClick() { if (mapActivity != null) { final MapMarkersHelper helper = mapActivity.getMyApplication().getMapMarkersHelper(); - final List markers = new ArrayList<>(helper.getMapMarkers()); + final List markers = new ArrayList<>(helper.getMapMarkers()); helper.moveAllActiveMarkersToHistory(); if (viewPager.getCurrentItem() == ACTIVE_MARKERS_POSITION) { activeFragment.updateAdapter(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroup.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroup.java new file mode 100644 index 0000000000..2a97af91c8 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroup.java @@ -0,0 +1,183 @@ +package net.osmand.plus.mapmarkers; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.plus.wikivoyage.data.TravelArticle; +import net.osmand.util.Algorithms; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +public class MapMarkersGroup { + + public static final int ANY_TYPE = -1; + public static final int FAVORITES_TYPE = 0; + public static final int GPX_TYPE = 1; + + public static final String MARKERS_SYNC_GROUP_ID = "markers_sync_group_id"; + + private String id; + private String name; + private int type = ANY_TYPE; + private Set wptCategories; + private long creationDate; + private boolean disabled; + private boolean visible = true; + private boolean wasShown = false; + private boolean visibleUntilRestart; + private List markers = new ArrayList<>(); + private TravelArticle wikivoyageArticle; + // TODO should be removed from this class: + private GroupHeader header; + private CategoriesSubHeader categoriesSubHeader; + private ShowHideHistoryButton showHideHistoryButton; + + public MapMarkersGroup() { + + } + + public MapMarkersGroup(@NonNull String id, @NonNull String name, int type) { + this.id = id; + this.name = name; + this.type = type; + } + + public String getId() { + return id; + } + + public String getGpxPath() { + return id; + } + + public TravelArticle getWikivoyageArticle() { + return wikivoyageArticle; + } + + public long getCreationDate() { + return creationDate; + } + + public void setCreationDate(long creationDate) { + this.creationDate = creationDate; + } + + public void setVisible(boolean visible) { + this.visible = visible; + } + + public void setMarkers(List markers) { + this.markers = markers; + } + + public void setHeader(GroupHeader header) { + this.header = header; + } + + public void setCategoriesSubHeader(CategoriesSubHeader categoriesSubHeader) { + this.categoriesSubHeader = categoriesSubHeader; + } + + public void setShowHideHistoryButton(ShowHideHistoryButton showHideHistoryButton) { + this.showHideHistoryButton = showHideHistoryButton; + } + + public boolean isWasShown() { + return wasShown; + } + + public boolean isVisibleUntilRestart() { + return visibleUntilRestart; + } + + public void setWikivoyageArticle(TravelArticle wikivoyageArticle) { + this.wikivoyageArticle = wikivoyageArticle; + } + + public String getName() { + return name; + } + + public int getType() { + return type; + } + + public void setWptCategories(Set wptCategories) { + this.wptCategories = wptCategories; + } + + public Set getWptCategories() { + return wptCategories; + } + + public boolean isDisabled() { + return disabled; + } + + public void setDisabled(boolean disabled) { + this.disabled = disabled; + } + + public boolean isVisible() { + return visible; + } + + public boolean wasShown() { + return wasShown; + } + + public void setWasShown(boolean wasShown) { + this.wasShown = wasShown; + } + + public void setVisibleUntilRestart(boolean visibleUntilRestart) { + this.visibleUntilRestart = visibleUntilRestart; + } + + public List getMarkers() { + return markers; + } + + public GroupHeader getGroupHeader() { + return header; + } + + public CategoriesSubHeader getCategoriesSubHeader() { + return categoriesSubHeader; + } + + public ShowHideHistoryButton getShowHideHistoryButton() { + return showHideHistoryButton; + } + + @Nullable + public String getWptCategoriesString() { + if (wptCategories != null) { + return Algorithms.encodeStringSet(wptCategories); + } + return null; + } + + public List getActiveMarkers() { + List markers = new ArrayList<>(this.markers); + List activeMarkers = new ArrayList<>(markers.size()); + for (MapMarker marker : markers) { + if (!marker.history) { + activeMarkers.add(marker); + } + } + return activeMarkers; + } + + public List getHistoryMarkers() { + List historyMarkers = new ArrayList<>(); + for (MapMarker marker : markers) { + if (marker.history) { + historyMarkers.add(marker); + } + } + return historyMarkers; + } +} diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java index 98b9128151..df071bf5b9 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java @@ -28,7 +28,6 @@ import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.WptLocationPoint; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmandApplication; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java index c2615538a4..7184c79cc1 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java @@ -1,12 +1,10 @@ package net.osmand.plus.mapmarkers; -import android.content.Context; import android.os.AsyncTask; import androidx.annotation.IntDef; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.core.content.ContextCompat; import net.osmand.FileUtils; import net.osmand.GPXUtilities; @@ -16,7 +14,6 @@ import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; -import net.osmand.data.LocationPoint; import net.osmand.data.PointDescription; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; import net.osmand.plus.GPXDatabase; @@ -152,12 +149,12 @@ public class MapMarkersHelper { if (group == null) { if (noGroup == null) { noGroup = new MapMarkersGroup(); - noGroup.creationDate = Long.MAX_VALUE; + noGroup.setCreationDate(Long.MAX_VALUE); } noGroup.getMarkers().add(marker); } else { - if (marker.creationDate < group.creationDate) { - group.creationDate = marker.creationDate; + if (marker.creationDate < group.getCreationDate()) { + group.setCreationDate(marker.creationDate); } group.getMarkers().add(marker); } @@ -194,16 +191,17 @@ public class MapMarkersHelper { } private void lookupAddress(final MapMarker mapMarker) { - if (mapMarker != null && mapMarker.pointDescription.isSearchingAddress(ctx)) { + if (mapMarker != null && mapMarker.getOriginalPointDescription().isSearchingAddress(ctx)) { cancelPointAddressRequests(mapMarker.point); AddressLookupRequest lookupRequest = new AddressLookupRequest(mapMarker.point, new GeocodingLookupService.OnAddressLookupResult() { @Override public void geocodingDone(String address) { + PointDescription pointDescription = mapMarker.getOriginalPointDescription(); if (Algorithms.isEmpty(address)) { - mapMarker.pointDescription.setName(PointDescription.getAddressNotFoundStr(ctx)); + pointDescription.setName(PointDescription.getAddressNotFoundStr(ctx)); } else { - mapMarker.pointDescription.setName(address); + pointDescription.setName(address); } markersDbHelper.updateMarker(mapMarker); refreshMarker(mapMarker); @@ -295,7 +293,6 @@ public class MapMarkersHelper { }); } - public void runSynchronization(final @NonNull MapMarkersGroup group) { ctx.runInUIThread(new Runnable() { @Override @@ -305,19 +302,17 @@ public class MapMarkersHelper { }); } - public MapMarkersGroup getMarkersGroup(GPXFile gpx) { if(gpx == null || gpx.path == null) { return null; } return getMapMarkerGroupById(getMarkerGroupId(new File(gpx.path)), MapMarkersGroup.GPX_TYPE); } - + public MapMarkersGroup getMarkersGroup(FavoriteGroup favGroup) { return getMapMarkerGroupById(getMarkerGroupId(favGroup), MapMarkersGroup.FAVORITES_TYPE); } - public MapMarkersGroup addOrEnableGpxGroup(@NonNull File file) { updateGpxShowAsMarkers(file); MapMarkersGroup gr = getMapMarkerGroupById(getMarkerGroupId(file), MapMarkersGroup.GPX_TYPE); @@ -328,7 +323,7 @@ public class MapMarkersHelper { enableGroup(gr); return gr; } - + public MapMarkersGroup addOrEnableGroup(@NonNull GPXFile file) { updateGpxShowAsMarkers(new File(file.path)); MapMarkersGroup gr = getMarkersGroup(file); @@ -340,7 +335,6 @@ public class MapMarkersHelper { return gr; } - public MapMarkersGroup addOrEnableGroup(@NonNull FavoriteGroup group) { MapMarkersGroup gr = getMarkersGroup(group); if (gr == null) { @@ -350,7 +344,7 @@ public class MapMarkersHelper { enableGroup(gr); return gr; } - + public void enableGroup(@NonNull MapMarkersGroup gr) { // check if group doesn't exist internally if(!mapMarkersGroups.contains(gr)) { @@ -397,14 +391,14 @@ public class MapMarkersHelper { String id = group.getId(); if (id != null) { markersDbHelper.updateGroupDisabled(id, disabled); - group.disabled = disabled; + group.setDisabled(disabled); } } public void updateGroupWptCategories(@NonNull MapMarkersGroup group, Set wptCategories) { String id = group.getId(); if (id != null) { - group.wptCategories = wptCategories; + group.setWptCategories(wptCategories); if (wptCategories != null) { markersDbHelper.updateGroupCategories(id, group.getWptCategoriesString()); } @@ -416,7 +410,7 @@ public class MapMarkersHelper { markersDbHelper.removeActiveMarkersFromGroup(group.getId()); removeFromMapMarkersList(group.getActiveMarkers()); if (updateGroup) { - group.markers = group.getHistoryMarkers(); + group.setMarkers(group.getHistoryMarkers()); updateGroup(group); } reorderActiveMarkersIfNeeded(); @@ -439,12 +433,12 @@ public class MapMarkersHelper { ShowHideHistoryButton showHideHistoryButton = mapMarkersGroup.getShowHideHistoryButton(); if (showHideHistoryButton != null) { if (historyMarkersCount == 0) { - mapMarkersGroup.showHideHistoryButton = null; + mapMarkersGroup.setShowHideHistoryButton(null); } } else if (historyMarkersCount > 0) { showHideHistoryButton = new ShowHideHistoryButton(); showHideHistoryButton.showHistory = false; - mapMarkersGroup.showHideHistoryButton = showHideHistoryButton; + mapMarkersGroup.setShowHideHistoryButton(showHideHistoryButton); } } @@ -464,10 +458,8 @@ public class MapMarkersHelper { sortMarkers(mapMarkersGroup.getMarkers(), false, BY_DATE_ADDED_DESC); } } else { - mapMarkersGroup = new MapMarkersGroup(); - mapMarkersGroup.id = marker.groupKey; - mapMarkersGroup.name = marker.groupName; - mapMarkersGroup.creationDate = Long.MAX_VALUE; + mapMarkersGroup = new MapMarkersGroup(marker.groupKey, marker.groupName, MapMarkersGroup.ANY_TYPE); + mapMarkersGroup.setCreationDate(Long.MAX_VALUE); mapMarkersGroup.getMarkers().add(marker); addToGroupsList(mapMarkersGroup); sortGroups(); @@ -477,18 +469,19 @@ public class MapMarkersHelper { } private void createHeadersInGroup(@NonNull MapMarkersGroup group) { - GroupHeader header = new GroupHeader(); - CategoriesSubHeader categoriesSubHeader = new CategoriesSubHeader(); int type = group.getType(); + int headerIconId = 0; + int subHeaderIconId = 0; if (type != -1) { - header.iconRes = type == MapMarkersGroup.FAVORITES_TYPE + headerIconId = type == MapMarkersGroup.FAVORITES_TYPE ? R.drawable.ic_action_favorite : R.drawable.ic_action_polygom_dark; - categoriesSubHeader.iconRes = R.drawable.ic_action_filter; + subHeaderIconId = R.drawable.ic_action_filter; } - header.group = group; - categoriesSubHeader.group = group; - group.header = header; - group.categoriesSubHeader = categoriesSubHeader; + GroupHeader header = new GroupHeader(headerIconId, group); + CategoriesSubHeader categoriesSubHeader = new CategoriesSubHeader(subHeaderIconId, group); + + group.setHeader(header); + group.setCategoriesSubHeader(categoriesSubHeader); } private void removeMarkerFromGroup(MapMarker marker) { @@ -506,8 +499,8 @@ public class MapMarkersHelper { Collections.sort(mapMarkersGroups, new Comparator() { @Override public int compare(MapMarkersGroup group1, MapMarkersGroup group2) { - long t1 = group1.creationDate; - long t2 = group2.creationDate; + long t1 = group1.getCreationDate(); + long t2 = group2.getCreationDate(); return (t1 > t2) ? -1 : ((t1 == t2) ? 0 : 1); } }); @@ -519,7 +512,7 @@ public class MapMarkersHelper { for (MapMarkersGroup group : mapMarkersGroups) { if ((id == null && group.getId() == null) || (group.getId() != null && group.getId().equals(id))) { - if(type == MapMarkersGroup.ANY_TYPE || type == group.type) { + if (type == MapMarkersGroup.ANY_TYPE || type == group.getType()) { return group; } } @@ -532,7 +525,7 @@ public class MapMarkersHelper { Algorithms.getFileNameWithoutExtension(fl.getName()), MapMarkersGroup.GPX_TYPE); } - + private MapMarkersGroup createFavMarkerGroup(FavoriteGroup favGroup) { return new MapMarkersGroup(favGroup.getName(), favGroup.getName(), MapMarkersGroup.FAVORITES_TYPE); } @@ -540,11 +533,11 @@ public class MapMarkersHelper { private String getMarkerGroupId(File gpx) { return gpx.getAbsolutePath(); } - + private String getMarkerGroupId(FavoriteGroup group) { return group.getName(); } - + @NonNull public List getGroupsForDisplayedGpx() { List res = new ArrayList<>(); @@ -553,14 +546,14 @@ public class MapMarkersHelper { MapMarkersGroup search = getMarkersGroup(selected.getGpxFile()); if (search == null && selected.getGpxFile() != null && selected.getGpxFile().path != null) { MapMarkersGroup group = createGPXMarkerGroup(new File(selected.getGpxFile().path)); - group.disabled = true; + group.setDisabled(true); createHeadersInGroup(group); res.add(group); } } return res; } - + @NonNull public List getGroupsForSavedArticlesTravelBook() { List res = new ArrayList<>(); @@ -574,7 +567,7 @@ public class MapMarkersHelper { MapMarkersGroup search = getMapMarkerGroupById(getMarkerGroupId(path), MapMarkersGroup.GPX_TYPE); if (search == null) { MapMarkersGroup group = createGPXMarkerGroup(path); - group.disabled = true; + group.setDisabled(true); createHeadersInGroup(group); res.add(group); } @@ -1159,7 +1152,7 @@ public class MapMarkersHelper { if (favGroup == null) { return; } - group.visible = favGroup.isVisible(); + group.setVisible(favGroup.isVisible()); if (!group.isVisible() || group.isDisabled()) { removeGroupActiveMarkers(group, true); return; @@ -1179,17 +1172,17 @@ public class MapMarkersHelper { String gpxPath = group.getId(); SelectedGpxFile selectedGpxFile = gpxHelper.getSelectedFileByPath(gpxPath); GPXFile gpx = selectedGpxFile == null ? null : selectedGpxFile.getGpxFile(); - group.visible = gpx != null || group.visibleUntilRestart; + group.setVisible(gpx != null || group.isVisibleUntilRestart()); if (gpx == null || group.isDisabled()) { removeGroupActiveMarkers(group, true); return; } - boolean addAll = group.wptCategories == null || group.wptCategories.isEmpty(); + boolean addAll = group.getWptCategories() == null || group.getWptCategories().isEmpty(); List gpxPoints = new ArrayList<>(gpx.getPoints()); for (WptPt pt : gpxPoints) { - if (addAll || group.wptCategories.contains(pt.category) - || (pt.category == null && group.wptCategories.contains(""))) { + if (addAll || group.getWptCategories().contains(pt.category) + || (pt.category == null && group.getWptCategories().contains(""))) { addNewMarkerIfNeeded(group, groupMarkers, new LatLon(pt.lat, pt.lon), pt.name, null, pt); } } @@ -1212,295 +1205,4 @@ public class MapMarkersHelper { } } } - - public static class MapMarkersGroup { - - public static final int ANY_TYPE = -1; - public static final int FAVORITES_TYPE = 0; - public static final int GPX_TYPE = 1; - - public static final String MARKERS_SYNC_GROUP_ID = "markers_sync_group_id"; - - private String id; - private String name; - private int type = -1; - private Set wptCategories; - private long creationDate; - private boolean disabled; - private boolean visible = true; - private boolean wasShown = false; - private boolean visibleUntilRestart; - private List markers = new ArrayList<>(); - private TravelArticle wikivoyageArticle; - // TODO should be removed from this class: - private GroupHeader header; - private CategoriesSubHeader categoriesSubHeader; - private ShowHideHistoryButton showHideHistoryButton; - - public MapMarkersGroup() { - - } - - public MapMarkersGroup(@NonNull String id, @NonNull String name, int type) { - this.id = id; - this.name = name; - this.type = type; - } - - public String getId() { - return id; - } - - public String getGpxPath() { - return id; - } - - public TravelArticle getWikivoyageArticle() { - return wikivoyageArticle; - } - - public void setWikivoyageArticle(TravelArticle wikivoyageArticle) { - this.wikivoyageArticle = wikivoyageArticle; - } - - public String getName() { - return name; - } - - public int getType() { - return type; - } - - public void setWptCategories(Set wptCategories) { - this.wptCategories = wptCategories; - } - - public Set getWptCategories() { - return wptCategories; - } - - public boolean isDisabled() { - return disabled; - } - - public void setDisabled(boolean disabled) { - this.disabled = disabled; - } - - public boolean isVisible() { - return visible; - } - - public boolean wasShown() { - return wasShown; - } - - public void setWasShown(boolean wasShown) { - this.wasShown = wasShown; - } - - public void setVisibleUntilRestart(boolean visibleUntilRestart) { - this.visibleUntilRestart = visibleUntilRestart; - } - - public List getMarkers() { - return markers; - } - - public GroupHeader getGroupHeader() { - return header; - } - - public CategoriesSubHeader getCategoriesSubHeader() { - return categoriesSubHeader; - } - - public ShowHideHistoryButton getShowHideHistoryButton() { - return showHideHistoryButton; - } - - @Nullable - public String getWptCategoriesString() { - if (wptCategories != null) { - return Algorithms.encodeStringSet(wptCategories); - } - return null; - } - - public List getActiveMarkers() { - List markers = new ArrayList<>(this.markers); - List activeMarkers = new ArrayList<>(markers.size()); - for (MapMarker marker : markers) { - if (!marker.history) { - activeMarkers.add(marker); - } - } - return activeMarkers; - } - - public List getHistoryMarkers() { - List historyMarkers = new ArrayList<>(); - for (MapMarker marker : markers) { - if (marker.history) { - historyMarkers.add(marker); - } - } - return historyMarkers; - } - } - - public static class ShowHideHistoryButton { - public boolean showHistory; - } - - public static class GroupHeader { - private int iconRes; - private MapMarkersGroup group; - - public int getIconRes() { - return iconRes; - } - - public MapMarkersGroup getGroup() { - return group; - } - } - - public static class CategoriesSubHeader { - private int iconRes; - private MapMarkersGroup group; - - public int getIconRes() { - return iconRes; - } - - public MapMarkersGroup getGroup() { - return group; - } - } - - public static class MapMarker implements LocationPoint { - private static int[] colors; - - public String id; - public LatLon point; - private PointDescription pointDescription; - public int colorIndex; - public int index; - public boolean history; - public boolean selected; - public int dist; - public long creationDate; - public long visitedDate; - public String nextKey; - public String groupKey; - public String groupName; - public WptPt wptPt; - public FavouritePoint favouritePoint; - public String mapObjectName; - - public MapMarker(LatLon point, PointDescription name, int colorIndex, boolean selected, int index) { - this.point = point; - this.pointDescription = name; - this.colorIndex = colorIndex; - this.selected = selected; - this.index = index; - } - - public int getType() { - return favouritePoint == null ? - (wptPt == null ? MapMarkersGroup.ANY_TYPE : MapMarkersGroup.GPX_TYPE) : - MapMarkersGroup.FAVORITES_TYPE; - } - - public PointDescription getPointDescription(Context ctx) { - return new PointDescription(POINT_TYPE_MAP_MARKER, ctx.getString(R.string.map_marker), getOnlyName()); - } - - public String getName(Context ctx) { - String name; - PointDescription pd = getPointDescription(ctx); - if (Algorithms.isEmpty(pd.getName())) { - name = pd.getTypeName(); - } else { - name = pd.getName(); - } - return name; - } - - public PointDescription getOriginalPointDescription() { - return pointDescription; - } - - public void setOriginalPointDescription(PointDescription pointDescription) { - this.pointDescription = pointDescription; - } - - public String getOnlyName() { - return pointDescription == null ? "" : pointDescription.getName(); - } - - public double getLatitude() { - return point.getLatitude(); - } - - public double getLongitude() { - return point.getLongitude(); - } - - @Override - public int getColor() { - return 0; - } - - @Override - public boolean isVisible() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MapMarker mapMarker = (MapMarker) o; - - return colorIndex == mapMarker.colorIndex && point.equals(mapMarker.point); - } - - @Override - public int hashCode() { - int result = point.hashCode(); - result = 31 * result + colorIndex; - return result; - } - - private static final int[] colorsIds = new int[]{ - R.color.marker_blue, - R.color.marker_green, - R.color.marker_orange, - R.color.marker_red, - R.color.marker_yellow, - R.color.marker_teal, - R.color.marker_purple - }; - - public static int[] getColors(Context context) { - if (colors != null) { - return colors; - } - colors = new int[colorsIds.length]; - for (int i = 0; i < colorsIds.length; i++) { - colors[i] = ContextCompat.getColor(context, colorsIds[i]); - } - return colors; - } - - public static int getColorId(int colorIndex) { - return (colorIndex >= 0 && colorIndex < colorsIds.length) ? colorsIds[colorIndex] : colorsIds[0]; - } - } - - - -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java index 5cc2b081ab..c631e3d3e7 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java @@ -20,7 +20,6 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.snackbar.Snackbar; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java index 8a891f7a11..3e0842710c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java @@ -39,7 +39,6 @@ import net.osmand.TspAnt; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.RotatedTileBox; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmandApplication; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java index 305d9a6b5b..d676372223 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java @@ -13,7 +13,6 @@ import net.osmand.GPXUtilities.WptPt; import net.osmand.IndexConstants; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.base.MenuBottomSheetDialogFragment; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/ShowHideHistoryButton.java b/OsmAnd/src/net/osmand/plus/mapmarkers/ShowHideHistoryButton.java new file mode 100644 index 0000000000..b21b656299 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/ShowHideHistoryButton.java @@ -0,0 +1,5 @@ +package net.osmand.plus.mapmarkers; + +public class ShowHideHistoryButton { + public boolean showHistory; +} diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java index c81dffbf63..c1e85387b3 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java @@ -13,9 +13,8 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.snackbar.Snackbar; import net.osmand.data.LatLon; -import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarker; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -215,7 +214,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter Date: Sun, 8 Nov 2020 17:00:41 +0200 Subject: [PATCH 4/7] Show markers groups in import settings UI --- .../backend/backup/MarkersSettingsItem.java | 15 ++++++++------- .../fragments/ImportDuplicatesFragment.java | 8 ++++++++ .../fragments/ImportSettingsFragment.java | 9 +++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java index 10384f2d2d..99722505d0 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java @@ -96,7 +96,7 @@ public class MarkersSettingsItem extends CollectionSettingsItem public boolean isDuplicate(@NonNull MapMarkersGroup markersGroup) { String name = markersGroup.getName(); for (MapMarkersGroup group : existingItems) { - if (group.getName().equals(name)) { + if (Algorithms.stringsEqual(group.getName(), name)) { return true; } } @@ -139,12 +139,13 @@ public class MarkersSettingsItem extends CollectionSettingsItem @Override public boolean writeToStream(@NonNull OutputStream outputStream) throws IOException { -// Exception error = GPXUtilities.writeGpx(new OutputStreamWriter(outputStream, "UTF-8"), gpxFile); -// if (error != null) { -// warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType()))); -// SettingsHelper.LOG.error("Failed write to gpx file", error); -// return false; -// } + GPXFile gpxFile = generateGpx(); + Exception error = GPXUtilities.writeGpx(new OutputStreamWriter(outputStream, "UTF-8"), gpxFile); + if (error != null) { + warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType()))); + SettingsHelper.LOG.error("Failed write to gpx file", error); + return false; + } return true; } }; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportDuplicatesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportDuplicatesFragment.java index 14d89803e2..c2610d06a2 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportDuplicatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportDuplicatesFragment.java @@ -32,6 +32,7 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; +import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.osmedit.OpenstreetmapPoint; import net.osmand.plus.osmedit.OsmNotesPoint; import net.osmand.plus.poi.PoiUIFilter; @@ -200,6 +201,7 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment { List ttsVoiceFilesList = new ArrayList<>(); List voiceFilesList = new ArrayList<>(); List mapFilesList = new ArrayList<>(); + List markersGroups = new ArrayList<>(); for (Object object : duplicatesList) { if (object instanceof ApplicationMode.ApplicationModeBean) { @@ -236,6 +238,8 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment { osmNotesPointList.add((OsmNotesPoint) object); } else if (object instanceof OpenstreetmapPoint) { osmEditsPointList.add((OpenstreetmapPoint) object); + } else if (object instanceof MapMarkersGroup) { + markersGroups.add((MapMarkersGroup) object); } } if (!profiles.isEmpty()) { @@ -298,6 +302,10 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment { duplicates.add(getString(R.string.local_indexes_cat_voice)); duplicates.addAll(voiceFilesList); } + if (!markersGroups.isEmpty()) { + duplicates.add(getString(R.string.map_markers)); + duplicates.addAll(markersGroups); + } return duplicates; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java index f9960db436..d7ae7eb77b 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java @@ -41,6 +41,7 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; +import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.osmedit.OpenstreetmapPoint; import net.osmand.plus.osmedit.OsmNotesPoint; import net.osmand.plus.poi.PoiUIFilter; @@ -49,6 +50,7 @@ import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean; import net.osmand.plus.settings.backend.ExportSettingsType; import net.osmand.plus.settings.backend.backup.FavoritesSettingsItem; import net.osmand.plus.settings.backend.backup.GlobalSettingsItem; +import net.osmand.plus.settings.backend.backup.MarkersSettingsItem; import net.osmand.plus.settings.backend.backup.OsmEditsSettingsItem; import net.osmand.plus.settings.backend.backup.OsmNotesSettingsItem; import net.osmand.plus.settings.backend.backup.SettingsHelper; @@ -436,6 +438,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment { List osmNotesPointList = new ArrayList<>(); List osmEditsPointList = new ArrayList<>(); List favoriteGroups = new ArrayList<>(); + List markersGroups = new ArrayList<>(); for (Object object : data) { if (object instanceof ApplicationModeBean) { appModeBeans.add((ApplicationModeBean) object); @@ -459,6 +462,8 @@ public class ImportSettingsFragment extends BaseOsmAndFragment { favoriteGroups.add((FavoriteGroup) object); } else if (object instanceof GlobalSettingsItem) { settingsItems.add((GlobalSettingsItem) object); + } else if (object instanceof MapMarkersGroup) { + markersGroups.add((MapMarkersGroup) object); } } if (!appModeBeans.isEmpty()) { @@ -490,6 +495,10 @@ public class ImportSettingsFragment extends BaseOsmAndFragment { FavoritesSettingsItem baseItem = getBaseItem(SettingsItemType.FAVOURITES, FavoritesSettingsItem.class); settingsItems.add(new FavoritesSettingsItem(app, baseItem, favoriteGroups)); } + if (!markersGroups.isEmpty()) { + MarkersSettingsItem baseItem = getBaseItem(SettingsItemType.MARKERS, MarkersSettingsItem.class); + settingsItems.add(new MarkersSettingsItem(app, baseItem, markersGroups)); + } return settingsItems; } From 460980a475829e74c19fa7b2e96412fb37b8b5f4 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 9 Nov 2020 10:31:17 +0200 Subject: [PATCH 5/7] Export and import markers to file --- .../mapmarkers/MapMarkersDialogFragment.java | 2 +- .../plus/mapmarkers/MapMarkersHelper.java | 42 ++++++--- .../backend/backup/MarkersSettingsItem.java | 93 +++++++++++++++++-- 3 files changed, 116 insertions(+), 21 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index fd9f100c4b..2a50192d03 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -481,7 +481,7 @@ public class MapMarkersDialogFragment extends DialogFragment implements OnGroupS @Override public void saveGpx(final String fileName) { - final String gpxPath = mapActivity.getMyApplication().getMapMarkersHelper().generateGpx(fileName); + final String gpxPath = mapActivity.getMyApplication().getMapMarkersHelper().saveMarkersToFile(fileName); snackbar = Snackbar.make(viewPager, String.format(getString(R.string.shared_string_file_is_saved), fileName) + ".", Snackbar.LENGTH_LONG) .setAction(R.string.shared_string_show, new View.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java index 7184c79cc1..d6d9b7cd2f 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java @@ -5,6 +5,7 @@ import android.os.AsyncTask; import androidx.annotation.IntDef; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; import net.osmand.FileUtils; import net.osmand.GPXUtilities; @@ -58,6 +59,10 @@ public class MapMarkersHelper { public static final int BY_DATE_ADDED_ASC = 4; + public static final String GROUP_NAME = "group_name"; + public static final String GROUP_TYPE = "group_type"; + public static final String MARKER_HISTORY = "marker_history"; + private static final Log LOG = PlatformUtil.getLog(MapMarkersHelper.class); @Retention(RetentionPolicy.SOURCE) @@ -303,7 +308,7 @@ public class MapMarkersHelper { } public MapMarkersGroup getMarkersGroup(GPXFile gpx) { - if(gpx == null || gpx.path == null) { + if (gpx == null || gpx.path == null) { return null; } return getMapMarkerGroupById(getMarkerGroupId(new File(gpx.path)), MapMarkersGroup.GPX_TYPE); @@ -347,7 +352,7 @@ public class MapMarkersHelper { public void enableGroup(@NonNull MapMarkersGroup gr) { // check if group doesn't exist internally - if(!mapMarkersGroups.contains(gr)) { + if (!mapMarkersGroups.contains(gr)) { addGroupInternally(gr); } if (gr.isDisabled()) { @@ -558,12 +563,12 @@ public class MapMarkersHelper { public List getGroupsForSavedArticlesTravelBook() { List res = new ArrayList<>(); TravelDbHelper travelDbHelper = ctx.getTravelDbHelper(); - if(travelDbHelper.getSelectedTravelBook() != null) { + if (travelDbHelper.getSelectedTravelBook() != null) { List savedArticles = travelDbHelper.getLocalDataHelper().getSavedArticles(); for (TravelArticle art : savedArticles) { String gpxName = travelDbHelper.getGPXName(art); File path = ctx.getAppPath(IndexConstants.GPX_TRAVEL_DIR + gpxName); - LOG.debug("Article group " + path.getAbsolutePath() + " " + path.exists()) ; + LOG.debug("Article group " + path.getAbsolutePath() + " " + path.exists()); MapMarkersGroup search = getMapMarkerGroupById(getMarkerGroupId(path), MapMarkersGroup.GPX_TYPE); if (search == null) { MapMarkersGroup group = createGPXMarkerGroup(path); @@ -1001,7 +1006,8 @@ public class MapMarkersHelper { }); } - public String generateGpx(String fileName) { + public String saveMarkersToFile(String fileName) { + GPXFile gpxFile = generateGpx(); String dirName = IndexConstants.GPX_INDEX_DIR + IndexConstants.MAP_MARKERS_INDEX_DIR; File dir = ctx.getAppPath(dirName); if (!dir.exists()) { @@ -1009,18 +1015,32 @@ public class MapMarkersHelper { } String uniqueFileName = FileUtils.createUniqueFileName(ctx, fileName, dirName, IndexConstants.GPX_FILE_EXT); File fout = new File(dir, uniqueFileName + IndexConstants.GPX_FILE_EXT); + GPXUtilities.writeGpxFile(fout, gpxFile); - GPXFile file = new GPXFile(Version.getFullVersion(ctx)); - for (MapMarker marker : mapMarkers) { + return fout.getAbsolutePath(); + } + + public GPXFile generateGpx() { + return generateGpx(mapMarkers, false); + } + + public GPXFile generateGpx(List markers, boolean completeBackup) { + GPXFile gpxFile = new GPXFile(Version.getFullVersion(ctx)); + for (MapMarker marker : markers) { WptPt wpt = new WptPt(); wpt.lat = marker.getLatitude(); wpt.lon = marker.getLongitude(); - wpt.setColor(ctx.getResources().getColor(MapMarker.getColorId(marker.colorIndex))); wpt.name = marker.getOnlyName(); - file.addPoint(wpt); + wpt.setColor(ContextCompat.getColor(ctx, MapMarker.getColorId(marker.colorIndex))); + if (completeBackup) { + wpt.category = marker.groupKey; + wpt.getExtensionsToWrite().put(GROUP_NAME, marker.groupName); + wpt.getExtensionsToWrite().put(GROUP_TYPE, String.valueOf(marker.getType())); + wpt.getExtensionsToWrite().put(MARKER_HISTORY, String.valueOf(marker.history)); + } + gpxFile.addPoint(wpt); } - GPXUtilities.writeGpxFile(fout, file); - return fout.getAbsolutePath(); + return gpxFile; } // --------------------------------------------------------------------------------------------- diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java index 99722505d0..0b57280d3a 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java @@ -7,28 +7,37 @@ import androidx.annotation.Nullable; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; -import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersGroup; +import net.osmand.GPXUtilities.WptPt; +import net.osmand.data.LatLon; +import net.osmand.data.PointDescription; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.mapmarkers.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersDbHelper; +import net.osmand.plus.mapmarkers.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.util.Algorithms; import org.json.JSONException; import org.json.JSONObject; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import static net.osmand.IndexConstants.GPX_FILE_EXT; +import static net.osmand.plus.mapmarkers.MapMarkersHelper.GROUP_NAME; +import static net.osmand.plus.mapmarkers.MapMarkersHelper.GROUP_TYPE; public class MarkersSettingsItem extends CollectionSettingsItem { private MapMarkersHelper markersHelper; + private Map flatGroups = new LinkedHashMap<>(); public MarkersSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { super(app, null, items); @@ -85,9 +94,20 @@ public class MarkersSettingsItem extends CollectionSettingsItem for (MapMarkersGroup duplicate : duplicateItems) { if (shouldReplace) { - + MapMarkersGroup existingGroup = markersHelper.getMapMarkerGroupById(duplicate.getId(), duplicate.getType()); + if (existingGroup != null) { + List existingMarkers = new ArrayList<>(existingGroup.getMarkers()); + for (MapMarker marker : existingMarkers) { + markersHelper.removeMarker(marker); + } + } + } + appliedItems.add(duplicate); + } + for (MapMarkersGroup markersGroup : appliedItems) { + for (MapMarker marker : markersGroup.getMarkers()) { + markersHelper.addMapMarker(marker.point, marker.getOriginalPointDescription()); } - appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate)); } } } @@ -96,7 +116,9 @@ public class MarkersSettingsItem extends CollectionSettingsItem public boolean isDuplicate(@NonNull MapMarkersGroup markersGroup) { String name = markersGroup.getName(); for (MapMarkersGroup group : existingItems) { - if (Algorithms.stringsEqual(group.getName(), name)) { + if (Algorithms.stringsEqual(group.getName(), name) + && !Algorithms.isEmpty(group.getMarkers()) + && !Algorithms.isEmpty(markersGroup.getMarkers())) { return true; } } @@ -120,18 +142,62 @@ public class MarkersSettingsItem extends CollectionSettingsItem return new SettingsItemReader(this) { @Override - public void readFromStream(@NonNull InputStream inputStream, File destination) throws IOException, IllegalArgumentException { + public void readFromStream(@NonNull InputStream inputStream, String entryName) throws IllegalArgumentException { GPXFile gpxFile = GPXUtilities.loadGPXFile(inputStream); if (gpxFile.error != null) { warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType()))); SettingsHelper.LOG.error("Failed read gpx file", gpxFile.error); } else { - Map flatGroups = new LinkedHashMap<>(); + List markerColors = getMarkersColors(); + for (WptPt point : gpxFile.getPoints()) { + LatLon latLon = new LatLon(point.lat, point.lon); + + int colorIndex = markerColors.indexOf(point.getColor()); + if (colorIndex == -1) { + colorIndex = 0; + } + + PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, point.name); + MapMarker marker = new MapMarker(latLon, pointDescription, colorIndex, false, 0); + marker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE; + + MapMarkersGroup group = getOrCreateGroup(point); + group.getMarkers().add(marker); + } } } }; } + private MapMarkersGroup getOrCreateGroup(WptPt point) { + MapMarkersGroup markersGroup = flatGroups.get(point.category); + if (markersGroup != null) { + return markersGroup; + } + Map extensions = point.getExtensionsToRead(); + String groupName = extensions.get(GROUP_NAME); + String groupType = extensions.get(GROUP_TYPE); + int type = Algorithms.parseIntSilently(groupType, MapMarkersGroup.ANY_TYPE); + + if (point.category != null && groupName != null) { + markersGroup = new MapMarkersGroup(point.category, groupName, type); + } else { + markersGroup = new MapMarkersGroup(); + } + flatGroups.put(markersGroup.getId(), markersGroup); + items.add(markersGroup); + + return markersGroup; + } + + private List getMarkersColors() { + List colors = new ArrayList<>(); + for (int color : MapMarker.getColors(app)) { + colors.add(color); + } + return colors; + } + @Nullable @Override SettingsItemWriter getWriter() { @@ -139,7 +205,8 @@ public class MarkersSettingsItem extends CollectionSettingsItem @Override public boolean writeToStream(@NonNull OutputStream outputStream) throws IOException { - GPXFile gpxFile = generateGpx(); + List mapMarkers = getMarkersFromGroups(items); + GPXFile gpxFile = markersHelper.generateGpx(mapMarkers, true); Exception error = GPXUtilities.writeGpx(new OutputStreamWriter(outputStream, "UTF-8"), gpxFile); if (error != null) { warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType()))); @@ -150,4 +217,12 @@ public class MarkersSettingsItem extends CollectionSettingsItem } }; } + + private List getMarkersFromGroups(List markersGroups) { + List mapMarkers = new ArrayList<>(); + for (MapMarkersGroup group : markersGroups) { + mapMarkers.addAll(group.getMarkers()); + } + return mapMarkers; + } } \ No newline at end of file From f57e0324ffb7ac5ab8c47683dfba75c578080fee Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 9 Nov 2020 11:27:21 +0200 Subject: [PATCH 6/7] Add history markers to exported file --- .../net/osmand/plus/mapmarkers/MapMarkersHelper.java | 4 ++++ .../settings/backend/backup/MarkersSettingsItem.java | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java index d6d9b7cd2f..dc3a25a61e 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java @@ -62,6 +62,8 @@ public class MapMarkersHelper { public static final String GROUP_NAME = "group_name"; public static final String GROUP_TYPE = "group_type"; public static final String MARKER_HISTORY = "marker_history"; + public static final String CREATION_DATE = "creation_date"; + public static final String VISITED_DATE = "visited_date"; private static final Log LOG = PlatformUtil.getLog(MapMarkersHelper.class); @@ -1037,6 +1039,8 @@ public class MapMarkersHelper { wpt.getExtensionsToWrite().put(GROUP_NAME, marker.groupName); wpt.getExtensionsToWrite().put(GROUP_TYPE, String.valueOf(marker.getType())); wpt.getExtensionsToWrite().put(MARKER_HISTORY, String.valueOf(marker.history)); + wpt.getExtensionsToWrite().put(CREATION_DATE, String.valueOf(marker.creationDate)); + wpt.getExtensionsToWrite().put(VISITED_DATE, String.valueOf(marker.visitedDate)); } gpxFile.addPoint(wpt); } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java index 0b57280d3a..4a8026ea44 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java @@ -31,8 +31,11 @@ import java.util.List; import java.util.Map; import static net.osmand.IndexConstants.GPX_FILE_EXT; +import static net.osmand.plus.mapmarkers.MapMarkersHelper.CREATION_DATE; import static net.osmand.plus.mapmarkers.MapMarkersHelper.GROUP_NAME; import static net.osmand.plus.mapmarkers.MapMarkersHelper.GROUP_TYPE; +import static net.osmand.plus.mapmarkers.MapMarkersHelper.MARKER_HISTORY; +import static net.osmand.plus.mapmarkers.MapMarkersHelper.VISITED_DATE; public class MarkersSettingsItem extends CollectionSettingsItem { @@ -106,7 +109,7 @@ public class MarkersSettingsItem extends CollectionSettingsItem } for (MapMarkersGroup markersGroup : appliedItems) { for (MapMarker marker : markersGroup.getMarkers()) { - markersHelper.addMapMarker(marker.point, marker.getOriginalPointDescription()); + markersHelper.addMarker(marker); } } } @@ -159,6 +162,13 @@ public class MarkersSettingsItem extends CollectionSettingsItem PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, point.name); MapMarker marker = new MapMarker(latLon, pointDescription, colorIndex, false, 0); + + String historyStr = point.getExtensionsToRead().get(MARKER_HISTORY); + String creationDateStr = point.getExtensionsToRead().get(CREATION_DATE); + String visitedDateStr = point.getExtensionsToRead().get(VISITED_DATE); + marker.creationDate = Algorithms.parseLongSilently(creationDateStr, 0); + marker.visitedDate = Algorithms.parseLongSilently(visitedDateStr, 0); + marker.history = Boolean.parseBoolean(historyStr); marker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE; MapMarkersGroup group = getOrCreateGroup(point); From 24a3d8fd53a15151981b20ff102d08a6f756f3cc Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 11 Nov 2020 03:15:17 +0200 Subject: [PATCH 7/7] Export markers and markers history to separate files --- OsmAnd/res/values/strings.xml | 1 + .../net/osmand/plus/mapmarkers/MapMarker.java | 20 ++- .../plus/mapmarkers/MapMarkersHelper.java | 37 ++-- .../settings/backend/ExportSettingsType.java | 3 +- .../backend/backup/FavoritesSettingsItem.java | 28 +-- .../backup/HistoryMarkersSettingsItem.java | 160 +++++++++++++++++ .../backend/backup/MarkersSettingsItem.java | 164 +++++------------- .../backend/backup/SettingsHelper.java | 57 +++++- .../settings/backend/backup/SettingsItem.java | 21 +++ .../backend/backup/SettingsItemType.java | 3 +- .../backend/backup/SettingsItemsFactory.java | 5 +- .../fragments/DuplicatesSettingsAdapter.java | 16 +- .../ExportImportSettingsAdapter.java | 18 +- .../fragments/ImportDuplicatesFragment.java | 15 +- .../fragments/ImportSettingsFragment.java | 39 ++++- .../ImportedSettingsItemsAdapter.java | 6 +- 16 files changed, 389 insertions(+), 204 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/settings/backend/backup/HistoryMarkersSettingsItem.java diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index dc262a8b1b..5209a248b3 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + Markers history OsmAnd Live subscription is on hold OsmAnd Live subscription has been paused OsmAnd Live subscription has been expired diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarker.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarker.java index 172aea8a46..498c36f93c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarker.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarker.java @@ -2,9 +2,10 @@ package net.osmand.plus.mapmarkers; import android.content.Context; +import androidx.annotation.ColorInt; import androidx.core.content.ContextCompat; -import net.osmand.GPXUtilities; +import net.osmand.GPXUtilities.WptPt; import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.LocationPoint; @@ -15,6 +16,7 @@ import net.osmand.util.Algorithms; import static net.osmand.data.PointDescription.POINT_TYPE_MAP_MARKER; public class MapMarker implements LocationPoint { + private static int[] colors; public String id; @@ -30,7 +32,7 @@ public class MapMarker implements LocationPoint { public String nextKey; public String groupKey; public String groupName; - public GPXUtilities.WptPt wptPt; + public WptPt wptPt; public FavouritePoint favouritePoint; public String mapObjectName; @@ -45,7 +47,7 @@ public class MapMarker implements LocationPoint { public int getType() { return favouritePoint == null ? (wptPt == null ? MapMarkersGroup.ANY_TYPE : MapMarkersGroup.GPX_TYPE) : - MapMarkersGroup.FAVORITES_TYPE; + MapMarkersGroup.FAVORITES_TYPE; } public PointDescription getPointDescription(Context ctx) { @@ -110,7 +112,7 @@ public class MapMarker implements LocationPoint { return result; } - private static final int[] colorsIds = new int[]{ + private static final int[] colorsIds = new int[] { R.color.marker_blue, R.color.marker_green, R.color.marker_orange, @@ -134,4 +136,14 @@ public class MapMarker implements LocationPoint { public static int getColorId(int colorIndex) { return (colorIndex >= 0 && colorIndex < colorsIds.length) ? colorsIds[colorIndex] : colorsIds[0]; } + + public static int getColorIndex(Context context, @ColorInt int color) { + int[] colors = getColors(context); + for (int i = 0; i < colors.length; i++) { + if (color == colors[i]) { + return i; + } + } + return 0; + } } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java index dc3a25a61e..b0a13d8e44 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java @@ -59,11 +59,8 @@ public class MapMarkersHelper { public static final int BY_DATE_ADDED_ASC = 4; - public static final String GROUP_NAME = "group_name"; - public static final String GROUP_TYPE = "group_type"; - public static final String MARKER_HISTORY = "marker_history"; - public static final String CREATION_DATE = "creation_date"; public static final String VISITED_DATE = "visited_date"; + public static final String CREATION_DATE = "creation_date"; private static final Log LOG = PlatformUtil.getLog(MapMarkersHelper.class); @@ -1035,18 +1032,38 @@ public class MapMarkersHelper { wpt.name = marker.getOnlyName(); wpt.setColor(ContextCompat.getColor(ctx, MapMarker.getColorId(marker.colorIndex))); if (completeBackup) { - wpt.category = marker.groupKey; - wpt.getExtensionsToWrite().put(GROUP_NAME, marker.groupName); - wpt.getExtensionsToWrite().put(GROUP_TYPE, String.valueOf(marker.getType())); - wpt.getExtensionsToWrite().put(MARKER_HISTORY, String.valueOf(marker.history)); - wpt.getExtensionsToWrite().put(CREATION_DATE, String.valueOf(marker.creationDate)); - wpt.getExtensionsToWrite().put(VISITED_DATE, String.valueOf(marker.visitedDate)); + if (marker.creationDate != 0) { + wpt.getExtensionsToWrite().put(CREATION_DATE, String.valueOf(marker.creationDate)); + } + if (marker.visitedDate != 0) { + wpt.getExtensionsToWrite().put(VISITED_DATE, String.valueOf(marker.visitedDate)); + } } gpxFile.addPoint(wpt); } return gpxFile; } + public List readMarkersFromGpx(GPXFile gpxFile, boolean history) { + List mapMarkers = new ArrayList<>(); + for (WptPt point : gpxFile.getPoints()) { + LatLon latLon = new LatLon(point.lat, point.lon); + int colorIndex = MapMarker.getColorIndex(ctx, point.getColor()); + PointDescription name = new PointDescription(PointDescription.POINT_TYPE_LOCATION, point.name); + + MapMarker marker = new MapMarker(latLon, name, colorIndex, false, 0); + + String visitedDateStr = point.getExtensionsToRead().get(VISITED_DATE); + String creationDateStr = point.getExtensionsToRead().get(CREATION_DATE); + marker.visitedDate = Algorithms.parseLongSilently(visitedDateStr, 0); + marker.creationDate = Algorithms.parseLongSilently(creationDateStr, 0); + marker.nextKey = history ? MapMarkersDbHelper.HISTORY_NEXT_VALUE : MapMarkersDbHelper.TAIL_NEXT_VALUE; + + mapMarkers.add(marker); + } + return mapMarkers; + } + // --------------------------------------------------------------------------------------------- // accessors to active markers: diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java index a530ef5dcf..3dcb680b06 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java @@ -17,5 +17,6 @@ public enum ExportSettingsType { FAVORITES, TTS_VOICE, VOICE, - MARKERS + ACTIVE_MARKERS, + HISTORY_MARKERS } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FavoritesSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FavoritesSettingsItem.java index 817ec38a49..acb96be110 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FavoritesSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FavoritesSettingsItem.java @@ -16,10 +16,7 @@ import net.osmand.plus.R; import org.json.JSONException; import org.json.JSONObject; -import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -69,11 +66,6 @@ public class FavoritesSettingsItem extends CollectionSettingsItem return ctx.getString(R.string.shared_string_favorites); } - @NonNull - public String getDefaultFileName() { - return getName() + getDefaultFileExtension(); - } - @NonNull public String getDefaultFileExtension() { return GPX_FILE_EXT; @@ -177,21 +169,9 @@ public class FavoritesSettingsItem extends CollectionSettingsItem @Nullable @Override - SettingsItemWriter getWriter() { - return new SettingsItemWriter(this) { - - @Override - public boolean writeToStream(@NonNull OutputStream outputStream) throws IOException { - List favourites = getPointsFromGroups(items); - GPXFile gpxFile = favoritesHelper.asGpxFile(favourites); - Exception error = GPXUtilities.writeGpx(new OutputStreamWriter(outputStream, "UTF-8"), gpxFile); - if (error != null) { - warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType()))); - SettingsHelper.LOG.error("Failed write to gpx file", error); - return false; - } - return true; - } - }; + SettingsItemWriter getWriter() { + List favourites = getPointsFromGroups(items); + GPXFile gpxFile = favoritesHelper.asGpxFile(favourites); + return getGpxWriter(gpxFile); } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/HistoryMarkersSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/HistoryMarkersSettingsItem.java new file mode 100644 index 0000000000..a07aeb07ea --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/HistoryMarkersSettingsItem.java @@ -0,0 +1,160 @@ +package net.osmand.plus.settings.backend.backup; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.GPXUtilities; +import net.osmand.GPXUtilities.GPXFile; +import net.osmand.data.PointDescription; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.mapmarkers.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersDbHelper; +import net.osmand.plus.mapmarkers.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.settings.backend.ExportSettingsType; +import net.osmand.util.Algorithms; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import static net.osmand.IndexConstants.GPX_FILE_EXT; + +public class HistoryMarkersSettingsItem extends CollectionSettingsItem { + + private MapMarkersHelper markersHelper; + + public HistoryMarkersSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { + super(app, null, items); + } + + public HistoryMarkersSettingsItem(@NonNull OsmandApplication app, @Nullable HistoryMarkersSettingsItem baseItem, @NonNull List items) { + super(app, baseItem, items); + } + + HistoryMarkersSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { + super(app, json); + } + + @Override + protected void init() { + super.init(); + markersHelper = app.getMapMarkersHelper(); + existingItems = new ArrayList<>(markersHelper.getMapMarkersHistory()); + } + + @NonNull + @Override + public SettingsItemType getType() { + return SettingsItemType.HISTORY_MARKERS; + } + + @NonNull + @Override + public String getName() { + return "history_markers"; + } + + @NonNull + @Override + public String getPublicName(@NonNull Context ctx) { + return ctx.getString(R.string.markers_history); + } + + @NonNull + public String getDefaultFileExtension() { + return GPX_FILE_EXT; + } + + @Override + public void apply() { + List newItems = getNewItems(); + if (!newItems.isEmpty() || !duplicateItems.isEmpty()) { + appliedItems = new ArrayList<>(newItems); + + for (MapMarker duplicate : duplicateItems) { + if (shouldReplace) { + MapMarker existingMarker = markersHelper.getMapMarker(duplicate.point); + markersHelper.removeMarker(existingMarker); + } + appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate)); + } + + for (MapMarker marker : appliedItems) { + markersHelper.moveMapMarkerToHistory(marker); + } + } + } + + @Override + public boolean isDuplicate(@NonNull MapMarker mapMarker) { + for (MapMarker marker : existingItems) { + if (marker.equals(mapMarker) + && Algorithms.objectEquals(marker.getOriginalPointDescription(), mapMarker.getOriginalPointDescription())) { + return true; + } + } + return false; + } + + @Override + public boolean shouldReadOnCollecting() { + return true; + } + + @NonNull + @Override + public MapMarker renameItem(@NonNull MapMarker item) { + int number = 0; + while (true) { + number++; + String name = item.getOnlyName() + "_" + number; + PointDescription description = new PointDescription(PointDescription.POINT_TYPE_LOCATION, name); + MapMarker renamedMarker = new MapMarker(item.point, description, item.getColor(), item.selected, item.index); + if (!isDuplicate(renamedMarker)) { + renamedMarker.nextKey = MapMarkersDbHelper.HISTORY_NEXT_VALUE; + return renamedMarker; + } + } + } + + public MapMarkersGroup getMarkersGroup() { + String name = app.getString(R.string.markers_history); + String groupId = ExportSettingsType.HISTORY_MARKERS.name(); + MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, MapMarkersGroup.ANY_TYPE); + markersGroup.setMarkers(items); + return markersGroup; + } + + @Nullable + @Override + SettingsItemReader getReader() { + return new SettingsItemReader(this) { + + @Override + public void readFromStream(@NonNull InputStream inputStream, String entryName) throws IllegalArgumentException { + GPXFile gpxFile = GPXUtilities.loadGPXFile(inputStream); + if (gpxFile.error != null) { + warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType()))); + SettingsHelper.LOG.error("Failed read gpx file", gpxFile.error); + } else { + List mapMarkers = markersHelper.readMarkersFromGpx(gpxFile, true); + items.addAll(mapMarkers); + } + } + }; + } + + @Nullable + @Override + SettingsItemWriter getWriter() { + GPXFile gpxFile = markersHelper.generateGpx(items, true); + return getGpxWriter(gpxFile); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java index 4a8026ea44..3fea648619 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MarkersSettingsItem.java @@ -7,8 +7,6 @@ import androidx.annotation.Nullable; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; -import net.osmand.GPXUtilities.WptPt; -import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -16,37 +14,27 @@ import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.mapmarkers.MapMarkersDbHelper; import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.settings.backend.ExportSettingsType; import net.osmand.util.Algorithms; import org.json.JSONException; import org.json.JSONObject; -import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; import java.util.ArrayList; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import static net.osmand.IndexConstants.GPX_FILE_EXT; -import static net.osmand.plus.mapmarkers.MapMarkersHelper.CREATION_DATE; -import static net.osmand.plus.mapmarkers.MapMarkersHelper.GROUP_NAME; -import static net.osmand.plus.mapmarkers.MapMarkersHelper.GROUP_TYPE; -import static net.osmand.plus.mapmarkers.MapMarkersHelper.MARKER_HISTORY; -import static net.osmand.plus.mapmarkers.MapMarkersHelper.VISITED_DATE; -public class MarkersSettingsItem extends CollectionSettingsItem { +public class MarkersSettingsItem extends CollectionSettingsItem { private MapMarkersHelper markersHelper; - private Map flatGroups = new LinkedHashMap<>(); - public MarkersSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { + public MarkersSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { super(app, null, items); } - public MarkersSettingsItem(@NonNull OsmandApplication app, @Nullable MarkersSettingsItem baseItem, @NonNull List items) { + public MarkersSettingsItem(@NonNull OsmandApplication app, @Nullable MarkersSettingsItem baseItem, @NonNull List items) { super(app, baseItem, items); } @@ -58,13 +46,13 @@ public class MarkersSettingsItem extends CollectionSettingsItem protected void init() { super.init(); markersHelper = app.getMapMarkersHelper(); - existingItems = new ArrayList<>(markersHelper.getMapMarkersGroups()); + existingItems = new ArrayList<>(markersHelper.getMapMarkers()); } @NonNull @Override public SettingsItemType getType() { - return SettingsItemType.MARKERS; + return SettingsItemType.ACTIVE_MARKERS; } @NonNull @@ -79,11 +67,6 @@ public class MarkersSettingsItem extends CollectionSettingsItem return ctx.getString(R.string.map_markers); } - @NonNull - public String getDefaultFileName() { - return getName() + getDefaultFileExtension(); - } - @NonNull public String getDefaultFileExtension() { return GPX_FILE_EXT; @@ -91,37 +74,29 @@ public class MarkersSettingsItem extends CollectionSettingsItem @Override public void apply() { - List newItems = getNewItems(); + List newItems = getNewItems(); if (!newItems.isEmpty() || !duplicateItems.isEmpty()) { appliedItems = new ArrayList<>(newItems); - for (MapMarkersGroup duplicate : duplicateItems) { + for (MapMarker duplicate : duplicateItems) { if (shouldReplace) { - MapMarkersGroup existingGroup = markersHelper.getMapMarkerGroupById(duplicate.getId(), duplicate.getType()); - if (existingGroup != null) { - List existingMarkers = new ArrayList<>(existingGroup.getMarkers()); - for (MapMarker marker : existingMarkers) { - markersHelper.removeMarker(marker); - } - } + MapMarker existingMarker = markersHelper.getMapMarker(duplicate.point); + markersHelper.removeMarker(existingMarker); } - appliedItems.add(duplicate); + appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate)); } - for (MapMarkersGroup markersGroup : appliedItems) { - for (MapMarker marker : markersGroup.getMarkers()) { - markersHelper.addMarker(marker); - } + + for (MapMarker marker : appliedItems) { + markersHelper.addMarker(marker); } } } @Override - public boolean isDuplicate(@NonNull MapMarkersGroup markersGroup) { - String name = markersGroup.getName(); - for (MapMarkersGroup group : existingItems) { - if (Algorithms.stringsEqual(group.getName(), name) - && !Algorithms.isEmpty(group.getMarkers()) - && !Algorithms.isEmpty(markersGroup.getMarkers())) { + public boolean isDuplicate(@NonNull MapMarker mapMarker) { + for (MapMarker marker : existingItems) { + if (marker.equals(mapMarker) + && Algorithms.objectEquals(marker.getOriginalPointDescription(), mapMarker.getOriginalPointDescription())) { return true; } } @@ -135,8 +110,26 @@ public class MarkersSettingsItem extends CollectionSettingsItem @NonNull @Override - public MapMarkersGroup renameItem(@NonNull MapMarkersGroup item) { - return item; + public MapMarker renameItem(@NonNull MapMarker item) { + int number = 0; + while (true) { + number++; + String name = item.getOnlyName() + "_" + number; + PointDescription description = new PointDescription(PointDescription.POINT_TYPE_LOCATION, name); + MapMarker renamedMarker = new MapMarker(item.point, description, item.getColor(), item.selected, item.index); + if (!isDuplicate(renamedMarker)) { + renamedMarker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE; + return renamedMarker; + } + } + } + + public MapMarkersGroup getMarkersGroup() { + String name = app.getString(R.string.map_markers); + String groupId = ExportSettingsType.ACTIVE_MARKERS.name(); + MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, MapMarkersGroup.ANY_TYPE); + markersGroup.setMarkers(items); + return markersGroup; } @Nullable @@ -151,88 +144,17 @@ public class MarkersSettingsItem extends CollectionSettingsItem warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType()))); SettingsHelper.LOG.error("Failed read gpx file", gpxFile.error); } else { - List markerColors = getMarkersColors(); - for (WptPt point : gpxFile.getPoints()) { - LatLon latLon = new LatLon(point.lat, point.lon); - - int colorIndex = markerColors.indexOf(point.getColor()); - if (colorIndex == -1) { - colorIndex = 0; - } - - PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, point.name); - MapMarker marker = new MapMarker(latLon, pointDescription, colorIndex, false, 0); - - String historyStr = point.getExtensionsToRead().get(MARKER_HISTORY); - String creationDateStr = point.getExtensionsToRead().get(CREATION_DATE); - String visitedDateStr = point.getExtensionsToRead().get(VISITED_DATE); - marker.creationDate = Algorithms.parseLongSilently(creationDateStr, 0); - marker.visitedDate = Algorithms.parseLongSilently(visitedDateStr, 0); - marker.history = Boolean.parseBoolean(historyStr); - marker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE; - - MapMarkersGroup group = getOrCreateGroup(point); - group.getMarkers().add(marker); - } + List mapMarkers = markersHelper.readMarkersFromGpx(gpxFile, false); + items.addAll(mapMarkers); } } }; } - private MapMarkersGroup getOrCreateGroup(WptPt point) { - MapMarkersGroup markersGroup = flatGroups.get(point.category); - if (markersGroup != null) { - return markersGroup; - } - Map extensions = point.getExtensionsToRead(); - String groupName = extensions.get(GROUP_NAME); - String groupType = extensions.get(GROUP_TYPE); - int type = Algorithms.parseIntSilently(groupType, MapMarkersGroup.ANY_TYPE); - - if (point.category != null && groupName != null) { - markersGroup = new MapMarkersGroup(point.category, groupName, type); - } else { - markersGroup = new MapMarkersGroup(); - } - flatGroups.put(markersGroup.getId(), markersGroup); - items.add(markersGroup); - - return markersGroup; - } - - private List getMarkersColors() { - List colors = new ArrayList<>(); - for (int color : MapMarker.getColors(app)) { - colors.add(color); - } - return colors; - } - @Nullable @Override - SettingsItemWriter getWriter() { - return new SettingsItemWriter(this) { - - @Override - public boolean writeToStream(@NonNull OutputStream outputStream) throws IOException { - List mapMarkers = getMarkersFromGroups(items); - GPXFile gpxFile = markersHelper.generateGpx(mapMarkers, true); - Exception error = GPXUtilities.writeGpx(new OutputStreamWriter(outputStream, "UTF-8"), gpxFile); - if (error != null) { - warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType()))); - SettingsHelper.LOG.error("Failed write to gpx file", error); - return false; - } - return true; - } - }; - } - - private List getMarkersFromGroups(List markersGroups) { - List mapMarkers = new ArrayList<>(); - for (MapMarkersGroup group : markersGroups) { - mapMarkers.addAll(group.getMarkers()); - } - return mapMarkers; + SettingsItemWriter getWriter() { + GPXFile gpxFile = markersHelper.generateGpx(items, true); + return getGpxWriter(gpxFile); } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java index be32a12370..35f85b8ee8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java @@ -16,9 +16,9 @@ import net.osmand.map.ITileSource; import net.osmand.map.TileSourceManager; import net.osmand.map.TileSourceManager.TileSourceTemplate; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; -import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.R; import net.osmand.plus.SQLiteTileSource; import net.osmand.plus.activities.LocalIndexHelper; import net.osmand.plus.activities.LocalIndexInfo; @@ -29,6 +29,8 @@ import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; +import net.osmand.plus.mapmarkers.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.osmedit.OpenstreetmapPoint; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.osmedit.OsmNotesPoint; @@ -595,9 +597,21 @@ public class SettingsHelper { if (!files.isEmpty()) { dataList.put(ExportSettingsType.VOICE, files); } - List markersGroups = app.getMapMarkersHelper().getMapMarkersGroups(); - if (!markersGroups.isEmpty()) { - dataList.put(ExportSettingsType.MARKERS, markersGroups); + List mapMarkers = app.getMapMarkersHelper().getMapMarkers(); + if (!mapMarkers.isEmpty()) { + String name = app.getString(R.string.map_markers); + String groupId = ExportSettingsType.ACTIVE_MARKERS.name(); + MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, MapMarkersGroup.ANY_TYPE); + markersGroup.setMarkers(mapMarkers); + dataList.put(ExportSettingsType.ACTIVE_MARKERS, Collections.singletonList(markersGroup)); + } + List markersHistory = app.getMapMarkersHelper().getMapMarkersHistory(); + if (!markersHistory.isEmpty()) { + String name = app.getString(R.string.shared_string_history); + String groupId = ExportSettingsType.HISTORY_MARKERS.name(); + MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, MapMarkersGroup.ANY_TYPE); + markersGroup.setMarkers(markersHistory); + dataList.put(ExportSettingsType.HISTORY_MARKERS, Collections.singletonList(markersGroup)); } return dataList; } @@ -639,6 +653,7 @@ public class SettingsHelper { List osmNotesPointList = new ArrayList<>(); List osmEditsPointList = new ArrayList<>(); List markersGroups = new ArrayList<>(); + List markersHistoryGroups = new ArrayList<>(); for (Object object : data) { if (object instanceof QuickAction) { @@ -664,7 +679,12 @@ public class SettingsHelper { } else if (object instanceof FavoriteGroup) { favoriteGroups.add((FavoriteGroup) object); } else if (object instanceof MapMarkersGroup) { - markersGroups.add((MapMarkersGroup) object); + MapMarkersGroup markersGroup = (MapMarkersGroup) object; + if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) { + markersGroups.add((MapMarkersGroup) object); + } else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) { + markersHistoryGroups.add((MapMarkersGroup) object); + } } } if (!quickActions.isEmpty()) { @@ -697,7 +717,18 @@ public class SettingsHelper { settingsItems.add(new FavoritesSettingsItem(app, favoriteGroups)); } if (!markersGroups.isEmpty()) { - settingsItems.add(new MarkersSettingsItem(app, markersGroups)); + List mapMarkers = new ArrayList<>(); + for (MapMarkersGroup group : markersGroups) { + mapMarkers.addAll(group.getMarkers()); + } + settingsItems.add(new MarkersSettingsItem(app, mapMarkers)); + } + if (!markersHistoryGroups.isEmpty()) { + List mapMarkers = new ArrayList<>(); + for (MapMarkersGroup group : markersHistoryGroups) { + mapMarkers.addAll(group.getMarkers()); + } + settingsItems.add(new HistoryMarkersSettingsItem(app, mapMarkers)); } return settingsItems; } @@ -721,6 +752,7 @@ public class SettingsHelper { List editsPointList = new ArrayList<>(); List favoriteGroups = new ArrayList<>(); List markersGroups = new ArrayList<>(); + List markersHistoryGroups = new ArrayList<>(); for (SettingsItem item : settingsItems) { switch (item.getType()) { @@ -800,9 +832,13 @@ public class SettingsHelper { FavoritesSettingsItem favoritesSettingsItem = (FavoritesSettingsItem) item; favoriteGroups.addAll(favoritesSettingsItem.getItems()); break; - case MARKERS: + case ACTIVE_MARKERS: MarkersSettingsItem markersSettingsItem = (MarkersSettingsItem) item; - markersGroups.addAll(markersSettingsItem.getItems()); + markersGroups.add(markersSettingsItem.getMarkersGroup()); + break; + case HISTORY_MARKERS: + HistoryMarkersSettingsItem historyMarkersSettingsItem = (HistoryMarkersSettingsItem) item; + markersHistoryGroups.add(historyMarkersSettingsItem.getMarkersGroup()); break; default: break; @@ -858,7 +894,10 @@ public class SettingsHelper { settingsToOperate.put(ExportSettingsType.VOICE, voiceFilesList); } if (!markersGroups.isEmpty()) { - settingsToOperate.put(ExportSettingsType.MARKERS, markersGroups); + settingsToOperate.put(ExportSettingsType.ACTIVE_MARKERS, markersGroups); + } + if (!markersGroups.isEmpty()) { + settingsToOperate.put(ExportSettingsType.HISTORY_MARKERS, markersHistoryGroups); } return settingsToOperate; } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItem.java index afe776db09..8b6736bf1d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItem.java @@ -5,7 +5,10 @@ import android.content.Context; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import net.osmand.GPXUtilities; +import net.osmand.GPXUtilities.GPXFile; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; import net.osmand.util.Algorithms; import org.json.JSONException; @@ -17,6 +20,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.List; @@ -205,6 +209,7 @@ public abstract class SettingsItem { String s = json.toString(2); outputStream.write(s.getBytes("UTF-8")); } catch (JSONException e) { + warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType()))); SettingsHelper.LOG.error("Failed to write json to stream", e); } return true; @@ -214,6 +219,22 @@ public abstract class SettingsItem { }; } + @NonNull + SettingsItemWriter getGpxWriter(@NonNull final GPXFile gpxFile) { + return new SettingsItemWriter(this) { + @Override + public boolean writeToStream(@NonNull OutputStream outputStream) throws IOException { + Exception error = GPXUtilities.writeGpx(new OutputStreamWriter(outputStream, "UTF-8"), gpxFile); + if (error != null) { + warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType()))); + SettingsHelper.LOG.error("Failed write to gpx file", error); + return false; + } + return true; + } + }; + } + @Override public int hashCode() { return (getType().name() + getName()).hashCode(); diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java index bc254e28ca..2fed0b2645 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java @@ -16,5 +16,6 @@ public enum SettingsItemType { OSM_NOTES, OSM_EDITS, FAVOURITES, - MARKERS + ACTIVE_MARKERS, + HISTORY_MARKERS } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java index 3012cc3dd8..5160000d0c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java @@ -134,9 +134,12 @@ class SettingsItemsFactory { case FAVOURITES: item = new FavoritesSettingsItem(app, json); break; - case MARKERS: + case ACTIVE_MARKERS: item = new MarkersSettingsItem(app, json); break; + case HISTORY_MARKERS: + item = new HistoryMarkersSettingsItem(app, json); + break; } return item; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java index 12f491e21a..798b29a476 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java @@ -14,18 +14,14 @@ import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.map.ITileSource; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; -import net.osmand.plus.audionotes.AudioVideoNotesPlugin; -import net.osmand.plus.helpers.FileNameTranslationHelper; -import net.osmand.plus.helpers.GpxUiHelper; -import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean; -import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; +import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.GpxUiHelper; +import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.profiles.ProfileIconColors; import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources; @@ -40,7 +36,7 @@ import org.apache.commons.logging.Log; import java.io.File; import java.util.List; -import static net.osmand.plus.settings.backend.backup.FileSettingsItem.*; +import static net.osmand.plus.settings.backend.backup.FileSettingsItem.FileSubtype; public class DuplicatesSettingsAdapter extends RecyclerView.Adapter { @@ -162,11 +158,7 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter voiceFilesList = new ArrayList<>(); List mapFilesList = new ArrayList<>(); List markersGroups = new ArrayList<>(); + List markersHistoryGroups = new ArrayList<>(); for (Object object : duplicatesList) { if (object instanceof ApplicationMode.ApplicationModeBean) { @@ -239,7 +241,12 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment { } else if (object instanceof OpenstreetmapPoint) { osmEditsPointList.add((OpenstreetmapPoint) object); } else if (object instanceof MapMarkersGroup) { - markersGroups.add((MapMarkersGroup) object); + MapMarkersGroup markersGroup = (MapMarkersGroup) object; + if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) { + markersGroups.add(markersGroup); + } else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) { + markersHistoryGroups.add(markersGroup); + } } } if (!profiles.isEmpty()) { @@ -306,6 +313,10 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment { duplicates.add(getString(R.string.map_markers)); duplicates.addAll(markersGroups); } + if (!markersHistoryGroups.isEmpty()) { + duplicates.add(getString(R.string.markers_history)); + duplicates.addAll(markersHistoryGroups); + } return duplicates; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java index d7ae7eb77b..48b8e7a6ee 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java @@ -41,6 +41,7 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; +import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.osmedit.OpenstreetmapPoint; import net.osmand.plus.osmedit.OsmNotesPoint; @@ -48,20 +49,21 @@ import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean; import net.osmand.plus.settings.backend.ExportSettingsType; +import net.osmand.plus.settings.backend.backup.AvoidRoadsSettingsItem; import net.osmand.plus.settings.backend.backup.FavoritesSettingsItem; +import net.osmand.plus.settings.backend.backup.FileSettingsItem; import net.osmand.plus.settings.backend.backup.GlobalSettingsItem; +import net.osmand.plus.settings.backend.backup.HistoryMarkersSettingsItem; +import net.osmand.plus.settings.backend.backup.MapSourcesSettingsItem; import net.osmand.plus.settings.backend.backup.MarkersSettingsItem; import net.osmand.plus.settings.backend.backup.OsmEditsSettingsItem; import net.osmand.plus.settings.backend.backup.OsmNotesSettingsItem; -import net.osmand.plus.settings.backend.backup.SettingsHelper; -import net.osmand.plus.settings.backend.backup.AvoidRoadsSettingsItem; -import net.osmand.plus.settings.backend.backup.FileSettingsItem; -import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportAsyncTask; -import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportType; -import net.osmand.plus.settings.backend.backup.MapSourcesSettingsItem; import net.osmand.plus.settings.backend.backup.PoiUiFiltersSettingsItem; import net.osmand.plus.settings.backend.backup.ProfileSettingsItem; import net.osmand.plus.settings.backend.backup.QuickActionsSettingsItem; +import net.osmand.plus.settings.backend.backup.SettingsHelper; +import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportAsyncTask; +import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportType; import net.osmand.plus.settings.backend.backup.SettingsItem; import net.osmand.plus.settings.backend.backup.SettingsItemType; import net.osmand.plus.widgets.TextViewEx; @@ -439,6 +441,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment { List osmEditsPointList = new ArrayList<>(); List favoriteGroups = new ArrayList<>(); List markersGroups = new ArrayList<>(); + List markersHistoryGroups = new ArrayList<>(); for (Object object : data) { if (object instanceof ApplicationModeBean) { appModeBeans.add((ApplicationModeBean) object); @@ -463,7 +466,12 @@ public class ImportSettingsFragment extends BaseOsmAndFragment { } else if (object instanceof GlobalSettingsItem) { settingsItems.add((GlobalSettingsItem) object); } else if (object instanceof MapMarkersGroup) { - markersGroups.add((MapMarkersGroup) object); + MapMarkersGroup markersGroup = (MapMarkersGroup) object; + if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) { + markersGroups.add((MapMarkersGroup) object); + } else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) { + markersHistoryGroups.add((MapMarkersGroup) object); + } } } if (!appModeBeans.isEmpty()) { @@ -496,9 +504,22 @@ public class ImportSettingsFragment extends BaseOsmAndFragment { settingsItems.add(new FavoritesSettingsItem(app, baseItem, favoriteGroups)); } if (!markersGroups.isEmpty()) { - MarkersSettingsItem baseItem = getBaseItem(SettingsItemType.MARKERS, MarkersSettingsItem.class); - settingsItems.add(new MarkersSettingsItem(app, baseItem, markersGroups)); + List mapMarkers = new ArrayList<>(); + for (MapMarkersGroup group : markersGroups) { + mapMarkers.addAll(group.getMarkers()); + } + MarkersSettingsItem baseItem = getBaseItem(SettingsItemType.ACTIVE_MARKERS, MarkersSettingsItem.class); + settingsItems.add(new MarkersSettingsItem(app, baseItem, mapMarkers)); } + if (!markersHistoryGroups.isEmpty()) { + List mapMarkers = new ArrayList<>(); + for (MapMarkersGroup group : markersHistoryGroups) { + mapMarkers.addAll(group.getMarkers()); + } + HistoryMarkersSettingsItem baseItem = getBaseItem(SettingsItemType.HISTORY_MARKERS, HistoryMarkersSettingsItem.class); + settingsItems.add(new HistoryMarkersSettingsItem(app, baseItem, mapMarkers)); + } + return settingsItems; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java index fd8bc5a781..9114c430b9 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java @@ -142,10 +142,14 @@ public class ImportedSettingsItemsAdapter extends holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_settings, activeColorRes)); holder.title.setText(R.string.general_settings_2); break; - case MARKERS: + case ACTIVE_MARKERS: holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_flag, activeColorRes)); holder.title.setText(R.string.map_markers); break; + case HISTORY_MARKERS: + holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_flag, activeColorRes)); + holder.title.setText(R.string.markers_history); + break; } }