diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index cecf223d73..8096a6e7be 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,7 +9,7 @@
3. 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
-->
-
+ Delete Osm Edit
Disabled
Coloring according to route scope
Coloring according to OSMC
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java
index b694422c27..555831580d 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java
@@ -1,5 +1,16 @@
package net.osmand.plus.osmedit;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.osmand.access.AccessibleToast;
+import net.osmand.data.PointDescription;
+import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.ProgressImplementation;
+import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.dashboard.DashBaseFragment;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
@@ -12,18 +23,6 @@ import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
-import net.osmand.access.AccessibleToast;
-import net.osmand.data.PointDescription;
-import net.osmand.plus.OsmandPlugin;
-import net.osmand.plus.ProgressImplementation;
-import net.osmand.plus.R;
-import net.osmand.plus.activities.MapActivity;
-import net.osmand.plus.dashboard.DashBaseFragment;
-import net.osmand.plus.myplaces.FavoritesActivity;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
/**
* Created by Denis
@@ -135,17 +134,14 @@ public class DashOsmEditsFragment extends DashBaseFragment implements OsmEditsUp
getString(R.string.uploading), getString(R.string.local_openstreetmap_uploading),
ProgressDialog.STYLE_HORIZONTAL).getDialog();
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog,
- DashOsmEditsFragment.this, remotepoi, remotebug, toUpload.length);
+ DashOsmEditsFragment.this, plugin, remotepoi, remotebug, toUpload.length);
uploadTask.execute(toUpload);
dialog.show();
}
private void getOsmPoints(ArrayList dataPoints) {
- OpenstreetmapsDbHelper dbpoi = new OpenstreetmapsDbHelper(getActivity());
- OsmBugsDbHelper dbbug = new OsmBugsDbHelper(getActivity());
-
- List l1 = dbpoi.getOpenstreetmapPoints();
- List l2 = dbbug.getOsmbugsPoints();
+ List l1 = plugin.getDBPOI().getOpenstreetmapPoints();
+ List l2 = plugin.getDBBug().getOsmbugsPoints();
if (l1.isEmpty()){
int i = 0;
for(OsmPoint point : l2){
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIDialogProvider.java b/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIDialogProvider.java
index 962f3faffa..68c445e037 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIDialogProvider.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIDialogProvider.java
@@ -112,10 +112,10 @@ public class EditingPOIDialogProvider implements DialogProvider {
settings = ((OsmandApplication) activity.getApplication()).getSettings();
isLocalEdit = true;
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
- this.openstreetmapUtil = new OpenstreetmapLocalUtil(activity);
+ this.openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
this.openstreetmapUtilToLoad = openstreetmapUtil;
} else if(!settings.isInternetConnectionAvailable(true)) {
- this.openstreetmapUtil = new OpenstreetmapLocalUtil(activity);
+ this.openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
this.openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity);
} else {
isLocalEdit = false;
@@ -692,7 +692,6 @@ public class EditingPOIDialogProvider implements DialogProvider {
@Override
protected void onPostExecute(Node result) {
progress.dismiss();
- plugin.collectLocalOsmEdits();
if (result != null) {
successAction.run();
}
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java
index 7b3962f471..21118972ca 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java
@@ -15,13 +15,14 @@ import android.content.Context;
public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
private final Context ctx;
- private final OpenstreetmapsDbHelper db;
public final static Log log = PlatformUtil.getLog(OpenstreetmapLocalUtil.class);
- public OpenstreetmapLocalUtil(Context uiContext) {
+ private OsmEditingPlugin plugin;
+
+ public OpenstreetmapLocalUtil(OsmEditingPlugin plugin, Context uiContext) {
+ this.plugin = plugin;
this.ctx = uiContext;
- this.db = new OpenstreetmapsDbHelper(ctx);
}
@Override
@@ -33,16 +34,16 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
public Node commitNodeImpl(OsmPoint.Action action, Node n, EntityInfo info, String comment, boolean closeChangeSet){
Node newNode = n;
if (n.getId() == -1) {
- newNode = new Node(n, Math.min(-2, db.getMinID() - 1)); // generate local id for the created node
+ newNode = new Node(n, Math.min(-2, plugin.getDBPOI().getMinID() - 1)); // generate local id for the created node
}
OpenstreetmapPoint p = new OpenstreetmapPoint();
p.setEntity(newNode);
p.setAction(action);
p.setComment(comment);
if (p.getAction() == OsmPoint.Action.DELETE && newNode.getId() < 0) { //if it is our local poi
- db.deletePOI(p);
+ plugin.getDBPOI().deletePOI(p);
} else {
- db.addOpenstreetmap(p);
+ plugin.getDBPOI().addOpenstreetmap(p);
}
return newNode;
}
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java
index d69e2bc6bd..7a4cae0a4d 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java
@@ -12,7 +12,6 @@ import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
-import java.net.URL;
import java.text.MessageFormat;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -40,7 +39,6 @@ import org.xmlpull.v1.XmlSerializer;
import android.content.Context;
import android.util.Xml;
-import android.view.View;
import android.widget.Toast;
public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapsDbHelper.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapsDbHelper.java
index 243734b60f..33b016486c 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapsDbHelper.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapsDbHelper.java
@@ -27,7 +27,7 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
OPENSTREETMAP_COL_LAT + " double," + OPENSTREETMAP_COL_LON + " double," +
OPENSTREETMAP_COL_TAGS + " VARCHAR(2048)," +
OPENSTREETMAP_COL_ACTION + " TEXT, " + OPENSTREETMAP_COL_COMMENT + " TEXT);"; //$NON-NLS-1$ //$NON-NLS-2$
-
+ List cache = null;
public OpenstreetmapsDbHelper(Context context) {
super(context, OPENSTREETMAP_DB_NAME, null, DATABASE_VERSION);
@@ -47,11 +47,13 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
}
public List getOpenstreetmapPoints() {
- return checkOpenstreetmapPoints();
+ if(cache == null ) {
+ return checkOpenstreetmapPoints();
+ }
+ return cache;
}
public boolean addOpenstreetmap(OpenstreetmapPoint p) {
- checkOpenstreetmapPoints();
SQLiteDatabase db = getWritableDatabase();
if (db != null) {
StringBuilder tags = new StringBuilder();
@@ -67,6 +69,8 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
" (" + OPENSTREETMAP_COL_ID + ", " + OPENSTREETMAP_COL_LAT + ", " + OPENSTREETMAP_COL_LON + ", " + OPENSTREETMAP_COL_TAGS + ", " + OPENSTREETMAP_COL_ACTION + "," + OPENSTREETMAP_COL_COMMENT + ")" +
" VALUES (?, ?, ?, ?, ?, ?)",
new Object[] { p.getId(),p.getLatitude(), p.getLongitude(), tags.toString() , OsmPoint.stringAction.get(p.getAction()), p.getComment(), }); //$NON-NLS-1$ //$NON-NLS-2$
+ db.close();
+ checkOpenstreetmapPoints();
return true;
}
return false;
@@ -75,11 +79,12 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
public boolean deletePOI(OpenstreetmapPoint p) {
- checkOpenstreetmapPoints();
SQLiteDatabase db = getWritableDatabase();
if (db != null) {
db.execSQL("DELETE FROM " + OPENSTREETMAP_TABLE_NAME +
" WHERE " + OPENSTREETMAP_COL_ID + " = ?", new Object[] { p.getId() }); //$NON-NLS-1$ //$NON-NLS-2$
+ db.close();
+ checkOpenstreetmapPoints();
return true;
}
return false;
@@ -87,8 +92,8 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
private List checkOpenstreetmapPoints(){
- SQLiteDatabase db = getWritableDatabase();
- List cachedOpenstreetmapPoints = new ArrayList();
+ SQLiteDatabase db = getReadableDatabase();
+ List points = new ArrayList();
if (db != null) {
Cursor query = db.rawQuery("SELECT " + OPENSTREETMAP_COL_ID + ", " + OPENSTREETMAP_COL_LAT + "," + OPENSTREETMAP_COL_LON + "," + OPENSTREETMAP_COL_ACTION + "," + OPENSTREETMAP_COL_COMMENT + "," + OPENSTREETMAP_COL_TAGS+ " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
OPENSTREETMAP_TABLE_NAME, null);
@@ -106,12 +111,13 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
p.setEntity(entity);
p.setAction(query.getString(3));
p.setComment(query.getString(4));
- cachedOpenstreetmapPoints.add(p);
+ points.add(p);
} while (query.moveToNext());
}
query.close();
}
- return cachedOpenstreetmapPoints;
+ cache = points;
+ return points;
}
public long getMinID() {
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsDbHelper.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsDbHelper.java
index 1e31ed493e..d3ae3afb72 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsDbHelper.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsDbHelper.java
@@ -23,7 +23,7 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
OSMBUGS_COL_ID + " INTEGER, " + OSMBUGS_COL_TEXT + " TEXT, " + //$NON-NLS-1$ //$NON-NLS-2$
OSMBUGS_COL_LAT + " double, " + OSMBUGS_COL_LON + " double, " + //$NON-NLS-1$ //$NON-NLS-2$
OSMBUGS_COL_ACTION + " TEXT, " + OSMBUGS_COL_AUTHOR + " TEXT);"; //$NON-NLS-1$ //$NON-NLS-2$
-
+ List cache = null;
public OsmBugsDbHelper(Context context) {
super(context, OSMBUGS_DB_NAME, null, DATABASE_VERSION);
}
@@ -38,11 +38,13 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
}
public List getOsmbugsPoints() {
- return checkOsmbugsPoints();
+ if (cache == null) {
+ return checkOsmbugsPoints();
+ }
+ return cache;
}
public boolean addOsmbugs(OsmNotesPoint p) {
- checkOsmbugsPoints();
SQLiteDatabase db = getWritableDatabase();
if (db != null) {
db.execSQL(
@@ -50,24 +52,27 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
+ OSMBUGS_COL_LON + "," + OSMBUGS_COL_ACTION + "," + OSMBUGS_COL_AUTHOR + ")" + " VALUES (?, ?, ?, ?, ?, ?)",
new Object[] { p.getId(), p.getText(), p.getLatitude(), p.getLongitude(),
OsmPoint.stringAction.get(p.getAction()), p.getAuthor() }); //$NON-NLS-1$ //$NON-NLS-2$
+ db.close();
+ checkOsmbugsPoints();
return true;
}
return false;
}
public boolean deleteAllBugModifications(OsmNotesPoint p) {
- checkOsmbugsPoints();
SQLiteDatabase db = getWritableDatabase();
if (db != null) {
db.execSQL("DELETE FROM " + OSMBUGS_TABLE_NAME +
" WHERE " + OSMBUGS_COL_ID + " = ?", new Object[] { p.getId() }); //$NON-NLS-1$ //$NON-NLS-2$
+ db.close();
+ checkOsmbugsPoints();
return true;
}
return false;
}
private List checkOsmbugsPoints(){
- SQLiteDatabase db = getWritableDatabase();
+ SQLiteDatabase db = getReadableDatabase();
List cachedOsmbugsPoints = new ArrayList();
if (db != null) {
Cursor query = db.rawQuery("SELECT " + OSMBUGS_COL_ID + ", " + OSMBUGS_COL_TEXT + ", " + OSMBUGS_COL_LAT + "," + OSMBUGS_COL_LON + "," + OSMBUGS_COL_ACTION + "," + OSMBUGS_COL_AUTHOR + " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -89,6 +94,7 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
query.close();
db.close();
}
+ cache = cachedOsmbugsPoints;
return cachedOsmbugsPoints;
}
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java
index 4a1d64af86..cd2bb2e22c 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java
@@ -1,20 +1,14 @@
package net.osmand.plus.osmedit;
-import android.app.AlertDialog;
-import android.app.AlertDialog.Builder;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.PointF;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.util.Xml;
-import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
-import android.widget.Toast;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Serializable;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.access.AccessibleToast;
@@ -39,13 +33,20 @@ import org.apache.commons.logging.Log;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Serializable;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.List;
+import android.app.AlertDialog;
+import android.app.AlertDialog.Builder;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.PointF;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.util.Xml;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.Toast;
public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider, DialogProvider {
@@ -220,9 +221,6 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
if(data != null) {
data.clearCache();
}
- if (plugin != null){
- plugin.collectLocalOsmEdits();
- }
}
private static String readText(XmlPullParser parser, String key) throws XmlPullParserException, IOException {
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java
index c64ca69a30..960bcb3b65 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java
@@ -1,23 +1,9 @@
package net.osmand.plus.osmedit;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.AlertDialog.Builder;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
-import android.content.Intent;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
-import android.widget.Spinner;
-import android.widget.Toast;
+import java.util.List;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
-import net.osmand.data.DataTileManager;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.OsmandApplication;
@@ -33,21 +19,48 @@ import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.Algorithms;
-
-import java.util.List;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.AlertDialog.Builder;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.content.Intent;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.Spinner;
+import android.widget.Toast;
public class OsmEditingPlugin extends OsmandPlugin {
private static final String ID = "osm.editing";
private OsmandSettings settings;
private OsmandApplication app;
- DataTileManager localOsmEditsInternal = null;
+ OpenstreetmapsDbHelper dbpoi ;
+ OsmBugsDbHelper dbbug ;
@Override
public String getId() {
return ID;
}
+ public OpenstreetmapsDbHelper getDBPOI() {
+ if(dbpoi == null) {
+ dbpoi = new OpenstreetmapsDbHelper(app);
+ }
+ return dbpoi;
+ }
+
+ public OsmBugsDbHelper getDBBug() {
+ if(dbbug == null) {
+ dbbug = new OsmBugsDbHelper(app);
+ }
+ return dbbug;
+ }
+
public OsmEditingPlugin(OsmandApplication app) {
this.app = app;
}
@@ -150,9 +163,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
@Override
public void addMyPlacesTab(FavoritesActivity favoritesActivity, List mTabs, Intent intent) {
- OpenstreetmapsDbHelper dbpoi = new OpenstreetmapsDbHelper(favoritesActivity);
- OsmBugsDbHelper dbbug = new OsmBugsDbHelper(favoritesActivity);
- if (dbpoi.getOpenstreetmapPoints().size() > 0 || dbbug.getOsmbugsPoints().size() > 0){
+ if (getDBPOI().getOpenstreetmapPoints().size() > 0 || getDBBug().getOsmbugsPoints().size() > 0){
mTabs.add(favoritesActivity.getTabIndicator(R.string.osm_edits, OsmEditsFragment.class));
if (intent != null && "OSM".equals(intent.getStringExtra("TAB"))) {
app.getSettings().FAVORITES_TAB.set(R.string.osm_edits);
@@ -223,11 +234,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
}
}
- public void onLocalItemDeleted(OsmPoint point) {
- if(localOsmEditsInternal != null) {
- localOsmEditsInternal.unregisterObject(point.getLatitude(), point.getLongitude(), point);
- }
- }
+
public enum UploadVisibility implements IEnumWithResource {
Public(R.string.gpxup_public),
@@ -285,40 +292,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
return true;
}
- public void onLocalOsmEditAdded(OsmPoint point){
- if(localOsmEditsInternal != null) {
- localOsmEditsInternal.registerObject(point.getLatitude(), point.getLongitude(), point);
- }
- }
- public void collectLocalOsmEdits() {
- DataTileManager res = new DataTileManager();
- OpenstreetmapsDbHelper dbpoi = new OpenstreetmapsDbHelper(app);
- OsmBugsDbHelper dbbug = new OsmBugsDbHelper(app);
-
- List l1 = dbpoi.getOpenstreetmapPoints();
- List l2 = dbbug.getOsmbugsPoints();
- for (OsmPoint point : l1) {
- res.registerObject(point.getLatitude(), point.getLongitude(), point);
- }
- for (OsmPoint point : l2) {
- res.registerObject(point.getLatitude(), point.getLongitude(), point);
- }
- localOsmEditsInternal = res;
-
- }
-
- public DataTileManager getLocalOsmEdits(){
- if(localOsmEditsInternal == null) {
- collectLocalOsmEdits();
- }
- return localOsmEditsInternal;
- }
-
- public List getAllEdits(){
- return getLocalOsmEdits().getAllObjects();
- }
-
@Override
public String getName() {
return app.getString(R.string.osm_settings);
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java
index 1d2e5e014f..9737a8b7fb 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java
@@ -61,9 +61,6 @@ public class OsmEditsFragment extends OsmAndListFragment implements OsmEditsUplo
private boolean selectionMode = false;
- private OpenstreetmapsDbHelper dbpoi;
- private OsmBugsDbHelper dbbug;
-
private OpenstreetmapRemoteUtil remotepoi;
private OsmBugsRemoteUtil remotebug;
@@ -82,8 +79,6 @@ public class OsmEditsFragment extends OsmAndListFragment implements OsmEditsUplo
plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
View view = getActivity().getLayoutInflater().inflate(R.layout.update_index, container, false);
((TextView) view.findViewById(R.id.header)).setText(R.string.your_edits);
- dbpoi = new OpenstreetmapsDbHelper(getActivity());
- dbbug = new OsmBugsDbHelper(getActivity());
remotepoi = new OpenstreetmapRemoteUtil(getActivity());
remotebug = new OsmBugsRemoteUtil(getMyApplication());
@@ -307,13 +302,12 @@ public class OsmEditsFragment extends OsmAndListFragment implements OsmEditsUplo
while (it.hasNext()) {
OsmPoint omsPoint = it.next();
if (omsPoint.getGroup() == OsmPoint.Group.POI) {
- dbpoi.deletePOI((OpenstreetmapPoint) omsPoint);
+ plugin.getDBPOI().deletePOI((OpenstreetmapPoint) omsPoint);
} else if (omsPoint.getGroup() == OsmPoint.Group.BUG) {
- dbbug.deleteAllBugModifications((OsmNotesPoint) omsPoint);
+ plugin.getDBBug().deleteAllBugModifications((OsmNotesPoint) omsPoint);
}
it.remove();
listAdapter.delete(omsPoint);
- plugin.onLocalItemDeleted(omsPoint);
}
listAdapter.notifyDataSetChanged();
@@ -327,8 +321,8 @@ public class OsmEditsFragment extends OsmAndListFragment implements OsmEditsUplo
public void onResume() {
super.onResume();
dataPoints = new ArrayList<>();
- List l1 = dbpoi.getOpenstreetmapPoints();
- List l2 = dbbug.getOsmbugsPoints();
+ List l1 = plugin.getDBPOI().getOpenstreetmapPoints();
+ List l2 = plugin.getDBBug().getOsmbugsPoints();
dataPoints.addAll(l1);
dataPoints.addAll(l2);
listAdapter = new OsmEditsAdapter(dataPoints);
@@ -507,7 +501,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements OsmEditsUplo
getString(R.string.uploading),
getString(R.string.local_openstreetmap_uploading),
ProgressDialog.STYLE_HORIZONTAL).getDialog();
- UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog, this, remotepoi,
+ UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog, this, plugin, remotepoi,
remotebug, toUpload.length);
uploadTask.execute(toUpload);
@@ -621,7 +615,6 @@ public class OsmEditsFragment extends OsmAndListFragment implements OsmEditsUplo
@Override
public void uploadUpdated(OsmPoint point) {
- plugin.onLocalItemDeleted(point);
listAdapter.delete(point);
}
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java
index cb1fcb649b..2bbd9133f8 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java
@@ -1,24 +1,23 @@
package net.osmand.plus.osmedit;
+import java.util.List;
+
+import net.osmand.data.LatLon;
+import net.osmand.data.PointDescription;
+import net.osmand.data.RotatedTileBox;
+import net.osmand.plus.ContextMenuAdapter;
+import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.views.ContextMenuLayer;
+import net.osmand.plus.views.OsmandMapLayer;
+import net.osmand.plus.views.OsmandMapTileView;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PointF;
-
-import net.osmand.data.DataTileManager;
-import net.osmand.data.LatLon;
-import net.osmand.data.PointDescription;
-import net.osmand.data.QuadRect;
-import net.osmand.data.RotatedTileBox;
-import net.osmand.plus.R;
-import net.osmand.plus.activities.MapActivity;
-import net.osmand.plus.views.ContextMenuLayer;
-import net.osmand.plus.views.OsmandMapLayer;
-import net.osmand.plus.views.OsmandMapTileView;
-
-import java.util.List;
+import android.widget.ArrayAdapter;
/**
* Created by Denis on
@@ -71,25 +70,26 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (tileBox.getZoom() >= startZoom) {
- DataTileManager points = plugin.getLocalOsmEdits();
- final QuadRect latlon = tileBox.getLatLonBounds();
- List objects = points.getObjects(latlon. top, latlon.left, latlon.bottom, latlon.right);
-
- for (OsmPoint o : objects) {
- int locationX = tileBox.getPixXFromLonNoRot(o.getLongitude());
- int locationY = tileBox.getPixYFromLatNoRot(o.getLatitude());
- canvas.rotate(-view.getRotate(), locationX, locationY);
- Bitmap b;
- if (o.getGroup() == OsmPoint.Group.POI) {
- b = poi;
- } else if (o.getGroup() == OsmPoint.Group.BUG) {
- b = bug;
- } else {
- b = poi;
- }
- canvas.drawBitmap(b, locationX - b.getWidth() / 2, locationY - b.getHeight(), paintIcon);
- canvas.rotate(view.getRotate(), locationX, locationY);
+ drawPoints(canvas, tileBox, plugin.getDBBug().getOsmbugsPoints());
+ drawPoints(canvas, tileBox, plugin.getDBPOI().getOpenstreetmapPoints());
+ }
+ }
+
+ private void drawPoints(Canvas canvas, RotatedTileBox tileBox, List extends OsmPoint> objects) {
+ for (OsmPoint o : objects) {
+ int locationX = tileBox.getPixXFromLonNoRot(o.getLongitude());
+ int locationY = tileBox.getPixYFromLatNoRot(o.getLatitude());
+ canvas.rotate(-view.getRotate(), locationX, locationY);
+ Bitmap b;
+ if (o.getGroup() == OsmPoint.Group.POI) {
+ b = poi;
+ } else if (o.getGroup() == OsmPoint.Group.BUG) {
+ b = bug;
+ } else {
+ b = poi;
}
+ canvas.drawBitmap(b, locationX - b.getWidth() / 2, locationY - b.getHeight(), paintIcon);
+ canvas.rotate(view.getRotate(), locationX, locationY);
}
}
@@ -109,7 +109,13 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
int ey = (int) point.y;
int compare = getRadiusPoi(tileBox);
int radius = compare * 3 / 2;
- for (OsmPoint n : plugin.getAllEdits()) {
+ compare = getFromPoint(tileBox, am, ex, ey, compare, radius, plugin.getDBBug().getOsmbugsPoints());
+ compare = getFromPoint(tileBox, am, ex, ey, compare, radius, plugin.getDBPOI().getOpenstreetmapPoints());
+ }
+
+ private int getFromPoint(RotatedTileBox tileBox, List super OsmPoint> am, int ex, int ey, int compare,
+ int radius, List extends OsmPoint> pnts) {
+ for (OsmPoint n : pnts) {
int x = (int) tileBox.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
if (calculateBelongs(ex, ey, x, y, compare)) {
@@ -117,6 +123,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
am.add(n);
}
}
+ return compare;
}
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {
@@ -145,6 +152,28 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
}
return null;
}
+
+ @Override
+ public void populateObjectContextMenu(Object o, ContextMenuAdapter adapter) {
+ if (o instanceof OsmPoint) {
+ final OsmPoint r = (OsmPoint) o;
+ adapter.item(R.string.osm_edit_context_menu_delete).iconColor(R.drawable.ic_action_delete_dark
+ ).listen(new ContextMenuAdapter.OnContextMenuClick() {
+ @Override
+ public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ if(r instanceof OsmNotesPoint) {
+ plugin.getDBBug().deleteAllBugModifications((OsmNotesPoint) r);
+ } else if(r instanceof OpenstreetmapPoint) {
+ plugin.getDBPOI().deletePOI((OpenstreetmapPoint) r);
+ }
+ view.refreshMap();
+ return true;
+ }
+
+
+ }).reg();
+ }
+ }
@Override
public String getObjectDescription(Object o) {
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java b/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java
index b991f57112..be3756f9bd 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java
@@ -20,8 +20,6 @@ public class UploadOpenstreetmapPointAsyncTask extends AsyncTask