use of net.osmand.plus.profiles.data.ProfileDataObject in project Osmand by osmandapp.
the class NavigationFragment method updateRoutingProfile.
void updateRoutingProfile(String profileKey) {
ProfileDataObject selectedRoutingProfileDataObject = routingProfileDataObjects.get(profileKey);
if (profileKey == null || selectedRoutingProfileDataObject == null) {
return;
}
for (Map.Entry<String, ProfileDataObject> rp : routingProfileDataObjects.entrySet()) {
boolean selected = profileKey.equals(rp.getKey());
rp.getValue().setSelected(selected);
}
navigationType.setSummary(selectedRoutingProfileDataObject.getName());
navigationType.setIcon(getActiveIcon(selectedRoutingProfileDataObject.getIconRes()));
ApplicationMode appMode = getSelectedAppMode();
RouteService routeService;
if (profileKey.equals(RoutingProfilesResources.STRAIGHT_LINE_MODE.name())) {
routeService = RouteService.STRAIGHT;
} else if (profileKey.equals(RoutingProfilesResources.DIRECT_TO_MODE.name())) {
routeService = RouteService.DIRECT_TO;
} else if (profileKey.equals(RoutingProfilesResources.BROUTER_MODE.name())) {
routeService = RouteService.BROUTER;
} else if (profileKey.startsWith(ONLINE_ROUTING_ENGINE_PREFIX)) {
routeService = RouteService.ONLINE;
} else {
routeService = RouteService.OSMAND;
}
appMode.setRouteService(routeService);
appMode.setRoutingProfile(profileKey);
}
use of net.osmand.plus.profiles.data.ProfileDataObject in project Osmand by osmandapp.
the class NavigationFragment method setupNavigationTypePref.
private void setupNavigationTypePref() {
String routingProfileKey = getSelectedAppMode().getRoutingProfile();
if (!Algorithms.isEmpty(routingProfileKey)) {
ProfileDataObject routingProfileDataObject = routingProfileDataObjects.get(routingProfileKey);
if (routingProfileDataObject != null) {
navigationType.setSummary(routingProfileDataObject.getName());
navigationType.setIcon(getActiveIcon(routingProfileDataObject.getIconRes()));
}
}
}
use of net.osmand.plus.profiles.data.ProfileDataObject in project Osmand by osmandapp.
the class MapActivityActions method createProfilesController.
private void createProfilesController(final OsmandApplication app, ContextMenuAdapter optionsMenuHelper, boolean nightMode, boolean listExpanded) {
// switch profile button
ApplicationMode currentMode = app.getSettings().APPLICATION_MODE.get();
String modeDescription;
Map<String, ProfileDataObject> profilesObjects = routingDataUtils.getRoutingProfiles();
if (currentMode.isCustomProfile()) {
modeDescription = getProfileDescription(app, currentMode, profilesObjects, getString(R.string.profile_type_user_string));
} else {
modeDescription = getProfileDescription(app, currentMode, profilesObjects, getString(R.string.profile_type_osmand_string));
}
int icArrowResId = listExpanded ? R.drawable.ic_action_arrow_drop_up : R.drawable.ic_action_arrow_drop_down;
final int nextMode = listExpanded ? DRAWER_MODE_NORMAL : DRAWER_MODE_SWITCH_PROFILE;
optionsMenuHelper.addItem(new ItemBuilder().setLayout(R.layout.main_menu_drawer_btn_switch_profile).setId(DRAWER_SWITCH_PROFILE_ID).setIcon(currentMode.getIconRes()).setSecondaryIcon(icArrowResId).setColor(currentMode.getProfileColor(nightMode)).setTitle(currentMode.toHumanString()).setDescription(modeDescription).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
drawerMode = nextMode;
updateDrawerMenu();
return false;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setLayout(R.layout.main_menu_drawer_btn_configure_profile).setId(DRAWER_CONFIGURE_PROFILE_ID).setColor(currentMode.getProfileColor(nightMode)).setTitle(getString(R.string.configure_profile)).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
mapActivity.dismissSettingsScreens();
BaseSettingsFragment.showInstance(mapActivity, BaseSettingsFragment.SettingsScreenType.CONFIGURE_PROFILE);
return true;
}
}).createItem());
}
use of net.osmand.plus.profiles.data.ProfileDataObject in project Osmand by osmandapp.
the class MapActivityActions method getProfileDescription.
private String getProfileDescription(OsmandApplication app, ApplicationMode mode, Map<String, ProfileDataObject> profilesObjects, String defaultDescription) {
String description = defaultDescription;
String routingProfileKey = mode.getRoutingProfile();
if (!Algorithms.isEmpty(routingProfileKey)) {
ProfileDataObject profileDataObject = profilesObjects.get(routingProfileKey);
if (profileDataObject != null) {
description = String.format(app.getString(R.string.profile_type_descr_string), Algorithms.capitalizeFirstLetterAndLowercase(profileDataObject.getName()));
}
}
return description;
}
Aggregations