Search in sources :

Example 1 with DescriptionItem

use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DescriptionItem 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 2 with DescriptionItem

use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DescriptionItem 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 3 with DescriptionItem

use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DescriptionItem 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)

Example 4 with DescriptionItem

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

the class SaveAsNewTrackBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    items.add(new TitleItem(getString(R.string.shared_string_save_as_gpx)));
    items.add(new DescriptionItem(getString(R.string.measurement_tool_save_as_new_track_descr)));
    if (Build.VERSION.SDK_INT >= 18) {
        final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
        View imagesRow = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_save_as_new_track_images_row, null);
        final ImageView routePointImage = (ImageView) imagesRow.findViewById(R.id.route_point_image);
        final ImageView lineImage = (ImageView) imagesRow.findViewById(R.id.line_image);
        routePointImage.setImageResource(nightMode ? R.drawable.img_help_trip_route_points_night : R.drawable.img_help_trip_route_points_day);
        lineImage.setImageResource(nightMode ? R.drawable.img_help_trip_track_night : R.drawable.img_help_trip_track_day);
        routePointImage.setOnClickListener(saveAsRoutePointOnClickListener);
        lineImage.setOnClickListener(saveAsLineOnClickListener);
        View.OnTouchListener textOnTouchListener = new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return false;
            }
        };
        imagesRow.findViewById(R.id.line_text).setOnTouchListener(textOnTouchListener);
        imagesRow.findViewById(R.id.route_point_text).setOnTouchListener(textOnTouchListener);
        items.add(new BaseBottomSheetItem.Builder().setCustomView(imagesRow).create());
    }
    BaseBottomSheetItem saveAsRoutePointsItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_route_points)).setTitle(getString(R.string.save_as_route_point)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(saveAsRoutePointOnClickListener).create();
    items.add(saveAsRoutePointsItem);
    BaseBottomSheetItem saveAsLineItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_split_interval)).setTitle(getString(R.string.save_as_line)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(saveAsLineOnClickListener).create();
    items.add(saveAsLineItem);
}
Also used : BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) ImageView(android.widget.ImageView) View(android.view.View) MotionEvent(android.view.MotionEvent) ContextThemeWrapper(android.view.ContextThemeWrapper) ImageView(android.widget.ImageView) DescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DescriptionItem)

Aggregations

View (android.view.View)4 DescriptionItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.DescriptionItem)4 TitleItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem)4 BaseBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem)3 SimpleBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem)2 Bundle (android.os.Bundle)1 ContextThemeWrapper (android.view.ContextThemeWrapper)1 MotionEvent (android.view.MotionEvent)1 CompoundButton (android.widget.CompoundButton)1 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)1 ImageView (android.widget.ImageView)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BottomSheetItemWithCompoundButton (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)1 BottomSheetItemWithDescription (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription)1 DividerItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem)1