Search in sources :

Example 1 with ShortDescriptionItem

use of net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem 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 ShortDescriptionItem(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_osm_note)).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) ShortDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem) View(android.view.View) BottomSheetItemWithDescription(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription)

Example 2 with ShortDescriptionItem

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

the class ImportGpxBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    items.add(new TitleItem(getString(R.string.import_file)));
    Context ctx = requireContext();
    int nameColor = ColorUtilities.getActiveColor(ctx, nightMode);
    int descrColor = ColorUtilities.getSecondaryTextColor(ctx, nightMode);
    String descr = getString(R.string.import_gpx_file_description);
    if (!descr.contains("%s")) {
        descr = "%s " + descr;
    }
    CharSequence txt = AndroidUtils.getStyledString(descr, fileName, new ForegroundColorSpan(descrColor), new ForegroundColorSpan(nameColor));
    items.add(new ShortDescriptionItem(txt));
    BaseBottomSheetItem asFavoritesItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_favorite)).setTitle(getString(R.string.import_as_favorites)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            importHelper.importFavoritesFromGpx(gpxFile, fileName);
            dismiss();
        }
    }).create();
    items.add(asFavoritesItem);
    items.add(new DividerHalfItem(getContext()));
    BaseBottomSheetItem asGpxItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_polygom_dark)).setTitle(getString(R.string.import_as_gpx)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            importHelper.handleGpxImport(gpxFile, fileName, fileSize, save, useImportDir);
            dismiss();
        }
    }).create();
    items.add(asGpxItem);
}
Also used : Context(android.content.Context) BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) ForegroundColorSpan(android.text.style.ForegroundColorSpan) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) ShortDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem) View(android.view.View) DividerHalfItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem)

Example 3 with ShortDescriptionItem

use of net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem 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 ShortDescriptionItem(getString(R.string.add_group_descr)));
    BaseBottomSheetItem favoritesItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_favorite)).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.shared_string_gpx_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) ShortDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem) View(android.view.View)

Example 4 with ShortDescriptionItem

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

the class SelectWptCategoriesBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    gpxFile = getGpxFile();
    if (gpxFile == null) {
        return;
    }
    int activeColorResId = ColorUtilities.getActiveColorId(nightMode);
    isUpdateMode = getArguments().getBoolean(UPDATE_CATEGORIES_KEY);
    List<String> categories = getArguments().getStringArrayList(ACTIVE_CATEGORIES_KEY);
    items.add(new TitleItem(getGpxName(gpxFile)));
    items.add(new ShortDescriptionItem(getString(R.string.select_waypoints_category_description)));
    final BottomSheetItemWithCompoundButton[] selectAllItem = new BottomSheetItemWithCompoundButton[1];
    selectAllItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(!isUpdateMode || categories != null && categories.size() == gpxFile.getPointsByCategories().size()).setCompoundButtonColorId(activeColorResId).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 (Map.Entry<String, List<WptPt>> entry : pointsByCategories.entrySet()) {
        String category = entry.getKey();
        final BottomSheetItemWithCompoundButton[] categoryItem = new BottomSheetItemWithCompoundButton[1];
        categoryItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(!isUpdateMode || (categories != null && categories.contains(category))).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());
                }
            }
        }).setCompoundButtonColorId(activeColorResId).setDescription(String.valueOf(entry.getValue().size())).setIcon(getContentIcon(R.drawable.ic_action_folder)).setTitle(category.isEmpty() ? getString(R.string.shared_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]);
        if (!isUpdateMode || categories != null && categories.contains(category)) {
            selectedCategories.add(category);
        }
    }
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) ShortDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem) View(android.view.View) ArrayList(java.util.ArrayList) List(java.util.List) DividerItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem) Map(java.util.Map) BottomSheetItemWithCompoundButton(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton) BottomSheetItemWithCompoundButton(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton) CompoundButton(android.widget.CompoundButton)

Example 5 with ShortDescriptionItem

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

the class ElevationDateBottomSheet method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    Context themedCtx = UiUtilities.getThemedContext(requireContext(), nightMode);
    on = getString(R.string.shared_string_enabled);
    off = getString(R.string.shared_string_disabled);
    appModeColor = appMode.getProfileColor(nightMode);
    activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic);
    disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary);
    checkedColor = ColorUtilities.getPrimaryTextColor(app, nightMode);
    uncheckedColor = ColorUtilities.getSecondaryTextColor(app, nightMode);
    items.add(new TitleItem(getString(R.string.routing_attr_height_obstacles_name)));
    createUseHeightButton(themedCtx);
    int contentPaddingSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small);
    items.add(new DividerSpaceItem(app, contentPaddingSmall));
    items.add(new ShortDescriptionItem((getString(R.string.routing_attr_height_obstacles_description))));
    createReliefFactorButtons(themedCtx);
}
Also used : Context(android.content.Context) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) DividerSpaceItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem) ShortDescriptionItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem)

Aggregations

ShortDescriptionItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem)5 TitleItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem)5 View (android.view.View)4 BaseBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem)3 Context (android.content.Context)2 SimpleBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem)2 Bundle (android.os.Bundle)1 ForegroundColorSpan (android.text.style.ForegroundColorSpan)1 CompoundButton (android.widget.CompoundButton)1 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 BottomSheetItemWithCompoundButton (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton)1 BottomSheetItemWithDescription (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription)1 DividerHalfItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem)1 DividerItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem)1 DividerSpaceItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem)1