Fix #7694 dismiss the recorded track without saving.

This commit is contained in:
Dima-1 2020-02-11 15:17:26 +02:00
parent e59e235c6d
commit ebc25edaed
3 changed files with 16 additions and 13 deletions

View file

@ -11,7 +11,8 @@
Thx - Hardy
-->
<string name="release_3_6">
<string name="clear_recorded_data">Clear recorded data</string>
<string name="release_3_6">
• Profiles: now you can change order, set icon for map, change all setting for base profiles and restore them back to defaults\n\n
• Added exit number in the navigation\n\n
• Reworked plugin settings\n\n

View file

@ -247,18 +247,18 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
}
}
}
clearRecordedData(warnings.isEmpty());
return new SaveGpxResult(warnings, filenames);
}
if (warnings.isEmpty()) {
public void clearRecordedData(boolean isWarningEmpty) {
if (isWarningEmpty) {
SQLiteDatabase db = getWritableDatabase();
if (db != null) {
try {
if (db.isOpen()) {
// remove all from db
db.execSQL("DELETE FROM " + TRACK_NAME + " WHERE " + TRACK_COL_DATE + " <= ?", new Object[]{System.currentTimeMillis()}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
db.execSQL("DELETE FROM " + POINT_NAME + " WHERE " + POINT_COL_DATE + " <= ?", new Object[]{System.currentTimeMillis()}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// delete all
// db.execSQL("DELETE FROM " + TRACK_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$
// db.execSQL("DELETE FROM " + POINT_NAME + " WHERE 1 = 1", new Object[] { }); //$NON-NLS-1$ //$NON-NLS-2$
}
} finally {
db.close();
@ -274,7 +274,6 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
currentTrack.getModifiablePointsToDisplay().clear();
currentTrack.getModifiableGpxFile().modifiedTime = System.currentTimeMillis();
prepareCurrentTrackForRecording();
return new SaveGpxResult(warnings, filenames);
}
public Map<String, GPXFile> collectRecordedData() {

View file

@ -310,6 +310,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
}
if (app.getSavingTrackHelper().hasDataToSave()) {
items.add(R.string.save_current_track);
items.add(R.string.clear_recorded_data);
}
String[] strings = new String[items.size()];
for (int i = 0; i < strings.length; i++) {
@ -326,6 +327,8 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
if (app.getLocationProvider().checkGPSEnabled(activity)) {
startGPXMonitoring(activity, showTrackSelection);
}
} else if (item == R.string.clear_recorded_data) {
app.getSavingTrackHelper().clearRecordedData(true);
} else if(item == R.string.gpx_monitoring_stop) {
stopRecording();
} else if(item == R.string.gpx_start_new_segment) {
@ -338,12 +341,12 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
showIntervalChooseDialog(activity, app.getString(R.string.live_monitoring_interval) + " : %s",
app.getString(R.string.save_track_to_gpx_globally), SECONDS, MINUTES,
null, vs, showTrackSelection, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
settings.LIVE_MONITORING_INTERVAL.set(vs.value);
settings.LIVE_MONITORING.set(true);
}
});
@Override
public void onClick(DialogInterface dialog, int which) {
settings.LIVE_MONITORING_INTERVAL.set(vs.value);
settings.LIVE_MONITORING.set(true);
}
});
}
if (monitoringControl != null) {
monitoringControl.updateInfo(null);