Search in sources :

Example 1 with DividerHalfItem

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

the class ItemMenuBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    if (recording != null) {
        items.add(new TitleItem(recording.getName(getContext(), true)));
        BaseBottomSheetItem playItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(recording.isPhoto() ? R.drawable.ic_action_view : R.drawable.ic_play_dark)).setTitle(getString(recording.isPhoto() ? R.string.watch : R.string.recording_context_menu_play)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.playOnClick(recording);
                }
                dismiss();
            }
        }).create();
        items.add(playItem);
        BaseBottomSheetItem shareItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_gshare_dark)).setTitle(getString(R.string.shared_string_share)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.shareOnClick(recording);
                }
                dismiss();
            }
        }).create();
        items.add(shareItem);
        BaseBottomSheetItem showOnMapItem = new BottomSheetItemWithDescription.Builder().setDescription(getString(R.string.route_descr_lat_lon, recording.getLatitude(), recording.getLongitude())).setIcon(getContentIcon(R.drawable.ic_show_on_map)).setTitle(getString(R.string.shared_string_show_on_map)).setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.showOnMapOnClick(recording);
                }
                dismiss();
            }
        }).create();
        items.add(showOnMapItem);
        items.add(new DividerHalfItem(getContext()));
        BaseBottomSheetItem renameItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_edit_dark)).setTitle(getString(R.string.shared_string_rename)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.renameOnClick(recording);
                }
                dismiss();
            }
        }).create();
        items.add(renameItem);
        BaseBottomSheetItem deleteItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_delete_dark)).setTitle(getString(R.string.shared_string_delete)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

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

Example 2 with DividerHalfItem

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

the class EditFavoriteGroupDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    final OsmandApplication app = getMyApplication();
    FavouritesDbHelper helper = app.getFavorites();
    Bundle args = getArguments();
    if (args != null) {
        String groupName = args.getString(GROUP_NAME_KEY);
        if (groupName != null) {
            group = helper.getGroup(groupName);
        }
    }
    if (group == null) {
        return;
    }
    items.add(new TitleItem(Algorithms.isEmpty(group.name) ? app.getString(R.string.shared_string_favorites) : group.name));
    BaseBottomSheetItem editNameItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_edit_dark)).setTitle(getString(R.string.edit_name)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AlertDialog.Builder b = new AlertDialog.Builder(getContext());
            b.setTitle(R.string.favorite_group_name);
            final EditText nameEditText = new EditText(getContext());
            nameEditText.setText(group.name);
            b.setView(nameEditText);
            b.setNegativeButton(R.string.shared_string_cancel, null);
            b.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String name = nameEditText.getText().toString();
                    boolean nameChanged = !Algorithms.objectEquals(group.name, name);
                    if (nameChanged) {
                        app.getFavorites().editFavouriteGroup(group, name, group.color, group.visible);
                        updateParentFragment();
                    }
                    dismiss();
                }
            });
            b.show();
        }
    }).create();
    items.add(editNameItem);
    final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
    final View changeColorView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.change_fav_color, null);
    ((ImageView) changeColorView.findViewById(R.id.change_color_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_appearance));
    updateColorView((ImageView) changeColorView.findViewById(R.id.colorImage));
    BaseBottomSheetItem changeColorItem = new BaseBottomSheetItem.Builder().setCustomView(changeColorView).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final ListPopupWindow popup = new ListPopupWindow(getActivity());
            popup.setAnchorView(changeColorView);
            popup.setContentWidth(AndroidUtils.dpToPx(app, 200f));
            popup.setModal(true);
            popup.setDropDownGravity(Gravity.END | Gravity.TOP);
            if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
                popup.setVerticalOffset(AndroidUtils.dpToPx(app, 48f));
            } else {
                popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
            }
            popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
            final FavoriteColorAdapter colorAdapter = new FavoriteColorAdapter(getActivity());
            popup.setAdapter(colorAdapter);
            popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    Integer color = colorAdapter.getItem(position);
                    if (color != null) {
                        if (color != group.color) {
                            app.getFavorites().editFavouriteGroup(group, group.name, color, group.visible);
                            updateParentFragment();
                        }
                    }
                    popup.dismiss();
                    dismiss();
                }
            });
            popup.show();
        }
    }).create();
    items.add(changeColorItem);
    BaseBottomSheetItem showOnMapItem = new BottomSheetItemWithCompoundButton.Builder().setChecked(group.visible).setIcon(getContentIcon(R.drawable.ic_map)).setTitle(getString(R.string.shared_string_show_on_map)).setLayoutId(R.layout.bottom_sheet_item_with_switch).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean visible = !group.visible;
            app.getFavorites().editFavouriteGroup(group, group.name, group.color, visible);
            updateParentFragment();
            dismiss();
        }
    }).create();
    items.add(showOnMapItem);
    if (group.points.size() > 0) {
        items.add(new DividerHalfItem(getContext()));
        final MapMarkersHelper markersHelper = app.getMapMarkersHelper();
        final MapMarkersGroup markersGr = markersHelper.getOrCreateGroup(this.group);
        final boolean synced = markersHelper.isGroupSynced(markersGr.getId());
        BaseBottomSheetItem markersGroupItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(synced ? R.drawable.ic_action_delete_dark : R.drawable.ic_action_flag_dark)).setTitle(getString(synced ? R.string.remove_from_map_markers : R.string.shared_string_add_to_map_markers)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                if (synced) {
                    markersHelper.removeMarkersGroup(markersGr);
                } else {
                    markersHelper.addOrEnableGroup(markersGr);
                }
                dismiss();
                MapActivity.launchMapActivityMoveToTop(getActivity());
            }
        }).create();
        items.add(markersGroupItem);
        BaseBottomSheetItem shareItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_gshare_dark)).setTitle(getString(R.string.shared_string_share)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                FavoritesTreeFragment fragment = getFavoritesTreeFragment();
                if (fragment != null) {
                    fragment.shareFavorites(EditFavoriteGroupDialogFragment.this.group);
                }
                dismiss();
            }
        }).create();
        items.add(shareItem);
    }
}
Also used : BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) AlertDialog(android.support.v7.app.AlertDialog) SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) OsmandApplication(net.osmand.plus.OsmandApplication) DialogInterface(android.content.DialogInterface) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) ListPopupWindow(android.support.v7.widget.ListPopupWindow) DividerHalfItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem) MapMarkersGroup(net.osmand.plus.MapMarkersHelper.MapMarkersGroup) ImageView(android.widget.ImageView) EditText(android.widget.EditText) Bundle(android.os.Bundle) FavouritesDbHelper(net.osmand.plus.FavouritesDbHelper) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ContextThemeWrapper(android.view.ContextThemeWrapper) MapMarkersHelper(net.osmand.plus.MapMarkersHelper) AdapterView(android.widget.AdapterView)

