diff --git a/OsmAnd/res/layout/editing_poi.xml b/OsmAnd/res/layout/editing_poi.xml index f566f597d9..220fd971ec 100644 --- a/OsmAnd/res/layout/editing_poi.xml +++ b/OsmAnd/res/layout/editing_poi.xml @@ -1,5 +1,6 @@ @@ -201,7 +202,9 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="1" - android:visibility="gone" > + android:visibility="gone" + tools:layout_height="25dp" + tools:visibility="visible"> - iterator = editPoiData.tags.iterator(); for (Tag tag : editPoiData.tags) { if (tag.tag.equals(OSMSettings.OSMTagKey.NAME.getValue())) { nameTextView.setText(tag.value); @@ -155,7 +170,8 @@ public class AdvancedDataFragment extends Fragment { private View getView(final Tag tag) { final View convertView = LayoutInflater.from(linearLayout.getContext()) .inflate(R.layout.poi_tag_list_item, null, false); - final EditText tagEditText = (EditText) convertView.findViewById(R.id.tagEditText); + final AutoCompleteTextView tagEditText = + (AutoCompleteTextView) convertView.findViewById(R.id.tagEditText); tagEditText.setText(tag.tag); final EditText valueEditText = (EditText) convertView.findViewById(R.id.valueEditText); ImageButton deleteItemImageButton = @@ -193,6 +209,35 @@ public class AdvancedDataFragment extends Fragment { editPoiData.notifyDatasetChanged(mTagsChangedListener); } }); + final Set tagKeys = new TreeSet(); + for (OSMSettings.OSMTagKey t : OSMSettings.OSMTagKey.values()) { + if ((t != OSMSettings.OSMTagKey.NAME) && (t != OSMSettings.OSMTagKey.OPENING_HOURS) && (t != OSMSettings.OSMTagKey.PHONE) + && (t != OSMSettings.OSMTagKey.WEBSITE)) { + tagKeys.add(t.getValue()); + } + } + + ArrayAdapter adapter = new ArrayAdapter(linearLayout.getContext(), + R.layout.list_textview, tagKeys.toArray()); + tagEditText.setAdapter(adapter); + tagEditText.setThreshold(1); + tagEditText.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // TODO: 8/29/15 Rewrite as dialog fragment + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + final String[] tags = tagKeys.toArray(new String[tagKeys.size()]); + builder.setItems(tags, new Dialog.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + tagEditText.setText(tags[which]); + } + + }); + builder.create(); + builder.show(); + } + }); valueEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -214,12 +259,4 @@ public class AdvancedDataFragment extends Fragment { return convertView; } } - - private EditPoiFragment getEditPoiFragment() { - return (EditPoiFragment) getParentFragment(); - } - - private EditPoiData getData() { - return getEditPoiFragment().getEditPoiData(); - } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 289554c5ab..c6bd4d19f5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -42,11 +42,13 @@ import java.util.List; public class OsmEditingPlugin extends OsmandPlugin { + private static final Log LOG = PlatformUtil.getLog(OsmEditingPlugin.class); private static final String ID = "osm.editing"; private OsmandSettings settings; private OsmandApplication app; OpenstreetmapsDbHelper dbpoi; OsmBugsDbHelper dbbug; + private EditingPOIDialogProvider poiActions; @Override public String getId() { @@ -136,12 +138,12 @@ public class OsmEditingPlugin extends OsmandPlugin { return SettingsOsmEditingActivity.class; } -// public EditingPOIDialogProvider getPoiActions(MapActivity activity) { -// if (poiActions == null) { -// poiActions = new EditingPOIDialogProvider(activity, this); -// } -// return poiActions; -// } + public EditingPOIDialogProvider getPoiActions(MapActivity activity) { + if (poiActions == null) { + poiActions = new EditingPOIDialogProvider(activity, this); + } + return poiActions; + } @Override public void registerMapContextMenuActions(final MapActivity mapActivity, @@ -152,6 +154,7 @@ public class OsmEditingPlugin extends OsmandPlugin { OnContextMenuClick listener = new OnContextMenuClick() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int resId, int pos, boolean isChecked) { + LOG.debug("onContextMenuClick()"); if (resId == R.string.context_menu_item_create_poi) { //getPoiActions(mapActivity).showCreateDialog(latitude, longitude); EditPoiFragment editPoiFragment = @@ -167,14 +170,15 @@ public class OsmEditingPlugin extends OsmandPlugin { } osmBugsLayer.openBug(latitude, longitude); } else if (resId == R.string.poi_context_menu_delete) { - new EditPoiFragment.ShowDeleteDialogAsyncTask(mapActivity) - .execute((Amenity) selectedObj); + LOG.debug("delete poi"); +// new EditPoiFragment.ShowDeleteDialogAsyncTask(mapActivity) +// .execute((Amenity) selectedObj); // TODO implement delete -// getPoiActions(mapActivity).showDeleteDialog((Amenity) selectedObj); - }//} else if (resId == R.string.poi_context_menu_modify) { + getPoiActions(mapActivity).showDeleteDialog((Amenity) selectedObj); + } else if (resId == R.string.poi_context_menu_modify) { // TODO implement edit -// getPoiActions(mapActivity).showEditDialog((Amenity) selectedObj); -// } + getPoiActions(mapActivity).showEditDialog((Amenity) selectedObj); + } return true; } };