Add support for showing current track
This commit is contained in:
parent
d81f8af243
commit
fd1b3c0abf
15 changed files with 137 additions and 47 deletions
|
@ -12,7 +12,7 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:b
|
||||||
android:layout_marginLeft="3dp" android:layout_marginTop="3dp"
|
android:layout_marginLeft="3dp" android:layout_marginTop="3dp"
|
||||||
android:text="@string/app_name" android:textColor="#000000" android:typeface="serif" android:textSize="20sp"/>
|
android:text="@string/app_name" android:textColor="#000000" android:typeface="serif" android:textSize="20sp"/>
|
||||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1"
|
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1"
|
||||||
android:layout_marginLeft="12dp" android:layout_marginTop="3dp" android:layout_marginBottom="3dp" android:text="0.5.1 beta(b6)" android:gravity="right"
|
android:layout_marginLeft="12dp" android:layout_marginTop="3dp" android:layout_marginBottom="3dp" android:text="@string/app_version" android:gravity="right"
|
||||||
android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion" android:textSize="13sp"/>
|
android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion" android:textSize="13sp"/>
|
||||||
<ImageView android:src="@drawable/help_icon" android:id="@+id/HelpButton" android:layout_marginTop="7dp"
|
<ImageView android:src="@drawable/help_icon" android:id="@+id/HelpButton" android:layout_marginTop="7dp"
|
||||||
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="4dp"
|
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="4dp"
|
||||||
|
|
|
@ -12,7 +12,7 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:b
|
||||||
android:layout_marginLeft="4dp" android:layout_marginTop="8dp"
|
android:layout_marginLeft="4dp" android:layout_marginTop="8dp"
|
||||||
android:text="@string/app_name" android:textColor="#000000" android:typeface="serif" android:textSize="30sp"/>
|
android:text="@string/app_name" android:textColor="#000000" android:typeface="serif" android:textSize="30sp"/>
|
||||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1"
|
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1"
|
||||||
android:layout_marginLeft="24dp" android:layout_marginTop="8dp" android:layout_marginBottom="8dp" android:text="0.5.1 beta(b6)" android:gravity="right"
|
android:layout_marginLeft="24dp" android:layout_marginTop="8dp" android:layout_marginBottom="8dp" android:text="@string/app_version" android:gravity="right"
|
||||||
android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion" android:textSize="18sp"/>
|
android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion" android:textSize="18sp"/>
|
||||||
<ImageView android:src="@drawable/help_icon" android:id="@+id/HelpButton" android:layout_marginTop="9dp"
|
<ImageView android:src="@drawable/help_icon" android:id="@+id/HelpButton" android:layout_marginTop="9dp"
|
||||||
android:focusable="true" android:clickable="true"
|
android:focusable="true" android:clickable="true"
|
||||||
|
|
|
@ -12,7 +12,7 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:b
|
||||||
android:layout_marginLeft="3dp" android:layout_marginTop="8dp"
|
android:layout_marginLeft="3dp" android:layout_marginTop="8dp"
|
||||||
android:text="@string/app_name" android:textColor="#000000" android:typeface="serif" android:textSize="22sp"/>
|
android:text="@string/app_name" android:textColor="#000000" android:typeface="serif" android:textSize="22sp"/>
|
||||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1"
|
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1"
|
||||||
android:layout_marginLeft="24dp" android:layout_marginTop="8dp" android:layout_marginBottom="8dp" android:text="0.5.1 beta(b6)" android:gravity="right"
|
android:layout_marginLeft="24dp" android:layout_marginTop="8dp" android:layout_marginBottom="8dp" android:text="@string/app_version" android:gravity="right"
|
||||||
android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion" android:textSize="20sp"/>
|
android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion" android:textSize="20sp"/>
|
||||||
<ImageView android:id="@+id/HelpButton" android:layout_marginRight="0dp" android:layout_marginTop="9dp"
|
<ImageView android:id="@+id/HelpButton" android:layout_marginRight="0dp" android:layout_marginTop="9dp"
|
||||||
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="7dp"
|
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="7dp"
|
||||||
|
|
|
@ -12,7 +12,7 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:b
|
||||||
android:layout_marginLeft="2dp" android:layout_marginTop="3dp"
|
android:layout_marginLeft="2dp" android:layout_marginTop="3dp"
|
||||||
android:text="@string/app_name" android:textColor="#000000" android:typeface="serif" android:textSize="20sp"/>
|
android:text="@string/app_name" android:textColor="#000000" android:typeface="serif" android:textSize="20sp"/>
|
||||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1"
|
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1"
|
||||||
android:layout_marginLeft="12dp" android:layout_marginTop="3dp" android:layout_marginBottom="3dp" android:text="0.5.1 beta(b6)" android:gravity="right"
|
android:layout_marginLeft="12dp" android:layout_marginTop="3dp" android:layout_marginBottom="3dp" android:text="@string/app_version" android:gravity="right"
|
||||||
android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion" android:textSize="13sp"/>
|
android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion" android:textSize="13sp"/>
|
||||||
<ImageView android:id="@+id/HelpButton" android:clickable="true" android:layout_marginTop="7dp" android:layout_marginLeft="4dp"
|
<ImageView android:id="@+id/HelpButton" android:clickable="true" android:layout_marginTop="7dp" android:layout_marginLeft="4dp"
|
||||||
android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/help_icon"
|
android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/help_icon"
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="gpx_monitoring_disabled_warn">Please enable GPX monitoring in the settings</string>
|
||||||
|
<string name="show_current_gpx_title">Show current track</string>
|
||||||
<string name="tip_recent_changes_0_7_0_t">Changes in 0.7.0 :
|
<string name="tip_recent_changes_0_7_0_t">Changes in 0.7.0 :
|
||||||
\n\t- Offline wikipedia data with articles
|
\n\t- Offline wikipedia data with articles
|
||||||
\n\t- Updated maps
|
\n\t- Updated maps
|
||||||
|
|
|
@ -68,6 +68,18 @@ public class GPXUtilities {
|
||||||
public double ele = Double.NaN;
|
public double ele = Double.NaN;
|
||||||
public double speed = 0;
|
public double speed = 0;
|
||||||
public double hdop = Double.NaN;
|
public double hdop = Double.NaN;
|
||||||
|
|
||||||
|
public WptPt(){}
|
||||||
|
|
||||||
|
public WptPt(double lat, double lon, long time, double ele, double speed, double hdop) {
|
||||||
|
this.lat = lat;
|
||||||
|
this.lon = lon;
|
||||||
|
this.time = time;
|
||||||
|
this.ele = ele;
|
||||||
|
this.speed = speed;
|
||||||
|
this.hdop = hdop;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,15 @@ public class FavouritesDbHelper extends SQLiteOpenHelper {
|
||||||
recalculateCachedFavPoints();
|
recalculateCachedFavPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addFavoritePointToGPXFile(FavouritePoint fp) {
|
||||||
|
fp.setCategory(GPX_GROUP);
|
||||||
|
fp.setStored(false);
|
||||||
|
if (!favoriteGroups.containsKey(GPX_GROUP)) {
|
||||||
|
favoriteGroups.put(GPX_GROUP, new ArrayList<FavouritePoint>());
|
||||||
|
}
|
||||||
|
favoriteGroups.get(GPX_GROUP).add(fp);
|
||||||
|
}
|
||||||
|
|
||||||
public List<FavouritePoint> getFavouritePoints() {
|
public List<FavouritePoint> getFavouritePoints() {
|
||||||
checkFavoritePoints();
|
checkFavoritePoints();
|
||||||
return cachedFavoritePoints;
|
return cachedFavoritePoints;
|
||||||
|
|
|
@ -174,6 +174,7 @@ public class OsmandSettings {
|
||||||
return internetConnectionAvailable;
|
return internetConnectionAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////// PREFERENCES classes ////////////////
|
/////////////// PREFERENCES classes ////////////////
|
||||||
|
|
||||||
public abstract class CommonPreference<T> implements OsmandPreference<T> {
|
public abstract class CommonPreference<T> implements OsmandPreference<T> {
|
||||||
|
@ -1046,6 +1047,9 @@ public class OsmandSettings {
|
||||||
public final OsmandPreference<Integer> SERVICE_OFF_INTERVAL = new IntPreference("service_off_interval",
|
public final OsmandPreference<Integer> SERVICE_OFF_INTERVAL = new IntPreference("service_off_interval",
|
||||||
5 * 60 * 1000, true);
|
5 * 60 * 1000, true);
|
||||||
|
|
||||||
|
public final CommonPreference<Boolean> SHOW_CURRENT_GPX_TRACK =
|
||||||
|
new BooleanPreference("show_current_gpx_track", false, true, true);
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public final OsmandPreference<Integer> SERVICE_OFF_WAIT_INTERVAL = new IntPreference("service_off_wait_interval",
|
public final OsmandPreference<Integer> SERVICE_OFF_WAIT_INTERVAL = new IntPreference("service_off_wait_interval",
|
||||||
90 * 1000, true);
|
90 * 1000, true);
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class LocalIndexesActivity extends ExpandableListActivity {
|
||||||
OsmandSettings settings = OsmandSettings.getOsmandSettings(LocalIndexesActivity.this);
|
OsmandSettings settings = OsmandSettings.getOsmandSettings(LocalIndexesActivity.this);
|
||||||
settings.setMapLocationToShow(loc.lat, loc.lon, settings.getLastKnownMapZoom());
|
settings.setMapLocationToShow(loc.lat, loc.lon, settings.getLastKnownMapZoom());
|
||||||
}
|
}
|
||||||
((OsmandApplication) getApplication()).setGpxFileToDisplay(info.getGpxFile());
|
((OsmandApplication) getApplication()).setGpxFileToDisplay(info.getGpxFile(), false);
|
||||||
MapActivity.launchMapActivityMoveToTop(LocalIndexesActivity.this);
|
MapActivity.launchMapActivityMoveToTop(LocalIndexesActivity.this);
|
||||||
}
|
}
|
||||||
} else if (resId == R.string.local_index_mi_rename) {
|
} else if (resId == R.string.local_index_mi_rename) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.google.android.apps.analytics.easytracking.TrackedActivity;
|
||||||
import net.osmand.Algoritms;
|
import net.osmand.Algoritms;
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.LogUtil;
|
import net.osmand.LogUtil;
|
||||||
import net.osmand.Version;
|
import net.osmand.Version;
|
||||||
import net.osmand.data.MapTileDownloader.DownloadRequest;
|
import net.osmand.data.MapTileDownloader.DownloadRequest;
|
||||||
|
@ -665,8 +666,15 @@ public class MapActivity extends TrackedActivity implements IMapLocationListener
|
||||||
if (!location.hasAccuracy() || location.getAccuracy() < ACCURACY_FOR_GPX_AND_ROUTING) {
|
if (!location.hasAccuracy() || location.getAccuracy() < ACCURACY_FOR_GPX_AND_ROUTING) {
|
||||||
savingTrackHelper.insertData(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getSpeed(),
|
savingTrackHelper.insertData(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getSpeed(),
|
||||||
location.getAccuracy(), location.getTime(), settings);
|
location.getAccuracy(), location.getTime(), settings);
|
||||||
|
if(settings.SHOW_CURRENT_GPX_TRACK.get()) {
|
||||||
|
WptPt pt = new GPXUtilities.WptPt(location.getLatitude(), location.getLongitude(), location.getTime(), location.getAltitude(), location.getSpeed(),
|
||||||
|
location.getAccuracy());
|
||||||
|
mapLayers.getGpxLayer().addTrackPoint(pt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
registerUnregisterSensor(location);
|
registerUnregisterSensor(location);
|
||||||
updateSpeedBearing(location);
|
updateSpeedBearing(location);
|
||||||
mapLayers.getLocationLayer().setLastKnownLocation(location);
|
mapLayers.getLocationLayer().setLastKnownLocation(location);
|
||||||
|
|
|
@ -209,6 +209,9 @@ public class MapActivityActions implements DialogProvider {
|
||||||
double longitude = args.getDouble(KEY_LONGITUDE);
|
double longitude = args.getDouble(KEY_LONGITUDE);
|
||||||
String name = editText.getText().toString();
|
String name = editText.getText().toString();
|
||||||
mapActivity.getSavingTrackHelper().insertPointData(latitude, longitude, System.currentTimeMillis(), name);
|
mapActivity.getSavingTrackHelper().insertPointData(latitude, longitude, System.currentTimeMillis(), name);
|
||||||
|
if(OsmandSettings.getOsmandSettings(mapActivity).SHOW_CURRENT_GPX_TRACK.get()) {
|
||||||
|
getMyApplication().favorites.addFavoritePointToGPXFile(new FavouritePoint(latitude, longitude, name, ""));
|
||||||
|
}
|
||||||
Toast.makeText(mapActivity, MessageFormat.format(getString(R.string.add_waypoint_dialog_added), name), Toast.LENGTH_SHORT)
|
Toast.makeText(mapActivity, MessageFormat.format(getString(R.string.add_waypoint_dialog_added), name), Toast.LENGTH_SHORT)
|
||||||
.show();
|
.show();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
@ -622,7 +625,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
builder.show();
|
builder.show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}, false);
|
}, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApplicationMode getAppMode(ToggleButton[] buttons, OsmandSettings settings){
|
private ApplicationMode getAppMode(ToggleButton[] buttons, OsmandSettings settings){
|
||||||
|
|
|
@ -255,7 +255,7 @@ public class MapActivityLayers {
|
||||||
selectedList.add(underlayLayer.getMap() != null ? 1 : 0);
|
selectedList.add(underlayLayer.getMap() != null ? 1 : 0);
|
||||||
|
|
||||||
layers.add(R.string.layer_gpx_layer);
|
layers.add(R.string.layer_gpx_layer);
|
||||||
selectedList.add(gpxLayer.isVisible() ? 1 : 0);
|
selectedList.add(getApplication().getGpxFileToDisplay() != null ? 1 : 0);
|
||||||
if(routeInfoLayer.couldBeVisible()){
|
if(routeInfoLayer.couldBeVisible()){
|
||||||
layers.add(R.string.layer_route);
|
layers.add(R.string.layer_route);
|
||||||
selectedList.add(routeInfoLayer.isUserDefinedVisible() ? 1 : 0);
|
selectedList.add(routeInfoLayer.isUserDefinedVisible() ? 1 : 0);
|
||||||
|
@ -317,8 +317,8 @@ public class MapActivityLayers {
|
||||||
mapTileLayer, mapVectorLayer);
|
mapTileLayer, mapVectorLayer);
|
||||||
}
|
}
|
||||||
} else if(layers.get(item) == R.string.layer_gpx_layer){
|
} else if(layers.get(item) == R.string.layer_gpx_layer){
|
||||||
if(gpxLayer.isVisible()){
|
if(getApplication().getGpxFileToDisplay() != null){
|
||||||
getApplication().setGpxFileToDisplay(null);
|
getApplication().setGpxFileToDisplay(null, false);
|
||||||
gpxLayer.clearCurrentGPX();
|
gpxLayer.clearCurrentGPX();
|
||||||
} else {
|
} else {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
@ -345,15 +345,27 @@ public class MapActivityLayers {
|
||||||
selectGPXFileLayer(new CallbackWithObject<GPXFile>() {
|
selectGPXFileLayer(new CallbackWithObject<GPXFile>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean processResult(GPXFile result) {
|
public boolean processResult(GPXFile result) {
|
||||||
settings.SHOW_FAVORITES.set(true);
|
GPXFile toShow = result;
|
||||||
if (result != null) {
|
if (toShow == null) {
|
||||||
getApplication().setGpxFileToDisplay(result);
|
if(!settings.SAVE_TRACK_TO_GPX.get()){
|
||||||
updateGPXLayer();
|
Toast.makeText(activity, R.string.gpx_monitoring_disabled_warn, Toast.LENGTH_SHORT).show();
|
||||||
mapView.refreshMap();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}, true);
|
Map<String, GPXFile> data = activity.getSavingTrackHelper().collectRecordedData();
|
||||||
|
if(data.isEmpty()){
|
||||||
|
toShow = new GPXFile();
|
||||||
|
} else {
|
||||||
|
toShow = data.values().iterator().next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.SHOW_FAVORITES.set(true);
|
||||||
|
getApplication().setGpxFileToDisplay(toShow, result == null);
|
||||||
|
updateGPXLayer();
|
||||||
|
mapView.refreshMap();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateGPXLayer(){
|
private void updateGPXLayer(){
|
||||||
|
@ -365,7 +377,8 @@ public class MapActivityLayers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectGPXFileLayer(final CallbackWithObject<GPXFile> callbackWithObject, final boolean convertCloudmade) {
|
public void selectGPXFileLayer(final CallbackWithObject<GPXFile> callbackWithObject, final boolean convertCloudmade,
|
||||||
|
final boolean showCurrentGpx) {
|
||||||
final List<String> list = new ArrayList<String>();
|
final List<String> list = new ArrayList<String>();
|
||||||
final OsmandSettings settings = getApplication().getSettings();
|
final OsmandSettings settings = getApplication().getSettings();
|
||||||
final File dir = settings.extendOsmandPath(ResourceManager.GPX_PATH);
|
final File dir = settings.extendOsmandPath(ResourceManager.GPX_PATH);
|
||||||
|
@ -395,13 +408,20 @@ public class MapActivityLayers {
|
||||||
|
|
||||||
if(list.isEmpty()){
|
if(list.isEmpty()){
|
||||||
Toast.makeText(activity, R.string.gpx_files_not_found, Toast.LENGTH_LONG).show();
|
Toast.makeText(activity, R.string.gpx_files_not_found, Toast.LENGTH_LONG).show();
|
||||||
} else {
|
}
|
||||||
|
if(!list.isEmpty() || showCurrentGpx){
|
||||||
Builder builder = new AlertDialog.Builder(activity);
|
Builder builder = new AlertDialog.Builder(activity);
|
||||||
|
if(showCurrentGpx){
|
||||||
|
list.add(0, getString(R.string.show_current_gpx_title));
|
||||||
|
}
|
||||||
builder.setItems(list.toArray(new String[list.size()]), new DialogInterface.OnClickListener() {
|
builder.setItems(list.toArray(new String[list.size()]), new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
if(showCurrentGpx && which == 0){
|
||||||
|
callbackWithObject.processResult(null);
|
||||||
|
} else {
|
||||||
final ProgressDialog dlg = ProgressDialog.show(activity, getString(R.string.loading),
|
final ProgressDialog dlg = ProgressDialog.show(activity, getString(R.string.loading),
|
||||||
getString(R.string.loading_data));
|
getString(R.string.loading_data));
|
||||||
final File f = new File(dir, list.get(which));
|
final File f = new File(dir, list.get(which));
|
||||||
|
@ -422,9 +442,9 @@ public class MapActivityLayers {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}, "Loading gpx").start(); //$NON-NLS-1$
|
}, "Loading gpx").start(); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
builder.show();
|
builder.show();
|
||||||
|
@ -636,6 +656,10 @@ public class MapActivityLayers {
|
||||||
return navigationLayer;
|
return navigationLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GPXLayer getGpxLayer() {
|
||||||
|
return gpxLayer;
|
||||||
|
}
|
||||||
|
|
||||||
public ContextMenuLayer getContextMenuLayer() {
|
public ContextMenuLayer getContextMenuLayer() {
|
||||||
return contextMenuLayer;
|
return contextMenuLayer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,8 +110,9 @@ public class OsmandApplication extends Application {
|
||||||
return poiFilters;
|
return poiFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGpxFileToDisplay(GPXFile gpxFileToDisplay) {
|
public void setGpxFileToDisplay(GPXFile gpxFileToDisplay, boolean showCurrentGpxFile) {
|
||||||
this.gpxFileToDisplay = gpxFileToDisplay;
|
this.gpxFileToDisplay = gpxFileToDisplay;
|
||||||
|
osmandSettings.SHOW_CURRENT_GPX_TRACK.set(showCurrentGpxFile);
|
||||||
if(gpxFileToDisplay == null){
|
if(gpxFileToDisplay == null){
|
||||||
getFavorites().setFavoritePointsFromGPXFile(null);
|
getFavorites().setFavoritePointsFromGPXFile(null);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -123,17 +123,14 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
* @return warnings
|
* @return warnings
|
||||||
*/
|
*/
|
||||||
public List<String> saveDataToGpx() {
|
public List<String> saveDataToGpx() {
|
||||||
SQLiteDatabase db = getReadableDatabase();
|
|
||||||
List<String> warnings = new ArrayList<String>();
|
List<String> warnings = new ArrayList<String>();
|
||||||
File dir = OsmandSettings.getOsmandSettings(ctx).getExternalStorageDirectory();
|
File dir = OsmandSettings.getOsmandSettings(ctx).getExternalStorageDirectory();
|
||||||
if (db != null && dir.canWrite()) {
|
if (dir.canWrite()) {
|
||||||
dir = new File(dir, ResourceManager.GPX_PATH);
|
dir = new File(dir, ResourceManager.GPX_PATH);
|
||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
if (dir.exists()) {
|
if (dir.exists()) {
|
||||||
|
|
||||||
Map<String, GPXFile> data = new LinkedHashMap<String, GPXFile>();
|
Map<String, GPXFile> data = collectRecordedData();
|
||||||
collectDBPoints(db, data);
|
|
||||||
collectDBTracks(db, data);
|
|
||||||
|
|
||||||
// save file
|
// save file
|
||||||
for (final String f : data.keySet()) {
|
for (final String f : data.keySet()) {
|
||||||
|
@ -156,7 +153,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
db = getWritableDatabase();
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
if (db != null && warnings.isEmpty()) {
|
if (db != null && warnings.isEmpty()) {
|
||||||
// remove all from db
|
// 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 " + TRACK_NAME + " WHERE " + TRACK_COL_DATE + " <= ?", new Object[] { System.currentTimeMillis() }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
@ -165,6 +162,16 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
return warnings;
|
return warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, GPXFile> collectRecordedData() {
|
||||||
|
Map<String, GPXFile> data = new LinkedHashMap<String, GPXFile>();
|
||||||
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
|
if(db != null) {
|
||||||
|
collectDBPoints(db, data);
|
||||||
|
collectDBTracks(db, data);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
private void collectDBPoints(SQLiteDatabase db, Map<String, GPXFile> dataTracks) {
|
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$
|
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 + " FROM " + POINT_NAME+" ORDER BY " + TRACK_COL_DATE +" ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
+ POINT_COL_DESCRIPTION + " FROM " + POINT_NAME+" ORDER BY " + TRACK_COL_DATE +" ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||||
import net.osmand.GPXUtilities.Track;
|
import net.osmand.GPXUtilities.Track;
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
import net.osmand.GPXUtilities.TrkSegment;
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
@ -25,6 +26,9 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private Path path;
|
private Path path;
|
||||||
|
|
||||||
|
private OsmandSettings settings;
|
||||||
|
|
||||||
|
|
||||||
private void initUI() {
|
private void initUI() {
|
||||||
paint = new Paint();
|
paint = new Paint();
|
||||||
paint.setColor(Color.argb(180, 160, 10, 215));
|
paint.setColor(Color.argb(180, 160, 10, 215));
|
||||||
|
@ -41,6 +45,7 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
@Override
|
@Override
|
||||||
public void initLayer(OsmandMapTileView view) {
|
public void initLayer(OsmandMapTileView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
settings = OsmandSettings.getOsmandSettings(view.getContext());
|
||||||
initUI();
|
initUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +101,8 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isVisible(){
|
public boolean isShowingCurrentTrack(){
|
||||||
return !points.isEmpty();
|
return settings.SHOW_CURRENT_GPX_TRACK.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,6 +125,21 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addTrackPoint(WptPt pt){
|
||||||
|
if(points.size() == 0){
|
||||||
|
points.add(new ArrayList<WptPt>());
|
||||||
|
}
|
||||||
|
List<WptPt> last = points.get(points.size() - 1);
|
||||||
|
if(last.size() == 0 || last.get(last.size() - 1).time - pt.time < 6 * 60 * 1000) {
|
||||||
|
// 6 minutes same segment
|
||||||
|
last.add(pt);
|
||||||
|
} else {
|
||||||
|
ArrayList<WptPt> l = new ArrayList<WptPt>();
|
||||||
|
l.add(pt);
|
||||||
|
points.add(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroyLayer() {
|
public void destroyLayer() {
|
||||||
|
|
Loading…
Reference in a new issue