Search in sources :

Example 1 with SubtitleItem

use of net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleItem in project Osmand by osmandapp.

the class CoordinateInputBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    final Context context = getContext();
    final OsmandSettings settings = getMyApplication().getSettings();
    items.add(new TitleItem(getString(R.string.shared_string_options)));
    boolean useOsmandKeyboard = settings.COORDS_INPUT_USE_OSMAND_KEYBOARD.get();
    BaseBottomSheetItem useSystemKeyboardItem = new BottomSheetItemWithCompoundButton.Builder().setChecked(!useOsmandKeyboard).setIcon(getContentIcon(R.drawable.ic_action_keyboard)).setTitle(getString(R.string.use_system_keyboard)).setLayoutId(R.layout.bottom_sheet_item_with_switch).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.onKeyboardChanged();
            }
            dismiss();
        }
    }).create();
    items.add(useSystemKeyboardItem);
    boolean useTwoDigitsLogtitude = settings.COORDS_INPUT_TWO_DIGITS_LONGTITUDE.get();
    BaseBottomSheetItem twoDigitsLongtitudeItem = new BottomSheetItemWithCompoundButton.Builder().setChecked(useTwoDigitsLogtitude).setIcon(getContentIcon(R.drawable.ic_action_next_field_stroke)).setTitle(getString(R.string.use_two_digits_longitude)).setLayoutId(R.layout.bottom_sheet_item_with_switch).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                OsmandSettings.CommonPreference<Boolean> pref = settings.COORDS_INPUT_TWO_DIGITS_LONGTITUDE;
                pref.set(!pref.get());
                listener.onInputSettingsChanged();
            }
            dismiss();
        }
    }).create();
    items.add(twoDigitsLongtitudeItem);
    if (!AndroidUiHelper.isOrientationPortrait(getActivity())) {
        boolean rightHand = settings.COORDS_INPUT_USE_RIGHT_SIDE.get();
        BaseBottomSheetItem showNumberPadItem = new BottomSheetItemWithDescription.Builder().setDescription(getString(rightHand ? R.string.shared_string_right : R.string.shared_string_left)).setDescriptionColorId(getActiveColorId()).setIcon(getContentIcon(rightHand ? R.drawable.ic_action_show_keypad_right : R.drawable.ic_action_show_keypad_left)).setTitle(getString(R.string.show_number_pad)).setLayoutId(R.layout.bottom_sheet_item_with_right_descr).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (listener != null) {
                    OsmandSettings.CommonPreference<Boolean> pref = settings.COORDS_INPUT_USE_RIGHT_SIDE;
                    pref.set(!pref.get());
                    listener.onHandChanged();
                }
                dismiss();
            }
        }).create();
        items.add(showNumberPadItem);
    }
    items.add(new SubtitleDividerItem(context));
    items.add(new SubtitleItem(getString(R.string.coordinates_format)));
    int selectedFormat = settings.COORDS_INPUT_FORMAT.get();
    Drawable formatIcon = getContentIcon(R.drawable.ic_action_coordinates_latitude);
    View.OnClickListener formatsOnClickListener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            int format = (int) v.getTag();
            settings.COORDS_INPUT_FORMAT.set(format);
            if (listener != null) {
                listener.onInputSettingsChanged();
            }
            dismiss();
        }
    };
    for (@CoordinateInputFormatDef int format : CoordinateInputFormats.VALUES) {
        boolean selectedItem = format == selectedFormat;
        BaseBottomSheetItem formatItem = new BottomSheetItemWithCompoundButton.Builder().setChecked(selectedItem).setButtonTintList(selectedItem ? ColorStateList.valueOf(getResolvedColor(getActiveColorId())) : null).setIcon(selectedItem ? getActiveIcon(R.drawable.ic_action_coordinates_latitude) : formatIcon).setTitle(CoordinateInputFormats.formatToHumanString(context, format)).setTitleColorId(selectedItem ? getActiveColorId() : BaseBottomSheetItem.INVALID_ID).setLayoutId(R.layout.bottom_sheet_item_with_radio_btn).setOnClickListener(formatsOnClickListener).setTag(format).create();
        items.add(formatItem);
    }
}
Also used : Context(android.content.Context) BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) SubtitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleItem) Drawable(android.graphics.drawable.Drawable) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) View(android.view.View) OsmandSettings(net.osmand.plus.OsmandSettings) BottomSheetItemWithDescription(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription) SubtitleDividerItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem) CoordinateInputFormatDef(net.osmand.plus.mapmarkers.CoordinateInputFormats.CoordinateInputFormatDef) BottomSheetItemWithCompoundButton(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)

Example 2 with SubtitleItem

use of net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleItem in project Osmand by osmandapp.

the class PlanRouteOptionsBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    items.add(new TitleItem(getString(R.string.shared_string_options)));
    if (!AndroidUiHelper.isOrientationPortrait(getActivity())) {
        boolean selectAll = getArguments().getBoolean(SELECT_ALL_KEY);
        BaseBottomSheetItem selectItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(selectAll ? R.drawable.ic_action_select_all : R.drawable.ic_action_deselect_all)).setTitle(getString(selectAll ? R.string.shared_string_select_all : R.string.shared_string_deselect_all)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.selectOnClick();
                }
                dismiss();
            }
        }).create();
        items.add(selectItem);
    }
    BaseBottomSheetItem navigateItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_gdirections_dark)).setTitle(getString(R.string.get_directions)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.navigateOnClick();
            }
            dismiss();
        }
    }).create();
    items.add(navigateItem);
    BaseBottomSheetItem roundTripItem = new BottomSheetItemWithCompoundButton.Builder().setChecked(getMyApplication().getSettings().ROUTE_MAP_MARKERS_ROUND_TRIP.get()).setDescription(getString(R.string.make_round_trip_descr)).setIcon(getContentIcon(R.drawable.ic_action_trip_round)).setTitle(getString(R.string.make_round_trip)).setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.makeRoundTripOnClick();
            }
            dismiss();
        }
    }).create();
    items.add(roundTripItem);
    items.add(new SubtitleDividerItem(getContext()));
    items.add(new SubtitleItem(getString(R.string.sort_by)));
    BaseBottomSheetItem doorToDoorItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_sort_door_to_door)).setTitle(getString(R.string.intermediate_items_sort_by_distance)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.doorToDoorOnClick();
            }
            dismiss();
        }
    }).create();
    items.add(doorToDoorItem);
    BaseBottomSheetItem reversItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_sort_reverse_order)).setTitle(getString(R.string.shared_string_reverse_order)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.reverseOrderOnClick();
            }
            dismiss();
        }
    }).create();
    items.add(reversItem);
}
Also used : BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) SubtitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) View(android.view.View) BottomSheetItemWithCompoundButton(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton) SubtitleDividerItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem)

Aggregations

View (android.view.View)2 BaseBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem)2 BottomSheetItemWithCompoundButton (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)2 SubtitleDividerItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem)2 SubtitleItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleItem)2 TitleItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem)2 Context (android.content.Context)1 Drawable (android.graphics.drawable.Drawable)1 OsmandSettings (net.osmand.plus.OsmandSettings)1 BottomSheetItemWithDescription (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription)1 SimpleBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem)1 CoordinateInputFormatDef (net.osmand.plus.mapmarkers.CoordinateInputFormats.CoordinateInputFormatDef)1