use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.
the class MapActivityActions method getRouteMode.
public ApplicationMode getRouteMode(LatLon from) {
MarkersPlanRouteContext planRouteContext = mapActivity.getMyApplication().getMapMarkersHelper().getPlanRouteContext();
if (planRouteContext.isNavigationFromMarkers() && planRouteContext.getSnappedMode() != ApplicationMode.DEFAULT) {
planRouteContext.setNavigationFromMarkers(false);
return planRouteContext.getSnappedMode();
}
ApplicationMode mode = settings.DEFAULT_APPLICATION_MODE.get();
ApplicationMode selected = settings.APPLICATION_MODE.get();
if (selected != ApplicationMode.DEFAULT) {
mode = selected;
} else if (mode == ApplicationMode.DEFAULT) {
mode = ApplicationMode.CAR;
if (settings.LAST_ROUTING_APPLICATION_MODE != null && settings.LAST_ROUTING_APPLICATION_MODE != ApplicationMode.DEFAULT) {
mode = settings.LAST_ROUTING_APPLICATION_MODE;
}
}
return mode;
}
use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.
the class MapActivityActions method enterRoutePlanningModeGivenGpx.
public void enterRoutePlanningModeGivenGpx(GPXFile gpxFile, LatLon from, PointDescription fromName, boolean useIntermediatePointsByDefault, boolean showDialog) {
settings.USE_INTERMEDIATE_POINTS_NAVIGATION.set(useIntermediatePointsByDefault);
OsmandApplication app = mapActivity.getMyApplication();
TargetPointsHelper targets = app.getTargetPointsHelper();
ApplicationMode mode = getRouteMode(from);
// app.getSettings().APPLICATION_MODE.set(mode);
app.getRoutingHelper().setAppMode(mode);
app.initVoiceCommandPlayer(mapActivity, mode, true, null, false, false);
// save application mode controls
settings.FOLLOW_THE_ROUTE.set(false);
app.getRoutingHelper().setFollowingMode(false);
app.getRoutingHelper().setRoutePlanningMode(true);
// reset start point
targets.setStartPoint(from, false, fromName);
// then set gpx
setGPXRouteParams(gpxFile);
// then update start and destination point
targets.updateRouteAndRefresh(true);
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
mapActivity.getMapView().refreshMap(true);
if (showDialog) {
mapActivity.getMapLayers().getMapControlsLayer().showDialog();
}
if (targets.hasTooLongDistanceToNavigate()) {
app.showToastMessage(R.string.route_is_too_long_v2);
}
}
use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.
the class MapWidgetRegistry method processVisibleModes.
private void processVisibleModes(String key, MapWidgetRegInfo ii) {
for (ApplicationMode ms : ApplicationMode.values(settings)) {
boolean collapse = ms.isWidgetCollapsible(key);
boolean def = ms.isWidgetVisible(key);
Set<String> set = visibleElementsFromSettings.get(ms);
if (set != null) {
if (set.contains(key)) {
def = true;
collapse = false;
} else if (set.contains(HIDE_PREFIX + key)) {
def = false;
collapse = false;
} else if (set.contains(COLLAPSED_PREFIX + key)) {
def = false;
collapse = true;
}
}
if (def) {
ii.visibleModes.add(ms);
} else if (collapse) {
ii.visibleCollapsible.add(ms);
}
}
}
use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.
the class MapWidgetRegistry method getViewConfigureMenuAdapter.
public ContextMenuAdapter getViewConfigureMenuAdapter(final MapActivity map) {
final ContextMenuAdapter cm = new ContextMenuAdapter();
cm.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.app_modes_choose, map).setLayout(R.layout.mode_toggles).createItem());
cm.setChangeAppModeListener(new ConfigureMapMenu.OnClickListener() {
@Override
public void onClick() {
map.getDashboard().updateListAdapter(getViewConfigureMenuAdapter(map));
}
});
final ApplicationMode mode = settings.getApplicationMode();
addControls(map, cm, mode);
return cm;
}
use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.
the class MapWidgetRegistry method resetToDefault.
public void resetToDefault() {
ApplicationMode appMode = settings.getApplicationMode();
resetDefault(appMode, leftWidgetSet);
resetDefault(appMode, rightWidgetSet);
resetDefaultAppearance(appMode);
this.visibleElementsFromSettings.put(appMode, null);
settings.MAP_INFO_CONTROLS.set(SHOW_PREFIX);
}
Aggregations