Search in sources :

Example 1 with MuteSoundRoutingParameter

use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter in project Osmand by osmandapp.

the class RouteOptionsBottomSheet method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    items.add(new TitleItem(app.getString(R.string.shared_string_settings), ColorUtilities.getActiveColorId(nightMode)));
    OsmAndAppCustomization customization = app.getAppCustomization();
    List<LocalRoutingParameter> list = getRoutingParameters(applicationMode);
    for (final LocalRoutingParameter optionsItem : list) {
        if (!dialogMode.isAvailableParameter(optionsItem) || !customization.isFeatureEnabled(optionsItem.getKey())) {
            continue;
        }
        if (optionsItem instanceof DividerItem) {
            if (isDividerRequired()) {
                items.add(new DividerStartItem(app));
            }
        } else if (optionsItem instanceof MuteSoundRoutingParameter) {
            items.add(createMuteSoundItem(optionsItem));
        } else if (optionsItem instanceof ShowAlongTheRouteItem) {
            items.add(createShowAlongTheRouteItem(optionsItem));
        } else if (optionsItem instanceof RouteSimulationItem) {
            items.add(createRouteSimulationItem(optionsItem));
        } else if (optionsItem instanceof AvoidPTTypesRoutingParameter) {
            items.add(createAvoidPTTypesItem(optionsItem));
        } else if (optionsItem instanceof AvoidRoadsRoutingParameter) {
            items.add(createAvoidRoadsItem(optionsItem));
        } else if (optionsItem instanceof GpxLocalRoutingParameter) {
            items.add(createGpxRoutingItem(optionsItem));
        } else if (optionsItem instanceof TimeConditionalRoutingItem) {
            items.add(createTimeConditionalRoutingItem(optionsItem));
        } else if (optionsItem instanceof OtherSettingsRoutingParameter) {
            items.add(createOtherSettingsRoutingItem(optionsItem));
        } else if (optionsItem instanceof CustomizeRouteLineRoutingParameter) {
            items.add(createCustomizeRouteLineRoutingItem(optionsItem));
        } else if (USE_HEIGHT_OBSTACLES.equals(optionsItem.getKey()) && hasReliefParameters()) {
            items.add(inflateElevationParameter(optionsItem));
        } else {
            inflateRoutingParameter(optionsItem);
        }
    }
}
Also used : OtherSettingsRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherSettingsRoutingParameter) MuteSoundRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter) AvoidPTTypesRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter) TimeConditionalRoutingItem(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.TimeConditionalRoutingItem) RouteSimulationItem(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.RouteSimulationItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) GpxLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter) LocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter) AvoidRoadsRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter) GpxLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter) DividerStartItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerStartItem) CustomizeRouteLineRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.CustomizeRouteLineRoutingParameter) OsmAndAppCustomization(net.osmand.plus.settings.backend.OsmAndAppCustomization) ShowAlongTheRouteItem(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.ShowAlongTheRouteItem) DividerItem(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DividerItem)

Example 2 with MuteSoundRoutingParameter

use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter in project Osmand by osmandapp.

the class RoutePreferencesMenu method getItemClickListener.

public OnItemClickListener getItemClickListener(final ArrayAdapter<?> listAdapter) {
    return new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
            Object obj = listAdapter.getItem(item);
            if (obj instanceof LocalRoutingParameterGroup) {
                final LocalRoutingParameterGroup group = (LocalRoutingParameterGroup) obj;
                final ContextMenuAdapter adapter = new ContextMenuAdapter(app);
                int i = 0;
                int selectedIndex = -1;
                for (LocalRoutingParameter p : group.getRoutingParameters()) {
                    adapter.addItem(ContextMenuItem.createBuilder(p.getText(mapActivity)).setSelected(false).createItem());
                    if (p.isSelected(settings)) {
                        selectedIndex = i;
                    }
                    i++;
                }
                if (selectedIndex == -1) {
                    selectedIndex = 0;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
                final int layout = R.layout.list_menu_item_native_singlechoice;
                final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(mapActivity, layout, R.id.text1, adapter.getItemNames()) {

                    @NonNull
                    @Override
                    public View getView(final int position, View convertView, ViewGroup parent) {
                        // User super class to create the View
                        View v = convertView;
                        if (v == null) {
                            v = mapActivity.getLayoutInflater().inflate(layout, null);
                        }
                        final ContextMenuItem item = adapter.getItem(position);
                        TextView tv = (TextView) v.findViewById(R.id.text1);
                        tv.setText(item.getTitle());
                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f);
                        return v;
                    }
                };
                final int[] selectedPosition = { selectedIndex };
                builder.setSingleChoiceItems(listAdapter, selectedIndex, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int position) {
                        selectedPosition[0] = position;
                    }
                });
                builder.setTitle(group.getText(mapActivity)).setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        int position = selectedPosition[0];
                        if (position >= 0 && position < group.getRoutingParameters().size()) {
                            for (int i = 0; i < group.getRoutingParameters().size(); i++) {
                                LocalRoutingParameter rp = group.getRoutingParameters().get(i);
                                rp.setSelected(settings, i == position);
                            }
                            mapActivity.getRoutingHelper().onSettingsChanged(true);
                            updateParameters();
                        }
                    }
                }).setNegativeButton(R.string.shared_string_cancel, null);
                builder.create().show();
            } else if (obj instanceof MuteSoundRoutingParameter) {
                final CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item);
                btn.performClick();
            } else if (obj instanceof VoiceGuidanceRoutingParameter) {
                doSelectVoiceGuidance();
            } else if (obj instanceof InterruptMusicRoutingParameter) {
                final CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item);
                btn.performClick();
            } else if (obj instanceof AvoidRoadsRoutingParameter) {
                routingOptionsHelper.selectRestrictedRoads(mapActivity);
            } else if (obj instanceof GpxLocalRoutingParameter) {
                showOptionsMenu((TextView) view.findViewById(R.id.description));
            } else {
                CheckBox ch = (CheckBox) view.findViewById(R.id.toggle_item);
                if (ch != null) {
                    ch.setChecked(!ch.isChecked());
                }
            }
        }
    };
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) DialogInterface(android.content.DialogInterface) GPXRouteParamsBuilder(net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder) InterruptMusicRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.InterruptMusicRoutingParameter) GpxLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter) LocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter) AvoidRoadsRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter) GpxLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter) TextView(android.widget.TextView) VoiceGuidanceRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.VoiceGuidanceRoutingParameter) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ContextMenuItem(net.osmand.plus.ContextMenuItem) MuteSoundRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter) ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) CheckBox(android.widget.CheckBox) AdapterView(android.widget.AdapterView) CallbackWithObject(net.osmand.CallbackWithObject) LocalRoutingParameterGroup(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameterGroup) ArrayAdapter(android.widget.ArrayAdapter) CompoundButton(android.widget.CompoundButton)

Aggregations

AvoidRoadsRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter)2 GpxLocalRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter)2 LocalRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter)2 MuteSoundRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter)2 DialogInterface (android.content.DialogInterface)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 AdapterView (android.widget.AdapterView)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 ArrayAdapter (android.widget.ArrayAdapter)1 CheckBox (android.widget.CheckBox)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 CallbackWithObject (net.osmand.CallbackWithObject)1 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)1 ContextMenuItem (net.osmand.plus.ContextMenuItem)1 DividerStartItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerStartItem)1 TitleItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem)1