Search in sources :

Example 6 with ProfileDataObject

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);
}
Also used : RouteService(net.osmand.plus.routing.RouteService) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) ProfileDataObject(net.osmand.plus.profiles.data.ProfileDataObject) Map(java.util.Map)

Example 7 with ProfileDataObject

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

Example 8 with ProfileDataObject

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());
}
Also used : ItemBuilder(net.osmand.plus.ContextMenuItem.ItemBuilder) ItemClickListener(net.osmand.plus.ContextMenuAdapter.ItemClickListener) ContextMenuItemClickListener(net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener) ContextMenuItem(net.osmand.plus.ContextMenuItem) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) ProfileDataObject(net.osmand.plus.profiles.data.ProfileDataObject) FavouritePoint(net.osmand.data.FavouritePoint)

Example 9 with ProfileDataObject

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

Aggregations

ProfileDataObject (net.osmand.plus.profiles.data.ProfileDataObject)9 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)5 FavouritePoint (net.osmand.data.FavouritePoint)2 ItemClickListener (net.osmand.plus.ContextMenuAdapter.ItemClickListener)2 ContextMenuItem (net.osmand.plus.ContextMenuItem)2 ItemBuilder (net.osmand.plus.ContextMenuItem.ItemBuilder)2 ContextMenuItemClickListener (net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener)2 SuppressLint (android.annotation.SuppressLint)1 SpannableString (android.text.SpannableString)1 View (android.view.View)1 ImageButton (android.widget.ImageButton)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Nullable (androidx.annotation.Nullable)1 FragmentActivity (androidx.fragment.app.FragmentActivity)1 ItemTouchHelper (androidx.recyclerview.widget.ItemTouchHelper)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 AppBarLayout (com.google.android.material.appbar.AppBarLayout)1 ArrayList (java.util.ArrayList)1