Example 3 with DividerHalfItem

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

the class OrderByBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    Drawable distanceIcon = getContentIcon(R.drawable.ic_action_markers_dark);
    Drawable dateIcon = getContentIcon(R.drawable.ic_action_sort_by_date);
    items.add(new TitleItem(getString(R.string.sort_by)));
    BaseBottomSheetItem byNameItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_sort_by_name)).setTitle(getString(R.string.shared_string_name)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.onMapMarkersOrderByModeChanged(MapMarkersHelper.BY_NAME);
            }
            dismiss();
        }
    }).create();
    items.add(byNameItem);
    items.add(new DividerHalfItem(getContext()));
    BaseBottomSheetItem distNearestItem = new SimpleBottomSheetItem.Builder().setIcon(distanceIcon).setTitle(getString(R.string.distance_nearest)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.onMapMarkersOrderByModeChanged(MapMarkersHelper.BY_DISTANCE_ASC);
            }
            dismiss();
        }
    }).create();
    items.add(distNearestItem);
    BaseBottomSheetItem distFarthestItem = new SimpleBottomSheetItem.Builder().setIcon(distanceIcon).setTitle(getString(R.string.distance_farthest)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.onMapMarkersOrderByModeChanged(MapMarkersHelper.BY_DISTANCE_DESC);
            }
            dismiss();
        }
    }).create();
    items.add(distFarthestItem);
    items.add(new DividerHalfItem(getContext()));
    BaseBottomSheetItem dateAscItem = new SimpleBottomSheetItem.Builder().setIcon(dateIcon).setTitle(getString(R.string.date_added) + " (" + getString(R.string.ascendingly) + ")").setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.onMapMarkersOrderByModeChanged(MapMarkersHelper.BY_DATE_ADDED_ASC);
            }
            dismiss();
        }
    }).create();
    items.add(dateAscItem);
    BaseBottomSheetItem dateDescItem = new SimpleBottomSheetItem.Builder().setIcon(dateIcon).setTitle(getString(R.string.date_added) + " (" + getString(R.string.descendingly) + ")").setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.onMapMarkersOrderByModeChanged(MapMarkersHelper.BY_DATE_ADDED_DESC);
            }
            dismiss();
        }
    }).create();
    items.add(dateDescItem);
}
Also used : BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) Drawable(android.graphics.drawable.Drawable) DividerHalfItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) View(android.view.View)

Example 4 with DividerHalfItem

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

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

the class SelectedPointBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    BaseBottomSheetItem titleItem = new BottomSheetItemWithDescription.Builder().setDescription(getDescription()).setIcon(getActiveIcon(R.drawable.ic_action_measure_point)).setTitle(getTitle()).setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp).create();
    items.add(titleItem);
    items.add(new TitleDividerItem(getContext()));
    BaseBottomSheetItem moveItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_move_point)).setTitle(getString(R.string.shared_string_move)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.moveOnClick();
            }
            dismiss();
        }
    }).create();
    items.add(moveItem);
    BaseBottomSheetItem deleteItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_remove_dark)).setTitle(getString(R.string.shared_string_delete)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

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

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.addPointAfterOnClick();
            }
            dismiss();
        }
    }).create();
    items.add(addAfterItem);
    BaseBottomSheetItem addBeforeItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_addpoint_below)).setTitle(getString(R.string.add_point_before)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.addPointBeforeOnClick();
            }
            dismiss();
        }
    }).create();
    items.add(addBeforeItem);
}
Also used : BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) DividerHalfItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem) TitleDividerItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleDividerItem) View(android.view.View) BottomSheetItemWithDescription(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription)

Aggregations

View (android.view.View)8 BaseBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem)8 DividerHalfItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem)8 TitleItem (net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem)7 SimpleBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem)6 Bundle (android.os.Bundle)4 Drawable (android.graphics.drawable.Drawable)2 BottomSheetItemWithDescription (net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription)2 DialogInterface (android.content.DialogInterface)1 AlertDialog (android.support.v7.app.AlertDialog)1 ListPopupWindow (android.support.v7.widget.ListPopupWindow)1 ContextThemeWrapper (android.view.ContextThemeWrapper)1 AdapterView (android.widget.AdapterView)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 LatLon (net.osmand.data.LatLon)1 PointDescription (net.osmand.data.PointDescription)1 FavouritesDbHelper (net.osmand.plus.FavouritesDbHelper)1 MapMarkersHelper (net.osmand.plus.MapMarkersHelper)1