Merge
This commit is contained in:
commit
d729e2fd0e
12 changed files with 55 additions and 30 deletions
|
@ -10,12 +10,14 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:ellipsize="end"
|
||||
android:textSize="20sp"/>
|
||||
|
||||
<TextView android:id="@+id/points_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:minWidth="16dp"
|
||||
android:textSize="20sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -261,11 +261,11 @@ public class GpxSelectionHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void setGpxFileToDisplay(GPXFile... gpxs) {
|
||||
public void setGpxFileToDisplay(boolean notShowNavigationDialog, GPXFile... gpxs) {
|
||||
// special case for gpx current route
|
||||
for(GPXFile gpx : gpxs) {
|
||||
boolean show = true;
|
||||
selectGpxFileImpl(gpx, show);
|
||||
selectGpxFileImpl(gpx, show, notShowNavigationDialog);
|
||||
}
|
||||
saveCurrentSelections();
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ public class GpxSelectionHelper {
|
|||
p.startTask(getString(R.string.loading_smth, fl.getName()), -1);
|
||||
}
|
||||
GPXFile gpx = GPXUtilities.loadGPXFile(app, fl);
|
||||
selectGpxFile(gpx, true);
|
||||
selectGpxFile(gpx, true, false);
|
||||
} else if(obj.has(CURRENT_TRACK)) {
|
||||
selectedGPXFiles.add(savingTrackHelper.getCurrentTrack());
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ public class GpxSelectionHelper {
|
|||
private void saveCurrentSelections() {
|
||||
JSONArray ar = new JSONArray();
|
||||
for(SelectedGpxFile s : selectedGPXFiles) {
|
||||
if(s.gpxFile != null) {
|
||||
if(s.gpxFile != null && !s.notShowNavigationDialog) {
|
||||
JSONObject obj = new JSONObject();
|
||||
try {
|
||||
if(!Algorithms.isEmpty(s.gpxFile.path)) {
|
||||
|
@ -315,11 +315,12 @@ public class GpxSelectionHelper {
|
|||
app.getSettings().SELECTED_GPX.set(ar.toString());
|
||||
}
|
||||
|
||||
private void selectGpxFileImpl(GPXFile gpx, boolean show) {
|
||||
private void selectGpxFileImpl(GPXFile gpx, boolean show, boolean notShowNavigationDialog) {
|
||||
boolean displayed = false;
|
||||
SelectedGpxFile sf ;
|
||||
if(gpx.showCurrentTrack) {
|
||||
sf = savingTrackHelper.getCurrentTrack();
|
||||
sf.notShowNavigationDialog = notShowNavigationDialog;
|
||||
displayed = selectedGPXFiles.contains(sf);
|
||||
} else {
|
||||
sf = getSelectedFileByPath(gpx.path);
|
||||
|
@ -327,6 +328,7 @@ public class GpxSelectionHelper {
|
|||
if(show && sf == null) {
|
||||
sf = new SelectedGpxFile();
|
||||
sf.setGpxFile(gpx);
|
||||
sf.notShowNavigationDialog = notShowNavigationDialog;
|
||||
}
|
||||
}
|
||||
if(displayed != show) {
|
||||
|
@ -338,8 +340,8 @@ public class GpxSelectionHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public void selectGpxFile(GPXFile gpx, boolean show) {
|
||||
selectGpxFileImpl(gpx, show);
|
||||
public void selectGpxFile(GPXFile gpx, boolean show, boolean showNavigationDialog) {
|
||||
selectGpxFileImpl(gpx, show, showNavigationDialog);
|
||||
saveCurrentSelections();
|
||||
}
|
||||
|
||||
|
@ -353,6 +355,8 @@ public class GpxSelectionHelper {
|
|||
|
||||
|
||||
public static class SelectedGpxFile {
|
||||
public boolean notShowNavigationDialog = false;
|
||||
|
||||
private boolean showCurrentTrack;
|
||||
private GPXFile gpxFile;
|
||||
private int color;
|
||||
|
@ -396,6 +400,7 @@ public class GpxSelectionHelper {
|
|||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum GpxDisplayItemType {
|
||||
|
|
|
@ -82,19 +82,17 @@ public abstract class OsmandPlugin {
|
|||
if(!f && Version.isParkingPluginInlined(app)) {
|
||||
installedPlugins.add(parking);
|
||||
}
|
||||
|
||||
Set<String> enabledPlugins = settings.getEnabledPlugins();
|
||||
if(Version.isRouteNavPluginInlined(app)) {
|
||||
RoutePointsPlugin routePointsPlugin = new RoutePointsPlugin(app);
|
||||
installedPlugins.add(routePointsPlugin);
|
||||
enablePlugin(app, routePointsPlugin, true);
|
||||
enabledPlugins.add(routePointsPlugin.getId());
|
||||
}
|
||||
|
||||
installPlugin(OSMODROID_PLUGIN_COMPONENT, OsMoDroidPlugin.ID, app, new OsMoDroidPlugin(app));
|
||||
installedPlugins.add(new OsmEditingPlugin(app));
|
||||
installedPlugins.add(new OsmandDevelopmentPlugin(app));
|
||||
|
||||
|
||||
Set<String> enabledPlugins = settings.getEnabledPlugins();
|
||||
for (OsmandPlugin plugin : installedPlugins) {
|
||||
if (enabledPlugins.contains(plugin.getId())) {
|
||||
try {
|
||||
|
|
|
@ -422,7 +422,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
if (loc != null) {
|
||||
settings.setMapLocationToShow(loc.lat, loc.lon, settings.getLastKnownMapZoom());
|
||||
e = false;
|
||||
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(info.gpx);
|
||||
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(false, info.gpx);
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
}
|
||||
|
@ -887,7 +887,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
protected void onProgressUpdate(GpxInfo... values) {
|
||||
for(GpxInfo g : values) {
|
||||
final boolean visible = selectedItems.contains(g);
|
||||
selectedGpxHelper.selectGpxFile(g.gpx, visible);
|
||||
selectedGpxHelper.selectGpxFile(g.gpx, visible, false);
|
||||
if(visible && toShow == null) {
|
||||
toShow = g.gpx.findPointToShow();
|
||||
}
|
||||
|
|
|
@ -583,13 +583,15 @@ public class MapActivityActions implements DialogProvider {
|
|||
public void enterRoutePlanningMode(final LatLon from, final String fromName) {
|
||||
List<SelectedGpxFile> selectedGPXFiles = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
|
||||
GPXFile gpxFile = null;
|
||||
boolean notShowDialog = false;
|
||||
for (SelectedGpxFile gs : selectedGPXFiles) {
|
||||
if (!gs.isShowCurrentTrack()) {
|
||||
notShowDialog = gs.notShowNavigationDialog;
|
||||
gpxFile = gs.getGpxFile();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(gpxFile != null) {
|
||||
if(gpxFile != null && !notShowDialog) {
|
||||
final GPXFile f = gpxFile;
|
||||
Builder bld = new AlertDialog.Builder(mapActivity);
|
||||
bld.setMessage(R.string.use_displayed_track_for_navigation);
|
||||
|
|
|
@ -390,7 +390,7 @@ public class MapActivityLayers {
|
|||
locToShow = g.findPointToShow();
|
||||
}
|
||||
}
|
||||
getApplication().getSelectedGpxHelper().setGpxFileToDisplay(result);
|
||||
getApplication().getSelectedGpxHelper().setGpxFileToDisplay(false, result);
|
||||
if(locToShow != null){
|
||||
mapView.getAnimatedDraggingThread().startMoving(locToShow.lat, locToShow.lon,
|
||||
mapView.getZoom(), true);
|
||||
|
|
|
@ -282,7 +282,7 @@ public class GpxImportHelper {
|
|||
}
|
||||
|
||||
private void showGpxOnMap(final GPXUtilities.GPXFile result) {
|
||||
application.getSelectedGpxHelper().setGpxFileToDisplay(result);
|
||||
application.getSelectedGpxHelper().setGpxFileToDisplay(false, result);
|
||||
final GPXUtilities.WptPt moveTo = result.findPointToShow();
|
||||
if (moveTo != null) {
|
||||
mapView.getAnimatedDraggingThread().startMoving(moveTo.lat, moveTo.lon, mapView.getZoom(), true);
|
||||
|
|
|
@ -367,7 +367,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
|||
}
|
||||
if(visible && (changed || makeVisible)) {
|
||||
GPXFile selectGPXFile = GPXUtilities.loadGPXFile(app, f);
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(selectGPXFile);
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(false, selectGPXFile);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -15,13 +15,14 @@ import net.osmand.plus.helpers.GpxUiHelper;
|
|||
import net.osmand.plus.routepointsnavigation.RoutePointsPlugin.RoutePoint;
|
||||
import net.osmand.plus.routepointsnavigation.RoutePointsPlugin.SelectedRouteGpxFile;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -76,7 +77,7 @@ public class RoutePointsActivity extends OsmandListActivity {
|
|||
public boolean processResult(GPXUtilities.GPXFile[] result) {
|
||||
final GPXFile gpx = result[0];
|
||||
app.getSelectedGpxHelper().clearAllGpxFileToShow();
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(gpx);
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(true, gpx);
|
||||
plugin.setCurrentRoute(gpx);
|
||||
SelectedRouteGpxFile sgpx = plugin.getCurrentRoute();
|
||||
if (!sgpx.getCurrentPoints().isEmpty() &&
|
||||
|
@ -100,6 +101,10 @@ public class RoutePointsActivity extends OsmandListActivity {
|
|||
|
||||
private void prepareView() {
|
||||
TextView gpxName = (TextView) findViewById(R.id.gpx_name);
|
||||
TextView visited = (TextView) findViewById(R.id.points_count);
|
||||
String visitedString = "(" + plugin.getVisitedAllString() + ")";
|
||||
visited.setText(visitedString);
|
||||
|
||||
SelectedRouteGpxFile route = plugin.getCurrentRoute();
|
||||
String fileName;
|
||||
if(route != null) {
|
||||
|
@ -107,7 +112,23 @@ public class RoutePointsActivity extends OsmandListActivity {
|
|||
} else {
|
||||
fileName = getString(R.string.rp_current_route_not_available);
|
||||
}
|
||||
SpannableString content = new SpannableString(fileName);
|
||||
DisplayMetrics displaymetrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
|
||||
float screenWight = displaymetrics.widthPixels - visited.getPaint().measureText(visitedString) - 15;
|
||||
Paint textPaint = gpxName.getPaint();
|
||||
String name = fileName;
|
||||
int i = fileName.length()-1;
|
||||
for(;;){
|
||||
float textSize = textPaint.measureText(name);
|
||||
if (textSize < screenWight){
|
||||
break;
|
||||
}
|
||||
name = fileName.substring(0, i);
|
||||
i--;
|
||||
}
|
||||
|
||||
|
||||
SpannableString content = new SpannableString(name);
|
||||
content.setSpan(new ClickableSpan() {
|
||||
|
||||
@Override
|
||||
|
@ -118,9 +139,6 @@ public class RoutePointsActivity extends OsmandListActivity {
|
|||
gpxName.setText(content);
|
||||
gpxName.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
TextView visited = (TextView) findViewById(R.id.points_count);
|
||||
visited.setText("(" + plugin.getVisitedAllString() + ")");
|
||||
|
||||
adapter = new PointItemAdapter(this, R.layout.route_point_info,
|
||||
route == null ? new ArrayList<RoutePoint>() :
|
||||
route.getCurrentPoints());
|
||||
|
@ -290,9 +308,7 @@ public class RoutePointsActivity extends OsmandListActivity {
|
|||
return true;
|
||||
} else if (item.getItemId() == NAVIGATE_DIALOG_ID){
|
||||
app.getSettings().navigateDialog();
|
||||
Intent intent = new Intent(this, app.getAppCustomization().getMapActivity());
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
|
|
@ -99,7 +99,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
private void registerWidget(MapActivity activity) {
|
||||
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
|
||||
if (mapInfoLayer != null) {
|
||||
routeStepsControl = createRouteStepsInfoControl(activity, mapInfoLayer.getPaintSubText(), mapInfoLayer.getPaintSubText());
|
||||
routeStepsControl = createRouteStepsInfoControl(activity, mapInfoLayer.getPaintText(), mapInfoLayer.getPaintSubText());
|
||||
mapInfoLayer.getMapInfoControls().registerSideWidget(routeStepsControl,
|
||||
R.drawable.widget_signpost, R.string.map_widget_route_points, "route_steps", false, 8);
|
||||
mapInfoLayer.recreateControls();
|
||||
|
@ -195,8 +195,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
|
||||
public String getDistance(RoutePoint rp) {
|
||||
double d = MapUtils.getDistance(rp.getPoint(), getPoint());
|
||||
String distance = OsmAndFormatter.getFormattedDistance((float) d, app);
|
||||
return distance;
|
||||
return OsmAndFormatter.getFormattedDistance((float) d, app);
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
|
|
|
@ -391,7 +391,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
if (gpx != null && gpx.findPointToShow() != null) {
|
||||
WptPt p = gpx.findPointToShow();
|
||||
getMyApplication().getSettings().setMapLocationToShow(p.lat, p.lon, 16, null);
|
||||
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(gpx);
|
||||
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(false, gpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,9 @@ public class MapNavigateControl extends MapControls {
|
|||
|
||||
public void startCounter() {
|
||||
OsmandSettings settings = mapActivity.getMyApplication().getSettings();
|
||||
if(settings.DELAY_TO_START_NAVIGATION.get() <= 0) {
|
||||
return;
|
||||
}
|
||||
if (startCounter <= 0) {
|
||||
startCounter = System.currentTimeMillis() + settings.DELAY_TO_START_NAVIGATION.get() * 1000;
|
||||
delayStart = new Runnable() {
|
||||
|
|
Loading…
Reference in a new issue