Search in sources :

Example 1 with TextToggleButton

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

the class SelectionBottomSheet method createHeaderView.

private BaseBottomSheetItem createHeaderView() {
    View view = inflater.inflate(R.layout.settings_group_title, null);
    title = view.findViewById(R.id.title);
    titleDescription = view.findViewById(R.id.title_description);
    primaryDescription = view.findViewById(R.id.primary_description);
    secondaryDescription = view.findViewById(R.id.secondary_description);
    selectedSize = view.findViewById(R.id.selected_size);
    toggleContainer = view.findViewById(R.id.custom_radio_buttons);
    radioGroup = new TextToggleButton(app, toggleContainer, nightMode);
    selectAllButton = view.findViewById(R.id.select_all_button);
    checkBoxTitle = view.findViewById(R.id.check_box_title);
    checkBox = view.findViewById(R.id.check_box);
    if (modes != null) {
        radioGroup.setItems(modes);
    }
    return new SimpleBottomSheetItem.Builder().setCustomView(view).create();
}
Also used : TextToggleButton(net.osmand.plus.widgets.multistatetoggle.TextToggleButton) View(android.view.View) TextView(android.widget.TextView)

Example 2 with TextToggleButton

use of net.osmand.plus.widgets.multistatetoggle.TextToggleButton 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 3 with TextToggleButton

use of net.osmand.plus.widgets.multistatetoggle.TextToggleButton 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 4 with TextToggleButton

use of net.osmand.plus.widgets.multistatetoggle.TextToggleButton 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 TextToggleButton

use of net.osmand.plus.widgets.multistatetoggle.TextToggleButton 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

TextToggleButton (net.osmand.plus.widgets.multistatetoggle.TextToggleButton)12 TextRadioItem (net.osmand.plus.widgets.multistatetoggle.TextToggleButton.TextRadioItem)10 LinearLayout (android.widget.LinearLayout)7 View (android.view.View)5 TextView (android.widget.TextView)5 ImageView (android.widget.ImageView)3 OsmandApplication (net.osmand.plus.OsmandApplication)3 Drawable (android.graphics.drawable.Drawable)2 LayoutInflater (android.view.LayoutInflater)2 BaseBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem)2 Context (android.content.Context)1 Typeface (android.graphics.Typeface)1 SpannableString (android.text.SpannableString)1 OnClickListener (android.view.View.OnClickListener)1 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)1 CompoundButton (android.widget.CompoundButton)1 ImageButton (android.widget.ImageButton)1 Nullable (androidx.annotation.Nullable)1 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)1 Fragment (androidx.fragment.app.Fragment)1