Search in sources :

Example 1 with TextRadioItem

use of net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem in project Osmand by osmandapp.

the class HikingRoutesFragment method setupTypesCard.

private void setupTypesCard(@NonNull View view) {
    View container = view.findViewById(R.id.card_container);
    boolean enabled = property != null && isEnabled();
    if (enabled) {
        TextRadioItem selectedItem = null;
        List<TextRadioItem> items = new ArrayList<>();
        for (String value : property.getPossibleValues()) {
            TextRadioItem item = createRadioButton(value);
            if (Algorithms.stringsEqual(value, pref.get())) {
                selectedItem = item;
            }
            items.add(item);
        }
        TextView title = container.findViewById(R.id.title);
        TextView description = container.findViewById(R.id.description);
        title.setText(R.string.routes_color_by_type);
        description.setText(AndroidUtils.getRenderingStringPropertyDescription(app, pref.get()));
        LinearLayout radioButtonsContainer = view.findViewById(R.id.custom_radio_buttons);
        TextToggleButton radioGroup = new TextToggleButton(app, radioButtonsContainer, nightMode, true);
        radioGroup.setItems(items);
        radioGroup.setSelectedItem(selectedItem);
    }
    AndroidUiHelper.updateVisibility(container, enabled);
    AndroidUiHelper.updateVisibility(container.findViewById(R.id.descr), false);
    AndroidUiHelper.updateVisibility(view.findViewById(R.id.topShadowView), enabled);
    AndroidUiHelper.updateVisibility(view.findViewById(R.id.card_bottom_divider), enabled);
}
Also used : TextToggleButton(net.osmand.plus.widgets.multistatetoggle.TextToggleButton) ArrayList(java.util.ArrayList) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 2 with TextRadioItem

use of net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem in project Osmand by osmandapp.

the class CycleRoutesFragment method setupTypesCard.

private void setupTypesCard(@NonNull View view) {
    CommonPreference<Boolean> pref = settings.getCustomRenderBooleanProperty(CYCLE_NODE_NETWORK_ROUTES_ATTR);
    View container = view.findViewById(R.id.card_container);
    TextView title = container.findViewById(R.id.title);
    TextView description = container.findViewById(R.id.description);
    title.setText(R.string.routes_color_by_type);
    description.setText(pref.get() ? R.string.rendering_value_walkingRoutesOSMCNodes_description : R.string.walking_route_osmc_description);
    TextRadioItem relation = createRadioButton(pref, false, R.string.layer_route);
    TextRadioItem nodeNetworks = createRadioButton(pref, true, R.string.rendering_value_walkingRoutesOSMCNodes_name);
    TextToggleButton radioGroup = new TextToggleButton(app, view.findViewById(R.id.custom_radio_buttons), nightMode);
    radioGroup.setItems(relation, nodeNetworks);
    radioGroup.setSelectedItem(pref.get() ? nodeNetworks : relation);
    boolean enabled = getPreference().get();
    AndroidUiHelper.updateVisibility(container, enabled);
    AndroidUiHelper.updateVisibility(view.findViewById(R.id.topShadowView), enabled);
    AndroidUiHelper.updateVisibility(container.findViewById(R.id.descr), false);
    AndroidUiHelper.updateVisibility(view.findViewById(R.id.card_bottom_divider), enabled);
}
Also used : TextToggleButton(net.osmand.plus.widgets.multistatetoggle.TextToggleButton) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 3 with TextRadioItem

use of net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem in project Osmand by osmandapp.

the class TravelRoutesFragment method createRadioButton.

private TextRadioItem createRadioButton(final TravelType type) {
    TextRadioItem item = new TextRadioItem(app.getString(type.titleRes));
    item.setOnClickListener((radioItem, v) -> {
        travelType = type;
        View view = getView();
        if (view != null) {
            setupPrefItems(view);
        }
        return true;
    });
    return item;
}
Also used : TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 4 with TextRadioItem

use of net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem in project Osmand by osmandapp.

the class TravelRoutesFragment method setupTypeRadioGroup.

