diff --git a/OsmAnd/res/layout/local_openstreetmap.xml b/OsmAnd/res/layout/local_openstreetmap.xml index 9759093947..12d4346e6f 100644 --- a/OsmAnd/res/layout/local_openstreetmap.xml +++ b/OsmAnd/res/layout/local_openstreetmap.xml @@ -9,7 +9,7 @@ android:layout_marginLeft = "3dp" android:layout_marginTop ="3dp" android:layout_marginRight = "3dp"/> - + diff --git a/OsmAnd/res/menu/localosm_child.xml b/OsmAnd/res/menu/localosm_child.xml index 79ee1b1dcf..d2e7362ce0 100644 --- a/OsmAnd/res/menu/localosm_child.xml +++ b/OsmAnd/res/menu/localosm_child.xml @@ -2,6 +2,6 @@ - + \ No newline at end of file diff --git a/OsmAnd/res/menu/localosm_group.xml b/OsmAnd/res/menu/localosm_group.xml deleted file mode 100644 index aa55b21ce0..0000000000 --- a/OsmAnd/res/menu/localosm_group.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index a047dac26b..ac33037688 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,7 +9,6 @@ 1. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> - Show alarms… Show speed limits, speed cameras, speed bumps, and other warnings Use the compass when no heading is detected otherwise diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AbstractOpenstreetmapUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/AbstractOpenstreetmapUtil.java index 7c35ba2be0..83f51bcad5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AbstractOpenstreetmapUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AbstractOpenstreetmapUtil.java @@ -12,7 +12,6 @@ import net.osmand.plus.OsmandApplication; import android.app.Activity; public abstract class AbstractOpenstreetmapUtil implements OpenstreetmapUtil { - @Override diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIActivity.java b/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIActivity.java index 5bfd0798c7..9ed05d8adc 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIActivity.java @@ -2,7 +2,6 @@ package net.osmand.plus.osmedit; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -121,7 +120,7 @@ public class EditingPOIActivity implements DialogProvider { } public void showDeleteDialog(Amenity a){ - final Node n = openstreetmapUtilToLoad.loadNode(a); + final Node n = openstreetmapUtil.loadNode(a); if(n == null){ AccessibleToast.makeText(ctx, ctx.getResources().getString(R.string.poi_error_poi_not_found), Toast.LENGTH_LONG).show(); return; @@ -174,9 +173,105 @@ public class EditingPOIActivity implements DialogProvider { phoneText.setText(a.getPhone()); EditText websiteText = ((EditText)dlg.findViewById(R.id.Website)); websiteText.setText(a.getSite()); + final TableLayout layout = ((TableLayout)dlg.findViewById(R.id.advancedModeTable)); + layout.setVisibility(View.GONE); updateType(a); } + private void addTagValueRow(final Node n, final TableLayout layout, String tg, String vl) { + final TableRow newTagRow = new TableRow(ctx); + TableRow.LayoutParams tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); + tlp.leftMargin = 5; + newTagRow.setLayoutParams(tlp); + + final AutoCompleteTextView tag = new AutoCompleteTextView(ctx); + final AutoCompleteTextView value = new AutoCompleteTextView(ctx); + final Button delete = new Button(ctx); + + tag.setLayoutParams(tlp); + if(tg != null) { + tag.setText(tg); + } else { + tag.setHint("Tag"); + } + + final Set tagKeys = new TreeSet(); + for (OSMTagKey t : OSMTagKey.values()) { + if ((t != OSMTagKey.NAME) && (t != OSMTagKey.OPENING_HOURS) && (t != OSMTagKey.PHONE) + && (t != OSMTagKey.WEBSITE)) { + tagKeys.add(t.getValue()); + } + } + ArrayAdapter adapter = new ArrayAdapter(ctx, R.layout.list_textview, tagKeys.toArray()); + tag.setAdapter(adapter); + tag.setThreshold(1); + tag.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Builder builder = new AlertDialog.Builder(ctx); + final String[] tags = tagKeys.toArray(new String[tagKeys.size()]); + builder.setItems(tags, new Dialog.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + tag.setText(tags[which]); + } + + }); + builder.create(); + builder.show(); + } + }); + tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.FILL_PARENT); + tlp.leftMargin = 5; + tlp.rightMargin = 5; + tlp.width = 80; + value.setLayoutParams(tlp); + if(vl != null) { + value.setText(vl); + } else { + value.setHint("Value"); + } + Set subCategories = MapRenderingTypes.getDefault().getAmenityNameToType().keySet(); + ArrayAdapter valueAdapter = new ArrayAdapter(ctx, R.layout.list_textview, subCategories.toArray()); + value.setThreshold(1); + value.setAdapter(valueAdapter); + value.addTextChangedListener(new TextWatcher() { + @Override + public void afterTextChanged(Editable s) { + if ((newTagRow != null) && (tag != null) && (value != null) && (tag.getText() != null) + && (value.getText() != null) && (!tag.getText().equals("")) && (!value.getText().equals(""))) { + n.putTag(tag.getText().toString(), value.getText().toString()); + } + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + } + }); + tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); + tlp.gravity = Gravity.CENTER; + tlp.rightMargin = 5; + delete.setLayoutParams(tlp); + delete.setText("X"); + delete.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + layout.removeView(newTagRow); + layout.invalidate(); + n.removeTag(tag.getText().toString()); + } + }); + newTagRow.addView(tag); + newTagRow.addView(value); + newTagRow.addView(delete); + layout.addView(newTagRow); + layout.invalidate(); + } + private Dialog createPOIDialog(final int dialogID, final Bundle args) { final Dialog dlg = new Dialog(ctx); dlg.setContentView(R.layout.editing_poi); @@ -256,14 +351,15 @@ public class EditingPOIActivity implements DialogProvider { }); final Button advancedModeButton = ((Button)dlg.findViewById(R.id.advancedMode)); - final Map additionalTags = new HashMap(); advancedModeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - final TableLayout layout = ((TableLayout)dlg.findViewById(R.id.advancedModeTable)); - TableLayout.LayoutParams tlParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT); - layout.setLayoutParams(tlParams); - layout.setColumnStretchable(1, true); + final Node n = (Node) args.getSerializable(KEY_AMENITY_NODE); + final TableLayout layout = ((TableLayout) dlg.findViewById(R.id.advancedModeTable)); + TableLayout.LayoutParams tlParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, + TableLayout.LayoutParams.WRAP_CONTENT); + layout.setLayoutParams(tlParams); + layout.setColumnStretchable(1, true); layout.setVisibility((layout.getVisibility() == View.VISIBLE) ? View.GONE : View.VISIBLE); Button addTag = (Button) dlg.findViewById(R.id.addTag); addTag.setVisibility((layout.getVisibility() == View.VISIBLE) ? View.VISIBLE : View.GONE); @@ -271,93 +367,23 @@ public class EditingPOIActivity implements DialogProvider { addTag.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - final TableRow newTagRow = new TableRow(ctx); - TableRow.LayoutParams tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); - tlp.leftMargin = 5; - newTagRow.setLayoutParams(tlp); - - final AutoCompleteTextView tag = new AutoCompleteTextView(ctx); - final AutoCompleteTextView value = new AutoCompleteTextView(ctx); - final Button delete = new Button(ctx); - - tag.setLayoutParams(tlp); - tag.setHint("Tag"); - - final Set tagKeys = new TreeSet(); - for (OSMTagKey t : OSMTagKey.values()) { - if ((t != OSMTagKey.NAME) && (t != OSMTagKey.OPENING_HOURS) && (t != OSMTagKey.PHONE) - && (t != OSMTagKey.WEBSITE)) { - tagKeys.add(t.getValue()); - } - } - ArrayAdapter adapter = new ArrayAdapter(ctx, R.layout.list_textview, tagKeys.toArray()); - tag.setAdapter(adapter); - tag.setThreshold(1); - tag.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Builder builder = new AlertDialog.Builder(ctx); - final String[] tags = tagKeys.toArray(new String[tagKeys.size()]); - builder.setItems(tags, new Dialog.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - tag.setText(tags[which]); - } - - }); - builder.create(); - builder.show(); - } - }); - tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.FILL_PARENT); - tlp.leftMargin = 5; - tlp.rightMargin = 5; - tlp.width = 80; - value.setLayoutParams(tlp); - value.setHint("Value"); - Set subCategories = MapRenderingTypes.getDefault().getAmenityNameToType().keySet(); - ArrayAdapter valueAdapter = new ArrayAdapter(ctx, R.layout.list_textview, subCategories.toArray()); - value.setThreshold(1); - value.setAdapter(valueAdapter); - value.addTextChangedListener(new TextWatcher() { - @Override - public void afterTextChanged(Editable s) { - if ((newTagRow != null) && (tag != null) && (value != null) && (tag.getText() != null) - && (value.getText() != null) && (!tag.getText().equals("")) && (!value.getText().equals(""))) { - additionalTags.put(tag.getText().toString(), value.getText().toString()); - } - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - }); - tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); - tlp.gravity = Gravity.CENTER; - tlp.rightMargin = 5; - delete.setLayoutParams(tlp); - delete.setText("X"); - delete.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - layout.removeView(newTagRow); - layout.invalidate(); - additionalTags.remove(tag.getText().toString()); - } - }); - newTagRow.addView(tag); - newTagRow.addView(value); - newTagRow.addView(delete); - layout.addView(newTagRow); - layout.invalidate(); + addTagValueRow(n, layout, null, null); } }); } + while (layout.getChildCount() > 0) { + layout.removeViewAt(0); + } layout.requestLayout(); + Amenity a = (Amenity) args.getSerializable(KEY_AMENITY); + for (String tg : n.getTagKeySet()) { + if (!tg.equals(OSMTagKey.NAME.getValue()) && !tg.equals(OSMTagKey.OPENING_HOURS.getValue()) + && !tg.equals(OSMTagKey.PHONE.getValue()) && !tg.equals(OSMTagKey.WEBSITE.getValue())) { + if(a == null || a.getType() == null || !a.getType().getDefaultTag().equals(tg)) { + addTagValueRow(n, layout, tg, n.getTag(tg)); + } + } + } } }); @@ -415,11 +441,6 @@ public class EditingPOIActivity implements DialogProvider { if (phone.length() > 0 ){ n.putTag(OSMTagKey.PHONE.getValue(),phone); } - if ((additionalTags != null) && (!additionalTags.isEmpty())) { - for (String tk : additionalTags.keySet()) { - n.putTag(tk, additionalTags.get(tk)); - } - } commitNode(action, n, openstreetmapUtil.getEntityInfo(), commentText.getText().toString(), new Runnable() { @Override public void run() { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/LocalOpenstreetmapActivity.java b/OsmAnd/src/net/osmand/plus/osmedit/LocalOpenstreetmapActivity.java index 3ac6134882..2ceab6a5d8 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/LocalOpenstreetmapActivity.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/LocalOpenstreetmapActivity.java @@ -2,22 +2,20 @@ package net.osmand.plus.osmedit; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import net.osmand.access.AccessibleToast; import net.osmand.osm.EntityInfo; import net.osmand.osm.Node; import net.osmand.plus.AmenityIndexRepositoryOdb; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.ProgressDialogImplementation; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; -import net.osmand.plus.activities.OsmandExpandableListActivity; import net.osmand.plus.osmedit.OsmPoint.Action; import android.app.Dialog; +import android.app.ListActivity; import android.app.ProgressDialog; import android.content.DialogInterface; import android.os.AsyncTask; @@ -29,12 +27,12 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.widget.ExpandableListView; -import android.widget.ExpandableListView.ExpandableListContextMenuInfo; +import android.widget.AdapterView.AdapterContextMenuInfo; +import android.widget.ArrayAdapter; import android.widget.TextView; import android.widget.Toast; -public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity { +public class LocalOpenstreetmapActivity extends ListActivity { /** dialogs **/ protected static final int DIALOG_PROGRESS_UPLOAD = 0; @@ -49,6 +47,10 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity { private OsmBugsRemoteUtil remotebug; protected OsmPoint[] toUpload; + private ArrayList dataPoints; + + + @Override protected void onCreate(Bundle savedInstanceState) { @@ -57,18 +59,11 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity { setContentView(R.layout.local_openstreetmap); listAdapter = new LocalOpenstreetmapAdapter(); - getExpandableListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { + getListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { - long packedPos = ((ExpandableListContextMenuInfo)menuInfo).packedPosition; - int group = ExpandableListView.getPackedPositionGroup(packedPos); - int child = ExpandableListView.getPackedPositionChild(packedPos); MenuInflater inflater = getMenuInflater(); - if (child >= 0 && group >= 0) { - inflater.inflate(R.menu.localosm_child, menu); - } else if (group >= 0) { //group menu - inflater.inflate(R.menu.localosm_group, menu); - } + inflater.inflate(R.menu.localosm_child, menu); } }); setListAdapter(listAdapter); @@ -80,12 +75,9 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity { remotebug = new OsmBugsRemoteUtil(); findViewById(R.id.UploadAllButton).setOnClickListener(new View.OnClickListener() { - - @Override public void onClick(View v) { - //NOTE, the order of upload is important, there can be more edits per one POI!! - toUpload = listAdapter.values().toArray(new OsmPoint[0]); + toUpload = dataPoints.toArray(new OsmPoint[0]); showDialog(DIALOG_PROGRESS_UPLOAD); } }); @@ -94,51 +86,59 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity { @Override protected void onResume() { super.onResume(); - listAdapter.clear(); + + dataPoints = new ArrayList(); List l1 = dbpoi.getOpenstreetmapPoints(); List l2 = dbbug.getOsmbugsPoints(); + dataPoints.addAll(l1); + dataPoints.addAll(l2); + listAdapter.clear(); for (OpenstreetmapPoint p : l1) { - listAdapter.addOsmPoint(p); + listAdapter.add(p); } for (OsmbugsPoint p : l2) { - listAdapter.addOsmPoint(p); + listAdapter.add(p); } listAdapter.notifyDataSetChanged(); } @Override public boolean onContextItemSelected(MenuItem item) { - long packedPos = ((ExpandableListContextMenuInfo)item.getMenuInfo()).packedPosition; - int group = ExpandableListView.getPackedPositionGroup(packedPos); - int child = ExpandableListView.getPackedPositionChild(packedPos); + int pos = ((AdapterContextMenuInfo)item.getMenuInfo()).position; int itemId = item.getItemId(); if(itemId == R.id.showmod) { OsmandSettings settings = getMyApplication().getSettings(); - OsmPoint info = (OsmPoint) listAdapter.getChild(group, child); + OsmPoint info = (OsmPoint) listAdapter.getItem(pos); settings.setMapLocationToShow(info.getLatitude(), info.getLongitude(), settings.getLastKnownMapZoom()); MapActivity.launchMapActivityMoveToTop(LocalOpenstreetmapActivity.this); return true; } else if(itemId == R.id.deletemod) { - OsmPoint info = (OsmPoint) listAdapter.getChild(group, child); + OsmPoint info = (OsmPoint) listAdapter.getItem(pos); if (info.getGroup() == OsmPoint.Group.POI) { dbpoi.deletePOI((OpenstreetmapPoint) info); + if (info.getAction() == Action.CREATE) { + AmenityIndexRepositoryOdb repo = getMyApplication().getResourceManager().getUpdatablePoiDb(); + repo.deleteAmenities(info.getId() << 1); + repo.clearCache(); + } } else if (info.getGroup() == OsmPoint.Group.BUG) { dbbug.deleteAllBugModifications((OsmbugsPoint) info); } listAdapter.delete(info); return true; - } else if(itemId == R.id.uploadmods) { - List list = listAdapter.data.get(listAdapter.category.get(group)); - if (list != null) { - toUpload = list.toArray(new OsmPoint[] {}); - showDialog(DIALOG_PROGRESS_UPLOAD); - return true; - } - } + } else if (itemId == R.id.uploadmods) { + toUpload = new OsmPoint[]{ listAdapter.getItem(pos)}; + showDialog(DIALOG_PROGRESS_UPLOAD); + return true; + } return super.onContextItemSelected(item); } + private OsmandApplication getMyApplication() { + return (OsmandApplication) getApplication(); + } + @Override protected void onDestroy() { super.onDestroy(); @@ -222,7 +222,7 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity { } else if (p.getAction() == OsmPoint.Action.MODIFY) { remotebug.addingComment(p.getId(), p.getText(), p.getAuthor()); } else if (p.getAction() == OsmPoint.Action.DELETE) { - remotebug.closingBug(p.getId()); + remotebug.closingBug(p.getId(), p.getText(), p.getAuthor()); } dbbug.deleteAllBugModifications(p); publishProgress(p); @@ -265,59 +265,25 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity { @Override protected void onProgressUpdate(OsmPoint... points) { - listAdapter.delete(points[0]); - progress.incrementProgressBy(1); + for(OsmPoint p : points) { + listAdapter.delete(p); + progress.incrementProgressBy(1); + } } } - protected class LocalOpenstreetmapAdapter extends OsmandBaseExpandableListAdapter { - Map> data = new LinkedHashMap>(); - List category = new ArrayList(); - + protected class LocalOpenstreetmapAdapter extends ArrayAdapter { public LocalOpenstreetmapAdapter() { + super(LocalOpenstreetmapActivity.this, net.osmand.plus.R.layout.local_openstreetmap_list_item); } - public void clear() { - data.clear(); - category.clear(); - notifyDataSetChanged(); - } - - public List values() { - List values = new ArrayList(); - for (List v : data.values()) { - values.addAll(v); - } - return values; - } public void delete(OsmPoint i) { - final AmenityIndexRepositoryOdb repo = getMyApplication().getResourceManager().getUpdatablePoiDb(); - Long c = i.getId(); - if(c != null){ - List list = data.get(c); - list.remove(i); - if (list.isEmpty()) { - data.remove(c); - category.remove(c); - } - if (i.getGroup() == OsmPoint.Group.POI && i.getAction() == Action.CREATE) { - repo.deleteAmenities(i.getId() << 1); - repo.clearCache(); - } - // We need to re-insert the POI if it is a delete or modify - // problem with bulk upload -// for (OsmPoint point : list) { -// if (point.getGroup() == OsmPoint.Group.POI) { -// OpenstreetmapPoint p = (OpenstreetmapPoint) point; -// remotepoi.updateNodeInIndexes(LocalOpenstreetmapActivity.this, p.getAction(), p.getEntity(), p.getEntity()); -// } -// } - - } + dataPoints.remove(i); + remove(i); listAdapter.notifyDataSetChanged(); } @@ -325,51 +291,20 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity { notifyDataSetChanged(); } - public void addOsmPoint(OsmPoint info) { - int found = -1; - // search from end - for (int i = category.size() - 1; i >= 0; i--) { - Long cat = category.get(i); - if (cat.compareTo(info.getId()) == 0) { - found = i; - break; - } - } - if (found == -1) { - found = category.size(); - category.add(info.getId()); - } - if (!data.containsKey(category.get(found))) { - data.put(category.get(found), new ArrayList()); - } - data.get(category.get(found)).add(info); - } - @Override - public OsmPoint getChild(int groupPosition, int childPosition) { - Long cat = category.get(groupPosition); - return data.get(cat).get(childPosition); - } - - @Override - public long getChildId(int groupPosition, int childPosition) { - // it would be unusable to have 10000 local categories - return groupPosition * 10000 + childPosition; - } - - @Override - public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { + public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; - final OsmPoint child = (OsmPoint) getChild(groupPosition, childPosition); + final OsmPoint child = getItem(position); if (v == null ) { LayoutInflater inflater = getLayoutInflater(); v = inflater.inflate(net.osmand.plus.R.layout.local_openstreetmap_list_item, parent, false); } TextView viewName = ((TextView) v.findViewById(R.id.local_openstreetmap_name)); + String idPrefix = (child.getGroup() == OsmPoint.Group.POI ? "POI " : "Bug ") + " id: " + child.getId(); if (child.getGroup() == OsmPoint.Group.POI) - viewName.setText("(" + ((OpenstreetmapPoint) child).getSubtype() + ") " + ((OpenstreetmapPoint) child).getName()); + viewName.setText(idPrefix + " (" + ((OpenstreetmapPoint) child).getSubtype() + ") " + ((OpenstreetmapPoint) child).getName()); else if (child.getGroup() == OsmPoint.Group.BUG) - viewName.setText("(" + ((OsmbugsPoint) child).getAuthor() + ") " + ((OsmbugsPoint) child).getText()); + viewName.setText(idPrefix + " (" + ((OsmbugsPoint) child).getAuthor() + ") " + ((OsmbugsPoint) child).getText()); if (child.getAction() == OsmPoint.Action.CREATE) { viewName.setTextColor(getResources().getColor(R.color.osm_create)); } else if (child.getAction() == OsmPoint.Action.MODIFY) { @@ -381,61 +316,5 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity { return v; } - @Override - public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { - View v = convertView; - Long group = getGroup(groupPosition); - if (v == null) { - LayoutInflater inflater = getLayoutInflater(); - v = inflater.inflate(net.osmand.plus.R.layout.local_openstreetmap_list_item_category, parent, false); - } - adjustIndicator(groupPosition, isExpanded, v); - StringBuilder t = new StringBuilder(); - t.append(" id:").append(group); - t.append(" [").append(getChildrenCount(groupPosition)); - if(getString(R.string.local_openstreetmap_items).length() > 0){ - t.append(" ").append(getString(R.string.local_openstreetmap_items)); - } - if(getString(R.string.local_openstreetmap_items).length() > 0){ - t.append(" ").append(getString(R.string.local_openstreetmap_items)); - } - t.append("]"); - TextView nameView = ((TextView) v.findViewById(R.id.local_openstreetmap_category_name)); - nameView.setText(t.toString()); - - - return v; - } - - @Override - public int getChildrenCount(int groupPosition) { - Long cat = category.get(groupPosition); - return data.get(cat).size(); - } - - @Override - public Long getGroup(int groupPosition) { - return category.get(groupPosition); - } - - @Override - public int getGroupCount() { - return category.size(); - } - - @Override - public long getGroupId(int groupPosition) { - return groupPosition; - } - - @Override - public boolean hasStableIds() { - return false; - } - - @Override - public boolean isChildSelectable(int groupPosition, int childPosition) { - return true; - } } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index ff8a5afefc..75c198e55c 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -20,7 +20,6 @@ import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; -import net.osmand.plus.R.drawable; import net.osmand.plus.activities.DialogProvider; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider; @@ -399,7 +398,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider @Override public void onClick(DialogInterface dialog, int which) { OpenStreetBug bug = (OpenStreetBug) args.getSerializable(KEY_BUG); - boolean closed = osmbugsUtil.closingBug(bug.getId()); + boolean closed = osmbugsUtil.closingBug(bug.getId(), "", ((OsmandApplication) OsmBugsLayer.this.activity.getApplication()).getSettings().USER_OSM_BUG_NAME.get()); if (closed) { AccessibleToast.makeText(activity, activity.getString(R.string.osb_close_dialog_success), Toast.LENGTH_LONG).show(); clearCache(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLocalUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLocalUtil.java index 74c2a8ea4f..5d5cb32fe7 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLocalUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLocalUtil.java @@ -1,14 +1,11 @@ package net.osmand.plus.osmedit; -import net.osmand.LogUtil; -import org.apache.commons.logging.Log; import android.content.Context; public class OsmBugsLocalUtil implements OsmBugsUtil { - private static final Log log = LogUtil.getLog(OsmBugsLocalUtil.class); private final Context ctx; private final OsmBugsDbHelper db; @@ -41,9 +38,11 @@ public class OsmBugsLocalUtil implements OsmBugsUtil { } @Override - public boolean closingBug(long id){ + public boolean closingBug(long id, String text, String authorName){ OsmbugsPoint p = new OsmbugsPoint(); p.setId(id); + p.setAuthor(authorName); + p.setText(text); p.setAction(OsmPoint.Action.DELETE); return db.addOsmbugs(p); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java index 3680a790fe..9eb00af12b 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java @@ -41,10 +41,15 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil { } @Override - public boolean closingBug(long id){ + public boolean closingBug(long id, String text, String authorName){ StringBuilder b = new StringBuilder(); b.append(SITE_API).append("closePOIexec?"); //$NON-NLS-1$ b.append("id=").append(id); //$NON-NLS-1$ + if(text != null) { + b.append("&text=").append(URLEncoder.encode(text)); //$NON-NLS-1$ + } + b.append("&name=").append(URLEncoder.encode(authorName)); //$NON-NLS-1$ + return editingPOI(b.toString(),"closing bug"); //$NON-NLS-1$ } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsUtil.java index e334e058e3..e20dcdb4b2 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsUtil.java @@ -8,5 +8,5 @@ public interface OsmBugsUtil { public boolean addingComment(long id, String text, String authorName); - public boolean closingBug(long id); + public boolean closingBug(long id, String text, String authorName); }