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();
}
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);
}
}
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);
}
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));
}
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));
}
Aggregations