Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
fe9f64af54
8 changed files with 92 additions and 11 deletions
|
@ -1553,6 +1553,15 @@ public class OsmandSettings {
|
||||||
public final static String INTERMEDIATE_POINTS_DESCRIPTION = "intermediate_points_description"; //$NON-NLS-1$
|
public final static String INTERMEDIATE_POINTS_DESCRIPTION = "intermediate_points_description"; //$NON-NLS-1$
|
||||||
private IntermediatePointsStorage intermediatePointsStorage = new IntermediatePointsStorage();
|
private IntermediatePointsStorage intermediatePointsStorage = new IntermediatePointsStorage();
|
||||||
|
|
||||||
|
public final static String POINT_NAVIGATE_LAT_BACKUP = "point_navigate_lat_backup"; //$NON-NLS-1$
|
||||||
|
public final static String POINT_NAVIGATE_LON_BACKUP = "point_navigate_lon_backup"; //$NON-NLS-1$
|
||||||
|
public final static String POINT_NAVIGATE_DESCRIPTION_BACKUP = "point_navigate_description_backup"; //$NON-NLS-1$
|
||||||
|
public final static String START_POINT_LAT_BACKUP = "start_point_lat_backup"; //$NON-NLS-1$
|
||||||
|
public final static String START_POINT_LON_BACKUP = "start_point_lon_backup"; //$NON-NLS-1$
|
||||||
|
public final static String START_POINT_DESCRIPTION_BACKUP = "start_point_description_backup"; //$NON-NLS-1$
|
||||||
|
public final static String INTERMEDIATE_POINTS_BACKUP = "intermediate_points_backup"; //$NON-NLS-1$
|
||||||
|
public final static String INTERMEDIATE_POINTS_DESCRIPTION_BACKUP = "intermediate_points_description_backup"; //$NON-NLS-1$
|
||||||
|
|
||||||
public final static String MAP_MARKERS_POINT = "map_markers_point"; //$NON-NLS-1$
|
public final static String MAP_MARKERS_POINT = "map_markers_point"; //$NON-NLS-1$
|
||||||
public final static String MAP_MARKERS_COLOR = "map_markers_color"; //$NON-NLS-1$
|
public final static String MAP_MARKERS_COLOR = "map_markers_color"; //$NON-NLS-1$
|
||||||
public final static String MAP_MARKERS_DESCRIPTION = "map_markers_description"; //$NON-NLS-1$
|
public final static String MAP_MARKERS_DESCRIPTION = "map_markers_description"; //$NON-NLS-1$
|
||||||
|
@ -1564,6 +1573,48 @@ public class OsmandSettings {
|
||||||
private MapMarkersStorage mapMarkersStorage = new MapMarkersStorage();
|
private MapMarkersStorage mapMarkersStorage = new MapMarkersStorage();
|
||||||
private MapMarkersHistoryStorage mapMarkersHistoryStorage = new MapMarkersHistoryStorage();
|
private MapMarkersHistoryStorage mapMarkersHistoryStorage = new MapMarkersHistoryStorage();
|
||||||
|
|
||||||
|
private void backupPointToStart() {
|
||||||
|
settingsAPI.edit(globalPreferences)
|
||||||
|
.putFloat(START_POINT_LAT_BACKUP, settingsAPI.getFloat(globalPreferences, START_POINT_LAT, 0))
|
||||||
|
.putFloat(START_POINT_LON_BACKUP, settingsAPI.getFloat(globalPreferences, START_POINT_LON, 0))
|
||||||
|
.putString(START_POINT_DESCRIPTION_BACKUP, settingsAPI.getString(globalPreferences, START_POINT_DESCRIPTION, ""))
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void backupPointToNavigate() {
|
||||||
|
settingsAPI.edit(globalPreferences)
|
||||||
|
.putFloat(POINT_NAVIGATE_LAT_BACKUP, settingsAPI.getFloat(globalPreferences, POINT_NAVIGATE_LAT, 0))
|
||||||
|
.putFloat(POINT_NAVIGATE_LON_BACKUP, settingsAPI.getFloat(globalPreferences, POINT_NAVIGATE_LON, 0))
|
||||||
|
.putString(POINT_NAVIGATE_DESCRIPTION_BACKUP, settingsAPI.getString(globalPreferences, POINT_NAVIGATE_DESCRIPTION, ""))
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void backupIntermediatePoints() {
|
||||||
|
settingsAPI.edit(globalPreferences)
|
||||||
|
.putString(INTERMEDIATE_POINTS_BACKUP, settingsAPI.getString(globalPreferences, INTERMEDIATE_POINTS, ""))
|
||||||
|
.putString(INTERMEDIATE_POINTS_DESCRIPTION_BACKUP, settingsAPI.getString(globalPreferences, INTERMEDIATE_POINTS_DESCRIPTION, ""))
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void backupTargetPoints() {
|
||||||
|
backupPointToStart();
|
||||||
|
backupPointToNavigate();
|
||||||
|
backupIntermediatePoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restoreTargetPoints() {
|
||||||
|
settingsAPI.edit(globalPreferences)
|
||||||
|
.putFloat(START_POINT_LAT, settingsAPI.getFloat(globalPreferences, START_POINT_LAT_BACKUP, 0))
|
||||||
|
.putFloat(START_POINT_LON, settingsAPI.getFloat(globalPreferences, START_POINT_LON_BACKUP, 0))
|
||||||
|
.putString(START_POINT_DESCRIPTION, settingsAPI.getString(globalPreferences, START_POINT_DESCRIPTION_BACKUP, ""))
|
||||||
|
.putFloat(POINT_NAVIGATE_LAT, settingsAPI.getFloat(globalPreferences, POINT_NAVIGATE_LAT_BACKUP, 0))
|
||||||
|
.putFloat(POINT_NAVIGATE_LON, settingsAPI.getFloat(globalPreferences, POINT_NAVIGATE_LON_BACKUP, 0))
|
||||||
|
.putString(POINT_NAVIGATE_DESCRIPTION, settingsAPI.getString(globalPreferences, POINT_NAVIGATE_DESCRIPTION_BACKUP, ""))
|
||||||
|
.putString(INTERMEDIATE_POINTS, settingsAPI.getString(globalPreferences, INTERMEDIATE_POINTS_BACKUP, ""))
|
||||||
|
.putString(INTERMEDIATE_POINTS_DESCRIPTION, settingsAPI.getString(globalPreferences, INTERMEDIATE_POINTS_DESCRIPTION_BACKUP, ""))
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
|
||||||
public LatLon getPointToNavigate() {
|
public LatLon getPointToNavigate() {
|
||||||
float lat = settingsAPI.getFloat(globalPreferences, POINT_NAVIGATE_LAT, 0);
|
float lat = settingsAPI.getFloat(globalPreferences, POINT_NAVIGATE_LAT, 0);
|
||||||
float lon = settingsAPI.getFloat(globalPreferences, POINT_NAVIGATE_LON, 0);
|
float lon = settingsAPI.getFloat(globalPreferences, POINT_NAVIGATE_LON, 0);
|
||||||
|
@ -1634,6 +1685,13 @@ public class OsmandSettings {
|
||||||
pointsKey = INTERMEDIATE_POINTS;
|
pointsKey = INTERMEDIATE_POINTS;
|
||||||
descriptionsKey = INTERMEDIATE_POINTS_DESCRIPTION;
|
descriptionsKey = INTERMEDIATE_POINTS_DESCRIPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean savePoints(List<LatLon> ps, List<String> ds) {
|
||||||
|
boolean res = super.savePoints(ps, ds);
|
||||||
|
backupTargetPoints();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MapMarkersHistoryStorage extends MapPointsStorage {
|
private class MapMarkersHistoryStorage extends MapPointsStorage {
|
||||||
|
@ -1642,6 +1700,15 @@ public class OsmandSettings {
|
||||||
pointsKey = MAP_MARKERS_HISTORY_POINT;
|
pointsKey = MAP_MARKERS_HISTORY_POINT;
|
||||||
descriptionsKey = MAP_MARKERS_HISTORY_DESCRIPTION;
|
descriptionsKey = MAP_MARKERS_HISTORY_DESCRIPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean savePoints(List<LatLon> ps, List<String> ds) {
|
||||||
|
while (ps.size() > MAP_MARKERS_HISTORY_LIMIT) {
|
||||||
|
ps.remove(ps.size() - 1);
|
||||||
|
ds.remove(ds.size() - 1);
|
||||||
|
}
|
||||||
|
return super.savePoints(ps, ds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MapMarkersStorage extends MapPointsStorage {
|
private class MapMarkersStorage extends MapPointsStorage {
|
||||||
|
@ -2103,12 +2170,14 @@ public class OsmandSettings {
|
||||||
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, p);
|
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
backupTargetPoints();
|
||||||
return add;
|
return add;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setPointToStart(double latitude, double longitude, PointDescription p) {
|
public boolean setPointToStart(double latitude, double longitude, PointDescription p) {
|
||||||
boolean add = settingsAPI.edit(globalPreferences).putFloat(START_POINT_LAT, (float) latitude).putFloat(START_POINT_LON, (float) longitude).commit();
|
boolean add = settingsAPI.edit(globalPreferences).putFloat(START_POINT_LAT, (float) latitude).putFloat(START_POINT_LON, (float) longitude).commit();
|
||||||
settingsAPI.edit(globalPreferences).putString(START_POINT_DESCRIPTION, PointDescription.serializeToString(p)).commit();
|
settingsAPI.edit(globalPreferences).putString(START_POINT_DESCRIPTION, PointDescription.serializeToString(p)).commit();
|
||||||
|
backupTargetPoints();
|
||||||
return add;
|
return add;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,10 +257,16 @@ public class TargetPointsHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void restoreTargetPoints(boolean updateRoute) {
|
||||||
|
settings.restoreTargetPoints();
|
||||||
|
readFromSettings();
|
||||||
|
updateRouteAndRefresh(updateRoute);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the local and persistent waypoints list and destination.
|
* Clear the local and persistent waypoints list and destination.
|
||||||
*/
|
*/
|
||||||
public void removeAllWayPoints(boolean updateRoute){
|
public void removeAllWayPoints(boolean updateRoute, boolean clearBackup){
|
||||||
cancelStartPointAddressRequest();
|
cancelStartPointAddressRequest();
|
||||||
cancelTargetPointAddressRequest();
|
cancelTargetPointAddressRequest();
|
||||||
cancelAllIntermediatePointsAddressRequests();
|
cancelAllIntermediatePointsAddressRequests();
|
||||||
|
@ -268,6 +274,9 @@ public class TargetPointsHelper {
|
||||||
settings.clearIntermediatePoints();
|
settings.clearIntermediatePoints();
|
||||||
settings.clearPointToNavigate();
|
settings.clearPointToNavigate();
|
||||||
settings.clearPointToStart();
|
settings.clearPointToStart();
|
||||||
|
if (clearBackup) {
|
||||||
|
settings.backupTargetPoints();
|
||||||
|
}
|
||||||
pointToNavigate = null;
|
pointToNavigate = null;
|
||||||
pointToStart = null;
|
pointToStart = null;
|
||||||
intermediatePoints.clear();
|
intermediatePoints.clear();
|
||||||
|
|
|
@ -283,7 +283,7 @@ public class IntermediatePointsDialog {
|
||||||
boolean changeDestinationFlag = !checkedIntermediates[checkedIntermediates.length - 1];
|
boolean changeDestinationFlag = !checkedIntermediates[checkedIntermediates.length - 1];
|
||||||
if (cnt == checkedIntermediates.length) { // there is no alternative destination if all points are to be
|
if (cnt == checkedIntermediates.length) { // there is no alternative destination if all points are to be
|
||||||
// removed?
|
// removed?
|
||||||
app.getTargetPointsHelper().removeAllWayPoints(true);
|
app.getTargetPointsHelper().removeAllWayPoints(true, true);
|
||||||
} else {
|
} else {
|
||||||
for (int i = checkedIntermediates.length - 2; i >= 0; i--) { // skip the destination until a retained
|
for (int i = checkedIntermediates.length - 2; i >= 0; i--) { // skip the destination until a retained
|
||||||
// waypoint is found
|
// waypoint is found
|
||||||
|
|
|
@ -256,7 +256,7 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
|
||||||
&& !settings.FOLLOW_THE_ROUTE.get()
|
&& !settings.FOLLOW_THE_ROUTE.get()
|
||||||
&& app.getTargetPointsHelper().getAllPoints().size() > 0) {
|
&& app.getTargetPointsHelper().getAllPoints().size() > 0) {
|
||||||
app.getRoutingHelper().clearCurrentRoute(null, new ArrayList<LatLon>());
|
app.getRoutingHelper().clearCurrentRoute(null, new ArrayList<LatLon>());
|
||||||
app.getTargetPointsHelper().removeAllWayPoints(false);
|
app.getTargetPointsHelper().removeAllWayPoints(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!settings.isLastKnownMapLocation()) {
|
if (!settings.isLastKnownMapLocation()) {
|
||||||
|
|
|
@ -813,7 +813,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
settings.LAST_ROUTING_APPLICATION_MODE = settings.APPLICATION_MODE.get();
|
settings.LAST_ROUTING_APPLICATION_MODE = settings.APPLICATION_MODE.get();
|
||||||
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
|
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
|
||||||
if (settings.USE_MAP_MARKERS.get()) {
|
if (settings.USE_MAP_MARKERS.get()) {
|
||||||
getMyApplication().getTargetPointsHelper().removeAllWayPoints(false);
|
getMyApplication().getTargetPointsHelper().removeAllWayPoints(false, false);
|
||||||
}
|
}
|
||||||
mapActivity.updateApplicationModeSettings();
|
mapActivity.updateApplicationModeSettings();
|
||||||
mapActivity.getDashboard().clearDeletedPoints();
|
mapActivity.getDashboard().clearDeletedPoints();
|
||||||
|
|
|
@ -184,7 +184,7 @@ public class FailSafeFuntions {
|
||||||
ma.updateApplicationModeSettings();
|
ma.updateApplicationModeSettings();
|
||||||
app.getRoutingHelper().clearCurrentRoute(null, new ArrayList<LatLon>());
|
app.getRoutingHelper().clearCurrentRoute(null, new ArrayList<LatLon>());
|
||||||
if (app.getSettings().USE_MAP_MARKERS.get()) {
|
if (app.getSettings().USE_MAP_MARKERS.get()) {
|
||||||
app.getTargetPointsHelper().removeAllWayPoints(false);
|
app.getTargetPointsHelper().removeAllWayPoints(false, false);
|
||||||
}
|
}
|
||||||
ma.refreshMap();
|
ma.refreshMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -492,7 +492,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (defaultVls[0] == 0) {
|
if (defaultVls[0] == 0) {
|
||||||
targets.removeAllWayPoints(false);
|
targets.removeAllWayPoints(false, true);
|
||||||
targets.navigateToPoint(latLon, true, -1, getPointDescriptionForTarget());
|
targets.navigateToPoint(latLon, true, -1, getPointDescriptionForTarget());
|
||||||
mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true);
|
mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true);
|
||||||
close();
|
close();
|
||||||
|
|
|
@ -391,10 +391,13 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
||||||
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
|
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
|
||||||
if (settings.USE_MAP_MARKERS.get() && !hasTargets) {
|
if (settings.USE_MAP_MARKERS.get() && !hasTargets) {
|
||||||
|
getTargets().restoreTargetPoints(false);
|
||||||
|
if (getTargets().getPointToNavigate() == null) {
|
||||||
mapActivity.getMapActions().setFirstMapMarkerAsTarget();
|
mapActivity.getMapActions().setFirstMapMarkerAsTarget();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
TargetPoint start = getTargets().getPointToStart();
|
TargetPoint start = getTargets().getPointToStart();
|
||||||
if (hasTargets && start != null) {
|
if (start != null) {
|
||||||
mapActivity.getMapActions().enterRoutePlanningMode(
|
mapActivity.getMapActions().enterRoutePlanningMode(
|
||||||
new LatLon(start.getLatitude(), start.getLongitude()), start.getOriginalPointDescription());
|
new LatLon(start.getLatitude(), start.getLongitude()), start.getOriginalPointDescription());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue