Search in sources :

Example 6 with TitleItem

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

the class OptionsBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    Bundle args = getArguments();
    boolean snapToRoadEnabled = args.getBoolean(SNAP_TO_ROAD_ENABLED_KEY);
    boolean addLineMode = args.getBoolean(ADD_LINE_MODE_KEY);
    items.add(new TitleItem(getString(R.string.shared_string_options)));
    BaseBottomSheetItem snapToRoadItem = new BottomSheetItemWithCompoundButton.Builder().setChecked(snapToRoadEnabled).setDescription(getString(snapToRoadEnabled ? R.string.shared_string_enabled : R.string.shared_string_disabled)).setIcon(snapToRoadEnabled ? getActiveIcon(R.drawable.ic_action_snap_to_road) : getContentIcon(R.drawable.ic_action_snap_to_road)).setTitle(getString(R.string.snap_to_road)).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.snapToRoadOnCLick();
            }
            dismiss();
        }
    }).create();
    items.add(snapToRoadItem);
    items.add(new DividerHalfItem(getContext()));
    if (addLineMode) {
        BaseBottomSheetItem saveAsNewSegmentItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_polygom_dark)).setTitle(getString(R.string.shared_string_save)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.addToGpxOnClick();
                }
                dismiss();
            }
        }).create();
        items.add(saveAsNewSegmentItem);
    } else {
        BaseBottomSheetItem saveAsNewTrackItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_polygom_dark)).setTitle(getString(R.string.shared_string_save_as_gpx)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.saveAsNewTrackOnClick();
                }
                dismiss();
            }
        }).create();
        items.add(saveAsNewTrackItem);
        BaseBottomSheetItem addToTrackItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_split_interval)).setTitle(getString(R.string.add_segment_to_the_track)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.addToTheTrackOnClick();
                }
                dismiss();
            }
        }).create();
        items.add(addToTrackItem);
    }
    items.add(new DividerHalfItem(getContext()));
    BaseBottomSheetItem clearAllItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_reset_to_default_dark)).setTitle(getString(R.string.shared_string_clear_all)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

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

Example 7 with TitleItem

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

the class ExportOptionsBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    Bundle args = getArguments();
    if (args != null) {
        poiCount = args.getInt(POI_COUNT_KEY);
        osmNotesCount = args.getInt(NOTES_COUNT_KEY);
    }
    items.add(new TitleItem(getString(R.string.shared_string_export)));
    items.add(new DescriptionItem(getString(R.string.osm_edits_export_desc)));
    BaseBottomSheetItem poiItem = new BottomSheetItemWithDescription.Builder().setDescription(String.valueOf(poiCount)).setIcon(getContentIcon(R.drawable.ic_action_info_dark)).setTitle(getString(R.string.poi)).setLayoutId(R.layout.bottom_sheet_item_with_right_descr).setDisabled(!(poiCount > 0)).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.onClick(OsmEditsFragment.EXPORT_TYPE_POI);
            }
            dismiss();
        }
    }).create();
    items.add(poiItem);
    BaseBottomSheetItem osmNotesItem = new BottomSheetItemWithDescription.Builder().setDescription(String.valueOf(osmNotesCount)).setIcon(getContentIcon(R.drawable.ic_action_bug_dark)).setTitle(getString(R.string.osm_notes)).setLayoutId(R.layout.bottom_sheet_item_with_right_descr).setDisabled(!(osmNotesCount > 0)).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.onClick(OsmEditsFragment.EXPORT_TYPE_NOTES);
            }
            dismiss();
        }
    }).create();
    items.add(osmNotesItem);
    BaseBottomSheetItem allDataItem = new BottomSheetItemWithDescription.Builder().setDescription(String.valueOf(poiCount + osmNotesCount)).setIcon(getContentIcon(R.drawable.ic_action_folder)).setTitle(getString(R.string.all_data)).setLayoutId(R.layout.bottom_sheet_item_with_right_descr).setDisabled(!(poiCount + osmNotesCount > 0)).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.onClick(OsmEditsFragment.EXPORT_TYPE_ALL);
            }
            dismiss();
        }
    }).create();
    items.add(allDataItem);
}
Also used : BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) Bundle(android.os.Bundle) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) View(android.view.View) BottomSheetItemWithDescription(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription) DescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DescriptionItem)

Example 8 with TitleItem

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

