FIX
- POI doesn't refresh map after delete https://github.com/osmandapp/Osmand/issues/1281 - No delete in context menu for POI/Editing https://github.com/osmandapp/Osmand/issues/1278 Conflicts: OsmAnd/res/values/strings.xml
This commit is contained in:
parent
e666da21b1
commit
9db293dbc3
12 changed files with 185 additions and 176 deletions
|
@ -9,6 +9,13 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
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
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="osm_edit_context_menu_delete">Delete Osm Edit</string>
|
||||||
|
<string name="rendering_value_disabled_name">Disabled</string>
|
||||||
|
<string name="rendering_value_walkingRoutesScopeOSMC_name">Coloring according to route scope</string>
|
||||||
|
<string name="rendering_value_walkingRoutesOSMC_name">Coloring according to OSMC</string>
|
||||||
|
<string name="osmo_share_my_location">Share my location</string>
|
||||||
|
<string name="shared_string_logoff">Log Off</string>
|
||||||
|
<string name="rendering_attr_hideHouseNumbers_name">Hide house numbers</string>
|
||||||
<string name="application_dir_change_warning3">Do you want OsmAnd to also copy its data files to the new destination?</string>
|
<string name="application_dir_change_warning3">Do you want OsmAnd to also copy its data files to the new destination?</string>
|
||||||
<string name="specified_directiory_not_writeable">Maps could not be created in specified directory</string>
|
<string name="specified_directiory_not_writeable">Maps could not be created in specified directory</string>
|
||||||
<string name="copying_osmand_file_failed">Copying files failed</string>
|
<string name="copying_osmand_file_failed">Copying files failed</string>
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
package net.osmand.plus.osmedit;
|
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.AlertDialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
@ -12,18 +23,6 @@ import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
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
|
* Created by Denis
|
||||||
|
@ -135,17 +134,14 @@ public class DashOsmEditsFragment extends DashBaseFragment implements OsmEditsUp
|
||||||
getString(R.string.uploading), getString(R.string.local_openstreetmap_uploading),
|
getString(R.string.uploading), getString(R.string.local_openstreetmap_uploading),
|
||||||
ProgressDialog.STYLE_HORIZONTAL).getDialog();
|
ProgressDialog.STYLE_HORIZONTAL).getDialog();
|
||||||
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog,
|
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog,
|
||||||
DashOsmEditsFragment.this, remotepoi, remotebug, toUpload.length);
|
DashOsmEditsFragment.this, plugin, remotepoi, remotebug, toUpload.length);
|
||||||
uploadTask.execute(toUpload);
|
uploadTask.execute(toUpload);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getOsmPoints(ArrayList<OsmPoint> dataPoints) {
|
private void getOsmPoints(ArrayList<OsmPoint> dataPoints) {
|
||||||
OpenstreetmapsDbHelper dbpoi = new OpenstreetmapsDbHelper(getActivity());
|
List<OpenstreetmapPoint> l1 = plugin.getDBPOI().getOpenstreetmapPoints();
|
||||||
OsmBugsDbHelper dbbug = new OsmBugsDbHelper(getActivity());
|
List<OsmNotesPoint> l2 = plugin.getDBBug().getOsmbugsPoints();
|
||||||
|
|
||||||
List<OpenstreetmapPoint> l1 = dbpoi.getOpenstreetmapPoints();
|
|
||||||
List<OsmNotesPoint> l2 = dbbug.getOsmbugsPoints();
|
|
||||||
if (l1.isEmpty()){
|
if (l1.isEmpty()){
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(OsmPoint point : l2){
|
for(OsmPoint point : l2){
|
||||||
|
|
|
@ -112,10 +112,10 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
||||||
settings = ((OsmandApplication) activity.getApplication()).getSettings();
|
settings = ((OsmandApplication) activity.getApplication()).getSettings();
|
||||||
isLocalEdit = true;
|
isLocalEdit = true;
|
||||||
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
|
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
|
||||||
this.openstreetmapUtil = new OpenstreetmapLocalUtil(activity);
|
this.openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
|
||||||
this.openstreetmapUtilToLoad = openstreetmapUtil;
|
this.openstreetmapUtilToLoad = openstreetmapUtil;
|
||||||
} else if(!settings.isInternetConnectionAvailable(true)) {
|
} else if(!settings.isInternetConnectionAvailable(true)) {
|
||||||
this.openstreetmapUtil = new OpenstreetmapLocalUtil(activity);
|
this.openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
|
||||||
this.openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity);
|
this.openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity);
|
||||||
} else {
|
} else {
|
||||||
isLocalEdit = false;
|
isLocalEdit = false;
|
||||||
|
@ -692,7 +692,6 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Node result) {
|
protected void onPostExecute(Node result) {
|
||||||
progress.dismiss();
|
progress.dismiss();
|
||||||
plugin.collectLocalOsmEdits();
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
successAction.run();
|
successAction.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,14 @@ import android.content.Context;
|
||||||
public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
|
public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
|
||||||
|
|
||||||
private final Context ctx;
|
private final Context ctx;
|
||||||
private final OpenstreetmapsDbHelper db;
|
|
||||||
|
|
||||||
public final static Log log = PlatformUtil.getLog(OpenstreetmapLocalUtil.class);
|
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.ctx = uiContext;
|
||||||
this.db = new OpenstreetmapsDbHelper(ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,16 +34,16 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
|
||||||
public Node commitNodeImpl(OsmPoint.Action action, Node n, EntityInfo info, String comment, boolean closeChangeSet){
|
public Node commitNodeImpl(OsmPoint.Action action, Node n, EntityInfo info, String comment, boolean closeChangeSet){
|
||||||
Node newNode = n;
|
Node newNode = n;
|
||||||
if (n.getId() == -1) {
|
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();
|
OpenstreetmapPoint p = new OpenstreetmapPoint();
|
||||||
p.setEntity(newNode);
|
p.setEntity(newNode);
|
||||||
p.setAction(action);
|
p.setAction(action);
|
||||||
p.setComment(comment);
|
p.setComment(comment);
|
||||||
if (p.getAction() == OsmPoint.Action.DELETE && newNode.getId() < 0) { //if it is our local poi
|
if (p.getAction() == OsmPoint.Action.DELETE && newNode.getId() < 0) { //if it is our local poi
|
||||||
db.deletePOI(p);
|
plugin.getDBPOI().deletePOI(p);
|
||||||
} else {
|
} else {
|
||||||
db.addOpenstreetmap(p);
|
plugin.getDBPOI().addOpenstreetmap(p);
|
||||||
}
|
}
|
||||||
return newNode;
|
return newNode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.io.OutputStreamWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -40,7 +39,6 @@ import org.xmlpull.v1.XmlSerializer;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Xml;
|
import android.util.Xml;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
||||||
OPENSTREETMAP_COL_LAT + " double," + OPENSTREETMAP_COL_LON + " double," +
|
OPENSTREETMAP_COL_LAT + " double," + OPENSTREETMAP_COL_LON + " double," +
|
||||||
OPENSTREETMAP_COL_TAGS + " VARCHAR(2048)," +
|
OPENSTREETMAP_COL_TAGS + " VARCHAR(2048)," +
|
||||||
OPENSTREETMAP_COL_ACTION + " TEXT, " + OPENSTREETMAP_COL_COMMENT + " TEXT);"; //$NON-NLS-1$ //$NON-NLS-2$
|
OPENSTREETMAP_COL_ACTION + " TEXT, " + OPENSTREETMAP_COL_COMMENT + " TEXT);"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
List<OpenstreetmapPoint> cache = null;
|
||||||
|
|
||||||
public OpenstreetmapsDbHelper(Context context) {
|
public OpenstreetmapsDbHelper(Context context) {
|
||||||
super(context, OPENSTREETMAP_DB_NAME, null, DATABASE_VERSION);
|
super(context, OPENSTREETMAP_DB_NAME, null, DATABASE_VERSION);
|
||||||
|
@ -47,11 +47,13 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OpenstreetmapPoint> getOpenstreetmapPoints() {
|
public List<OpenstreetmapPoint> getOpenstreetmapPoints() {
|
||||||
return checkOpenstreetmapPoints();
|
if(cache == null ) {
|
||||||
|
return checkOpenstreetmapPoints();
|
||||||
|
}
|
||||||
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addOpenstreetmap(OpenstreetmapPoint p) {
|
public boolean addOpenstreetmap(OpenstreetmapPoint p) {
|
||||||
checkOpenstreetmapPoints();
|
|
||||||
SQLiteDatabase db = getWritableDatabase();
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
StringBuilder tags = new StringBuilder();
|
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 + ")" +
|
" (" + OPENSTREETMAP_COL_ID + ", " + OPENSTREETMAP_COL_LAT + ", " + OPENSTREETMAP_COL_LON + ", " + OPENSTREETMAP_COL_TAGS + ", " + OPENSTREETMAP_COL_ACTION + "," + OPENSTREETMAP_COL_COMMENT + ")" +
|
||||||
" VALUES (?, ?, ?, ?, ?, ?)",
|
" VALUES (?, ?, ?, ?, ?, ?)",
|
||||||
new Object[] { p.getId(),p.getLatitude(), p.getLongitude(), tags.toString() , OsmPoint.stringAction.get(p.getAction()), p.getComment(), }); //$NON-NLS-1$ //$NON-NLS-2$
|
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 true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -75,11 +79,12 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
|
|
||||||
public boolean deletePOI(OpenstreetmapPoint p) {
|
public boolean deletePOI(OpenstreetmapPoint p) {
|
||||||
checkOpenstreetmapPoints();
|
|
||||||
SQLiteDatabase db = getWritableDatabase();
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
db.execSQL("DELETE FROM " + OPENSTREETMAP_TABLE_NAME +
|
db.execSQL("DELETE FROM " + OPENSTREETMAP_TABLE_NAME +
|
||||||
" WHERE " + OPENSTREETMAP_COL_ID + " = ?", new Object[] { p.getId() }); //$NON-NLS-1$ //$NON-NLS-2$
|
" WHERE " + OPENSTREETMAP_COL_ID + " = ?", new Object[] { p.getId() }); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
db.close();
|
||||||
|
checkOpenstreetmapPoints();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -87,8 +92,8 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
|
|
||||||
private List<OpenstreetmapPoint> checkOpenstreetmapPoints(){
|
private List<OpenstreetmapPoint> checkOpenstreetmapPoints(){
|
||||||
SQLiteDatabase db = getWritableDatabase();
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
List<OpenstreetmapPoint> cachedOpenstreetmapPoints = new ArrayList<OpenstreetmapPoint>();
|
List<OpenstreetmapPoint> points = new ArrayList<OpenstreetmapPoint>();
|
||||||
if (db != null) {
|
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$
|
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);
|
OPENSTREETMAP_TABLE_NAME, null);
|
||||||
|
@ -106,12 +111,13 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
||||||
p.setEntity(entity);
|
p.setEntity(entity);
|
||||||
p.setAction(query.getString(3));
|
p.setAction(query.getString(3));
|
||||||
p.setComment(query.getString(4));
|
p.setComment(query.getString(4));
|
||||||
cachedOpenstreetmapPoints.add(p);
|
points.add(p);
|
||||||
} while (query.moveToNext());
|
} while (query.moveToNext());
|
||||||
}
|
}
|
||||||
query.close();
|
query.close();
|
||||||
}
|
}
|
||||||
return cachedOpenstreetmapPoints;
|
cache = points;
|
||||||
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getMinID() {
|
public long getMinID() {
|
||||||
|
|
|
@ -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_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_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$
|
OSMBUGS_COL_ACTION + " TEXT, " + OSMBUGS_COL_AUTHOR + " TEXT);"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
List<OsmNotesPoint> cache = null;
|
||||||
public OsmBugsDbHelper(Context context) {
|
public OsmBugsDbHelper(Context context) {
|
||||||
super(context, OSMBUGS_DB_NAME, null, DATABASE_VERSION);
|
super(context, OSMBUGS_DB_NAME, null, DATABASE_VERSION);
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,13 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OsmNotesPoint> getOsmbugsPoints() {
|
public List<OsmNotesPoint> getOsmbugsPoints() {
|
||||||
return checkOsmbugsPoints();
|
if (cache == null) {
|
||||||
|
return checkOsmbugsPoints();
|
||||||
|
}
|
||||||
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addOsmbugs(OsmNotesPoint p) {
|
public boolean addOsmbugs(OsmNotesPoint p) {
|
||||||
checkOsmbugsPoints();
|
|
||||||
SQLiteDatabase db = getWritableDatabase();
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
db.execSQL(
|
db.execSQL(
|
||||||
|
@ -50,24 +52,27 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
|
||||||
+ OSMBUGS_COL_LON + "," + OSMBUGS_COL_ACTION + "," + OSMBUGS_COL_AUTHOR + ")" + " VALUES (?, ?, ?, ?, ?, ?)",
|
+ OSMBUGS_COL_LON + "," + OSMBUGS_COL_ACTION + "," + OSMBUGS_COL_AUTHOR + ")" + " VALUES (?, ?, ?, ?, ?, ?)",
|
||||||
new Object[] { p.getId(), p.getText(), p.getLatitude(), p.getLongitude(),
|
new Object[] { p.getId(), p.getText(), p.getLatitude(), p.getLongitude(),
|
||||||
OsmPoint.stringAction.get(p.getAction()), p.getAuthor() }); //$NON-NLS-1$ //$NON-NLS-2$
|
OsmPoint.stringAction.get(p.getAction()), p.getAuthor() }); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
db.close();
|
||||||
|
checkOsmbugsPoints();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean deleteAllBugModifications(OsmNotesPoint p) {
|
public boolean deleteAllBugModifications(OsmNotesPoint p) {
|
||||||
checkOsmbugsPoints();
|
|
||||||
SQLiteDatabase db = getWritableDatabase();
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
db.execSQL("DELETE FROM " + OSMBUGS_TABLE_NAME +
|
db.execSQL("DELETE FROM " + OSMBUGS_TABLE_NAME +
|
||||||
" WHERE " + OSMBUGS_COL_ID + " = ?", new Object[] { p.getId() }); //$NON-NLS-1$ //$NON-NLS-2$
|
" WHERE " + OSMBUGS_COL_ID + " = ?", new Object[] { p.getId() }); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
db.close();
|
||||||
|
checkOsmbugsPoints();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<OsmNotesPoint> checkOsmbugsPoints(){
|
private List<OsmNotesPoint> checkOsmbugsPoints(){
|
||||||
SQLiteDatabase db = getWritableDatabase();
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
List<OsmNotesPoint> cachedOsmbugsPoints = new ArrayList<OsmNotesPoint>();
|
List<OsmNotesPoint> cachedOsmbugsPoints = new ArrayList<OsmNotesPoint>();
|
||||||
if (db != null) {
|
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$
|
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$
|
||||||
|
@ -88,6 +93,7 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
query.close();
|
query.close();
|
||||||
}
|
}
|
||||||
|
cache = cachedOsmbugsPoints;
|
||||||
return cachedOsmbugsPoints;
|
return cachedOsmbugsPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,14 @@
|
||||||
package net.osmand.plus.osmedit;
|
package net.osmand.plus.osmedit;
|
||||||
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import java.io.BufferedReader;
|
||||||
import android.app.AlertDialog.Builder;
|
import java.io.IOException;
|
||||||
import android.app.Dialog;
|
import java.io.InputStreamReader;
|
||||||
import android.content.DialogInterface;
|
import java.io.Serializable;
|
||||||
import android.graphics.Canvas;
|
import java.net.URLConnection;
|
||||||
import android.graphics.Paint;
|
import java.util.ArrayList;
|
||||||
import android.graphics.PointF;
|
import java.util.List;
|
||||||
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 net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
|
@ -39,13 +33,20 @@ import org.apache.commons.logging.Log;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import android.app.AlertDialog;
|
||||||
import java.io.IOException;
|
import android.app.AlertDialog.Builder;
|
||||||
import java.io.InputStreamReader;
|
import android.app.Dialog;
|
||||||
import java.io.Serializable;
|
import android.content.DialogInterface;
|
||||||
import java.net.URLConnection;
|
import android.graphics.Canvas;
|
||||||
import java.util.ArrayList;
|
import android.graphics.Paint;
|
||||||
import java.util.List;
|
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 {
|
public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider, DialogProvider {
|
||||||
|
|
||||||
|
@ -220,9 +221,6 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
if(data != null) {
|
if(data != null) {
|
||||||
data.clearCache();
|
data.clearCache();
|
||||||
}
|
}
|
||||||
if (plugin != null){
|
|
||||||
plugin.collectLocalOsmEdits();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String readText(XmlPullParser parser, String key) throws XmlPullParserException, IOException {
|
private static String readText(XmlPullParser parser, String key) throws XmlPullParserException, IOException {
|
||||||
|
|
|
@ -1,23 +1,9 @@
|
||||||
package net.osmand.plus.osmedit;
|
package net.osmand.plus.osmedit;
|
||||||
|
|
||||||
import android.app.Activity;
|
import java.util.List;
|
||||||
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 net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.DataTileManager;
|
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||||
import net.osmand.plus.OsmandApplication;
|
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.myplaces.FavoritesActivity;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
import android.app.Activity;
|
||||||
import java.util.List;
|
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 {
|
public class OsmEditingPlugin extends OsmandPlugin {
|
||||||
private static final String ID = "osm.editing";
|
private static final String ID = "osm.editing";
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
DataTileManager<OsmPoint> localOsmEditsInternal = null;
|
OpenstreetmapsDbHelper dbpoi ;
|
||||||
|
OsmBugsDbHelper dbbug ;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return ID;
|
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) {
|
public OsmEditingPlugin(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
@ -150,9 +163,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addMyPlacesTab(FavoritesActivity favoritesActivity, List<TabActivity.TabItem> mTabs, Intent intent) {
|
public void addMyPlacesTab(FavoritesActivity favoritesActivity, List<TabActivity.TabItem> mTabs, Intent intent) {
|
||||||
OpenstreetmapsDbHelper dbpoi = new OpenstreetmapsDbHelper(favoritesActivity);
|
if (getDBPOI().getOpenstreetmapPoints().size() > 0 || getDBBug().getOsmbugsPoints().size() > 0){
|
||||||
OsmBugsDbHelper dbbug = new OsmBugsDbHelper(favoritesActivity);
|
|
||||||
if (dbpoi.getOpenstreetmapPoints().size() > 0 || dbbug.getOsmbugsPoints().size() > 0){
|
|
||||||
mTabs.add(favoritesActivity.getTabIndicator(R.string.osm_edits, OsmEditsFragment.class));
|
mTabs.add(favoritesActivity.getTabIndicator(R.string.osm_edits, OsmEditsFragment.class));
|
||||||
if (intent != null && "OSM".equals(intent.getStringExtra("TAB"))) {
|
if (intent != null && "OSM".equals(intent.getStringExtra("TAB"))) {
|
||||||
app.getSettings().FAVORITES_TAB.set(R.string.osm_edits);
|
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 enum UploadVisibility implements IEnumWithResource {
|
||||||
Public(R.string.gpxup_public),
|
Public(R.string.gpxup_public),
|
||||||
|
@ -285,40 +292,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLocalOsmEditAdded(OsmPoint point){
|
|
||||||
if(localOsmEditsInternal != null) {
|
|
||||||
localOsmEditsInternal.registerObject(point.getLatitude(), point.getLongitude(), point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void collectLocalOsmEdits() {
|
|
||||||
DataTileManager<OsmPoint> res = new DataTileManager<OsmPoint>();
|
|
||||||
OpenstreetmapsDbHelper dbpoi = new OpenstreetmapsDbHelper(app);
|
|
||||||
OsmBugsDbHelper dbbug = new OsmBugsDbHelper(app);
|
|
||||||
|
|
||||||
List<OpenstreetmapPoint> l1 = dbpoi.getOpenstreetmapPoints();
|
|
||||||
List<OsmNotesPoint> 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<OsmPoint> getLocalOsmEdits(){
|
|
||||||
if(localOsmEditsInternal == null) {
|
|
||||||
collectLocalOsmEdits();
|
|
||||||
}
|
|
||||||
return localOsmEditsInternal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OsmPoint> getAllEdits(){
|
|
||||||
return getLocalOsmEdits().getAllObjects();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return app.getString(R.string.osm_settings);
|
return app.getString(R.string.osm_settings);
|
||||||
|
|
|
@ -61,9 +61,6 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList
|
||||||
|
|
||||||
private boolean selectionMode = false;
|
private boolean selectionMode = false;
|
||||||
|
|
||||||
private OpenstreetmapsDbHelper dbpoi;
|
|
||||||
private OsmBugsDbHelper dbbug;
|
|
||||||
|
|
||||||
private OpenstreetmapRemoteUtil remotepoi;
|
private OpenstreetmapRemoteUtil remotepoi;
|
||||||
private OsmBugsRemoteUtil remotebug;
|
private OsmBugsRemoteUtil remotebug;
|
||||||
|
|
||||||
|
@ -82,8 +79,6 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList
|
||||||
plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
|
plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
|
||||||
View view = getActivity().getLayoutInflater().inflate(R.layout.update_index, container, false);
|
View view = getActivity().getLayoutInflater().inflate(R.layout.update_index, container, false);
|
||||||
((TextView) view.findViewById(R.id.header)).setText(R.string.your_edits);
|
((TextView) view.findViewById(R.id.header)).setText(R.string.your_edits);
|
||||||
dbpoi = new OpenstreetmapsDbHelper(getActivity());
|
|
||||||
dbbug = new OsmBugsDbHelper(getActivity());
|
|
||||||
|
|
||||||
remotepoi = new OpenstreetmapRemoteUtil(getActivity());
|
remotepoi = new OpenstreetmapRemoteUtil(getActivity());
|
||||||
remotebug = new OsmBugsRemoteUtil(getMyApplication());
|
remotebug = new OsmBugsRemoteUtil(getMyApplication());
|
||||||
|
@ -307,13 +302,12 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
OsmPoint omsPoint = it.next();
|
OsmPoint omsPoint = it.next();
|
||||||
if (omsPoint.getGroup() == OsmPoint.Group.POI) {
|
if (omsPoint.getGroup() == OsmPoint.Group.POI) {
|
||||||
dbpoi.deletePOI((OpenstreetmapPoint) omsPoint);
|
plugin.getDBPOI().deletePOI((OpenstreetmapPoint) omsPoint);
|
||||||
} else if (omsPoint.getGroup() == OsmPoint.Group.BUG) {
|
} else if (omsPoint.getGroup() == OsmPoint.Group.BUG) {
|
||||||
dbbug.deleteAllBugModifications((OsmNotesPoint) omsPoint);
|
plugin.getDBBug().deleteAllBugModifications((OsmNotesPoint) omsPoint);
|
||||||
}
|
}
|
||||||
it.remove();
|
it.remove();
|
||||||
listAdapter.delete(omsPoint);
|
listAdapter.delete(omsPoint);
|
||||||
plugin.onLocalItemDeleted(omsPoint);
|
|
||||||
}
|
}
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
@ -327,8 +321,8 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
dataPoints = new ArrayList<>();
|
dataPoints = new ArrayList<>();
|
||||||
List<OpenstreetmapPoint> l1 = dbpoi.getOpenstreetmapPoints();
|
List<OpenstreetmapPoint> l1 = plugin.getDBPOI().getOpenstreetmapPoints();
|
||||||
List<OsmNotesPoint> l2 = dbbug.getOsmbugsPoints();
|
List<OsmNotesPoint> l2 = plugin.getDBBug().getOsmbugsPoints();
|
||||||
dataPoints.addAll(l1);
|
dataPoints.addAll(l1);
|
||||||
dataPoints.addAll(l2);
|
dataPoints.addAll(l2);
|
||||||
listAdapter = new OsmEditsAdapter(dataPoints);
|
listAdapter = new OsmEditsAdapter(dataPoints);
|
||||||
|
@ -507,7 +501,7 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList
|
||||||
getString(R.string.uploading),
|
getString(R.string.uploading),
|
||||||
getString(R.string.local_openstreetmap_uploading),
|
getString(R.string.local_openstreetmap_uploading),
|
||||||
ProgressDialog.STYLE_HORIZONTAL).getDialog();
|
ProgressDialog.STYLE_HORIZONTAL).getDialog();
|
||||||
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog, this, remotepoi,
|
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog, this, plugin, remotepoi,
|
||||||
remotebug, toUpload.length);
|
remotebug, toUpload.length);
|
||||||
uploadTask.execute(toUpload);
|
uploadTask.execute(toUpload);
|
||||||
|
|
||||||
|
@ -621,7 +615,6 @@ public class OsmEditsFragment extends ListFragment implements OsmEditsUploadList
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uploadUpdated(OsmPoint point) {
|
public void uploadUpdated(OsmPoint point) {
|
||||||
plugin.onLocalItemDeleted(point);
|
|
||||||
listAdapter.delete(point);
|
listAdapter.delete(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,23 @@
|
||||||
package net.osmand.plus.osmedit;
|
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.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Denis on
|
* Created by Denis on
|
||||||
|
@ -71,25 +70,26 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
if (tileBox.getZoom() >= startZoom) {
|
if (tileBox.getZoom() >= startZoom) {
|
||||||
DataTileManager<OsmPoint> points = plugin.getLocalOsmEdits();
|
drawPoints(canvas, tileBox, plugin.getDBBug().getOsmbugsPoints());
|
||||||
final QuadRect latlon = tileBox.getLatLonBounds();
|
drawPoints(canvas, tileBox, plugin.getDBPOI().getOpenstreetmapPoints());
|
||||||
List<OsmPoint> objects = points.getObjects(latlon. top, latlon.left, latlon.bottom, latlon.right);
|
}
|
||||||
|
}
|
||||||
for (OsmPoint o : objects) {
|
|
||||||
int locationX = tileBox.getPixXFromLonNoRot(o.getLongitude());
|
private void drawPoints(Canvas canvas, RotatedTileBox tileBox, List<? extends OsmPoint> objects) {
|
||||||
int locationY = tileBox.getPixYFromLatNoRot(o.getLatitude());
|
for (OsmPoint o : objects) {
|
||||||
canvas.rotate(-view.getRotate(), locationX, locationY);
|
int locationX = tileBox.getPixXFromLonNoRot(o.getLongitude());
|
||||||
Bitmap b;
|
int locationY = tileBox.getPixYFromLatNoRot(o.getLatitude());
|
||||||
if (o.getGroup() == OsmPoint.Group.POI) {
|
canvas.rotate(-view.getRotate(), locationX, locationY);
|
||||||
b = poi;
|
Bitmap b;
|
||||||
} else if (o.getGroup() == OsmPoint.Group.BUG) {
|
if (o.getGroup() == OsmPoint.Group.POI) {
|
||||||
b = bug;
|
b = poi;
|
||||||
} else {
|
} else if (o.getGroup() == OsmPoint.Group.BUG) {
|
||||||
b = poi;
|
b = bug;
|
||||||
}
|
} else {
|
||||||
canvas.drawBitmap(b, locationX - b.getWidth() / 2, locationY - b.getHeight(), paintIcon);
|
b = poi;
|
||||||
canvas.rotate(view.getRotate(), locationX, locationY);
|
|
||||||
}
|
}
|
||||||
|
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 ey = (int) point.y;
|
||||||
int compare = getRadiusPoi(tileBox);
|
int compare = getRadiusPoi(tileBox);
|
||||||
int radius = compare * 3 / 2;
|
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 x = (int) tileBox.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
|
||||||
int y = (int) tileBox.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
|
int y = (int) tileBox.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
|
||||||
if (calculateBelongs(ex, ey, x, y, compare)) {
|
if (calculateBelongs(ex, ey, x, y, compare)) {
|
||||||
|
@ -117,6 +123,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
||||||
am.add(n);
|
am.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return compare;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {
|
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;
|
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
|
@Override
|
||||||
public String getObjectDescription(Object o) {
|
public String getObjectDescription(Object o) {
|
||||||
|
|
|
@ -20,8 +20,6 @@ public class UploadOpenstreetmapPointAsyncTask extends AsyncTask<OsmPoint, OsmPo
|
||||||
|
|
||||||
private OsmBugsRemoteUtil remotebug;
|
private OsmBugsRemoteUtil remotebug;
|
||||||
|
|
||||||
private OpenstreetmapsDbHelper dbpoi;
|
|
||||||
private OsmBugsDbHelper dbbug;
|
|
||||||
|
|
||||||
private int listSize = 0;
|
private int listSize = 0;
|
||||||
|
|
||||||
|
@ -29,15 +27,18 @@ public class UploadOpenstreetmapPointAsyncTask extends AsyncTask<OsmPoint, OsmPo
|
||||||
|
|
||||||
private Fragment ctx;
|
private Fragment ctx;
|
||||||
|
|
||||||
public UploadOpenstreetmapPointAsyncTask(ProgressDialog progress,Fragment ctx, OpenstreetmapRemoteUtil remotepoi, OsmBugsRemoteUtil remotebug,
|
private OsmEditingPlugin plugin;
|
||||||
|
|
||||||
|
public UploadOpenstreetmapPointAsyncTask(ProgressDialog progress,Fragment ctx,
|
||||||
|
OsmEditingPlugin plugin,
|
||||||
|
OpenstreetmapRemoteUtil remotepoi, OsmBugsRemoteUtil remotebug,
|
||||||
int listSize) {
|
int listSize) {
|
||||||
this.progress = progress;
|
this.progress = progress;
|
||||||
|
this.plugin = plugin;
|
||||||
this.remotepoi = remotepoi;
|
this.remotepoi = remotepoi;
|
||||||
this.remotebug = remotebug;
|
this.remotebug = remotebug;
|
||||||
this.listSize = listSize;
|
this.listSize = listSize;
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
dbpoi = new OpenstreetmapsDbHelper(ctx.getActivity());
|
|
||||||
dbbug = new OsmBugsDbHelper(ctx.getActivity());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,7 +57,8 @@ public class UploadOpenstreetmapPointAsyncTask extends AsyncTask<OsmPoint, OsmPo
|
||||||
}
|
}
|
||||||
Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, p.getComment(), false);
|
Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, p.getComment(), false);
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
dbpoi.deletePOI(p);
|
|
||||||
|
plugin.getDBPOI().deletePOI(p);
|
||||||
publishProgress(p);
|
publishProgress(p);
|
||||||
uploaded++;
|
uploaded++;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +73,7 @@ public class UploadOpenstreetmapPointAsyncTask extends AsyncTask<OsmPoint, OsmPo
|
||||||
success = remotebug.closingBug(p.getId(), p.getText(), p.getAuthor()) == null;
|
success = remotebug.closingBug(p.getId(), p.getText(), p.getAuthor()) == null;
|
||||||
}
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
dbbug.deleteAllBugModifications(p);
|
plugin.getDBBug().deleteAllBugModifications(p);
|
||||||
uploaded++;
|
uploaded++;
|
||||||
publishProgress(p);
|
publishProgress(p);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue