Save selected gpx
This commit is contained in:
parent
ecb1580c81
commit
7a2bbe329a
9 changed files with 90 additions and 8 deletions
|
@ -9,6 +9,8 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="loading_smth">Loading %1$s …</string>
|
||||
<string name="map_widget_plain_time">Current time</string>
|
||||
<string name="gpx_wpt">Waypoint</string>
|
||||
<string name="selected_gpx_info_show">\n\nPress and hold to see on map</string>
|
||||
<string name="delay_navigation_start">Start navigation with delay</string>
|
||||
|
@ -1699,7 +1701,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
|
|||
<string name="loading_postcodes">Loading postcodes…</string>
|
||||
<string name="loading_streets">Loading streets…</string>
|
||||
<string name="loading_cities">Loading cities…</string>
|
||||
<string name="loading">Loading…</string>
|
||||
<string name="poi">POI</string>
|
||||
<string name="error_occurred_saving_gpx">Error while saving GPX</string>
|
||||
<string name="error_calculating_route">Error calculating route</string>
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GPXUtilities.Route;
|
||||
|
@ -16,6 +22,8 @@ import android.graphics.Bitmap;
|
|||
|
||||
public class GpxSelectionHelper {
|
||||
|
||||
private static final String CURRENT_TRACK = "currentTrack";
|
||||
private static final String FILE = "file";
|
||||
private OsmandApplication app;
|
||||
// save into settings
|
||||
// public final CommonPreference<Boolean> SHOW_CURRENT_GPX_TRACK =
|
||||
|
@ -264,8 +272,49 @@ public class GpxSelectionHelper {
|
|||
saveCurrentSelections();
|
||||
}
|
||||
|
||||
public void loadGPXTracks(IProgress p) {
|
||||
String load = app.getSettings().SELECTED_GPX.get();
|
||||
if(!Algorithms.isEmpty(load)) {
|
||||
try {
|
||||
JSONArray ar = new JSONArray("load");
|
||||
for(int i = 0; i < ar.length(); i++) {
|
||||
JSONObject obj = ar.getJSONObject(i);
|
||||
if(obj.has(FILE)) {
|
||||
File fl = new File(obj.getString(FILE));
|
||||
if(p != null) {
|
||||
p.startTask(getString(R.string.loading, fl.getName()), -1);
|
||||
}
|
||||
GPXFile gpx = GPXUtilities.loadGPXFile(app, fl);
|
||||
selectGpxFile(gpx, true);
|
||||
} else if(obj.has(CURRENT_TRACK)) {
|
||||
selectedGPXFiles.add(savingTrackHelper.getCurrentTrack());
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
app.getSettings().SELECTED_GPX.set("");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveCurrentSelections() {
|
||||
// TODO;
|
||||
JSONArray ar = new JSONArray();
|
||||
for(SelectedGpxFile s : selectedGPXFiles) {
|
||||
if(s.gpxFile != null) {
|
||||
JSONObject obj = new JSONObject();
|
||||
try {
|
||||
if(!Algorithms.isEmpty(s.gpxFile.path)) {
|
||||
obj.put(FILE, s.gpxFile.path);
|
||||
} else {
|
||||
obj.put(CURRENT_TRACK, true);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ar.put(obj);
|
||||
}
|
||||
}
|
||||
app.getSettings().SELECTED_GPX.set(ar.toString());
|
||||
}
|
||||
|
||||
private void selectGpxFileImpl(GPXFile gpx, boolean show) {
|
||||
|
|
|
@ -849,6 +849,9 @@ public class OsmandSettings {
|
|||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Boolean> SHOW_FAVORITES = new BooleanPreference("show_favorites", false).makeGlobal();
|
||||
|
||||
// Json
|
||||
public final OsmandPreference<String> SELECTED_GPX = new StringPreference("selected_gpx", "").makeGlobal();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Integer> MAP_SCREEN_ORIENTATION =
|
||||
new IntPreference("map_screen_orientation", -1/*ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED*/).makeGlobal();
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ContributionVersionActivity extends OsmandListActivity {
|
|||
private void startThreadOperation(int operationId, String message, int total) {
|
||||
|
||||
progressDlg = new ProgressDialog(this);
|
||||
progressDlg.setTitle(getString(R.string.loading));
|
||||
progressDlg.setTitle(getString(R.string.loading_smth, ""));
|
||||
progressDlg.setMessage(message);
|
||||
if(total != -1){
|
||||
progressDlg.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
|
|
|
@ -89,7 +89,7 @@ public class GpxImportHelper {
|
|||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progress = ProgressDialog.show(mapActivity, application.getString(R.string.loading), application.getString(R.string.loading_data));
|
||||
progress = ProgressDialog.show(mapActivity, application.getString(R.string.loading_smth, ""), application.getString(R.string.loading_data));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -127,7 +127,7 @@ public class GpxImportHelper {
|
|||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progress = ProgressDialog.show(mapActivity, application.getString(R.string.loading), application.getString(R.string.loading_data));
|
||||
progress = ProgressDialog.show(mapActivity, application.getString(R.string.loading_smth, ""), application.getString(R.string.loading_data));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -333,7 +333,7 @@ public class GpxUiHelper {
|
|||
|
||||
private static void loadGPXFileInDifferentThread(final Activity activity, final CallbackWithObject<GPXFile[]> callbackWithObject,
|
||||
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_smth, ""),
|
||||
activity.getString(R.string.loading_data));
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
|
|
|
@ -412,6 +412,7 @@ public class ResourceManager {
|
|||
indexRegionsBoundaries(progress, false);
|
||||
// do it lazy
|
||||
// indexingImageTiles(progress);
|
||||
context.getSelectedGpxHelper().loadGPXTracks(progress);
|
||||
warnings.addAll(indexingMaps(progress));
|
||||
warnings.addAll(indexVoiceFiles(progress));
|
||||
warnings.addAll(OsmandPlugin.onIndexingFiles(progress));
|
||||
|
|
|
@ -197,6 +197,8 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
mapInfoControls.registerSideWidget(maxspeed, R.drawable.widget_max_speed, R.string.map_widget_max_speed, "max_speed", false, 18);
|
||||
TextInfoWidget alt = mic.createAltitudeControl(map, paintText, paintSubText);
|
||||
mapInfoControls.registerSideWidget(alt, R.drawable.widget_altitude, R.string.map_widget_altitude, "altitude", false, 20);
|
||||
TextInfoWidget plainTime = ric.createPlainTimeControl(map, paintText, paintSubText);
|
||||
mapInfoControls.registerSideWidget(plainTime, R.drawable.widget_time_to_distance, R.string.map_widget_plain_time, "plain_time", false, 25);
|
||||
|
||||
// Top widgets
|
||||
ImageViewWidget compassView = mic.createCompassView(map);
|
||||
|
|
|
@ -220,7 +220,6 @@ public class RouteInfoWidgetsFactory {
|
|||
return nextTurnInfo;
|
||||
}
|
||||
|
||||
|
||||
public TextInfoWidget createTimeControl(final MapActivity map, Paint paintText, Paint paintSubText){
|
||||
final RoutingHelper routingHelper = map.getRoutingHelper();
|
||||
final Drawable time = map.getResources().getDrawable(R.drawable.widget_time);
|
||||
|
@ -287,6 +286,33 @@ public class RouteInfoWidgetsFactory {
|
|||
}
|
||||
|
||||
|
||||
public TextInfoWidget createPlainTimeControl(final MapActivity map, Paint paintText, Paint paintSubText){
|
||||
final Drawable timeToGo = map.getResources().getDrawable(R.drawable.widget_time_to_distance);
|
||||
final OsmandApplication ctx = map.getMyApplication();
|
||||
final TextInfoWidget plainTimeControl = new TextInfoWidget(map, 0, paintText, paintSubText) {
|
||||
private long cachedLeftTime = 0;
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
long time = System.currentTimeMillis();
|
||||
if(time - cachedLeftTime > 5000) {
|
||||
cachedLeftTime = time;
|
||||
if (DateFormat.is24HourFormat(ctx)) {
|
||||
setText(DateFormat.format("k:mm", time).toString(), null); //$NON-NLS-1$
|
||||
} else {
|
||||
setText(DateFormat.format("h:mm", time).toString(),
|
||||
DateFormat.format("aa", time).toString()); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
};
|
||||
plainTimeControl.setText(null, null);
|
||||
plainTimeControl.setImageDrawable(timeToGo);
|
||||
return plainTimeControl;
|
||||
}
|
||||
|
||||
|
||||
public TextInfoWidget createMaxSpeedControl(final MapActivity map, Paint paintText, Paint paintSubText) {
|
||||
final RoutingHelper rh = map.getMyApplication().getRoutingHelper();
|
||||
final OsmAndLocationProvider locationProvider = map.getMyApplication().getLocationProvider();
|
||||
|
|
Loading…
Reference in a new issue