Search in sources :

Example 36 with ApplicationMode

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;
}
Also used : MarkersPlanRouteContext(net.osmand.plus.mapmarkers.MarkersPlanRouteContext) ApplicationMode(net.osmand.plus.ApplicationMode)

Example 37 with ApplicationMode

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);
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) ApplicationMode(net.osmand.plus.ApplicationMode) TargetPointsHelper(net.osmand.plus.TargetPointsHelper)

Example 38 with ApplicationMode

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);
        }
    }
}
Also used : ApplicationMode(net.osmand.plus.ApplicationMode)

Example 39 with ApplicationMode

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;
}
Also used : ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) ConfigureMapMenu(net.osmand.plus.dialogs.ConfigureMapMenu) ApplicationMode(net.osmand.plus.ApplicationMode)

Example 40 with ApplicationMode

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);
}
Also used : ApplicationMode(net.osmand.plus.ApplicationMode)

Aggregations

ApplicationMode (net.osmand.plus.ApplicationMode)41 View (android.view.View)13 TextView (android.widget.TextView)11 ImageView (android.widget.ImageView)7 OsmandApplication (net.osmand.plus.OsmandApplication)7 OsmandSettings (net.osmand.plus.OsmandSettings)7 AlertDialog (android.support.v7.app.AlertDialog)6 ArrayList (java.util.ArrayList)6 DialogInterface (android.content.DialogInterface)5 AdapterView (android.widget.AdapterView)5 LatLon (net.osmand.data.LatLon)5 Intent (android.content.Intent)4 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)4 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)4 File (java.io.File)3 OsmandPreference (net.osmand.plus.OsmandSettings.OsmandPreference)3 RoutingHelper (net.osmand.plus.routing.RoutingHelper)3 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)3 Uri (android.net.Uri)2 PreferenceCategory (android.preference.PreferenceCategory)2