Merge branch 'master' of github.com:osmandapp/Osmand
This commit is contained in:
commit
bf060c12d9
17 changed files with 387 additions and 66 deletions
|
@ -2020,4 +2020,6 @@
|
|||
<string name="save_poi_without_poi_type_message">Gem IP uden at angive type?</string>
|
||||
<string name="poi_context_menu_modify_osm_change">Rediger OSM ændring</string>
|
||||
<string name="shared_string_location">Placering</string>
|
||||
<string name="context_menu_item_delete_waypoint">Slet GPX-rutepunkt?</string>
|
||||
<string name="context_menu_item_edit_waypoint">Rediger GPX-rutepunkt</string>
|
||||
</resources>
|
||||
|
|
|
@ -1388,4 +1388,66 @@
|
|||
<string name="poi_payment_credit_cards_no">Neprijíma kreditné karty</string>
|
||||
<string name="poi_traffic_calming_island">Ostrovček v ceste</string>
|
||||
<string name="poi_tourism_yes">Turistický objekt</string>
|
||||
<string name="poi_buoy_isolated_danger">Bója izolovaného nebezpečenstva</string>
|
||||
<string name="poi_seamark_light">Svetlo, námorná značka</string>
|
||||
<string name="poi_seamark_light_major">Významné svetlo, námorná značka</string>
|
||||
<string name="poi_seamark_light_minor">Druhoradé svetlo, námorná značka</string>
|
||||
<string name="poi_seamark_light_float">Plávajúce svetlo, námorná značka</string>
|
||||
<string name="poi_seamark_light_vessel">Svetlo plavidla, námorná značka</string>
|
||||
<string name="poi_notice">Upozornenie, námorná značka</string>
|
||||
<string name="poi_radar_transponder">Radarový vysielač, námorná značka</string>
|
||||
<string name="poi_debris">Trosky</string>
|
||||
<string name="poi_jersey_barrier">Skladacia bariéra</string>
|
||||
<string name="poi_animal_shelter">Prístrešok pre zvieratá</string>
|
||||
<string name="poi_payment_notes_yes">Prijíma bankovky</string>
|
||||
<string name="poi_payment_notes_no">Neprijíma bankovky</string>
|
||||
<string name="poi_payment_electronic_purses_yes">Prijíma elektronické peňaženky</string>
|
||||
<string name="poi_payment_electronic_purses_no">Neprijíma elektronické peňaženky</string>
|
||||
<string name="poi_payment_cash_yes">Prijíma hotovosť</string>
|
||||
<string name="poi_payment_cash_no">Neprijíma hotovosť</string>
|
||||
<string name="poi_payment_debit_cards_yes">Prijíma debetné karty</string>
|
||||
<string name="poi_payment_debit_cards_no">Neprijíma debetné karty</string>
|
||||
<string name="poi_payment_bitcoin_yes">Prijíma Bitcoin</string>
|
||||
<string name="poi_payment_bitcoin_no">Neprijíma Bitcoin</string>
|
||||
<string name="poi_payment_visa_yes">Prijíma Visa karty</string>
|
||||
<string name="poi_payment_visa_no">Neprijíma Visa karty</string>
|
||||
<string name="poi_payment_mastercard_yes">Prijíma MasterCard karty</string>
|
||||
<string name="poi_payment_mastercard_no">Neprijíma MasterCard karty</string>
|
||||
<string name="poi_payment_none">Bez poplatku</string>
|
||||
<string name="poi_payment_account_cards_yes">Prijíma účtové karty</string>
|
||||
<string name="poi_payment_account_cards_no">Neprijíma účtové karty</string>
|
||||
<string name="poi_payment_maestro_yes">Prijíma Maestro karty</string>
|
||||
<string name="poi_payment_maestro_no">Neprijíma Maestro karty</string>
|
||||
<string name="poi_payment_american_express_yes">Prijíma American Express (AMEX) karty</string>
|
||||
<string name="poi_payment_american_express_no">Neprijíma American Express (AMEX) karty</string>
|
||||
<string name="poi_payment_diners_club_yes">Prijíma Diners Club karty</string>
|
||||
<string name="poi_payment_diners_club_no">Neprijíma Diners Club karty</string>
|
||||
<string name="poi_payment_dkv_yes">Prijíma DKV</string>
|
||||
<string name="poi_payment_dkv_no">Neprijíma DKV</string>
|
||||
<string name="poi_payment_uta_yes">Prijíma UTA karty</string>
|
||||
<string name="poi_payment_uta_no">Neprijíma UTA karty</string>
|
||||
<string name="poi_payment_efectivo_yes">Prijíma Efectivo</string>
|
||||
<string name="poi_payment_efectivo_no">Neprijíma Efectivo</string>
|
||||
<string name="poi_payment_girocard_yes">Prijíma Girocard</string>
|
||||
<string name="poi_payment_girocard_no">Neprijíma Girocard</string>
|
||||
<string name="poi_payment_discover_card_yes">Prijíma Discover karty</string>
|
||||
<string name="poi_payment_discover_card_no">Neprijíma Discover karty</string>
|
||||
<string name="poi_payment_visa_electron_yes">Prijíma Visa Electron karty</string>
|
||||
<string name="poi_payment_visa_electron_no">Neprijíma Visa Electron karty</string>
|
||||
<string name="poi_payment_litecoin_yes">Prijíma Litecoin</string>
|
||||
<string name="poi_payment_litecoin_no">Neprijíma Litecoin</string>
|
||||
<string name="poi_payment_cheque_yes">Prijíma šeky</string>
|
||||
<string name="poi_payment_cheque_no">Neprijíma šeky</string>
|
||||
<string name="poi_payment_pikepass_yes">Prijíma PIKEPASS</string>
|
||||
<string name="poi_payment_pikepass_no">Neprijíma PIKEPASS</string>
|
||||
<string name="poi_payment_pikepass_designated">Prijíma PIKEPASS (designated)</string>
|
||||
<string name="poi_payment_visa_debit_yes">Prijíma Visa debetné karty</string>
|
||||
<string name="poi_payment_visa_debit_no">Neprijíma Visa debetné karty</string>
|
||||
<string name="poi_payment_cryptocurrencies_no">Neprijíma kryptomeny</string>
|
||||
<string name="poi_payment_others_yes">Prijíma iné spôsoby platby</string>
|
||||
<string name="poi_payment_others_no">Neprijíma iné spôsoby platby</string>
|
||||
<string name="poi_payment_routex_yes">Prijíma Routex palivové karty</string>
|
||||
<string name="poi_payment_routex_no">Neprijíma Routex palivové karty</string>
|
||||
<string name="poi_payment_bancomat_yes">Prijíma Bancomat</string>
|
||||
<string name="poi_payment_bancomat_no">Prijíma Bancomat</string>
|
||||
</resources>
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
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
|
||||
-->
|
||||
<string name="context_menu_item_delete_waypoint">Delete GPX waypoint?</string>
|
||||
<string name="context_menu_item_edit_waypoint">Edit GPX waypoint</string>
|
||||
<string name="shared_string_location">Location</string>
|
||||
<string name="share_osm_edits_subject">Osm Edits shared via OsmAnd</string>
|
||||
<string name="lang_nds">Low German</string>
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.graphics.Color;
|
|||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -581,7 +582,7 @@ public class GPXUtilities {
|
|||
return g ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean hasRtePt() {
|
||||
for(Route r : routes) {
|
||||
if(r.points.size() > 0) {
|
||||
|
@ -605,7 +606,23 @@ public class GPXUtilities {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void updateWptPt(WptPt pt, double lat, double lon, long time, String description, String name, String category, int color) {
|
||||
pt.lat = lat;
|
||||
pt.lon = lon;
|
||||
pt.time = time;
|
||||
pt.desc = description;
|
||||
pt.name = name;
|
||||
pt.category = category;
|
||||
if (color != 0) {
|
||||
pt.setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean deleteWptPt(WptPt pt) {
|
||||
return points.remove(pt);
|
||||
}
|
||||
|
||||
public List<TrkSegment> processRoutePoints() {
|
||||
List<TrkSegment> tpoints = new ArrayList<TrkSegment>();
|
||||
if (routes.size() > 0) {
|
||||
|
|
|
@ -52,7 +52,19 @@ public class GpxSelectionHelper {
|
|||
public List<SelectedGpxFile> getSelectedGPXFiles() {
|
||||
return selectedGPXFiles;
|
||||
}
|
||||
|
||||
|
||||
public SelectedGpxFile getSelectedGPXFile(WptPt point) {
|
||||
for (SelectedGpxFile g : selectedGPXFiles) {
|
||||
List<WptPt> pts = g.getGpxFile().points;
|
||||
for (WptPt n : pts) {
|
||||
if (n == point) {
|
||||
return g;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final String getString(int resId, Object... formatArgs) {
|
||||
return app.getString(resId, formatArgs);
|
||||
}
|
||||
|
|
|
@ -200,7 +200,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
double longitude = args.getDouble(KEY_LONGITUDE);
|
||||
String name = editText.getText().toString();
|
||||
SavingTrackHelper savingTrackHelper = mapActivity.getMyApplication().getSavingTrackHelper();
|
||||
savingTrackHelper.insertPointData(latitude, longitude, System.currentTimeMillis(), null, name, null);
|
||||
savingTrackHelper.insertPointData(latitude, longitude, System.currentTimeMillis(), null, name, null, 0);
|
||||
AccessibleToast.makeText(mapActivity, MessageFormat.format(getString(R.string.add_waypoint_dialog_added), name), Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
dialog.dismiss();
|
||||
|
|
|
@ -33,7 +33,7 @@ import android.text.format.DateFormat;
|
|||
public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||
|
||||
public final static String DATABASE_NAME = "tracks"; //$NON-NLS-1$
|
||||
public final static int DATABASE_VERSION = 4;
|
||||
public final static int DATABASE_VERSION = 5;
|
||||
|
||||
public final static String TRACK_NAME = "track"; //$NON-NLS-1$
|
||||
public final static String TRACK_COL_DATE = "date"; //$NON-NLS-1$
|
||||
|
@ -50,12 +50,13 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
public final static String POINT_COL_NAME = "pname"; //$NON-NLS-1$
|
||||
public final static String POINT_COL_CATEGORY = "category"; //$NON-NLS-1$
|
||||
public final static String POINT_COL_DESCRIPTION = "description"; //$NON-NLS-1$
|
||||
public final static String POINT_COL_COLOR = "color"; //$NON-NLS-1$
|
||||
|
||||
public final static Log log = PlatformUtil.getLog(SavingTrackHelper.class);
|
||||
|
||||
private String updateScript;
|
||||
private String updatePointsScript;
|
||||
|
||||
private String insertPointsScript;
|
||||
|
||||
private long lastTimeUpdated = 0;
|
||||
private final OsmandApplication ctx;
|
||||
|
||||
|
@ -73,10 +74,12 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
gx.showCurrentTrack = true;
|
||||
this.currentTrack.setGpxFile(gx);
|
||||
prepareCurrentTrackForRecording();
|
||||
|
||||
updateScript = "INSERT INTO " + TRACK_NAME + " (" + TRACK_COL_LAT + ", " + TRACK_COL_LON + ", "
|
||||
+ TRACK_COL_ALTITUDE + ", " + TRACK_COL_SPEED + ", " + TRACK_COL_HDOP + ", " + TRACK_COL_DATE + ")"
|
||||
+ " VALUES (?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
updatePointsScript = "INSERT INTO " + POINT_NAME + " VALUES (?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
insertPointsScript = "INSERT INTO " + POINT_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,15 +89,16 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
}
|
||||
|
||||
private void createTableForTrack(SQLiteDatabase db){
|
||||
db.execSQL("CREATE TABLE " + TRACK_NAME+ " ("+TRACK_COL_LAT +" double, " + TRACK_COL_LON+" double, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ TRACK_COL_ALTITUDE+" double, " + TRACK_COL_SPEED+" double, " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ TRACK_COL_HDOP +" double, " + TRACK_COL_DATE +" long )" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
db.execSQL("CREATE TABLE " + TRACK_NAME + " (" + TRACK_COL_LAT + " double, " + TRACK_COL_LON + " double, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ TRACK_COL_ALTITUDE + " double, " + TRACK_COL_SPEED + " double, " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ TRACK_COL_HDOP + " double, " + TRACK_COL_DATE + " long )"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
private void createTableForPoints(SQLiteDatabase db){
|
||||
try {
|
||||
db.execSQL("CREATE TABLE " + POINT_NAME + " (" + POINT_COL_LAT + " double, " + POINT_COL_LON + " double, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ POINT_COL_DATE + " long, " + POINT_COL_DESCRIPTION + " text, " + POINT_COL_NAME + " text, " + POINT_COL_CATEGORY + " text" + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ POINT_COL_DATE + " long, " + POINT_COL_DESCRIPTION + " text, " + POINT_COL_NAME + " text, "
|
||||
+ POINT_COL_CATEGORY + " text, " + POINT_COL_COLOR + " long" + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} catch (RuntimeException e) {
|
||||
// ignore if already exists
|
||||
}
|
||||
|
@ -112,6 +116,9 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_NAME + " text");
|
||||
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_CATEGORY + " text");
|
||||
}
|
||||
if(oldVersion < 5){
|
||||
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_COLOR + " long");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,7 +128,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
SQLiteDatabase db = getWritableDatabase();
|
||||
if (db != null) {
|
||||
try {
|
||||
Cursor query = db.rawQuery("SELECT " + TRACK_COL_DATE + " FROM " + TRACK_NAME+" ORDER BY " + TRACK_COL_DATE +" DESC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
Cursor query = db.rawQuery("SELECT " + TRACK_COL_DATE + " FROM " + TRACK_NAME + " ORDER BY " + TRACK_COL_DATE + " DESC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
if(query.moveToFirst()) {
|
||||
res = query.getLong(0);
|
||||
}
|
||||
|
@ -243,7 +250,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
|
||||
private void collectDBPoints(SQLiteDatabase db, Map<String, GPXFile> dataTracks) {
|
||||
Cursor query = db.rawQuery("SELECT " + POINT_COL_LAT + "," + POINT_COL_LON + "," + POINT_COL_DATE + "," //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ POINT_COL_DESCRIPTION + "," + POINT_COL_NAME + "," + POINT_COL_CATEGORY + " FROM " + POINT_NAME+" ORDER BY " + POINT_COL_DATE +" ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ POINT_COL_DESCRIPTION + "," + POINT_COL_NAME + "," + POINT_COL_CATEGORY + "," + POINT_COL_COLOR + " FROM " + POINT_NAME+" ORDER BY " + POINT_COL_DATE +" ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
if (query.moveToFirst()) {
|
||||
do {
|
||||
WptPt pt = new WptPt();
|
||||
|
@ -254,6 +261,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
pt.desc = query.getString(3);
|
||||
pt.name = query.getString(4);
|
||||
pt.category = query.getString(5);
|
||||
int color = query.getInt(6);
|
||||
if (color != 0) {
|
||||
pt.setColor(color);
|
||||
}
|
||||
|
||||
// check if name is extension (needed for audio/video plugin & josm integration)
|
||||
if(pt.name != null && pt.name.length() > 4 && pt.name.charAt(pt.name.length() - 4) == '.') {
|
||||
|
@ -334,7 +345,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
lastTimeUpdated = 0;
|
||||
lastPoint = null;
|
||||
execWithClose(updateScript, new Object[] { 0, 0, 0, 0, 0, System.currentTimeMillis()});
|
||||
addTrackPoint( null, true, System.currentTimeMillis());
|
||||
addTrackPoint(null, true, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public void updateLocation(net.osmand.Location location) {
|
||||
|
@ -403,17 +414,126 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
currentTrack.getModifiableGpxFile().modifiedTime = time;
|
||||
}
|
||||
|
||||
public void insertPointData(double lat, double lon, long time, String description, String name, String category) {
|
||||
public WptPt insertPointData(double lat, double lon, long time, String description, String name, String category, int color) {
|
||||
final WptPt pt = new WptPt(lat, lon, time, Double.NaN, 0, Double.NaN);
|
||||
pt.name = name;
|
||||
pt.category = category;
|
||||
pt.desc = description;
|
||||
if (color != 0) {
|
||||
pt.setColor(color);
|
||||
}
|
||||
currentTrack.getModifiableGpxFile().points.add(pt);
|
||||
currentTrack.getModifiableGpxFile().modifiedTime = time;
|
||||
points++;
|
||||
execWithClose(updatePointsScript, new Object[] { lat, lon, time, description, name, category });
|
||||
execWithClose(insertPointsScript, new Object[] { lat, lon, time, description, name, category, color });
|
||||
return pt;
|
||||
}
|
||||
|
||||
|
||||
public void updatePointData(WptPt pt, double lat, double lon, long time, String description, String name, String category, int color) {
|
||||
currentTrack.getModifiableGpxFile().modifiedTime = time;
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(lat);
|
||||
params.add(lon);
|
||||
params.add(time);
|
||||
params.add(description);
|
||||
params.add(name);
|
||||
params.add(category);
|
||||
params.add(color);
|
||||
|
||||
params.add(pt.getLatitude());
|
||||
params.add(pt.getLongitude());
|
||||
params.add(pt.time);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String prefix = "UPDATE " + POINT_NAME
|
||||
+ " SET "
|
||||
+ POINT_COL_LAT + "=?, "
|
||||
+ POINT_COL_LON + "=?, "
|
||||
+ POINT_COL_DATE + "=?, "
|
||||
+ POINT_COL_DESCRIPTION + "=?, "
|
||||
+ POINT_COL_NAME + "=?, "
|
||||
+ POINT_COL_CATEGORY + "=?, "
|
||||
+ POINT_COL_COLOR + "=? "
|
||||
+ "WHERE "
|
||||
+ POINT_COL_LAT + "=? AND "
|
||||
+ POINT_COL_LON + "=? AND "
|
||||
+ POINT_COL_DATE + "=?";
|
||||
|
||||
sb.append(prefix);
|
||||
if (pt.desc != null) {
|
||||
sb.append(" AND ").append(POINT_COL_DESCRIPTION).append("=?");
|
||||
params.add(pt.desc);
|
||||
} else {
|
||||
sb.append(" AND ").append(POINT_COL_DESCRIPTION).append(" IS NULL");
|
||||
}
|
||||
if (pt.name != null) {
|
||||
sb.append(" AND ").append(POINT_COL_NAME).append("=?");
|
||||
params.add(pt.name);
|
||||
} else {
|
||||
sb.append(" AND ").append(POINT_COL_NAME).append(" IS NULL");
|
||||
}
|
||||
if (pt.category != null) {
|
||||
sb.append(" AND ").append(POINT_COL_CATEGORY).append("=?");
|
||||
params.add(pt.category);
|
||||
} else {
|
||||
sb.append(" AND ").append(POINT_COL_CATEGORY).append(" IS NULL");
|
||||
}
|
||||
|
||||
execWithClose(sb.toString(), params.toArray());
|
||||
|
||||
pt.lat = lat;
|
||||
pt.lon = lon;
|
||||
pt.time = time;
|
||||
pt.desc = description;
|
||||
pt.name = name;
|
||||
pt.category = category;
|
||||
if (color != 0) {
|
||||
pt.setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
public void deletePointData(WptPt pt) {
|
||||
currentTrack.getModifiableGpxFile().points.remove(pt);
|
||||
currentTrack.getModifiableGpxFile().modifiedTime = System.currentTimeMillis();
|
||||
points--;
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(pt.getLatitude());
|
||||
params.add(pt.getLongitude());
|
||||
params.add(pt.time);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String prefix = "DELETE FROM "
|
||||
+ POINT_NAME
|
||||
+ " WHERE "
|
||||
+ POINT_COL_LAT + "=? AND "
|
||||
+ POINT_COL_LON + "=? AND "
|
||||
+ POINT_COL_DATE + "=?";
|
||||
|
||||
sb.append(prefix);
|
||||
if (pt.desc != null) {
|
||||
sb.append(" AND ").append(POINT_COL_DESCRIPTION).append("=?");
|
||||
params.add(pt.desc);
|
||||
} else {
|
||||
sb.append(" AND ").append(POINT_COL_DESCRIPTION).append(" IS NULL");
|
||||
}
|
||||
if (pt.name != null) {
|
||||
sb.append(" AND ").append(POINT_COL_NAME).append("=?");
|
||||
params.add(pt.name);
|
||||
} else {
|
||||
sb.append(" AND ").append(POINT_COL_NAME).append(" IS NULL");
|
||||
}
|
||||
if (pt.category != null) {
|
||||
sb.append(" AND ").append(POINT_COL_CATEGORY).append("=?");
|
||||
params.add(pt.category);
|
||||
} else {
|
||||
sb.append(" AND ").append(POINT_COL_CATEGORY).append(" IS NULL");
|
||||
}
|
||||
|
||||
execWithClose(sb.toString(), params.toArray());
|
||||
}
|
||||
|
||||
private synchronized void execWithClose(String script, Object[] objects) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
try {
|
||||
|
|
|
@ -1168,7 +1168,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
&& OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
|
||||
String name = f.getName();
|
||||
SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
|
||||
savingTrackHelper.insertPointData(rec.lat, rec.lon, System.currentTimeMillis(), null, name, null);
|
||||
savingTrackHelper.insertPointData(rec.lat, rec.lon, System.currentTimeMillis(), null, name, null, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -203,6 +203,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
originalGPX = null;
|
||||
measurementPoints.clear();
|
||||
calculateDistance();
|
||||
activity.getContextMenu().close();
|
||||
} else if (id == R.string.shared_string_save_as_gpx) {
|
||||
saveGpx(activity);
|
||||
} else if (id == R.string.distance_measurement_load_gpx) {
|
||||
|
@ -637,25 +638,40 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
public void populateObjectContextMenu(Object o, ContextMenuAdapter adapter) {
|
||||
if(o instanceof WptPt) {
|
||||
final WptPt p = (WptPt) o;
|
||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
if (itemId == R.string.delete_point) {
|
||||
for (int i = 0; i < measurementPoints.size(); i++) {
|
||||
Iterator<WptPt> it = measurementPoints.get(i).iterator();
|
||||
while (it.hasNext()) {
|
||||
if (it.next() == p) {
|
||||
it.remove();
|
||||
boolean containsPoint = false;
|
||||
for (int i = 0; i < measurementPoints.size(); i++) {
|
||||
Iterator<WptPt> it = measurementPoints.get(i).iterator();
|
||||
while (it.hasNext()) {
|
||||
if (it.next() == p) {
|
||||
containsPoint = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (containsPoint) {
|
||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
if (itemId == R.string.delete_point) {
|
||||
for (int i = 0; i < measurementPoints.size(); i++) {
|
||||
Iterator<WptPt> it = measurementPoints.get(i).iterator();
|
||||
while (it.hasNext()) {
|
||||
if (it.next() == p) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
calculateDistance();
|
||||
if (adapter.getContext() instanceof MapActivity) {
|
||||
((MapActivity)adapter.getContext()).getContextMenu().close();
|
||||
}
|
||||
}
|
||||
calculateDistance();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.delete_point).iconColor(R.drawable.ic_action_delete_dark).listen(listener).reg();
|
||||
};
|
||||
adapter.item(R.string.delete_point).iconColor(R.drawable.ic_action_delete_dark).listen(listener).reg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -240,7 +240,10 @@ public class GpxUiHelper {
|
|||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
// User super class to create the View
|
||||
View v = activity.getLayoutInflater().inflate(layout, null);
|
||||
View v = convertView;
|
||||
if (v == null) {
|
||||
v = activity.getLayoutInflater().inflate(layout, null);
|
||||
}
|
||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
icon.setImageDrawable(adapter.getImage(app, position, light));
|
||||
final ArrayAdapter<String> arrayAdapter = this;
|
||||
|
|
|
@ -212,7 +212,7 @@ public class MapContextMenu extends MenuTitleController {
|
|||
mapActivity.getMapView().setMapPosition(0);
|
||||
}
|
||||
|
||||
mapActivity.getMapView().refreshMap();
|
||||
mapActivity.refreshMap();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -246,12 +246,14 @@ public class MapContextMenu extends MenuTitleController {
|
|||
}
|
||||
|
||||
public void close() {
|
||||
active = false;
|
||||
if (this.object != null) {
|
||||
clearSelectedObject(this.object);
|
||||
if (active) {
|
||||
active = false;
|
||||
if (this.object != null) {
|
||||
clearSelectedObject(this.object);
|
||||
}
|
||||
hide();
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
hide();
|
||||
mapActivity.getMapView().refreshMap();
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
|
|
|
@ -145,7 +145,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
} else {
|
||||
helper.editFavouriteName(favorite, name, category, description);
|
||||
}
|
||||
getMapActivity().getMapView().refreshMap(true);
|
||||
getMapActivity().refreshMap();
|
||||
if (needDismiss) {
|
||||
dismiss(false);
|
||||
}
|
||||
|
@ -173,10 +173,12 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
helper.deleteFavourite(favorite);
|
||||
saved = true;
|
||||
if (needDismiss) {
|
||||
dismiss(true);
|
||||
} else {
|
||||
getMapActivity().refreshMap();
|
||||
}
|
||||
getMapActivity().getMapView().refreshMap(true);
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.osmand.plus.mapcontextmenu.editors;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
|
|
@ -288,7 +288,6 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
|
||||
public void dismiss(boolean includingMenu) {
|
||||
if (includingMenu) {
|
||||
//getMapActivity().getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
getMapActivity().getSupportFragmentManager().popBackStack();
|
||||
getMapActivity().getContextMenu().close();
|
||||
} else {
|
||||
|
@ -320,7 +319,7 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
public String getCategoryTextValue() {
|
||||
AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
|
||||
String name = categoryEdit.getText().toString().trim();
|
||||
return name.equals(getString(R.string.shared_string_favorites)) ? "" : name;
|
||||
return name.equals(getDefaultCategoryName()) ? "" : name;
|
||||
}
|
||||
|
||||
public String getDescriptionTextValue() {
|
||||
|
|
|
@ -4,10 +4,17 @@ import android.app.Activity;
|
|||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
|
@ -15,18 +22,23 @@ import net.osmand.plus.base.FavoriteImageDrawable;
|
|||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class WptPtEditorFragment extends PointEditorFragment {
|
||||
private WptPtEditor editor;
|
||||
private WptPt wpt;
|
||||
private SavingTrackHelper helper;
|
||||
private SavingTrackHelper savingTrackHelper;
|
||||
private GpxSelectionHelper selectedGpxHelper;
|
||||
private SelectedGpxFile selectedGpxFile;
|
||||
|
||||
private boolean saved;
|
||||
private int defaultColor;
|
||||
private int color;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
helper = getMapActivity().getMyApplication().getSavingTrackHelper();
|
||||
savingTrackHelper = getMapActivity().getMyApplication().getSavingTrackHelper();
|
||||
selectedGpxHelper = getMapActivity().getMyApplication().getSelectedGpxHelper();
|
||||
editor = getMapActivity().getContextMenu().getWptPtPointEditor();
|
||||
}
|
||||
|
||||
|
@ -34,9 +46,10 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
defaultColor = getResources().getColor(R.color.gpx_color_point);
|
||||
|
||||
wpt = editor.getWptPt();
|
||||
selectedGpxFile = selectedGpxHelper.getSelectedGPXFile(wpt);
|
||||
int defaultColor = getResources().getColor(R.color.gpx_color_point);
|
||||
color = wpt.getColor(defaultColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,9 +91,9 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
if (editor.isNew()) {
|
||||
doAddWpt(name, category, description);
|
||||
} else {
|
||||
//todo save wpt
|
||||
doUpdateWpt(name, category, description);
|
||||
}
|
||||
getMapActivity().getMapView().refreshMap(true);
|
||||
getMapActivity().refreshMap();
|
||||
if (needDismiss) {
|
||||
dismiss(false);
|
||||
}
|
||||
|
@ -98,27 +111,70 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
wpt.name = name;
|
||||
wpt.category = category;
|
||||
wpt.desc = description;
|
||||
helper.insertPointData(wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), description, name, category);
|
||||
if (color != 0) {
|
||||
wpt.setColor(color);
|
||||
}
|
||||
wpt = savingTrackHelper.insertPointData(wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), description, name, category, color);
|
||||
}
|
||||
|
||||
private boolean isCurrentTrack() {
|
||||
return selectedGpxFile != null && selectedGpxFile.isShowCurrentTrack();
|
||||
}
|
||||
|
||||
private void doUpdateWpt(String name, String category, String description) {
|
||||
if (isCurrentTrack()) {
|
||||
savingTrackHelper.updatePointData(wpt, wpt.getLatitude(), wpt.getLongitude(),
|
||||
System.currentTimeMillis(), description, name, category, color);
|
||||
} else if (selectedGpxFile != null) {
|
||||
GPXFile gpx = selectedGpxFile.getModifiableGpxFile();
|
||||
gpx.updateWptPt(wpt, wpt.getLatitude(), wpt.getLongitude(),
|
||||
System.currentTimeMillis(), description, name, category, color);
|
||||
new SaveGpxAsyncTask(getMyApplication(), gpx).execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void delete(final boolean needDismiss) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(getString(R.string.favourites_remove_dialog_msg, wpt.name));
|
||||
builder.setMessage(getString(R.string.context_menu_item_delete_waypoint));
|
||||
builder.setNegativeButton(R.string.shared_string_no, null);
|
||||
builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
//helper.deleteFavourite(wpt); todo delete wpt
|
||||
|
||||
if (isCurrentTrack()) {
|
||||
savingTrackHelper.deletePointData(wpt);
|
||||
} else {
|
||||
GPXFile gpx = selectedGpxFile.getModifiableGpxFile();
|
||||
gpx.deleteWptPt(wpt);
|
||||
new SaveGpxAsyncTask(getMyApplication(), gpx).execute();
|
||||
}
|
||||
saved = true;
|
||||
|
||||
if (needDismiss) {
|
||||
dismiss(true);
|
||||
} else {
|
||||
getMapActivity().refreshMap();
|
||||
}
|
||||
getMapActivity().getMapView().refreshMap(true);
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategory(String name) {
|
||||
FavoriteGroup group = getMyApplication().getFavorites().getGroup(name);
|
||||
if (group != null) {
|
||||
color = group.color;
|
||||
}
|
||||
super.setCategory(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultCategoryName() {
|
||||
return getString(R.string.shared_string_favorites);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeaderCaption() {
|
||||
return getMapActivity().getResources().getString(R.string.gpx_wpt);
|
||||
|
@ -141,13 +197,28 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
|
||||
@Override
|
||||
public Drawable getNameIcon() {
|
||||
int color = wpt.getColor(defaultColor);
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity(), color, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getCategoryIcon() {
|
||||
int color = wpt.getColor(defaultColor);
|
||||
return getPaintedIcon(R.drawable.ic_action_folder_stroke, color);
|
||||
}
|
||||
|
||||
private static class SaveGpxAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private final OsmandApplication app;
|
||||
private final GPXFile gpx;
|
||||
|
||||
public SaveGpxAsyncTask(OsmandApplication app, GPXFile gpx) {
|
||||
this.app = app;
|
||||
this.gpx = gpx;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
GPXUtilities.writeGpxFile(new File(gpx.path), gpx, app);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.osmand.ValueHolder;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.NavigationService;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmAndTaskManager.OsmAndTaskRunnable;
|
||||
|
@ -133,12 +134,21 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) {
|
||||
if (resId == R.string.context_menu_item_add_waypoint) {
|
||||
mapActivity.getContextMenu().addWptPt();
|
||||
} else if (resId == R.string.context_menu_item_edit_waypoint) {
|
||||
mapActivity.getContextMenu().editWptPt();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.context_menu_item_add_waypoint).iconColor(R.drawable.ic_action_gnew_label_dark)
|
||||
.listen(listener).reg();
|
||||
.listen(listener).reg();
|
||||
if (selectedObj instanceof WptPt) {
|
||||
WptPt pt = (WptPt) selectedObj;
|
||||
if (app.getSelectedGpxHelper().getSelectedGPXFile(pt) != null) {
|
||||
adapter.item(R.string.context_menu_item_edit_waypoint).iconColor(R.drawable.ic_action_edit_dark)
|
||||
.listen(listener).reg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final int[] SECONDS = new int[] {0, 1, 2, 3, 5, 10, 15, 30, 60, 90};
|
||||
|
|
|
@ -83,18 +83,22 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
public boolean isVisible() {
|
||||
return menu.isActive();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings nightMode) {
|
||||
if(menu.isActive()) {
|
||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||
if (menu.isActive()) {
|
||||
LatLon latLon = menu.getLatLon();
|
||||
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
int x = (int) tileBox.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
int y = (int) tileBox.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
canvas.translate(x - contextMarker.getWidth() / 2, y - contextMarker.getHeight());
|
||||
contextMarker.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings nightMode) {
|
||||
}
|
||||
|
||||
|
||||
public void setSelectOnMap(CallbackWithObject<LatLon> selectOnMap) {
|
||||
this.selectOnMap = selectOnMap;
|
||||
|
|
Loading…
Reference in a new issue