Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-01-26 14:36:55 +01:00
commit d68e2dde0e
3 changed files with 40 additions and 9 deletions

View file

@ -1487,13 +1487,18 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
public void run() {
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
List<TargetPoint> allTargets = new ArrayList<>();
TargetPoint start = null;
if (items != null) {
for (Object obj : items) {
if (obj instanceof LocationPointWrapper) {
LocationPointWrapper p = (LocationPointWrapper) obj;
if (p.getPoint() instanceof TargetPoint) {
TargetPoint t = (TargetPoint) p.getPoint();
if (t.start) {
start = t;
} else {
t.intermediate = true;
}
allTargets.add(t);
}
}
@ -1503,15 +1508,24 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
if (allTargets.size() > 0) {
TargetPoint start = allTargets.remove(0);
targetPointsHelper.setStartPoint(new LatLon(start.getLatitude(), start.getLongitude()),
false, start.getPointDescription(getMyApplication()));
if (start != null) {
int startInd = allTargets.indexOf(start);
TargetPoint first = allTargets.remove(0);
if (startInd != 0) {
start.start = false;
start.intermediate = startInd != allTargets.size() - 1;
if (targetPointsHelper.getPointToStart() == null) {
start.getOriginalPointDescription().setName(start.getLatitude() + ", " + start.getLongitude());
}
first.start = true;
first.intermediate = false;
targetPointsHelper.setStartPoint(new LatLon(first.getLatitude(), first.getLongitude()),
false, first.getPointDescription(getMyApplication()));
}
}
targetPointsHelper.reorderAllTargetPoints(allTargets, false);
newRouteIsCalculated(false, new ValueHolder<Boolean>());
targetPointsHelper.updateRouteAndRefresh(true);
}
}
}, 50);

View file

@ -6,6 +6,7 @@ import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import net.osmand.IndexConstants;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
@ -13,6 +14,9 @@ import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadResources;
import net.osmand.plus.render.RendererRegistry;
import java.util.LinkedHashSet;
import java.util.Set;
public class NauticalMapsPlugin extends OsmandPlugin {
public static final String ID = "nauticalPlugin.plugin";
@ -53,6 +57,7 @@ public class NauticalMapsPlugin extends OsmandPlugin {
@Override
public boolean init(final OsmandApplication app, final Activity activity) {
if(activity != null) {
addBoatProfile(true);
// called from UI
previousRenderer = app.getSettings().RENDERER.get();
app.getSettings().RENDERER.set(RendererRegistry.NAUTICAL_RENDER);
@ -83,12 +88,24 @@ public class NauticalMapsPlugin extends OsmandPlugin {
return true;
}
public void addBoatProfile(boolean flag) {
Set<ApplicationMode> selectedProfiles = new LinkedHashSet<>(ApplicationMode.values(app.getSettings()));
boolean isBoatEnabled = selectedProfiles.contains(ApplicationMode.BOAT);
if((!isBoatEnabled && flag) || (isBoatEnabled && !flag)) {
String s = app.getSettings().AVAILABLE_APP_MODES.get();
String currModes = flag ? s + ApplicationMode.BOAT.getStringKey() + ","
: s.replace(ApplicationMode.BOAT.getStringKey() + ",", "");
app.getSettings().AVAILABLE_APP_MODES.set(currModes);
}
}
@Override
public void disable(OsmandApplication app) {
super.disable(app);
if(app.getSettings().RENDERER.get().equals(RendererRegistry.NAUTICAL_RENDER)) {
app.getSettings().RENDERER.set(previousRenderer);
}
addBoatProfile(false);
}
@Override