Boat navigation is enabled with Nautical plugin
This commit is contained in:
parent
3eb7dd5165
commit
14ac84f363
1 changed files with 17 additions and 0 deletions
|
@ -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()));
|
||||
if((!selectedProfiles.contains(ApplicationMode.BOAT) && flag) ||
|
||||
((selectedProfiles.contains(ApplicationMode.BOAT) && !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
|
||||
|
|
Loading…
Reference in a new issue