Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-06-25 18:19:13 +02:00
commit 17aff2d507
12 changed files with 53 additions and 26 deletions

View file

@ -10,12 +10,14 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:ellipsize="end"
android:textSize="20sp"/> android:textSize="20sp"/>
<TextView android:id="@+id/points_count" <TextView android:id="@+id/points_count"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:minWidth="16dp"
android:textSize="20sp"/> android:textSize="20sp"/>
</LinearLayout> </LinearLayout>

View file

@ -261,11 +261,11 @@ public class GpxSelectionHelper {
return null; return null;
} }
public void setGpxFileToDisplay(GPXFile... gpxs) { public void setGpxFileToDisplay(boolean notShowNavigationDialog, GPXFile... gpxs) {
// special case for gpx current route // special case for gpx current route
for(GPXFile gpx : gpxs) { for(GPXFile gpx : gpxs) {
boolean show = true; boolean show = true;
selectGpxFileImpl(gpx, show); selectGpxFileImpl(gpx, show, notShowNavigationDialog);
} }
saveCurrentSelections(); saveCurrentSelections();
} }
@ -283,7 +283,7 @@ public class GpxSelectionHelper {
p.startTask(getString(R.string.loading_smth, fl.getName()), -1); p.startTask(getString(R.string.loading_smth, fl.getName()), -1);
} }
GPXFile gpx = GPXUtilities.loadGPXFile(app, fl); GPXFile gpx = GPXUtilities.loadGPXFile(app, fl);
selectGpxFile(gpx, true); selectGpxFile(gpx, true, false);
} else if(obj.has(CURRENT_TRACK)) { } else if(obj.has(CURRENT_TRACK)) {
selectedGPXFiles.add(savingTrackHelper.getCurrentTrack()); selectedGPXFiles.add(savingTrackHelper.getCurrentTrack());
} }
@ -298,7 +298,7 @@ public class GpxSelectionHelper {
private void saveCurrentSelections() { private void saveCurrentSelections() {
JSONArray ar = new JSONArray(); JSONArray ar = new JSONArray();
for(SelectedGpxFile s : selectedGPXFiles) { for(SelectedGpxFile s : selectedGPXFiles) {
if(s.gpxFile != null) { if(s.gpxFile != null && !s.notShowNavigationDialog) {
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
try { try {
if(!Algorithms.isEmpty(s.gpxFile.path)) { if(!Algorithms.isEmpty(s.gpxFile.path)) {
@ -315,11 +315,12 @@ public class GpxSelectionHelper {
app.getSettings().SELECTED_GPX.set(ar.toString()); 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; boolean displayed = false;
SelectedGpxFile sf ; SelectedGpxFile sf ;
if(gpx.showCurrentTrack) { if(gpx.showCurrentTrack) {
sf = savingTrackHelper.getCurrentTrack(); sf = savingTrackHelper.getCurrentTrack();
sf.notShowNavigationDialog = notShowNavigationDialog;
displayed = selectedGPXFiles.contains(sf); displayed = selectedGPXFiles.contains(sf);
} else { } else {
sf = getSelectedFileByPath(gpx.path); sf = getSelectedFileByPath(gpx.path);
@ -327,6 +328,7 @@ public class GpxSelectionHelper {
if(show && sf == null) { if(show && sf == null) {
sf = new SelectedGpxFile(); sf = new SelectedGpxFile();
sf.setGpxFile(gpx); sf.setGpxFile(gpx);
sf.notShowNavigationDialog = notShowNavigationDialog;
} }
} }
if(displayed != show) { if(displayed != show) {
@ -338,8 +340,8 @@ public class GpxSelectionHelper {
} }
} }
public void selectGpxFile(GPXFile gpx, boolean show) { public void selectGpxFile(GPXFile gpx, boolean show, boolean showNavigationDialog) {
selectGpxFileImpl(gpx, show); selectGpxFileImpl(gpx, show, showNavigationDialog);
saveCurrentSelections(); saveCurrentSelections();
} }
@ -353,6 +355,8 @@ public class GpxSelectionHelper {
public static class SelectedGpxFile { public static class SelectedGpxFile {
public boolean notShowNavigationDialog = false;
private boolean showCurrentTrack; private boolean showCurrentTrack;
private GPXFile gpxFile; private GPXFile gpxFile;
private int color; private int color;
@ -396,6 +400,7 @@ public class GpxSelectionHelper {
public int getColor() { public int getColor() {
return color; return color;
} }
} }
public enum GpxDisplayItemType { public enum GpxDisplayItemType {

View file

@ -86,7 +86,6 @@ public abstract class OsmandPlugin {
if(Version.isRouteNavPluginInlined(app)) { if(Version.isRouteNavPluginInlined(app)) {
RoutePointsPlugin routePointsPlugin = new RoutePointsPlugin(app); RoutePointsPlugin routePointsPlugin = new RoutePointsPlugin(app);
installedPlugins.add(routePointsPlugin); installedPlugins.add(routePointsPlugin);
enablePlugin(app, routePointsPlugin, true);
} }
installPlugin(OSMODROID_PLUGIN_COMPONENT, OsMoDroidPlugin.ID, app, new OsMoDroidPlugin(app)); installPlugin(OSMODROID_PLUGIN_COMPONENT, OsMoDroidPlugin.ID, app, new OsMoDroidPlugin(app));

View file

@ -422,7 +422,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().getSelectedGpxHelper().setGpxFileToDisplay(info.gpx); getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(false, info.gpx);
MapActivity.launchMapActivityMoveToTop(getActivity()); MapActivity.launchMapActivityMoveToTop(getActivity());
} }
} }
@ -887,7 +887,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
protected void onProgressUpdate(GpxInfo... values) { protected void onProgressUpdate(GpxInfo... values) {
for(GpxInfo g : values) { for(GpxInfo g : values) {
final boolean visible = selectedItems.contains(g); final boolean visible = selectedItems.contains(g);
selectedGpxHelper.selectGpxFile(g.gpx, visible); selectedGpxHelper.selectGpxFile(g.gpx, visible, false);
if(visible && toShow == null) { if(visible && toShow == null) {
toShow = g.gpx.findPointToShow(); toShow = g.gpx.findPointToShow();
} }

View file

@ -583,13 +583,15 @@ public class MapActivityActions implements DialogProvider {
public void enterRoutePlanningMode(final LatLon from, final String fromName) { public void enterRoutePlanningMode(final LatLon from, final String fromName) {
List<SelectedGpxFile> selectedGPXFiles = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles(); List<SelectedGpxFile> selectedGPXFiles = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
GPXFile gpxFile = null; GPXFile gpxFile = null;
boolean notShowDialog = false;
for (SelectedGpxFile gs : selectedGPXFiles) { for (SelectedGpxFile gs : selectedGPXFiles) {
if (!gs.isShowCurrentTrack()) { if (!gs.isShowCurrentTrack()) {
notShowDialog = gs.notShowNavigationDialog;
gpxFile = gs.getGpxFile(); gpxFile = gs.getGpxFile();
break; break;
} }
} }
if(gpxFile != null) { if(gpxFile != null && !notShowDialog) {
final GPXFile f = gpxFile; 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);

View file

@ -390,7 +390,7 @@ public class MapActivityLayers {
locToShow = g.findPointToShow(); locToShow = g.findPointToShow();
} }
} }
getApplication().getSelectedGpxHelper().setGpxFileToDisplay(result); getApplication().getSelectedGpxHelper().setGpxFileToDisplay(false, result);
if(locToShow != null){ if(locToShow != null){
mapView.getAnimatedDraggingThread().startMoving(locToShow.lat, locToShow.lon, mapView.getAnimatedDraggingThread().startMoving(locToShow.lat, locToShow.lon,
mapView.getZoom(), true); mapView.getZoom(), true);

View file

@ -282,7 +282,7 @@ public class GpxImportHelper {
} }
private void showGpxOnMap(final GPXUtilities.GPXFile result) { private void showGpxOnMap(final GPXUtilities.GPXFile result) {
application.getSelectedGpxHelper().setGpxFileToDisplay(result); application.getSelectedGpxHelper().setGpxFileToDisplay(false, 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);

View file

@ -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.getSelectedGpxHelper().setGpxFileToDisplay(selectGPXFile); app.getSelectedGpxHelper().setGpxFileToDisplay(false, selectGPXFile);
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();

View file

@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import android.content.Intent; import android.content.Intent;
import android.graphics.Paint;
import android.util.DisplayMetrics;
import android.util.TypedValue; import android.util.TypedValue;
import net.osmand.CallbackWithObject; import net.osmand.CallbackWithObject;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -77,7 +79,7 @@ public class RoutePointsActivity extends OsmandListActivity {
public boolean processResult(GPXUtilities.GPXFile[] result) { public boolean processResult(GPXUtilities.GPXFile[] result) {
final GPXFile gpx = result[0]; final GPXFile gpx = result[0];
app.getSelectedGpxHelper().clearAllGpxFileToShow(); app.getSelectedGpxHelper().clearAllGpxFileToShow();
app.getSelectedGpxHelper().setGpxFileToDisplay(gpx); app.getSelectedGpxHelper().setGpxFileToDisplay(true, gpx);
plugin.setCurrentRoute(gpx); plugin.setCurrentRoute(gpx);
SelectedRouteGpxFile sgpx = plugin.getCurrentRoute(); SelectedRouteGpxFile sgpx = plugin.getCurrentRoute();
if (!sgpx.getCurrentPoints().isEmpty() && if (!sgpx.getCurrentPoints().isEmpty() &&
@ -101,6 +103,10 @@ public class RoutePointsActivity extends OsmandListActivity {
private void prepareView() { private void prepareView() {
TextView gpxName = (TextView) findViewById(R.id.gpx_name); 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(); SelectedRouteGpxFile route = plugin.getCurrentRoute();
String fileName; String fileName;
if(route != null) { if(route != null) {
@ -108,7 +114,23 @@ public class RoutePointsActivity extends OsmandListActivity {
} else { } else {
fileName = getString(R.string.rp_current_route_not_available); 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() { content.setSpan(new ClickableSpan() {
@Override @Override
@ -119,9 +141,6 @@ public class RoutePointsActivity extends OsmandListActivity {
gpxName.setText(content); gpxName.setText(content);
gpxName.setMovementMethod(LinkMovementMethod.getInstance()); 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, adapter = new PointItemAdapter(this, R.layout.route_point_info,
route == null ? new ArrayList<RoutePoint>() : route == null ? new ArrayList<RoutePoint>() :
route.getCurrentPoints()); route.getCurrentPoints());
@ -291,9 +310,7 @@ public class RoutePointsActivity extends OsmandListActivity {
return true; return true;
} else if (item.getItemId() == NAVIGATE_DIALOG_ID){ } else if (item.getItemId() == NAVIGATE_DIALOG_ID){
app.getSettings().navigateDialog(); app.getSettings().navigateDialog();
Intent intent = new Intent(this, app.getAppCustomization().getMapActivity()); finish();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

View file

@ -99,7 +99,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
private void registerWidget(MapActivity activity) { private void registerWidget(MapActivity activity) {
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer(); MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
if (mapInfoLayer != null) { if (mapInfoLayer != null) {
routeStepsControl = createRouteStepsInfoControl(activity, mapInfoLayer.getPaintSubText(), mapInfoLayer.getPaintSubText()); routeStepsControl = createRouteStepsInfoControl(activity, mapInfoLayer.getPaintText(), mapInfoLayer.getPaintSubText());
mapInfoLayer.getMapInfoControls().registerSideWidget(routeStepsControl, mapInfoLayer.getMapInfoControls().registerSideWidget(routeStepsControl,
R.drawable.widget_signpost, R.string.map_widget_route_points, "route_steps", false, 8); R.drawable.widget_signpost, R.string.map_widget_route_points, "route_steps", false, 8);
mapInfoLayer.recreateControls(); mapInfoLayer.recreateControls();
@ -195,8 +195,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
public String getDistance(RoutePoint rp) { public String getDistance(RoutePoint rp) {
double d = MapUtils.getDistance(rp.getPoint(), getPoint()); double d = MapUtils.getDistance(rp.getPoint(), getPoint());
String distance = OsmAndFormatter.getFormattedDistance((float) d, app); return OsmAndFormatter.getFormattedDistance((float) d, app);
return distance;
} }
public String getTime() { public String getTime() {

View file

@ -391,7 +391,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
if (gpx != null && gpx.findPointToShow() != null) { if (gpx != null && gpx.findPointToShow() != null) {
WptPt p = gpx.findPointToShow(); WptPt p = gpx.findPointToShow();
getMyApplication().getSettings().setMapLocationToShow(p.lat, p.lon, 16, null); getMyApplication().getSettings().setMapLocationToShow(p.lat, p.lon, 16, null);
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(gpx); getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(false, gpx);
} }
} }
} }

View file

@ -53,6 +53,9 @@ public class MapNavigateControl extends MapControls {
public void startCounter() { public void startCounter() {
OsmandSettings settings = mapActivity.getMyApplication().getSettings(); OsmandSettings settings = mapActivity.getMyApplication().getSettings();
if(settings.DELAY_TO_START_NAVIGATION.get() <= 0) {
return;
}
if (startCounter <= 0) { if (startCounter <= 0) {
startCounter = System.currentTimeMillis() + settings.DELAY_TO_START_NAVIGATION.get() * 1000; startCounter = System.currentTimeMillis() + settings.DELAY_TO_START_NAVIGATION.get() * 1000;
delayStart = new Runnable() { delayStart = new Runnable() {