Search in sources :

Example 21 with OsmNotesPoint

use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.

the class OsmEditsFragment method showBugDialog.

private void showBugDialog(final OsmNotesPoint point) {
    final View view = LayoutInflater.from(getActivity()).inflate(R.layout.open_bug, null);
    view.findViewById(R.id.user_name_field).setVisibility(View.GONE);
    view.findViewById(R.id.userNameEditTextLabel).setVisibility(View.GONE);
    view.findViewById(R.id.password_field).setVisibility(View.GONE);
    view.findViewById(R.id.passwordEditTextLabel).setVisibility(View.GONE);
    String text = point.getText();
    if (!Algorithms.isEmpty(text)) {
        ((EditText) view.findViewById(R.id.message_field)).setText(text);
    }
    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.shared_string_commit);
    builder.setView(view);
    builder.setPositiveButton(R.string.osn_modify_dialog_title, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String text = ((EditText) view.findViewById(R.id.message_field)).getText().toString();
            plugin.getDBBug().updateOsmBug(point.getId(), text);
            point.setText(text);
            notifyDataSetChanged();
        }
    });
    builder.setNegativeButton(R.string.shared_string_cancel, null);
    builder.create().show();
}
Also used : EditText(android.widget.EditText) AlertDialog(androidx.appcompat.app.AlertDialog) DialogInterface(android.content.DialogInterface) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)

Example 22 with OsmNotesPoint

use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.

the class OsmEditOptionsBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    Bundle args = getArguments();
    if (args != null) {
        final OsmPoint osmPoint = (OsmPoint) args.getSerializable(OSM_POINT);
        String name = OsmEditingPlugin.getName(osmPoint);
        if (Algorithms.isEmpty(name)) {
            name = OsmEditingPlugin.getCategory(osmPoint, getContext());
        }
        items.add(new TitleItem(name + ":"));
        BaseBottomSheetItem uploadItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_export)).setTitle(getString(R.string.local_openstreetmap_upload)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onUploadClick(osmPoint);
                }
                dismiss();
            }
        }).create();
        items.add(uploadItem);
        BaseBottomSheetItem showOnMapItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_show_on_map)).setTitle(getString(R.string.shared_string_show_on_map)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onShowOnMapClick(osmPoint);
                }
                dismiss();
            }
        }).create();
        items.add(showOnMapItem);
        items.add(new DividerHalfItem(getContext()));
        if (osmPoint instanceof OpenstreetmapPoint && osmPoint.getAction() != OsmPoint.Action.DELETE) {
            BaseBottomSheetItem modifyOsmChangeItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_edit_dark)).setTitle(getString(R.string.poi_context_menu_modify_osm_change)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (listener != null) {
                        listener.onModifyOsmChangeClick(osmPoint);
                    }
                    dismiss();
                }
            }).create();
            items.add(modifyOsmChangeItem);
        }
        if (osmPoint instanceof OsmNotesPoint) {
            BaseBottomSheetItem modifyOsmNoteItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_edit_dark)).setTitle(getString(R.string.context_menu_item_modify_note)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (listener != null) {
                        listener.onModifyOsmNoteClick(osmPoint);
                    }
                    dismiss();
                }
            }).create();
            items.add(modifyOsmNoteItem);
        }
        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.onDeleteClick(osmPoint);
                }
                dismiss();
            }
        }).create();
        items.add(deleteItem);
    }
}
Also used : BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) Bundle(android.os.Bundle) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) DividerHalfItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) View(android.view.View)

Example 23 with OsmNotesPoint

use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.

the class SendOsmNoteBottomSheetFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    app = getMyApplication();
    plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
    if (app == null || plugin == null)
        return;
    poi = (OsmPoint[]) getArguments().getSerializable(OPENSTREETMAP_POINT);
    items.add(new TitleItem(getString(R.string.upload_osm_note)));
    final View sendOsmNoteView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.send_osm_note_fragment, null);
    sendOsmNoteView.getViewTreeObserver().addOnGlobalLayoutListener(getShadowLayoutListener());
    noteText = sendOsmNoteView.findViewById(R.id.note_text);
    noteText.setText(((OsmNotesPoint) poi[0]).getText());
    noteText.setSelection(noteText.getText().length());
    TextInputLayout noteHint = sendOsmNoteView.findViewById(R.id.note_hint);
    noteHint.setHint(AndroidUtils.addColon(app, R.string.osn_bug_name));
    accountBlockView = sendOsmNoteView.findViewById(R.id.account_container);
    signInView = sendOsmNoteView.findViewById(R.id.sign_in_container);
    uploadAnonymously = sendOsmNoteView.findViewById(R.id.upload_anonymously_switch);
    accountName = sendOsmNoteView.findViewById(R.id.user_name);
    updateAccountName();
    View signInButton = sendOsmNoteView.findViewById(R.id.sign_in_button);
    setupButton(signInButton, R.string.sign_in_with_open_street_map, DialogButtonType.PRIMARY, R.drawable.ic_action_openstreetmap_logo);
    signInButton.setOnClickListener(v -> {
        Fragment fragment = getParentFragment();
        if (fragment instanceof OsmAuthorizationListener) {
            app.getOsmOAuthHelper().addListener((OsmAuthorizationListener) fragment);
        }
        app.getOsmOAuthHelper().startOAuth((ViewGroup) getView(), nightMode);
    });
    View loginButton = sendOsmNoteView.findViewById(R.id.login_button);
    setupButton(loginButton, R.string.use_login_password, DialogButtonType.SECONDARY, -1);
    loginButton.setOnClickListener(v -> {
        FragmentManager fragmentManager = getFragmentManager();
        if (fragmentManager != null) {
            OsmLoginDataBottomSheet.showInstance(fragmentManager, OSM_LOGIN_DATA, SendOsmNoteBottomSheetFragment.this, usedOnMap, null);
        }
    });
    updateSignIn(uploadAnonymously.isChecked());
    uploadAnonymously.setBackgroundResource(nightMode ? R.drawable.layout_bg_dark : R.drawable.layout_bg);
    final int paddingSmall = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
    uploadAnonymously.setPadding(paddingSmall, 0, paddingSmall, 0);
    uploadAnonymously.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateSignIn(isChecked);
            if (nightMode) {
                uploadAnonymously.setBackgroundResource(isChecked ? R.drawable.layout_bg_dark_solid : R.drawable.layout_bg_dark);
            } else {
                uploadAnonymously.setBackgroundResource(isChecked ? R.drawable.layout_bg_solid : R.drawable.layout_bg);
            }
            uploadAnonymously.setPadding(paddingSmall, 0, paddingSmall, 0);
        }
    });
    LinearLayout account = accountBlockView.findViewById(R.id.account_container);
    account.setOnClickListener(v -> {
        FragmentActivity activity = getActivity();
        if (activity != null) {
            showOpenStreetMapScreen(activity);
        }
        dismiss();
    });
    final SimpleBottomSheetItem bottomSheetItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder().setCustomView(sendOsmNoteView).create();
    items.add(bottomSheetItem);
}
Also used : SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmAuthorizationListener(net.osmand.plus.plugins.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) View(android.view.View) TextView(android.widget.TextView) Fragment(androidx.fragment.app.Fragment) DashOsmEditsFragment(net.osmand.plus.plugins.osmedit.fragments.DashOsmEditsFragment) MenuBottomSheetDialogFragment(net.osmand.plus.base.MenuBottomSheetDialogFragment) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OsmEditingPlugin(net.osmand.plus.plugins.osmedit.OsmEditingPlugin) FragmentManager(androidx.fragment.app.FragmentManager) FragmentActivity(androidx.fragment.app.FragmentActivity) ContextThemeWrapper(android.view.ContextThemeWrapper) TextInputLayout(com.google.android.material.textfield.TextInputLayout) CompoundButton(android.widget.CompoundButton) LinearLayout(android.widget.LinearLayout)

Example 24 with OsmNotesPoint

use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.

the class OsmBugsLocalUtil method modify.

@Override
public OsmBugResult modify(OsmNotesPoint point, String text) {
    OsmNotesPoint pnt = new OsmNotesPoint();
    pnt.setId(point.getId());
    pnt.setLatitude(point.getLatitude());
    pnt.setLongitude(point.getLongitude());
    pnt.setText(text);
    pnt.setAction(point.getAction());
    point = pnt;
    return wrap(point, db.updateOsmBug(point.getId(), text));
}
Also used : OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)

Example 25 with OsmNotesPoint

use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.

the class OsmBugsLocalUtil method commit.

@Override
public OsmBugResult commit(OsmNotesPoint point, String text, Action action) {
    if (action == OsmPoint.Action.CREATE) {
        point.setId(Math.min(-2, db.getMinID() - 1));
        point.setText(text);
        point.setAction(action);
    } else {
        OsmNotesPoint pnt = new OsmNotesPoint();
        pnt.setId(point.getId());
        pnt.setLatitude(point.getLatitude());
        pnt.setLongitude(point.getLongitude());
        pnt.setAction(action);
        pnt.setText(text);
        point = pnt;
    }
    return wrap(point, db.addOsmbugs(point));
}
Also used : OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)

Aggregations

OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)29 OpenstreetmapPoint (net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)16 OsmPoint (net.osmand.plus.plugins.osmedit.data.OsmPoint)13 ArrayList (java.util.ArrayList)7 View (android.view.View)5 File (java.io.File)5 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)5 MapMarkersGroup (net.osmand.plus.mapmarkers.MapMarkersGroup)5 FavoriteGroup (net.osmand.plus.myplaces.FavoriteGroup)5 ITileSource (net.osmand.map.ITileSource)4 AvoidRoadInfo (net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo)4 OnlineRoutingEngine (net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine)4 OsmEditingPlugin (net.osmand.plus.plugins.osmedit.OsmEditingPlugin)4 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)4 QuickAction (net.osmand.plus.quickaction.QuickAction)4 TextView (android.widget.TextView)3 Entity (net.osmand.osm.edit.Entity)3 LinearLayout (android.widget.LinearLayout)2 NonNull (androidx.annotation.NonNull)2 FragmentActivity (androidx.fragment.app.FragmentActivity)2