Add osm edit options menu
This commit is contained in:
parent
690ba5dfbb
commit
fd53cefc1b
5 changed files with 400 additions and 74 deletions
|
@ -0,0 +1,210 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/osm_edit_options_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/osm_edit_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_title_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
tools:text="Universal Bank"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/upload_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/upload_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_export"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="@string/local_openstreetmap_upload"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/show_on_map_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/show_on_map_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:background="@drawable/ic_show_on_map"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_show_on_map"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
android:id="@+id/modify_osm_change_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/modify_osm_change_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_edit_dark"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="@string/poi_context_menu_modify_osm_change"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
android:id="@+id/modify_osm_note_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/modify_osm_note_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_edit_dark"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="@string/context_menu_item_modify_note"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/delete_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/delete_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_delete_dark"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_delete"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/cancel_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cancel_row_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/shared_string_close"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:textStyle="bold"/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,129 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.widgets.TextViewEx;
|
||||
|
||||
public class OsmEditOptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
public final static String TAG = "OsmEditOptionsBottomSheetDialogFragment";
|
||||
|
||||
public static final String OSM_POINT = "osm_point";
|
||||
|
||||
private OsmEditOptionsFragmentListener listener;
|
||||
|
||||
public void setListener(OsmEditOptionsFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_osm_edit_options_bottom_sheet_dialog, container);
|
||||
|
||||
Bundle args = getArguments();
|
||||
if (args != null) {
|
||||
final OsmPoint osmPoint = (OsmPoint) args.getSerializable(OSM_POINT);
|
||||
|
||||
((TextViewEx) mainView.findViewById(R.id.osm_edit_name)).setText(OsmEditingPlugin.getName(osmPoint) + ":");
|
||||
|
||||
((ImageView) mainView.findViewById(R.id.upload_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_export));
|
||||
mainView.findViewById(R.id.upload_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.onUploadClick(osmPoint);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
((ImageView) mainView.findViewById(R.id.show_on_map_icon)).setImageDrawable(getContentIcon(R.drawable.ic_show_on_map));
|
||||
mainView.findViewById(R.id.show_on_map_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.onShowOnMapClick(osmPoint);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
if (osmPoint instanceof OpenstreetmapPoint && osmPoint.getAction() != OsmPoint.Action.DELETE) {
|
||||
mainView.findViewById(R.id.modify_osm_change_row).setVisibility(View.VISIBLE);
|
||||
((ImageView) mainView.findViewById(R.id.modify_osm_change_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark));
|
||||
mainView.findViewById(R.id.modify_osm_change_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.onModifyOsmChangeClick(osmPoint);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (osmPoint instanceof OsmNotesPoint) {
|
||||
mainView.findViewById(R.id.modify_osm_note_row).setVisibility(View.VISIBLE);
|
||||
((ImageView) mainView.findViewById(R.id.modify_osm_note_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark));
|
||||
mainView.findViewById(R.id.modify_osm_note_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.onModifyOsmNoteClick(osmPoint);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
((ImageView) mainView.findViewById(R.id.delete_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_delete_dark));
|
||||
mainView.findViewById(R.id.delete_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.onDeleteClick(osmPoint);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (nightMode) {
|
||||
((TextViewEx) mainView.findViewById(R.id.osm_edit_name)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
|
||||
}
|
||||
|
||||
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
setupHeightAndBackground(mainView, R.id.osm_edit_options_scroll_view);
|
||||
|
||||
return mainView;
|
||||
}
|
||||
|
||||
public interface OsmEditOptionsFragmentListener {
|
||||
|
||||
void onUploadClick(OsmPoint osmPoint);
|
||||
|
||||
void onShowOnMapClick(OsmPoint osmPoint);
|
||||
|
||||
void onModifyOsmChangeClick(OsmPoint osmPoint);
|
||||
|
||||
void onModifyOsmNoteClick(OsmPoint osmPoint);
|
||||
|
||||
void onDeleteClick(OsmPoint osmPoint);
|
||||
}
|
||||
}
|
|
@ -421,19 +421,30 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
|
||||
public static String getEditName(OsmPoint point) {
|
||||
String prefix = getPrefix(point);
|
||||
String name = getName(point);
|
||||
if (point.getGroup() == OsmPoint.Group.POI) {
|
||||
String subtype = "";
|
||||
if (!Algorithms.isEmpty(((OpenstreetmapPoint) point).getSubtype())) {
|
||||
subtype = " (" + ((OpenstreetmapPoint) point).getSubtype() + ") ";
|
||||
}
|
||||
return prefix + subtype + ((OpenstreetmapPoint) point).getName();
|
||||
return prefix + subtype + name;
|
||||
} else if (point.getGroup() == OsmPoint.Group.BUG) {
|
||||
return prefix + ((OsmNotesPoint) point).getText();
|
||||
return prefix + name;
|
||||
} else {
|
||||
return prefix;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getName(OsmPoint point) {
|
||||
if (point.getGroup() == OsmPoint.Group.POI) {
|
||||
return ((OpenstreetmapPoint) point).getName();
|
||||
} else if (point.getGroup() == OsmPoint.Group.BUG) {
|
||||
return ((OsmNotesPoint) point).getText();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPrefix(OsmPoint osmPoint) {
|
||||
return (osmPoint.getGroup() == OsmPoint.Group.POI ? "POI" : "Bug") + " id: " + osmPoint.getId() + " ";
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class OsmEditsAdapter extends ArrayAdapter<OsmPoint> {
|
|||
if (osmEdit != null) {
|
||||
final OsmEditViewHolder holder = (OsmEditViewHolder) view.getTag();
|
||||
|
||||
holder.titleTextView.setText(getName(osmEdit));
|
||||
holder.titleTextView.setText(OsmEditingPlugin.getName(osmEdit));
|
||||
holder.descriptionTextView.setText(getDescription(osmEdit));
|
||||
Drawable icon = getIcon(osmEdit);
|
||||
if (icon != null) {
|
||||
|
@ -94,7 +94,7 @@ public class OsmEditsAdapter extends ArrayAdapter<OsmPoint> {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.onOptionsClick(v, osmEdit);
|
||||
listener.onOptionsClick(osmEdit);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -147,16 +147,6 @@ public class OsmEditsAdapter extends ArrayAdapter<OsmPoint> {
|
|||
return null;
|
||||
}
|
||||
|
||||
private String getName(OsmPoint point) {
|
||||
if (point.getGroup() == OsmPoint.Group.POI) {
|
||||
return ((OpenstreetmapPoint) point).getName();
|
||||
} else if (point.getGroup() == OsmPoint.Group.BUG) {
|
||||
return ((OsmNotesPoint) point).getText();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String getDescription(OsmPoint point) {
|
||||
String action = "";
|
||||
if (point.getAction() == OsmPoint.Action.CREATE) {
|
||||
|
@ -214,6 +204,6 @@ public class OsmEditsAdapter extends ArrayAdapter<OsmPoint> {
|
|||
|
||||
void onItemShowMap(OsmPoint point);
|
||||
|
||||
void onOptionsClick(View view, OsmPoint note);
|
||||
void onOptionsClick(OsmPoint note);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.view.ActionMode;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.util.Xml;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
@ -20,8 +20,6 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewStub;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
|
@ -40,13 +38,12 @@ import net.osmand.plus.activities.ActionBarProgressActivity;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||
import net.osmand.plus.base.OsmAndListFragment;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.dialogs.ProgressDialogFragment;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||
import net.osmand.plus.osmedit.OsmPoint.Action;
|
||||
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment;
|
||||
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment.PoiUploaderType;
|
||||
import net.osmand.plus.osmedit.OsmEditOptionsBottomSheetDialogFragment.OsmEditOptionsFragmentListener;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
@ -70,7 +67,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
private View headerView;
|
||||
private View emptyView;
|
||||
|
||||
private List<OsmPoint> osmEdits;
|
||||
private List<OsmPoint> osmEdits = new ArrayList<>();
|
||||
private OsmEditsAdapter listAdapter;
|
||||
private ArrayList<OsmPoint> osmEditsSelected = new ArrayList<>();
|
||||
|
||||
|
@ -114,6 +111,11 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
? R.drawable.ic_empty_state_osm_edits_day : R.drawable.ic_empty_state_osm_edits_night;
|
||||
((ImageView) emptyView.findViewById(R.id.empty_state_image_view)).setImageResource(icRes);
|
||||
|
||||
Fragment optionsFragment = getChildFragmentManager().findFragmentByTag(OsmEditOptionsBottomSheetDialogFragment.TAG);
|
||||
if (optionsFragment != null) {
|
||||
((OsmEditOptionsBottomSheetDialogFragment) optionsFragment).setListener(createOsmEditOptionsFragmentListener());
|
||||
}
|
||||
|
||||
plugin.getPoiModificationLocalUtil().addNodeCommittedListener(this);
|
||||
return view;
|
||||
}
|
||||
|
@ -397,8 +399,8 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onOptionsClick(View view, OsmPoint note) {
|
||||
openPopUpMenu(view, note);
|
||||
public void onOptionsClick(OsmPoint note) {
|
||||
openPopUpMenu(note);
|
||||
}
|
||||
});
|
||||
listView.setAdapter(listAdapter);
|
||||
|
@ -441,66 +443,50 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
});
|
||||
}
|
||||
|
||||
private void openPopUpMenu(View v, final OsmPoint info) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
||||
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
|
||||
MenuItem item = optionsMenu.getMenu().add(R.string.shared_string_show_on_map).setIcon(app.getIconsCache().getThemedIcon(R.drawable.ic_show_on_map));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
private void openPopUpMenu(final OsmPoint info) {
|
||||
OsmEditOptionsBottomSheetDialogFragment optionsFragment = new OsmEditOptionsBottomSheetDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(OsmEditOptionsBottomSheetDialogFragment.OSM_POINT, info);
|
||||
optionsFragment.setUsedOnMap(false);
|
||||
optionsFragment.setArguments(args);
|
||||
optionsFragment.setListener(createOsmEditOptionsFragmentListener());
|
||||
optionsFragment.show(getChildFragmentManager(), OsmEditOptionsBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
|
||||
private OsmEditOptionsFragmentListener createOsmEditOptionsFragmentListener() {
|
||||
return new OsmEditOptionsFragmentListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
public void onUploadClick(OsmPoint osmPoint) {
|
||||
uploadItems(new OsmPoint[]{getPointAfterModify(osmPoint)});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowOnMapClick(OsmPoint osmPoint) {
|
||||
OsmandSettings settings = getMyApplication().getSettings();
|
||||
settings.setMapLocationToShow(info.getLatitude(), info.getLongitude(), settings.getLastKnownMapZoom());
|
||||
settings.setMapLocationToShow(osmPoint.getLatitude(), osmPoint.getLongitude(), settings.getLastKnownMapZoom());
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (info instanceof OpenstreetmapPoint && info.getAction() != Action.DELETE) {
|
||||
item = optionsMenu.getMenu().add(R.string.poi_context_menu_modify_osm_change).setIcon(app.getIconsCache().getThemedIcon(R.drawable.ic_action_edit_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
OpenstreetmapPoint i = (OpenstreetmapPoint) getPointAfterModify(info);
|
||||
final Node entity = i.getEntity();
|
||||
refreshId = entity.getId();
|
||||
EditPoiDialogFragment.createInstance(entity, false).show(getActivity().getSupportFragmentManager(), "edit_poi");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (info instanceof OsmNotesPoint) {
|
||||
item = optionsMenu.getMenu().add(R.string.context_menu_item_modify_note).setIcon(app.getIconsCache().getThemedIcon(R.drawable.ic_action_edit_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
showBugDialog((OsmNotesPoint) info);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
item = optionsMenu.getMenu().add(R.string.shared_string_delete).setIcon(app.getIconsCache().getThemedIcon(R.drawable.ic_action_delete_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
public void onModifyOsmChangeClick(OsmPoint osmPoint) {
|
||||
OpenstreetmapPoint i = (OpenstreetmapPoint) getPointAfterModify(osmPoint);
|
||||
final Node entity = i.getEntity();
|
||||
refreshId = entity.getId();
|
||||
EditPoiDialogFragment.createInstance(entity, false).show(getActivity().getSupportFragmentManager(), "edit_poi");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModifyOsmNoteClick(OsmPoint osmPoint) {
|
||||
showBugDialog((OsmNotesPoint) osmPoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteClick(OsmPoint osmPoint) {
|
||||
ArrayList<OsmPoint> points = new ArrayList<>();
|
||||
points.add(info);
|
||||
points.add(osmPoint);
|
||||
deleteItems(new ArrayList<>(points));
|
||||
return true;
|
||||
|
||||
}
|
||||
});
|
||||
item = optionsMenu.getMenu().add(R.string.local_openstreetmap_upload).setIcon(app.getIconsCache().getThemedIcon(R.drawable.ic_action_export));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
uploadItems(new OsmPoint[]{getPointAfterModify(info)});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
optionsMenu.show();
|
||||
};
|
||||
}
|
||||
|
||||
protected OsmPoint getPointAfterModify(OsmPoint info) {
|
||||
|
|
Loading…
Reference in a new issue