private void setupTypeRadioGroup(@NonNull View view) {
    boolean selected = settings.SHOW_TRAVEL.get();
    LinearLayout buttonsContainer = view.findViewById(R.id.custom_radio_buttons);
    if (selected) {
        TextRadioItem routes = createRadioButton(TravelType.ROUTE_TYPES);
        TextRadioItem files = createRadioButton(TravelType.TRAVEL_FILES);
        TextRadioItem points = createRadioButton(TravelType.ROUTE_POINTS);
        TextToggleButton radioGroup = new TextToggleButton(app, buttonsContainer, nightMode, true);
        radioGroup.setItems(routes, files, points);
        switch(travelType) {
            case ROUTE_TYPES:
                radioGroup.setSelectedItem(routes);
                break;
            case TRAVEL_FILES:
                radioGroup.setSelectedItem(files);
                break;
            case ROUTE_POINTS:
                radioGroup.setSelectedItem(points);
                break;
        }
    }
    AndroidUiHelper.updateVisibility(buttonsContainer, selected);
    AndroidUiHelper.updateVisibility(view.findViewById(R.id.space), selected);
    AndroidUiHelper.updateVisibility(view.findViewById(R.id.header_divider), selected);
}
Also used : TextToggleButton(net.osmand.plus.widgets.multistatetoggle.TextToggleButton) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) LinearLayout(android.widget.LinearLayout)

Example 5 with TextRadioItem

use of net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem in project Osmand by osmandapp.

the class GPXAction method setupTrackToggleButton.

private void setupTrackToggleButton(@NonNull View container, @NonNull MapActivity mapActivity) {
    OsmandApplication app = mapActivity.getMyApplication();
    boolean night = isNightMode(mapActivity);
    LinearLayout trackToggle = container.findViewById(R.id.track_toggle);
    trackToggleButton = new TextToggleButton(app, trackToggle, night);
    TextRadioItem alwaysAskButton = new TextRadioItem(app.getString(R.string.confirm_every_run));
    TextRadioItem selectTrackButton = new TextRadioItem(app.getString(R.string.shared_string_select));
    alwaysAskButton.setOnClickListener(getOnTrackToggleButtonClicked(container, true, mapActivity));
    selectTrackButton.setOnClickListener(getOnTrackToggleButtonClicked(container, false, mapActivity));
    trackToggleButton.setItems(alwaysAskButton, selectTrackButton);
    trackToggleButton.setSelectedItem(shouldUseSelectedGpxFile() ? selectTrackButton : alwaysAskButton);
    updateTrackBottomInfo(container, !shouldUseSelectedGpxFile());
    setupSelectAnotherTrackButton(container, night, mapActivity);
    if (shouldUseSelectedGpxFile()) {
        setupGpxTrackInfo(container, app);
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) TextToggleButton(net.osmand.plus.widgets.multistatetoggle.TextToggleButton) TextRadioItem(net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem) LinearLayout(android.widget.LinearLayout)

Aggregations

TextRadioItem (net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem)19 View (android.view.View)10 TextToggleButton (net.osmand.plus.widgets.multistatetoggle.TextToggleButton)10 TextView (android.widget.TextView)9 ImageView (android.widget.ImageView)6 LinearLayout (android.widget.LinearLayout)6 RadioItem (net.osmand.plus.widgets.multistatetoggle.RadioItem)5 OnRadioItemClickListener (net.osmand.plus.widgets.multistatetoggle.RadioItem.OnRadioItemClickListener)5 OsmandApplication (net.osmand.plus.OsmandApplication)3 Drawable (android.graphics.drawable.Drawable)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 MapActivity (net.osmand.plus.activities.MapActivity)2 Typeface (android.graphics.Typeface)1 SpannableString (android.text.SpannableString)1 LayoutInflater (android.view.LayoutInflater)1 OnClickListener (android.view.View.OnClickListener)1 CompoundButton (android.widget.CompoundButton)1 ImageButton (android.widget.ImageButton)1 Nullable (androidx.annotation.Nullable)1 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)1