Add settings for #3158

This commit is contained in:
Victor Shcherb 2016-10-19 23:28:11 +02:00
parent 1275f85fb5
commit bd53399f53
3 changed files with 35 additions and 2 deletions

View file

@ -547,7 +547,7 @@ public class SearchCoreFactory {
res.objectType = ObjectType.POI_TYPE;
resultMatcher.publish(res);
}
for(int i =0 ; i< customPoiFilters.size(); i++) {
for (int i = 0; i < customPoiFilters.size(); i++) {
CustomSearchPoiFilter csf = customPoiFilters.get(i);
int p = customPoiFiltersPriorites.get(i);
if (!phrase.isUnknownSearchWordPresent() || nm.matches(csf.getName())) {

View file

@ -1053,6 +1053,26 @@ public class OsmandSettings {
SAVE_TRACK_INTERVAL.setModeDefaultValue(ApplicationMode.BICYCLE, 7000);
SAVE_TRACK_INTERVAL.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 10000);
}
public final CommonPreference<Integer> SAVE_TRACK_PRECISION = new IntPreference("save_track_precision", 0).makeProfile();
{
// SAVE_TRACK_PRECISION.setModeDefaultValue(ApplicationMode.CAR, 50);
// SAVE_TRACK_PRECISION.setModeDefaultValue(ApplicationMode.BICYCLE, 50);
// SAVE_TRACK_PRECISION.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 50);
}
public final CommonPreference<Float> SAVE_TRACK_MIN_SPEED = new FloatPreference("save_track_min_speed", 0.f).makeProfile();
{
// SAVE_TRACK_MIN_SPEED.setModeDefaultValue(ApplicationMode.CAR, 1.f);
// SAVE_TRACK_MIN_SPEED.setModeDefaultValue(ApplicationMode.BICYCLE, 1.f);
// SAVE_TRACK_MIN_SPEED.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 0.f);
}
public final CommonPreference<Integer> SAVE_TRACK_MIN_DISTANCE = new IntPreference("save_track_min_distance", 5).makeProfile();
{
// SAVE_TRACK_MIN_DISTANCE.setModeDefaultValue(ApplicationMode.CAR, 5);
// SAVE_TRACK_MIN_DISTANCE.setModeDefaultValue(ApplicationMode.BICYCLE, 5);
// SAVE_TRACK_MIN_DISTANCE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 5);
}
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Boolean> LIVE_MONITORING = new BooleanPreference("live_monitoring", false).makeGlobal();

View file

@ -4,7 +4,6 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.text.format.DateFormat;
import net.osmand.PlatformUtil;
import net.osmand.data.LatLon;
import net.osmand.plus.GPXUtilities;
@ -19,6 +18,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.util.MapUtils;
import org.apache.commons.logging.Log;
@ -365,6 +365,19 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
&& locationTime - lastTimeUpdated > settings.SAVE_GLOBAL_TRACK_INTERVAL.get()) {
record = true;
}
int minDistance = settings.SAVE_TRACK_MIN_DISTANCE.get();
if(minDistance > 0 && lastPoint != null && MapUtils.getDistance(lastPoint, location.getLatitude(), location.getLongitude()) <
minDistance) {
record = false;
}
int precision = settings.SAVE_TRACK_PRECISION.get();
if(precision > 0 && (!location.hasAccuracy() || location.getAccuracy() < precision)) {
record = false;
}
int minSpeed = settings.SAVE_TRACK_MIN_SPEED.get();
if(minSpeed > 0 && (!location.hasSpeed() || location.getSpeed() < minSpeed)) {
record = false;
}
}
}
if (record) {