Initial refactoring
This commit is contained in:
parent
a00a477415
commit
d4fe3288d2
24 changed files with 401 additions and 348 deletions
|
@ -8,7 +8,6 @@ public class FavouritePoint implements Serializable {
|
||||||
private String category = "";
|
private String category = "";
|
||||||
private double latitude;
|
private double latitude;
|
||||||
private double longitude;
|
private double longitude;
|
||||||
private boolean stored = false;
|
|
||||||
|
|
||||||
|
|
||||||
public FavouritePoint(){
|
public FavouritePoint(){
|
||||||
|
@ -25,13 +24,6 @@ public class FavouritePoint implements Serializable {
|
||||||
return latitude;
|
return latitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStored() {
|
|
||||||
return stored;
|
|
||||||
}
|
|
||||||
public void setStored(boolean stored) {
|
|
||||||
this.stored = stored;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLatitude(double latitude) {
|
public void setLatitude(double latitude) {
|
||||||
this.latitude = latitude;
|
this.latitude = latitude;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@
|
||||||
<activity android:name="net.osmand.plus.activities.DownloadIndexActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/local_index_download"></activity>
|
<activity android:name="net.osmand.plus.activities.DownloadIndexActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/local_index_download"></activity>
|
||||||
<activity android:name="net.osmand.plus.activities.ShowRouteInfoActivity" android:label="@string/show_route"></activity>
|
<activity android:name="net.osmand.plus.activities.ShowRouteInfoActivity" android:label="@string/show_route"></activity>
|
||||||
<activity android:name="net.osmand.plus.activities.FavouritesListActivity" android:label="@string/favourites_list_activity"></activity>
|
<activity android:name="net.osmand.plus.activities.FavouritesListActivity" android:label="@string/favourites_list_activity"></activity>
|
||||||
<activity android:name="net.osmand.plus.activities.FavouritesActivity"></activity>
|
<activity android:name="net.osmand.plus.activities.FavouritesActivity" android:windowSoftInputMode="adjustPan"></activity>
|
||||||
<activity android:name="net.osmand.plus.activities.PluginsActivity"></activity>
|
<activity android:name="net.osmand.plus.activities.PluginsActivity"></activity>
|
||||||
<activity android:name="net.osmand.plus.activities.ContributionVersionActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/contribution_activity"></activity>
|
<activity android:name="net.osmand.plus.activities.ContributionVersionActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/contribution_activity"></activity>
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,6 @@ public class FavouritesDbHelper {
|
||||||
public static final String FILE_TO_SAVE = "favourites.gpx"; //$NON-NLS-1$
|
public static final String FILE_TO_SAVE = "favourites.gpx"; //$NON-NLS-1$
|
||||||
public static final String FILE_TO_BACKUP = "favourites_bak.gpx"; //$NON-NLS-1$
|
public static final String FILE_TO_BACKUP = "favourites_bak.gpx"; //$NON-NLS-1$
|
||||||
|
|
||||||
// externalize ?
|
|
||||||
private static final String GPX_GROUP = "Gpx";
|
|
||||||
|
|
||||||
private List<FavouritePoint> favoritePointsFromGPXFile = null;
|
private List<FavouritePoint> favoritePointsFromGPXFile = null;
|
||||||
private List<FavouritePoint> cachedFavoritePoints = new ArrayList<FavouritePoint>();
|
private List<FavouritePoint> cachedFavoritePoints = new ArrayList<FavouritePoint>();
|
||||||
private Map<String, List<FavouritePoint>> favoriteGroups = null;
|
private Map<String, List<FavouritePoint>> favoriteGroups = null;
|
||||||
|
@ -96,15 +93,13 @@ public class FavouritesDbHelper {
|
||||||
public GPXFile asGpxFile() {
|
public GPXFile asGpxFile() {
|
||||||
GPXFile gpx = new GPXFile();
|
GPXFile gpx = new GPXFile();
|
||||||
for (FavouritePoint p : getFavouritePoints()) {
|
for (FavouritePoint p : getFavouritePoints()) {
|
||||||
if (p.isStored()) {
|
WptPt pt = new WptPt();
|
||||||
WptPt pt = new WptPt();
|
pt.lat = p.getLatitude();
|
||||||
pt.lat = p.getLatitude();
|
pt.lon = p.getLongitude();
|
||||||
pt.lon = p.getLongitude();
|
pt.name = p.getName();
|
||||||
pt.name = p.getName();
|
if (p.getCategory().length() > 0)
|
||||||
if (p.getCategory().length() > 0)
|
pt.category = p.getCategory();
|
||||||
pt.category = p.getCategory();
|
gpx.points.add(pt);
|
||||||
gpx.points.add(pt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return gpx;
|
return gpx;
|
||||||
}
|
}
|
||||||
|
@ -120,30 +115,7 @@ public class FavouritesDbHelper {
|
||||||
return favoritePointsFromGPXFile;
|
return favoritePointsFromGPXFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFavoritePointsFromGPXFile(List<FavouritePoint> favoritePointsFromGPXFile) {
|
|
||||||
this.favoritePointsFromGPXFile = favoritePointsFromGPXFile;
|
|
||||||
if(favoritePointsFromGPXFile == null){
|
|
||||||
favoriteGroups.remove(GPX_GROUP);
|
|
||||||
} else {
|
|
||||||
checkFavoritePoints();
|
|
||||||
for(FavouritePoint t : favoritePointsFromGPXFile){
|
|
||||||
t.setCategory(GPX_GROUP);
|
|
||||||
t.setStored(false);
|
|
||||||
}
|
|
||||||
favoriteGroups.put(GPX_GROUP, favoritePointsFromGPXFile);
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
recalculateCachedFavPoints();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FavouritePoint> getFavouritePoints() {
|
public List<FavouritePoint> getFavouritePoints() {
|
||||||
checkFavoritePoints();
|
checkFavoritePoints();
|
||||||
|
@ -227,7 +199,6 @@ public class FavouritesDbHelper {
|
||||||
if (fp != null) {
|
if (fp != null) {
|
||||||
favoriteGroups.get(p.getCategory()).remove(fp);
|
favoriteGroups.get(p.getCategory()).remove(fp);
|
||||||
cachedFavoritePoints.remove(fp);
|
cachedFavoritePoints.remove(fp);
|
||||||
fp.setStored(false);
|
|
||||||
}
|
}
|
||||||
backupSilently();
|
backupSilently();
|
||||||
} finally{
|
} finally{
|
||||||
|
@ -269,7 +240,6 @@ public class FavouritesDbHelper {
|
||||||
favoriteGroups.get(p.getCategory()).add(p);
|
favoriteGroups.get(p.getCategory()).add(p);
|
||||||
cachedFavoritePoints.add(p);
|
cachedFavoritePoints.add(p);
|
||||||
}
|
}
|
||||||
p.setStored(true);
|
|
||||||
backupSilently();
|
backupSilently();
|
||||||
} finally {
|
} finally {
|
||||||
db.close();
|
db.close();
|
||||||
|
@ -314,7 +284,6 @@ public class FavouritesDbHelper {
|
||||||
FavouritePoint p = new FavouritePoint();
|
FavouritePoint p = new FavouritePoint();
|
||||||
p.setName(name);
|
p.setName(name);
|
||||||
p.setCategory(cat);
|
p.setCategory(cat);
|
||||||
p.setStored(true);
|
|
||||||
p.setLatitude(query.getDouble(2));
|
p.setLatitude(query.getDouble(2));
|
||||||
p.setLongitude(query.getDouble(3));
|
p.setLongitude(query.getDouble(3));
|
||||||
favoriteGroups.get(cat).add(p);
|
favoriteGroups.get(cat).add(p);
|
||||||
|
|
|
@ -350,8 +350,6 @@ public class GPXUtilities {
|
||||||
public String path = "";
|
public String path = "";
|
||||||
public boolean showCurrentTrack;
|
public boolean showCurrentTrack;
|
||||||
|
|
||||||
public List<List<WptPt>> processedPointsToDisplay = new ArrayList<List<WptPt>>();
|
|
||||||
|
|
||||||
public boolean isCloudmadeRouteFile() {
|
public boolean isCloudmadeRouteFile() {
|
||||||
return "cloudmade".equalsIgnoreCase(author);
|
return "cloudmade".equalsIgnoreCase(author);
|
||||||
}
|
}
|
||||||
|
@ -469,7 +467,7 @@ public class GPXUtilities {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void proccessPoints() {
|
public List<List<WptPt>> proccessPoints() {
|
||||||
List<List<WptPt>> tpoints = new ArrayList<List<WptPt>>();
|
List<List<WptPt>> tpoints = new ArrayList<List<WptPt>>();
|
||||||
boolean created = false;
|
boolean created = false;
|
||||||
for (Track t : tracks) {
|
for (Track t : tracks) {
|
||||||
|
@ -485,7 +483,7 @@ public class GPXUtilities {
|
||||||
tpoints.add(r.points);
|
tpoints.add(r.points);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
processedPointsToDisplay = tpoints;
|
return tpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WptPt findPointToShow() {
|
public WptPt findPointToShow() {
|
||||||
|
|
207
OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
Normal file
207
OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
Normal file
|
@ -0,0 +1,207 @@
|
||||||
|
package net.osmand.plus;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
|
public class GpxSelectionHelper {
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
// save into settings
|
||||||
|
// public final CommonPreference<Boolean> SHOW_CURRENT_GPX_TRACK =
|
||||||
|
// new BooleanPreference("show_current_gpx_track", false).makeGlobal().cache();
|
||||||
|
private List<SelectedGpxFile> selectedGPXFiles = new java.util.concurrent.CopyOnWriteArrayList<SelectedGpxFile>();
|
||||||
|
|
||||||
|
public GpxSelectionHelper(OsmandApplication osmandApplication) {
|
||||||
|
this.app = osmandApplication;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearAllGpxFileToShow() {
|
||||||
|
selectedGPXFiles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShowingCurrentTrack() {
|
||||||
|
return getCurrentTrack() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShowingAnyGpxFiles() {
|
||||||
|
return !selectedGPXFiles.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SelectedGpxFile getCurrentTrack() {
|
||||||
|
for(SelectedGpxFile s : selectedGPXFiles) {
|
||||||
|
if(s.isShowCurrentTrack()) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SelectedGpxFile> getSelectedGPXFiles() {
|
||||||
|
return selectedGPXFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToDisplayCurrentGpxFile(boolean show) {
|
||||||
|
if(show != isShowingCurrentTrack()) {
|
||||||
|
if(show) {
|
||||||
|
TODO_LOAD_CURRENT_BUFFER ;
|
||||||
|
SelectedGpxFile sg = new SelectedGpxFile();
|
||||||
|
sg.setGpxFile(new GPXFile());
|
||||||
|
sg.setShowCurrentTrack(true);
|
||||||
|
selectedGPXFiles.add(sg);
|
||||||
|
} else {
|
||||||
|
Iterator<SelectedGpxFile> it = selectedGPXFiles.iterator();
|
||||||
|
while(it.hasNext()) {
|
||||||
|
if(it.next().isShowCurrentTrack()) {
|
||||||
|
it.remove();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TODO_SAVE_IN_SETTINGS;
|
||||||
|
}
|
||||||
|
public List<GpxDisplayGroup> getDisplayGroups() {
|
||||||
|
TODO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SelectedGpxFile getSelectedFileByPath(String path) {
|
||||||
|
for(SelectedGpxFile s : selectedGPXFiles) {
|
||||||
|
if(s.getGpxFile().path.equals(path)) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SelectedGpxFile setGpxFileToDisplay(GPXFile... gpx) {
|
||||||
|
// special case for gpx current route
|
||||||
|
SelectedGpxFile sf = getSelectedFileByPath(gpx.path);
|
||||||
|
boolean displayed = sf != null;
|
||||||
|
if(displayed != show) {
|
||||||
|
if(show) {
|
||||||
|
sf = new SelectedGpxFile();
|
||||||
|
sf.setGpxFile(gpx);
|
||||||
|
selectedGPXFiles.add(sf);
|
||||||
|
} else {
|
||||||
|
selectedGPXFiles.remove(sf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SelectedGpxFile setGpxFileToDisplay(String path, boolean show) {
|
||||||
|
SelectedGpxFile sf = getSelectedFileByPath(path);
|
||||||
|
boolean displayed = sf != null;
|
||||||
|
if(displayed != show) {
|
||||||
|
if(show) {
|
||||||
|
TODO_ASYNC;
|
||||||
|
GPXFile r = GPXUtilities.loadGPXFile(app, new File(path));
|
||||||
|
sf = new SelectedGpxFile();
|
||||||
|
sf.setGpxFile(r);
|
||||||
|
selectedGPXFiles.add(sf);
|
||||||
|
} else {
|
||||||
|
selectedGPXFiles.remove(sf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SelectedGpxFile {
|
||||||
|
private boolean showCurrentTrack;
|
||||||
|
private GPXFile gpxFile;
|
||||||
|
private int color;
|
||||||
|
private List<List<WptPt>> processedPointsToDisplay = new ArrayList<List<WptPt>>();
|
||||||
|
|
||||||
|
public void setGpxFile(GPXFile gpxFile) {
|
||||||
|
this.gpxFile = gpxFile;
|
||||||
|
this.processedPointsToDisplay = gpxFile.proccessPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<List<WptPt>> getPointsToDisplay() {
|
||||||
|
return processedPointsToDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<List<WptPt>> getModifiablePointsToDisplay() {
|
||||||
|
return processedPointsToDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GPXFile getGpxFile() {
|
||||||
|
return gpxFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShowCurrentTrack() {
|
||||||
|
return showCurrentTrack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowCurrentTrack(boolean showCurrentTrack) {
|
||||||
|
this.showCurrentTrack = showCurrentTrack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum GpxDisplayItemType {
|
||||||
|
TRACK_SEGMENT,
|
||||||
|
TRACK_POINTS,
|
||||||
|
TRACK_ROUTE_POINTS
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class GpxDisplayGroup {
|
||||||
|
|
||||||
|
private GpxDisplayItemType type = GpxDisplayItemType.TRACK_SEGMENT;
|
||||||
|
private List<GpxDisplayItem> list = new ArrayList<GpxDisplayItem>();
|
||||||
|
|
||||||
|
public GpxDisplayGroup cloneInstance() {
|
||||||
|
GpxDisplayGroup group = new GpxDisplayGroup();
|
||||||
|
group.type = type;
|
||||||
|
group.list = new ArrayList<GpxSelectionHelper.GpxDisplayItem>(list);
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<GpxDisplayItem> getModifiableList() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GpxDisplayItemType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(GpxDisplayItemType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getGroupName(Context ctx) {
|
||||||
|
return TODO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class GpxDisplayItem {
|
||||||
|
|
||||||
|
private boolean filter;
|
||||||
|
private String description;
|
||||||
|
private Bitmap image;
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
public boolean isFilter() {
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilter(boolean filter) {
|
||||||
|
this.filter = filter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -82,10 +82,10 @@ public class OsmAndLocationSimulation {
|
||||||
boolean gpxNavigation = radioGPX.isChecked();
|
boolean gpxNavigation = radioGPX.isChecked();
|
||||||
if (gpxNavigation) {
|
if (gpxNavigation) {
|
||||||
GpxUiHelper.selectGPXFile(ma, false, false,
|
GpxUiHelper.selectGPXFile(ma, false, false,
|
||||||
new CallbackWithObject<GPXUtilities.GPXFile>() {
|
new CallbackWithObject<GPXUtilities.GPXFile[]>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean processResult(GPXUtilities.GPXFile result) {
|
public boolean processResult(GPXUtilities.GPXFile[] result) {
|
||||||
GPXRouteParamsBuilder builder = new GPXRouteParamsBuilder(result, app.getSettings());
|
GPXRouteParamsBuilder builder = new GPXRouteParamsBuilder(result[0], app.getSettings());
|
||||||
if(ch.isChecked()){
|
if(ch.isChecked()){
|
||||||
builder.setAnnounceWaypoints(true);
|
builder.setAnnounceWaypoints(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,6 @@ import net.osmand.PlatformUtil;
|
||||||
import net.osmand.access.AccessibilityPlugin;
|
import net.osmand.access.AccessibilityPlugin;
|
||||||
import net.osmand.access.AccessibleAlertBuilder;
|
import net.osmand.access.AccessibleAlertBuilder;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.FavouritePoint;
|
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
|
||||||
import net.osmand.plus.access.AccessibilityMode;
|
import net.osmand.plus.access.AccessibilityMode;
|
||||||
import net.osmand.plus.activities.DayNightHelper;
|
import net.osmand.plus.activities.DayNightHelper;
|
||||||
import net.osmand.plus.activities.SavingTrackHelper;
|
import net.osmand.plus.activities.SavingTrackHelper;
|
||||||
|
@ -63,8 +60,8 @@ import android.util.TypedValue;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.LinearLayout.LayoutParams;
|
import android.widget.LinearLayout.LayoutParams;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import btools.routingapp.BRouterServiceConnection;
|
import btools.routingapp.BRouterServiceConnection;
|
||||||
|
@ -99,7 +96,7 @@ public class OsmandApplication extends Application {
|
||||||
// start variables
|
// start variables
|
||||||
private ProgressImplementation startDialog;
|
private ProgressImplementation startDialog;
|
||||||
private Handler uiHandler;
|
private Handler uiHandler;
|
||||||
private GPXFile gpxFileToDisplay;
|
private GpxSelectionHelper selectedGpxHelper;
|
||||||
private SavingTrackHelper savingTrackHelper;
|
private SavingTrackHelper savingTrackHelper;
|
||||||
private LiveMonitoringHelper liveMonitoringHelper;
|
private LiveMonitoringHelper liveMonitoringHelper;
|
||||||
private TargetPointsHelper targetPointsHelper;
|
private TargetPointsHelper targetPointsHelper;
|
||||||
|
@ -150,6 +147,7 @@ public class OsmandApplication extends Application {
|
||||||
locationProvider = new OsmAndLocationProvider(this);
|
locationProvider = new OsmAndLocationProvider(this);
|
||||||
savingTrackHelper = new SavingTrackHelper(this);
|
savingTrackHelper = new SavingTrackHelper(this);
|
||||||
liveMonitoringHelper = new LiveMonitoringHelper(this);
|
liveMonitoringHelper = new LiveMonitoringHelper(this);
|
||||||
|
selectedGpxHelper = new GpxSelectionHelper(this);
|
||||||
uiHandler = new Handler();
|
uiHandler = new Handler();
|
||||||
rendererRegistry = new RendererRegistry();
|
rendererRegistry = new RendererRegistry();
|
||||||
targetPointsHelper = new TargetPointsHelper(this);
|
targetPointsHelper = new TargetPointsHelper(this);
|
||||||
|
@ -229,30 +227,9 @@ public class OsmandApplication extends Application {
|
||||||
return poiFilters;
|
return poiFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGpxFileToDisplay(GPXFile gpxFileToDisplay, boolean showCurrentGpxFile) {
|
|
||||||
this.gpxFileToDisplay = gpxFileToDisplay;
|
|
||||||
osmandSettings.SHOW_CURRENT_GPX_TRACK.set(showCurrentGpxFile);
|
|
||||||
if (gpxFileToDisplay == null) {
|
|
||||||
getFavorites().setFavoritePointsFromGPXFile(null);
|
|
||||||
} else {
|
|
||||||
List<FavouritePoint> pts = new ArrayList<FavouritePoint>();
|
|
||||||
for (WptPt p : gpxFileToDisplay.points) {
|
|
||||||
FavouritePoint pt = new FavouritePoint();
|
|
||||||
pt.setLatitude(p.lat);
|
|
||||||
pt.setLongitude(p.lon);
|
|
||||||
if (p.name == null) {
|
|
||||||
p.name = "";
|
|
||||||
}
|
|
||||||
pt.setName(p.name);
|
|
||||||
pts.add(pt);
|
|
||||||
}
|
|
||||||
gpxFileToDisplay.proccessPoints();
|
|
||||||
getFavorites().setFavoritePointsFromGPXFile(pts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public GPXFile getGpxFileToDisplay() {
|
public GpxSelectionHelper getSelectedGpxHelper() {
|
||||||
return gpxFileToDisplay;
|
return selectedGpxHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FavouritesDbHelper getFavorites() {
|
public FavouritesDbHelper getFavorites() {
|
||||||
|
|
|
@ -1650,8 +1650,6 @@ 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).makeGlobal();
|
5 * 60 * 1000).makeGlobal();
|
||||||
|
|
||||||
public final CommonPreference<Boolean> SHOW_CURRENT_GPX_TRACK =
|
|
||||||
new BooleanPreference("show_current_gpx_track", false).makeGlobal().cache();
|
|
||||||
|
|
||||||
public final OsmandPreference<String> CONTRIBUTION_INSTALL_APP_DATE = new StringPreference("CONTRIBUTION_INSTALL_APP_DATE", null).makeGlobal();
|
public final OsmandPreference<String> CONTRIBUTION_INSTALL_APP_DATE = new StringPreference("CONTRIBUTION_INSTALL_APP_DATE", null).makeGlobal();
|
||||||
|
|
||||||
|
|
|
@ -423,7 +423,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
settings.setMapLocationToShow(loc.lat, loc.lon, settings.getLastKnownMapZoom());
|
settings.setMapLocationToShow(loc.lat, loc.lon, settings.getLastKnownMapZoom());
|
||||||
e = false;
|
e = false;
|
||||||
getMyApplication().setGpxFileToDisplay(info.gpx, false);
|
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(info.gpx);
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,11 +175,7 @@ public class FavouritesListFragment extends SherlockListFragment implements Sear
|
||||||
TextView label = (TextView) row.findViewById(R.id.favourite_label);
|
TextView label = (TextView) row.findViewById(R.id.favourite_label);
|
||||||
ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
|
ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
|
||||||
final FavouritePoint model = getItem(position);
|
final FavouritePoint model = getItem(position);
|
||||||
if (model.isStored()) {
|
icon.setImageResource(R.drawable.list_favorite);
|
||||||
icon.setImageResource(R.drawable.list_favorite);
|
|
||||||
} else {
|
|
||||||
icon.setImageResource(R.drawable.opened_poi);
|
|
||||||
}
|
|
||||||
String distance = "";
|
String distance = "";
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(), location.getLatitude(), location
|
int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(), location.getLatitude(), location
|
||||||
|
|
|
@ -183,31 +183,29 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
|
||||||
};
|
};
|
||||||
MapActivityActions.createDirectionsActions(qa, location, point, name, settings.getLastKnownMapZoom(),
|
MapActivityActions.createDirectionsActions(qa, location, point, name, settings.getLastKnownMapZoom(),
|
||||||
getActivity(), true, onshow, false);
|
getActivity(), true, onshow, false);
|
||||||
if (point.isStored()) {
|
ActionItem edit = new ActionItem();
|
||||||
ActionItem edit = new ActionItem();
|
edit.setIcon(getResources().getDrawable(R.drawable.ic_action_edit_light));
|
||||||
edit.setIcon(getResources().getDrawable(R.drawable.ic_action_edit_light));
|
edit.setTitle(getString(R.string.favourites_context_menu_edit));
|
||||||
edit.setTitle(getString(R.string.favourites_context_menu_edit));
|
edit.setOnClickListener(new OnClickListener() {
|
||||||
edit.setOnClickListener(new OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(View v) {
|
||||||
public void onClick(View v) {
|
editPoint(point);
|
||||||
editPoint(point);
|
qa.dismiss();
|
||||||
qa.dismiss();
|
}
|
||||||
}
|
});
|
||||||
});
|
qa.addActionItem(edit);
|
||||||
qa.addActionItem(edit);
|
|
||||||
|
|
||||||
ActionItem delete = new ActionItem();
|
ActionItem delete = new ActionItem();
|
||||||
delete.setTitle(getString(R.string.favourites_context_menu_delete));
|
delete.setTitle(getString(R.string.favourites_context_menu_delete));
|
||||||
delete.setIcon(getResources().getDrawable(R.drawable.ic_action_delete_light));
|
delete.setIcon(getResources().getDrawable(R.drawable.ic_action_delete_light));
|
||||||
delete.setOnClickListener(new OnClickListener() {
|
delete.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
deletePoint(point);
|
deletePoint(point);
|
||||||
qa.dismiss();
|
qa.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
qa.addActionItem(delete);
|
qa.addActionItem(delete);
|
||||||
}
|
|
||||||
|
|
||||||
qa.show();
|
qa.show();
|
||||||
}
|
}
|
||||||
|
@ -698,11 +696,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
|
||||||
ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
|
ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
|
||||||
final FavouritePoint model = (FavouritePoint) getChild(groupPosition, childPosition);
|
final FavouritePoint model = (FavouritePoint) getChild(groupPosition, childPosition);
|
||||||
row.setTag(model);
|
row.setTag(model);
|
||||||
if (model.isStored()) {
|
icon.setImageResource(R.drawable.list_favorite);
|
||||||
icon.setImageResource(R.drawable.list_favorite);
|
|
||||||
} else {
|
|
||||||
icon.setImageResource(R.drawable.opened_poi);
|
|
||||||
}
|
|
||||||
LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||||
int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(),
|
int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(),
|
||||||
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
|
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
|
||||||
|
@ -712,7 +706,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
|
||||||
new ForegroundColorSpan(getResources().getColor(R.color.color_distance)), 0, distance.length() - 1,
|
new ForegroundColorSpan(getResources().getColor(R.color.color_distance)), 0, distance.length() - 1,
|
||||||
0);
|
0);
|
||||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
|
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
|
||||||
if (selectionMode && model.isStored()) {
|
if (selectionMode) {
|
||||||
ch.setVisibility(View.VISIBLE);
|
ch.setVisibility(View.VISIBLE);
|
||||||
ch.setChecked(favoritesToDelete.contains(model));
|
ch.setChecked(favoritesToDelete.contains(model));
|
||||||
row.findViewById(R.id.favourite_icon).setVisibility(View.GONE);
|
row.findViewById(R.id.favourite_icon).setVisibility(View.GONE);
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||||
import net.osmand.plus.FavouritesDbHelper;
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
import net.osmand.plus.GPXUtilities;
|
import net.osmand.plus.GPXUtilities;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.OsmAndLocationProvider;
|
import net.osmand.plus.OsmAndLocationProvider;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
@ -200,11 +201,9 @@ public class MapActivityActions implements DialogProvider {
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
FavouritePoint fp = it.next();
|
FavouritePoint fp = it.next();
|
||||||
// filter gpx points
|
// filter gpx points
|
||||||
if (fp.isStored()) {
|
favs[i] = fp;
|
||||||
favs[i] = fp;
|
names[i] = fp.getName();
|
||||||
names[i] = fp.getName();
|
i++;
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
b.setItems(names, new DialogInterface.OnClickListener(){
|
b.setItems(names, new DialogInterface.OnClickListener(){
|
||||||
@Override
|
@Override
|
||||||
|
@ -247,9 +246,6 @@ public class MapActivityActions implements DialogProvider {
|
||||||
String name = editText.getText().toString();
|
String name = editText.getText().toString();
|
||||||
SavingTrackHelper savingTrackHelper = mapActivity.getMyApplication().getSavingTrackHelper();
|
SavingTrackHelper savingTrackHelper = mapActivity.getMyApplication().getSavingTrackHelper();
|
||||||
savingTrackHelper.insertPointData(latitude, longitude, System.currentTimeMillis(), name);
|
savingTrackHelper.insertPointData(latitude, longitude, System.currentTimeMillis(), name);
|
||||||
if(settings.SHOW_CURRENT_GPX_TRACK.get()) {
|
|
||||||
getMyApplication().getFavorites().addFavoritePointToGPXFile(new FavouritePoint(latitude, longitude, name, ""));
|
|
||||||
}
|
|
||||||
AccessibleToast.makeText(mapActivity, MessageFormat.format(getString(R.string.add_waypoint_dialog_added), name), Toast.LENGTH_SHORT)
|
AccessibleToast.makeText(mapActivity, MessageFormat.format(getString(R.string.add_waypoint_dialog_added), name), Toast.LENGTH_SHORT)
|
||||||
.show();
|
.show();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
@ -500,14 +496,22 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enterRoutePlanningMode(final LatLon from, final String fromName) {
|
public void enterRoutePlanningMode(final LatLon from, final String fromName) {
|
||||||
final GPXFile gpxFile = mapActivity.getMyApplication().getGpxFileToDisplay();
|
List<SelectedGpxFile> selectedGPXFiles = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
|
||||||
|
GPXFile gpxFile = null;
|
||||||
|
for (SelectedGpxFile gs : selectedGPXFiles) {
|
||||||
|
if (!gs.isShowCurrentTrack()) {
|
||||||
|
gpxFile = gs.getGpxFile();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(gpxFile != null) {
|
if(gpxFile != null) {
|
||||||
|
final GPXFile f = gpxFile;
|
||||||
Builder bld = new AlertDialog.Builder(mapActivity);
|
Builder bld = new AlertDialog.Builder(mapActivity);
|
||||||
bld.setMessage(R.string.use_displayed_track_for_navigation);
|
bld.setMessage(R.string.use_displayed_track_for_navigation);
|
||||||
bld.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
bld.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
enterRoutePlanningModeImpl(gpxFile, from, fromName);
|
enterRoutePlanningModeImpl(f, from, fromName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bld.setNegativeButton(R.string.default_buttons_no, new DialogInterface.OnClickListener() {
|
bld.setNegativeButton(R.string.default_buttons_no, new DialogInterface.OnClickListener() {
|
||||||
|
|
|
@ -254,8 +254,8 @@ public class MapActivityLayers {
|
||||||
} else if(itemId == R.string.layer_favorites){
|
} else if(itemId == R.string.layer_favorites){
|
||||||
settings.SHOW_FAVORITES.set(isChecked);
|
settings.SHOW_FAVORITES.set(isChecked);
|
||||||
} else if(itemId == R.string.layer_gpx_layer){
|
} else if(itemId == R.string.layer_gpx_layer){
|
||||||
if(getApplication().getGpxFileToDisplay() != null){
|
if(getApplication().getSelectedGpxHelper().isShowingAnyGpxFiles()){
|
||||||
getApplication().setGpxFileToDisplay(null, false);
|
getApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
|
||||||
} else {
|
} else {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
showGPXFileLayer(mapView);
|
showGPXFileLayer(mapView);
|
||||||
|
@ -281,7 +281,7 @@ public class MapActivityLayers {
|
||||||
adapter.item(R.string.layer_favorites).selected(settings.SHOW_FAVORITES.get() ? 1 : 0)
|
adapter.item(R.string.layer_favorites).selected(settings.SHOW_FAVORITES.get() ? 1 : 0)
|
||||||
.icons(R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light).reg();
|
.icons(R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light).reg();
|
||||||
adapter.item(R.string.layer_gpx_layer).selected(
|
adapter.item(R.string.layer_gpx_layer).selected(
|
||||||
getApplication().getGpxFileToDisplay() != null ? 1 : 0)
|
getApplication().getSelectedGpxHelper() != null ? 1 : 0)
|
||||||
// .icons(R.drawable.ic_action_foot_dark, R.drawable.ic_action_foot_light)
|
// .icons(R.drawable.ic_action_foot_dark, R.drawable.ic_action_foot_light)
|
||||||
.icons(R.drawable.ic_action_polygom_dark, R.drawable.ic_action_polygom_light)
|
.icons(R.drawable.ic_action_polygom_dark, R.drawable.ic_action_polygom_light)
|
||||||
.reg();
|
.reg();
|
||||||
|
@ -372,30 +372,24 @@ public class MapActivityLayers {
|
||||||
|
|
||||||
public void showGPXFileLayer(final OsmandMapTileView mapView){
|
public void showGPXFileLayer(final OsmandMapTileView mapView){
|
||||||
final OsmandSettings settings = getApplication().getSettings();
|
final OsmandSettings settings = getApplication().getSettings();
|
||||||
GpxUiHelper.selectGPXFile(activity, true, true, new CallbackWithObject<GPXFile>() {
|
GpxUiHelper.selectGPXFile(activity, true, true, new CallbackWithObject<GPXFile[]>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean processResult(GPXFile result) {
|
public boolean processResult(GPXFile[] result) {
|
||||||
GPXFile toShow = result;
|
WptPt locToShow = null;
|
||||||
if (toShow == null || toShow.showCurrentTrack) {
|
for(GPXFile g : result) {
|
||||||
if(!settings.SAVE_TRACK_TO_GPX.get()){
|
if(g.showCurrentTrack) {
|
||||||
AccessibleToast.makeText(activity, R.string.gpx_monitoring_disabled_warn, Toast.LENGTH_SHORT).show();
|
if(!settings.SAVE_TRACK_TO_GPX.get()){
|
||||||
|
AccessibleToast.makeText(activity, R.string.gpx_monitoring_disabled_warn, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
Map<String, GPXFile> data = getApplication().getSavingTrackHelper().collectRecordedData();
|
if(!g.showCurrentTrack || locToShow == null) {
|
||||||
if(toShow == null) {
|
locToShow = g.findPointToShow();
|
||||||
toShow = new GPXFile();
|
|
||||||
toShow.showCurrentTrack = true;
|
|
||||||
}
|
|
||||||
if(!data.isEmpty()) {
|
|
||||||
GPXFile last = data.values().iterator().next();
|
|
||||||
GPXUtilities.mergeGPXFileInto(toShow, last);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
getApplication().getSelectedGpxHelper().setGpxFileToDisplay(result);
|
||||||
settings.SHOW_FAVORITES.set(true);
|
if(locToShow != null){
|
||||||
getApplication().setGpxFileToDisplay(toShow, toShow.showCurrentTrack);
|
mapView.getAnimatedDraggingThread().startMoving(locToShow.lat, locToShow.lon,
|
||||||
WptPt loc = toShow.findPointToShow();
|
|
||||||
if(loc != null){
|
|
||||||
mapView.getAnimatedDraggingThread().startMoving(loc.lat, loc.lon,
|
|
||||||
mapView.getZoom(), true);
|
mapView.getZoom(), true);
|
||||||
}
|
}
|
||||||
mapView.refreshMap();
|
mapView.refreshMap();
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.Track;
|
import net.osmand.plus.GPXUtilities.Track;
|
||||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.OsmAndLocationProvider;
|
import net.osmand.plus.OsmAndLocationProvider;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
@ -58,10 +59,15 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
private LatLon lastPoint;
|
private LatLon lastPoint;
|
||||||
private float distance = 0;
|
private float distance = 0;
|
||||||
|
private SelectedGpxFile currentTrack;
|
||||||
|
|
||||||
public SavingTrackHelper(OsmandApplication ctx){
|
public SavingTrackHelper(OsmandApplication ctx){
|
||||||
super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
|
super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
|
this.currentTrack = new SelectedGpxFile();
|
||||||
|
this.currentTrack.setShowCurrentTrack(true);
|
||||||
|
this.currentTrack.getGpxFile().showCurrentTrack = true;
|
||||||
|
this.currentTrack.getGpxFile().tracks.add(new Track());
|
||||||
updateScript = "INSERT INTO " + TRACK_NAME +
|
updateScript = "INSERT INTO " + TRACK_NAME +
|
||||||
" (" +TRACK_COL_LAT +", " +TRACK_COL_LON+", " +TRACK_COL_ALTITUDE+", " +TRACK_COL_SPEED
|
" (" +TRACK_COL_LAT +", " +TRACK_COL_LON+", " +TRACK_COL_ALTITUDE+", " +TRACK_COL_SPEED
|
||||||
+", " +TRACK_COL_HDOP+", " +TRACK_COL_DATE+ ")" +
|
+", " +TRACK_COL_HDOP+", " +TRACK_COL_DATE+ ")" +
|
||||||
|
@ -281,7 +287,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
lastTimeUpdated = 0;
|
lastTimeUpdated = 0;
|
||||||
lastPoint = null;
|
lastPoint = null;
|
||||||
execWithClose(updateScript, new Object[] { 0, 0, 0, 0, 0, System.currentTimeMillis()});
|
execWithClose(updateScript, new Object[] { 0, 0, 0, 0, 0, System.currentTimeMillis()});
|
||||||
addTrackPoint(null, true);
|
addTrackPoint( null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLocation(net.osmand.Location location) {
|
public void updateLocation(net.osmand.Location location) {
|
||||||
|
@ -306,34 +312,37 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
newSegment = true;
|
newSegment = true;
|
||||||
} else {
|
} else {
|
||||||
float[] lastInterval = new float[1];
|
float[] lastInterval = new float[1];
|
||||||
net.osmand.Location.distanceBetween(lat, lon, lastPoint.getLatitude(), lastPoint.getLongitude(), lastInterval);
|
net.osmand.Location.distanceBetween(lat, lon, lastPoint.getLatitude(), lastPoint.getLongitude(),
|
||||||
|
lastInterval);
|
||||||
distance += lastInterval[0];
|
distance += lastInterval[0];
|
||||||
lastPoint = new LatLon(lat, lon);
|
lastPoint = new LatLon(lat, lon);
|
||||||
}
|
}
|
||||||
lastTimeUpdated = time;
|
lastTimeUpdated = time;
|
||||||
if (settings.SHOW_CURRENT_GPX_TRACK.get()) {
|
WptPt pt = new GPXUtilities.WptPt(lat, lon, time, alt, speed, hdop);
|
||||||
WptPt pt = new GPXUtilities.WptPt(lat, lon, time,
|
addTrackPoint(pt, newSegment);
|
||||||
alt, speed, hdop);
|
|
||||||
addTrackPoint(pt, newSegment);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTrackPoint(WptPt pt, boolean newSegment) {
|
private void addTrackPoint(WptPt pt, boolean newSegment) {
|
||||||
GPXFile file = ctx.getGpxFileToDisplay();
|
List<List<WptPt>> points = currentTrack.getModifiablePointsToDisplay();
|
||||||
if (file != null && ctx.getSettings().SHOW_CURRENT_GPX_TRACK.get()) {
|
Track track = currentTrack.getGpxFile().tracks.get(0);
|
||||||
List<List<WptPt>> points = file.processedPointsToDisplay;
|
assert track.segments.size() == points.size();
|
||||||
if (points.size() == 0 || newSegment) {
|
if (points.size() == 0 || newSegment) {
|
||||||
points.add(new ArrayList<WptPt>());
|
points.add(new ArrayList<WptPt>());
|
||||||
}
|
track.segments.add(new TrkSegment());
|
||||||
if (pt != null) {
|
}
|
||||||
List<WptPt> last = points.get(points.size() - 1);
|
if (pt != null) {
|
||||||
last.add(pt);
|
int ind = points.size() - 1;
|
||||||
}
|
List<WptPt> last = points.get(ind);
|
||||||
|
last.add(pt);
|
||||||
|
track.segments.get(ind).points.add(pt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertPointData(double lat, double lon, long time, String description) {
|
public void insertPointData(double lat, double lon, long time, String description) {
|
||||||
|
final WptPt pt = new WptPt(lat, lon, time, Double.NaN, 0, Double.NaN);
|
||||||
|
pt.name = description;
|
||||||
|
currentTrack.getGpxFile().points.add(pt);
|
||||||
execWithClose(updatePointsScript, new Object[] { lat, lon, time, description });
|
execWithClose(updatePointsScript, new Object[] { lat, lon, time, description });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,4 +367,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
return lastTimeUpdated;
|
return lastTimeUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GPXFile getCurrentGpx() {
|
||||||
|
return currentTrack.getGpxFile();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
package net.osmand.plus.activities;
|
package net.osmand.plus.activities;
|
||||||
|
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||||
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -10,11 +16,9 @@ import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ExpandableListView;
|
import android.widget.ExpandableListView;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.actionbarsherlock.view.ActionMode;
|
import com.actionbarsherlock.view.ActionMode;
|
||||||
import com.actionbarsherlock.view.ActionMode.Callback;
|
|
||||||
import com.actionbarsherlock.view.Menu;
|
import com.actionbarsherlock.view.Menu;
|
||||||
import com.actionbarsherlock.view.MenuInflater;
|
import com.actionbarsherlock.view.MenuInflater;
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
@ -26,9 +30,12 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
|
||||||
public static final int SEARCH_ID = -1;
|
public static final int SEARCH_ID = -1;
|
||||||
public static final int ACTION_ID = 0;
|
public static final int ACTION_ID = 0;
|
||||||
protected static final int DELETE_ACTION_ID = 1;
|
protected static final int DELETE_ACTION_ID = 1;
|
||||||
private boolean selectionMode = false;
|
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
private SearchView searchView;
|
private SearchView searchView;
|
||||||
|
private OsmandApplication app;
|
||||||
|
private GpxSelectionHelper selectedGpxHelper;
|
||||||
|
private SelectedGPXAdapter adapter;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
|
@ -36,12 +43,17 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
final Collator collator = Collator.getInstance();
|
final Collator collator = Collator.getInstance();
|
||||||
collator.setStrength(Collator.SECONDARY);
|
collator.setStrength(Collator.SECONDARY);
|
||||||
|
app = (OsmandApplication) activity.getApplication();
|
||||||
|
selectedGpxHelper = app.getSelectedGpxHelper();
|
||||||
|
|
||||||
|
adapter = new SelectedGPXAdapter();
|
||||||
|
setAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
adapter.setDisplayGroups(selectedGpxHelper.getDisplayGroups());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,56 +97,21 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
|
||||||
getSherlockActivity().setSupportProgressBarIndeterminateVisibility(false);
|
getSherlockActivity().setSupportProgressBarIndeterminateVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterDeleteMode() {
|
|
||||||
actionMode = getSherlockActivity().startActionMode(new Callback() {
|
|
||||||
|
|
||||||
@Override
|
class SelectedGPXAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
|
||||||
selectionMode = true;
|
|
||||||
createMenuItem(menu, DELETE_ACTION_ID, R.string.default_buttons_delete,
|
|
||||||
R.drawable.ic_action_delete_light, R.drawable.ic_action_delete_dark,
|
|
||||||
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroyActionMode(ActionMode mode) {
|
|
||||||
selectionMode = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
|
||||||
if (item.getItemId() == DELETE_ACTION_ID) {
|
|
||||||
// TODO delete
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SelectedGPXAdapter extends OsmandBaseExpandableListAdapter implements Filterable {
|
|
||||||
|
|
||||||
Filter myFilter;
|
Filter myFilter;
|
||||||
|
private List<GpxDisplayGroup> displayGroups = new ArrayList<GpxDisplayGroup>();
|
||||||
|
|
||||||
|
public void setDisplayGroups(List<GpxDisplayGroup> displayGroups) {
|
||||||
|
this.displayGroups = displayGroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getChild(int groupPosition, int childPosition) {
|
public GpxDisplayItem getChild(int groupPosition, int childPosition) {
|
||||||
return null;
|
GpxDisplayGroup group = getGroup(groupPosition);
|
||||||
|
return group.getModifiableList().get(childPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -144,17 +121,17 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getChildrenCount(int groupPosition) {
|
public int getChildrenCount(int groupPosition) {
|
||||||
return 0;
|
return getGroup(groupPosition).getModifiableList().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGroup(int groupPosition) {
|
public GpxDisplayGroup getGroup(int groupPosition) {
|
||||||
return "";
|
return displayGroups.get(groupPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getGroupCount() {
|
public int getGroupCount() {
|
||||||
return 0;
|
return displayGroups.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -182,10 +159,9 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
adjustIndicator(groupPosition, isExpanded, row);
|
adjustIndicator(groupPosition, isExpanded, row);
|
||||||
TextView label = (TextView) row.findViewById(R.id.category_name);
|
TextView label = (TextView) row.findViewById(R.id.category_name);
|
||||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
|
final GpxDisplayGroup model = getGroup(groupPosition);
|
||||||
// final String model = getGroup(groupPosition);
|
label.setText(model.getGroupName(app));
|
||||||
// label.setText(model);
|
// final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
|
||||||
//
|
|
||||||
// if (selectionMode) {
|
// if (selectionMode) {
|
||||||
// ch.setVisibility(View.VISIBLE);
|
// ch.setVisibility(View.VISIBLE);
|
||||||
// ch.setChecked(groupsToDelete.contains(model));
|
// ch.setChecked(groupsToDelete.contains(model));
|
||||||
|
@ -264,77 +240,13 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Filter getFilter() {
|
|
||||||
if (myFilter == null) {
|
|
||||||
myFilter = new SearchFilter();
|
|
||||||
}
|
|
||||||
return myFilter;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SearchFilter extends Filter {
|
|
||||||
|
|
||||||
|
|
||||||
public SearchFilter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
|
||||||
FilterResults results = new FilterResults();
|
|
||||||
// if (constraint == null || constraint.length() == 0) {
|
|
||||||
// results.values = helper.getFavoriteGroups();
|
|
||||||
// results.count = 1;
|
|
||||||
// } else {
|
|
||||||
// TreeMap<String, List<FavouritePoint>> filter = new TreeMap<String, List<FavouritePoint>>(helper.getFavoriteGroups());
|
|
||||||
// TreeMap<String, List<FavouritePoint>> filterLists = new TreeMap<String, List<FavouritePoint>>();
|
|
||||||
// String cs = constraint.toString().toLowerCase();
|
|
||||||
// Iterator<Entry<String, List<FavouritePoint>>> ti = filter.entrySet().iterator();
|
|
||||||
// while(ti.hasNext()) {
|
|
||||||
// Entry<String, List<FavouritePoint>> next = ti.next();
|
|
||||||
// if(next.getKey().toLowerCase().indexOf(cs) == -1) {
|
|
||||||
// ti.remove();
|
|
||||||
// filterLists.put(next.getKey(), next.getValue());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// ti = filterLists.entrySet().iterator();
|
|
||||||
// while(ti.hasNext()) {
|
|
||||||
// Entry<String, List<FavouritePoint>> next = ti.next();
|
|
||||||
// final List<FavouritePoint> list = next.getValue();
|
|
||||||
// LinkedList<FavouritePoint> ll = new LinkedList<FavouritePoint>();
|
|
||||||
// for(FavouritePoint l : list) {
|
|
||||||
// if(l.getName().toLowerCase().indexOf(cs) != -1) {
|
|
||||||
// ll.add(l);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// if(ll.size() > 0) {
|
|
||||||
// filter.put(next.getKey(), ll);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// results.values = filter;
|
|
||||||
// results.count = filter.size();
|
|
||||||
// }
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
|
||||||
// synchronized (adapter) {
|
|
||||||
// favouritesAdapter.setFavoriteGroups((Map<String, List<FavouritePoint>>) results.values);
|
|
||||||
// }
|
|
||||||
// favouritesAdapter.notifyDataSetChanged();
|
|
||||||
// if(constraint != null && constraint.length() > 1) {
|
|
||||||
// collapseTrees();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import net.osmand.PlatformUtil;
|
||||||
import net.osmand.access.AccessibleAlertBuilder;
|
import net.osmand.access.AccessibleAlertBuilder;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.DataTileManager;
|
import net.osmand.data.DataTileManager;
|
||||||
import net.osmand.data.FavouritePoint;
|
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
|
@ -967,11 +966,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
&& OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
|
&& OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
|
||||||
String name = f.getName();
|
String name = f.getName();
|
||||||
SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
|
SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
|
||||||
|
|
||||||
savingTrackHelper.insertPointData(rec.lat, rec.lon, System.currentTimeMillis(), name);
|
savingTrackHelper.insertPointData(rec.lat, rec.lon, System.currentTimeMillis(), name);
|
||||||
if (app.getSettings().SHOW_CURRENT_GPX_TRACK.get()) {
|
|
||||||
app.getFavorites().addFavoritePointToGPXFile(new FavouritePoint(rec.lat, rec.lon, name, ""));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,12 +188,13 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
|
|
||||||
protected void loadGpx(final MapActivity activity) {
|
protected void loadGpx(final MapActivity activity) {
|
||||||
GpxUiHelper.selectGPXFile(activity, false, false, new CallbackWithObject<GPXUtilities.GPXFile>() {
|
GpxUiHelper.selectGPXFile(activity, false, false, new CallbackWithObject<GPXUtilities.GPXFile[]>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean processResult(GPXFile result) {
|
public boolean processResult(GPXFile[] res) {
|
||||||
measurementPoints.clear();
|
measurementPoints.clear();
|
||||||
if (result != null) {
|
if (res.length > 0 && res[0] != null) {
|
||||||
|
GPXFile result = res[0];
|
||||||
originalGPX = result;
|
originalGPX = result;
|
||||||
for (Track t : result.tracks) {
|
for (Track t : result.tracks) {
|
||||||
for (TrkSegment s : t.segments) {
|
for (TrkSegment s : t.segments) {
|
||||||
|
|
|
@ -282,7 +282,7 @@ public class GpxImportHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showGpxOnMap(final GPXUtilities.GPXFile result) {
|
private void showGpxOnMap(final GPXUtilities.GPXFile result) {
|
||||||
application.setGpxFileToDisplay(result, true);
|
application.getSelectedGpxHelper().setGpxFileToDisplay(result);
|
||||||
final GPXUtilities.WptPt moveTo = result.findPointToShow();
|
final GPXUtilities.WptPt moveTo = result.findPointToShow();
|
||||||
if (moveTo != null) {
|
if (moveTo != null) {
|
||||||
mapView.getAnimatedDraggingThread().startMoving(moveTo.lat, moveTo.lon, mapView.getZoom(), true);
|
mapView.getAnimatedDraggingThread().startMoving(moveTo.lat, moveTo.lon, mapView.getZoom(), true);
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class GpxUiHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void selectGPXFile(final Activity activity,
|
public static void selectGPXFile(final Activity activity,
|
||||||
final boolean showCurrentGpx, final boolean multipleChoice, final CallbackWithObject<GPXFile> callbackWithObject) {
|
final boolean showCurrentGpx, final boolean multipleChoice, final CallbackWithObject<GPXFile[]> callbackWithObject) {
|
||||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||||
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||||
final List<String> list = getSortedGPXFilenames(dir);
|
final List<String> list = getSortedGPXFilenames(dir);
|
||||||
|
@ -114,11 +114,11 @@ public class GpxUiHelper {
|
||||||
final File dir, String filename, final int position) {
|
final File dir, String filename, final int position) {
|
||||||
final Application app = activity.getApplication();
|
final Application app = activity.getApplication();
|
||||||
final File f = new File(dir, filename);
|
final File f = new File(dir, filename);
|
||||||
loadGPXFileInDifferentThread(activity, new CallbackWithObject<GPXUtilities.GPXFile>() {
|
loadGPXFileInDifferentThread(activity, new CallbackWithObject<GPXUtilities.GPXFile[]>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean processResult(GPXFile result) {
|
public boolean processResult(GPXFile[] result) {
|
||||||
cmAdapter.setItemName(position, cmAdapter.getItemName(position) + "\n" + getDescription((OsmandApplication) app, result, f));
|
cmAdapter.setItemName(position, cmAdapter.getItemName(position) + "\n" + getDescription((OsmandApplication) app, result[0], f));
|
||||||
adapter.notifyDataSetInvalidated();
|
adapter.notifyDataSetInvalidated();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ public class GpxUiHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createDialog(final Activity activity, final boolean showCurrentGpx,
|
private static void createDialog(final Activity activity, final boolean showCurrentGpx,
|
||||||
final boolean multipleChoice, final CallbackWithObject<GPXFile> callbackWithObject,
|
final boolean multipleChoice, final CallbackWithObject<GPXFile[]> callbackWithObject,
|
||||||
final List<String> list, final ContextMenuAdapter adapter) {
|
final List<String> list, final ContextMenuAdapter adapter) {
|
||||||
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||||
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||||
|
@ -209,8 +209,7 @@ public class GpxUiHelper {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
GPXFile currentGPX = null;
|
GPXFile currentGPX = null;
|
||||||
if (showCurrentGpx && adapter.getSelection(0) > 0) {
|
if (showCurrentGpx && adapter.getSelection(0) > 0) {
|
||||||
currentGPX = new GPXFile();
|
currentGPX = app.getSavingTrackHelper().getCurrentGpx();
|
||||||
currentGPX.showCurrentTrack = true;
|
|
||||||
}
|
}
|
||||||
List<String> s = new ArrayList<String>();
|
List<String> s = new ArrayList<String>();
|
||||||
for (int i = (showCurrentGpx ? 1 : 0); i < adapter.length(); i++) {
|
for (int i = (showCurrentGpx ? 1 : 0); i < adapter.length(); i++) {
|
||||||
|
@ -288,34 +287,39 @@ public class GpxUiHelper {
|
||||||
return getSortedGPXFilenames(dir, null);
|
return getSortedGPXFilenames(dir, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadGPXFileInDifferentThread(final Activity activity, final CallbackWithObject<GPXFile> callbackWithObject,
|
private static void loadGPXFileInDifferentThread(final Activity activity, final CallbackWithObject<GPXFile[]> callbackWithObject,
|
||||||
final File dir, final GPXFile currentFile, final String... filename) {
|
final File dir, final GPXFile currentFile, final String... filename) {
|
||||||
final ProgressDialog dlg = ProgressDialog.show(activity, activity.getString(R.string.loading),
|
final ProgressDialog dlg = ProgressDialog.show(activity, activity.getString(R.string.loading),
|
||||||
activity.getString(R.string.loading_data));
|
activity.getString(R.string.loading_data));
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GPXFile r = currentFile;
|
final GPXFile[] result = new GPXFile[filename.length + (currentFile == null ? 1 : 0)];
|
||||||
for(String fname : filename) {
|
int k = 0;
|
||||||
|
String w = "";
|
||||||
|
if (currentFile != null) {
|
||||||
|
result[k++] = currentFile;
|
||||||
|
}
|
||||||
|
for (String fname : filename) {
|
||||||
final File f = new File(dir, fname);
|
final File f = new File(dir, fname);
|
||||||
GPXFile res = GPXUtilities.loadGPXFile(activity.getApplication(), f);
|
GPXFile res = GPXUtilities.loadGPXFile(activity.getApplication(), f);
|
||||||
GPXUtilities.mergeGPXFileInto(res, r);
|
if (res.warning != null && res.warning.length() > 0) {
|
||||||
r = res;
|
w += res.warning + "\n";
|
||||||
|
}
|
||||||
|
result[k++] = res;
|
||||||
}
|
}
|
||||||
final GPXFile res = r;
|
|
||||||
dlg.dismiss();
|
dlg.dismiss();
|
||||||
if (res != null) {
|
final String warn = w;
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (res.warning != null) {
|
if (warn.length() > 0) {
|
||||||
AccessibleToast.makeText(activity, res.warning, Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(activity, warn, Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
callbackWithObject.processResult(res);
|
callbackWithObject.processResult(result);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}, "Loading gpx").start(); //$NON-NLS-1$
|
}, "Loading gpx").start(); //$NON-NLS-1$
|
||||||
|
|
|
@ -367,7 +367,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
||||||
}
|
}
|
||||||
if(visible && (changed || makeVisible)) {
|
if(visible && (changed || makeVisible)) {
|
||||||
GPXFile selectGPXFile = GPXUtilities.loadGPXFile(app, f);
|
GPXFile selectGPXFile = GPXUtilities.loadGPXFile(app, f);
|
||||||
app.setGpxFileToDisplay(selectGPXFile, app.getSettings().SHOW_CURRENT_GPX_TRACK.get());
|
app.getSelectedGpxHelper().setGpxFileToDisplay(selectGPXFile);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -136,8 +136,7 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
||||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
|
|
||||||
for (ColoredGPX cg : gpxArrayList){
|
for (ColoredGPX cg : gpxArrayList){
|
||||||
cg.gpxFile.proccessPoints();
|
List<List<WptPt>> points = cg.gpxFile.proccessPoints();
|
||||||
List<List<WptPt>> points = cg.gpxFile.processedPointsToDisplay;
|
|
||||||
|
|
||||||
paint.setColor(cg.color);
|
paint.setColor(cg.color);
|
||||||
|
|
||||||
|
|
|
@ -280,7 +280,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
||||||
WptPt p = gpx.findPointToShow();
|
WptPt p = gpx.findPointToShow();
|
||||||
getMyApplication().getSettings().setMapLocationToShow(p.lat, p.lon,
|
getMyApplication().getSettings().setMapLocationToShow(p.lat, p.lon,
|
||||||
getMyApplication().getSettings().getLastKnownMapZoom(), null);
|
getMyApplication().getSettings().getLastKnownMapZoom(), null);
|
||||||
getMyApplication().setGpxFileToDisplay(gpx, false);
|
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(gpx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
|
|
|
@ -4,9 +4,9 @@ import java.util.List;
|
||||||
|
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.render.RenderingRuleSearchRequest;
|
import net.osmand.render.RenderingRuleSearchRequest;
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
|
@ -26,12 +26,13 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private Path path;
|
private Path path;
|
||||||
|
|
||||||
private OsmandSettings settings;
|
|
||||||
|
|
||||||
private RenderingRulesStorage cachedRrs;
|
private RenderingRulesStorage cachedRrs;
|
||||||
private boolean cachedNightMode;
|
private boolean cachedNightMode;
|
||||||
private int cachedColor;
|
private int cachedColor;
|
||||||
|
|
||||||
|
private GpxSelectionHelper selectedGpxHelper;
|
||||||
|
|
||||||
|
|
||||||
private void initUI() {
|
private void initUI() {
|
||||||
paint = new Paint();
|
paint = new Paint();
|
||||||
|
@ -47,7 +48,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 = view.getSettings();
|
selectedGpxHelper = view.getApplication().getSelectedGpxHelper();
|
||||||
initUI();
|
initUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,14 +73,19 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
GPXFile gpxFile = view.getApplication().getGpxFileToDisplay();
|
List<SelectedGpxFile> selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles();
|
||||||
if(gpxFile == null){
|
int clr = getColor(settings);
|
||||||
return;
|
if (!selectedGPXFiles.isEmpty()) {
|
||||||
|
for (SelectedGpxFile g : selectedGPXFiles) {
|
||||||
|
List<List<WptPt>> points = g.getPointsToDisplay();
|
||||||
|
int t = g.getColor();
|
||||||
|
paint.setColor(t == 0 ? clr : t);
|
||||||
|
drawSegments(canvas, tileBox, points);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
List<List<WptPt>> points = gpxFile.processedPointsToDisplay;
|
}
|
||||||
|
|
||||||
paint.setColor(getColor(settings));
|
|
||||||
|
|
||||||
|
private void drawSegments(Canvas canvas, RotatedTileBox tileBox, List<List<WptPt>> points) {
|
||||||
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||||
for (List<WptPt> l : points) {
|
for (List<WptPt> l : points) {
|
||||||
path.rewind();
|
path.rewind();
|
||||||
|
@ -100,7 +106,6 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
if (startIndex != -1) {
|
if (startIndex != -1) {
|
||||||
drawSegment(canvas, tileBox, l, startIndex, l.size() - 1);
|
drawSegment(canvas, tileBox, l, startIndex, l.size() - 1);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,11 +129,6 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isShowingCurrentTrack(){
|
|
||||||
return settings.SHOW_CURRENT_GPX_TRACK.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroyLayer() {
|
public void destroyLayer() {
|
||||||
|
|
||||||
|
|
|
@ -356,11 +356,11 @@ public class MapRoutePreferencesControl extends MapControls {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void openGPXFileSelection(final Spinner gpxSpinner) {
|
protected void openGPXFileSelection(final Spinner gpxSpinner) {
|
||||||
GpxUiHelper.selectGPXFile(mapActivity, false, false, new CallbackWithObject<GPXUtilities.GPXFile>() {
|
GpxUiHelper.selectGPXFile(mapActivity, false, false, new CallbackWithObject<GPXUtilities.GPXFile[]>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean processResult(GPXFile result) {
|
public boolean processResult(GPXFile[] result) {
|
||||||
mapActivity.getMapActions().setGPXRouteParams(result);
|
mapActivity.getMapActions().setGPXRouteParams(result[0]);
|
||||||
mapActivity.getMyApplication().getTargetPointsHelper().updateRoutingHelper();
|
mapActivity.getMyApplication().getTargetPointsHelper().updateRoutingHelper();
|
||||||
updateSpinnerItems(gpxSpinner);
|
updateSpinnerItems(gpxSpinner);
|
||||||
updateParameters();
|
updateParameters();
|
||||||
|
|
Loading…
Reference in a new issue