the class ParkingTypeBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    items.add(new TitleItem(getString(R.string.parking_options)));
    BaseBottomSheetItem byTypeItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_time_start)).setTitle(getString(R.string.osmand_parking_no_lim_text)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            addParkingPosition(false);
        }
    }).create();
    items.add(byTypeItem);
    BaseBottomSheetItem byDateItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_time_span)).setTitle(getString(R.string.osmand_parking_time_limit)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            addParkingPosition(true);
        }
    }).create();
    items.add(byDateItem);
}
Also used : BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) View(android.view.View)

Example 9 with TitleItem

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

the class SelectWptCategoriesBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    gpxFile = getGpxFile();
    if (gpxFile == null) {
        return;
    }
    items.add(new TitleItem(getGpxName(gpxFile)));
    items.add(new DescriptionItem(getString(R.string.select_waypoints_category_description)));
    final BottomSheetItemWithCompoundButton[] selectAllItem = new BottomSheetItemWithCompoundButton[1];
    selectAllItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(true).setDescription(getString(R.string.shared_string_total) + ": " + gpxFile.getPoints().size()).setIcon(getContentIcon(R.drawable.ic_action_group_select_all)).setTitle(getString(R.string.shared_string_select_all)).setLayoutId(R.layout.bottom_sheet_item_with_descr_and_checkbox_56dp).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean checked = !selectAllItem[0].isChecked();
            selectAllItem[0].setChecked(checked);
            for (BottomSheetItemWithCompoundButton item : categoryItems) {
                item.setChecked(checked);
            }
        }
    }).create();
    items.add(selectAllItem[0]);
    items.add(new DividerItem(getContext()));
    Map<String, List<WptPt>> pointsByCategories = gpxFile.getPointsByCategories();
    for (String category : pointsByCategories.keySet()) {
        final BottomSheetItemWithCompoundButton[] categoryItem = new BottomSheetItemWithCompoundButton[1];
        categoryItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(true).setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    selectedCategories.add((String) categoryItem[0].getTag());
                } else {
                    selectedCategories.remove((String) categoryItem[0].getTag());
                }
            }
        }).setDescription(String.valueOf(pointsByCategories.get(category).size())).setIcon(getContentIcon(R.drawable.ic_action_folder)).setTitle(category.equals("") ? getString(R.string.waypoints) : category).setLayoutId(R.layout.bottom_sheet_item_with_descr_and_checkbox_56dp).setTag(category).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                categoryItem[0].setChecked(!categoryItem[0].isChecked());
                selectAllItem[0].setChecked(isAllChecked());
            }
        }).create();
        items.add(categoryItem[0]);
        categoryItems.add(categoryItem[0]);
        selectedCategories.add(category);
    }
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) View(android.view.View) ArrayList(java.util.ArrayList) List(java.util.List) DividerItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem) BottomSheetItemWithCompoundButton(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton) BottomSheetItemWithCompoundButton(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton) CompoundButton(android.widget.CompoundButton) DescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DescriptionItem)

Example 10 with TitleItem

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

the class SelectionMarkersGroupBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    items.add(new TitleItem(getString(R.string.add_group)));
    items.add(new DescriptionItem(getString(R.string.add_group_descr)));
    BaseBottomSheetItem favoritesItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_fav_dark)).setTitle(getString(R.string.favourites_group)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.favouritesOnClick();
            }
            dismiss();
        }
    }).create();
    items.add(favoritesItem);
    BaseBottomSheetItem waypointsItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_polygom_dark)).setTitle(getString(R.string.track_waypoints)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

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

Aggregations

View (android.view.View)16 TitleItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem)16 BaseBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem)15 SimpleBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem)10 DividerHalfItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem)7 Bundle (android.os.Bundle)5 BottomSheetItemWithCompoundButton (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)4 DescriptionItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.DescriptionItem)4 Drawable (android.graphics.drawable.Drawable)3 BottomSheetItemWithDescription (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription)3 ContextThemeWrapper (android.view.ContextThemeWrapper)2 ImageView (android.widget.ImageView)2 SubtitleDividerItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem)2 SubtitleItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleItem)2 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 AlertDialog (android.support.v7.app.AlertDialog)1 ListPopupWindow (android.support.v7.widget.ListPopupWindow)1 MotionEvent (android.view.MotionEvent)1 AdapterView (android.widget.AdapterView)1