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$
|
||||
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_COLOR = "map_markers_color"; //$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 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() {
|
||||
float lat = settingsAPI.getFloat(globalPreferences, POINT_NAVIGATE_LAT, 0);
|
||||
float lon = settingsAPI.getFloat(globalPreferences, POINT_NAVIGATE_LON, 0);
|
||||
|
@ -1634,6 +1685,13 @@ public class OsmandSettings {
|
|||
pointsKey = INTERMEDIATE_POINTS;
|
||||
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 {
|
||||
|
@ -1642,6 +1700,15 @@ public class OsmandSettings {
|
|||
pointsKey = MAP_MARKERS_HISTORY_POINT;
|
||||
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 {
|
||||
|
@ -2103,12 +2170,14 @@ public class OsmandSettings {
|
|||
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, p);
|
||||
}
|
||||
}
|
||||
backupTargetPoints();
|
||||
return add;
|
||||
}
|
||||
|
||||
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();
|
||||
settingsAPI.edit(globalPreferences).putString(START_POINT_DESCRIPTION, PointDescription.serializeToString(p)).commit();
|
||||
backupTargetPoints();
|
||||
return add;
|
||||
}
|
||||
|
||||
|
|
|
@ -257,10 +257,16 @@ public class TargetPointsHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void restoreTargetPoints(boolean updateRoute) {
|
||||
settings.restoreTargetPoints();
|
||||
readFromSettings();
|
||||
updateRouteAndRefresh(updateRoute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the local and persistent waypoints list and destination.
|
||||
*/
|
||||
public void removeAllWayPoints(boolean updateRoute){
|
||||
public void removeAllWayPoints(boolean updateRoute, boolean clearBackup){
|
||||
cancelStartPointAddressRequest();
|
||||
cancelTargetPointAddressRequest();
|
||||
cancelAllIntermediatePointsAddressRequests();
|
||||
|
@ -268,6 +274,9 @@ public class TargetPointsHelper {
|
|||
settings.clearIntermediatePoints();
|
||||
settings.clearPointToNavigate();
|
||||
settings.clearPointToStart();
|
||||
if (clearBackup) {
|
||||
settings.backupTargetPoints();
|
||||
}
|
||||
pointToNavigate = null;
|
||||
pointToStart = null;
|
||||
intermediatePoints.clear();
|
||||
|
|
|
@ -283,7 +283,7 @@ public class IntermediatePointsDialog {
|
|||
boolean changeDestinationFlag = !checkedIntermediates[checkedIntermediates.length - 1];
|
||||
if (cnt == checkedIntermediates.length) { // there is no alternative destination if all points are to be
|
||||
// removed?
|
||||
app.getTargetPointsHelper().removeAllWayPoints(true);
|
||||
app.getTargetPointsHelper().removeAllWayPoints(true, true);
|
||||
} else {
|
||||
for (int i = checkedIntermediates.length - 2; i >= 0; i--) { // skip the destination until a retained
|
||||
// waypoint is found
|
||||
|
|
|
@ -256,7 +256,7 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
|
|||
&& !settings.FOLLOW_THE_ROUTE.get()
|
||||
&& app.getTargetPointsHelper().getAllPoints().size() > 0) {
|
||||
app.getRoutingHelper().clearCurrentRoute(null, new ArrayList<LatLon>());
|
||||
app.getTargetPointsHelper().removeAllWayPoints(false);
|
||||
app.getTargetPointsHelper().removeAllWayPoints(false, false);
|
||||
}
|
||||
|
||||
if (!settings.isLastKnownMapLocation()) {
|
||||
|
|
|
@ -813,7 +813,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
settings.LAST_ROUTING_APPLICATION_MODE = settings.APPLICATION_MODE.get();
|
||||
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
|
||||
if (settings.USE_MAP_MARKERS.get()) {
|
||||
getMyApplication().getTargetPointsHelper().removeAllWayPoints(false);
|
||||
getMyApplication().getTargetPointsHelper().removeAllWayPoints(false, false);
|
||||
}
|
||||
mapActivity.updateApplicationModeSettings();
|
||||
mapActivity.getDashboard().clearDeletedPoints();
|
||||
|
|
|
@ -184,7 +184,7 @@ public class FailSafeFuntions {
|
|||
ma.updateApplicationModeSettings();
|
||||
app.getRoutingHelper().clearCurrentRoute(null, new ArrayList<LatLon>());
|
||||
if (app.getSettings().USE_MAP_MARKERS.get()) {
|
||||
app.getTargetPointsHelper().removeAllWayPoints(false);
|
||||
app.getTargetPointsHelper().removeAllWayPoints(false, false);
|
||||
}
|
||||
ma.refreshMap();
|
||||
}
|
||||
|
|
|
@ -492,7 +492,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (defaultVls[0] == 0) {
|
||||
targets.removeAllWayPoints(false);
|
||||
targets.removeAllWayPoints(false, true);
|
||||
targets.navigateToPoint(latLon, true, -1, getPointDescriptionForTarget());
|
||||
mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true);
|
||||
close();
|
||||
|
|
|
@ -391,10 +391,13 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
||||
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
|
||||
if (settings.USE_MAP_MARKERS.get() && !hasTargets) {
|
||||
getTargets().restoreTargetPoints(false);
|
||||
if (getTargets().getPointToNavigate() == null) {
|
||||
mapActivity.getMapActions().setFirstMapMarkerAsTarget();
|
||||
}
|
||||
}
|
||||
TargetPoint start = getTargets().getPointToStart();
|
||||
if (hasTargets && start != null) {
|
||||
if (start != null) {
|
||||
mapActivity.getMapActions().enterRoutePlanningMode(
|
||||
new LatLon(start.getLatitude(), start.getLongitude()), start.getOriginalPointDescription());
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue