Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-10-26 23:51:15 +01:00
commit 01f43a91c9
8 changed files with 61 additions and 28 deletions

View file

@ -23,7 +23,7 @@ import org.apache.commons.logging.Log;
public class RoutePlannerFrontEnd { public class RoutePlannerFrontEnd {
private boolean useOldVersion; private boolean useOldVersion;
protected static final Log log = PlatformUtil.getLog(BinaryRoutePlannerOld.class); protected static final Log log = PlatformUtil.getLog(RoutePlannerFrontEnd.class);
public RoutePlannerFrontEnd(boolean useOldVersion) { public RoutePlannerFrontEnd(boolean useOldVersion) {
this.useOldVersion = useOldVersion; this.useOldVersion = useOldVersion;
@ -336,9 +336,13 @@ public class RoutePlannerFrontEnd {
List<RouteSegmentResult> prev = ctx.previouslyCalculatedRoute; List<RouteSegmentResult> prev = ctx.previouslyCalculatedRoute;
long id = points.get(1).getRoad().id; long id = points.get(1).getRoad().id;
int ss = points.get(1).getSegmentStart(); int ss = points.get(1).getSegmentStart();
int px = points.get(1).getRoad().getPoint31XTile(ss);
int py = points.get(1).getRoad().getPoint31YTile(ss);
for (int i = 0; i < prev.size(); i++) { for (int i = 0; i < prev.size(); i++) {
RouteSegmentResult rsr = prev.get(i); RouteSegmentResult rsr = prev.get(i);
if (id == rsr.getObject().getId() && ss == rsr.getEndPointIndex()) { if (id == rsr.getObject().getId()) {
if (MapUtils.getDistance(rsr.getPoint(rsr.getEndPointIndex()), MapUtils.get31LatitudeY(py),
MapUtils.get31LongitudeX(px)) < 50) {
firstPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(i + 1); firstPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(i + 1);
restPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(prev.size() - i); restPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(prev.size() - i);
for (int k = 0; k < prev.size(); k++) { for (int k = 0; k < prev.size(); k++) {
@ -348,10 +352,12 @@ public class RoutePlannerFrontEnd {
restPartRecalculatedRoute.add(prev.get(k)); restPartRecalculatedRoute.add(prev.get(k));
} }
} }
System.out.println("Recalculate only first part of the route");
break; break;
} }
} }
} }
}
List<RouteSegmentResult> results = new ArrayList<RouteSegmentResult>(); List<RouteSegmentResult> results = new ArrayList<RouteSegmentResult>();
for (int i = 0; i < points.size() - 1; i++) { for (int i = 0; i < points.size() - 1; i++) {
RoutingContext local = new RoutingContext(ctx); RoutingContext local = new RoutingContext(ctx);

View file

@ -224,7 +224,7 @@ public class ConfigureMapMenu {
final String[] txtNames = new String[txtValues.length]; final String[] txtNames = new String[txtValues.length];
for (int i = 0; i < txtNames.length; i++) { for (int i = 0; i < txtNames.length; i++) {
txtNames[i] = (int) (txtValues[i] * 100) + " %"; txtNames[i] = (int) (txtValues[i] * 100) + " %";
if (view.getSettings().TEXT_SCALE.get() == txtValues[i]) { if (Math.abs(view.getSettings().TEXT_SCALE.get() - txtValues[i]) < 0.1f) {
selected = i; selected = i;
} }
} }
@ -235,6 +235,7 @@ public class ConfigureMapMenu {
refreshMapComplete(activity); refreshMapComplete(activity);
adapter.setItemDescription(pos, getScale(activity)); adapter.setItemDescription(pos, getScale(activity));
ad.notifyDataSetInvalidated(); ad.notifyDataSetInvalidated();
dialog.dismiss();
} }
}); });
b.show(); b.show();

View file

@ -36,11 +36,14 @@ public class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implem
private int updateColor; private int updateColor;
private OsmandRegions osmandRegions; private OsmandRegions osmandRegions;
private java.text.DateFormat format; private java.text.DateFormat format;
private OsmandApplication app;
public DownloadIndexAdapter(DownloadIndexFragment downloadFragment, List<IndexItem> indexFiles) { public DownloadIndexAdapter(DownloadIndexFragment downloadFragment, List<IndexItem> indexFiles) {
this.downloadFragment = downloadFragment; this.downloadFragment = downloadFragment;
this.indexFiles = new ArrayList<IndexItem>(indexFiles); this.indexFiles = new ArrayList<IndexItem>(indexFiles);
List<IndexItemCategory> cats = IndexItemCategory.categorizeIndexItems(downloadFragment.getMyApplication(), indexFiles); app = downloadFragment.getMyApplication();
List<IndexItemCategory> cats = IndexItemCategory.categorizeIndexItems(app, indexFiles);
synchronized (this) { synchronized (this) {
list.clear(); list.clear();
list.addAll(cats); list.addAll(cats);
@ -165,7 +168,7 @@ public class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implem
list.clear(); list.clear();
Collection<IndexItem> items = (Collection<IndexItem>) results.values; Collection<IndexItem> items = (Collection<IndexItem>) results.values;
if (items != null && !items.isEmpty()) { if (items != null && !items.isEmpty()) {
list.addAll(IndexItemCategory.categorizeIndexItems(downloadFragment.getMyApplication(), items)); list.addAll(IndexItemCategory.categorizeIndexItems(app, items));
} else if(DownloadIndexAdapter.this.indexFiles.isEmpty()){ } else if(DownloadIndexAdapter.this.indexFiles.isEmpty()){
list.add(new IndexItemCategory(downloadFragment.getResources().getString(R.string.no_index_file_to_download), 1)); list.add(new IndexItemCategory(downloadFragment.getResources().getString(R.string.no_index_file_to_download), 1));
} else { } else {

View file

@ -1,8 +1,11 @@
package net.osmand.plus.download; package net.osmand.plus.download;
import java.io.File; import java.io.File;
import java.text.Collator;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
@ -264,6 +267,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
@Override @Override
protected void onPostExecute(List<LocalIndexInfo> result) { protected void onPostExecute(List<LocalIndexInfo> result) {
this.result = result; this.result = result;
listAdapter.sortData();
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false); getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
getDownloadActivity().setLocalIndexInfos(result); getDownloadActivity().setLocalIndexInfos(result);
} }
@ -760,6 +765,19 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
notifyDataSetChanged(); notifyDataSetChanged();
} }
public void sortData() {
final Collator cl = Collator.getInstance();
for(List<LocalIndexInfo> i : data.values()) {
Collections.sort(i, new Comparator<LocalIndexInfo>() {
@Override
public int compare(LocalIndexInfo lhs, LocalIndexInfo rhs) {
return cl.compare(lhs.getName(), rhs.getName());
}
});
}
}
public LocalIndexInfo findCategory(LocalIndexInfo val, boolean backuped){ public LocalIndexInfo findCategory(LocalIndexInfo val, boolean backuped){
for(LocalIndexInfo i : category){ for(LocalIndexInfo i : category){
if(i.isBackupedData() == backuped && val.getType() == i.getType() && if(i.isBackupedData() == backuped && val.getType() == i.getType() &&

View file

@ -16,11 +16,13 @@ public class RouteCalculationParams {
public LatLon end; public LatLon end;
public List<LatLon> intermediates; public List<LatLon> intermediates;
public OsmandApplication ctx; public OsmandApplication ctx;
public ApplicationMode mode; public ApplicationMode mode;
public RouteService type; public RouteService type;
public GPXRouteParams gpxRoute; public GPXRouteParams gpxRoute;
public RouteCalculationResult previousToRecalculate; public RouteCalculationResult previousToRecalculate;
public boolean onlyStartPointChanged;
public boolean fast; public boolean fast;
public boolean leftSide; public boolean leftSide;
public RouteCalculationProgress calculationProgress; public RouteCalculationProgress calculationProgress;

View file

@ -394,6 +394,7 @@ public class RouteProvider {
rp.leftSide = routeParams.leftSide; rp.leftSide = routeParams.leftSide;
rp.type = routeParams.type; rp.type = routeParams.type;
rp.fast = routeParams.fast; rp.fast = routeParams.fast;
rp.onlyStartPointChanged = routeParams.onlyStartPointChanged;
rp.previousToRecalculate = routeParams.previousToRecalculate; rp.previousToRecalculate = routeParams.previousToRecalculate;
rp.intermediates = new ArrayList<LatLon>(); rp.intermediates = new ArrayList<LatLon>();
for(Location w : intermediates) { for(Location w : intermediates) {
@ -656,8 +657,7 @@ public class RouteProvider {
} }
ctx.leftSideNavigation = params.leftSide; ctx.leftSideNavigation = params.leftSide;
ctx.calculationProgress = params.calculationProgress; ctx.calculationProgress = params.calculationProgress;
if(params.previousToRecalculate != null) { if(params.previousToRecalculate != null && params.onlyStartPointChanged) {
// not used any more
ctx.previouslyCalculatedRoute = params.previousToRecalculate.getOriginalRoute(); ctx.previouslyCalculatedRoute = params.previousToRecalculate.getOriginalRoute();
} }
LatLon st = new LatLon(params.start.getLatitude(), params.start.getLongitude()); LatLon st = new LatLon(params.start.getLatitude(), params.start.getLongitude());

View file

@ -138,7 +138,7 @@ public class RoutingHelper {
RouteCalculationResult previousRoute = route; RouteCalculationResult previousRoute = route;
clearCurrentRoute(finalLocation, intermediatePoints); clearCurrentRoute(finalLocation, intermediatePoints);
// to update route // to update route
setCurrentLocation(currentLocation, false, previousRoute); setCurrentLocation(currentLocation, false, previousRoute, true);
} }
public synchronized void clearCurrentRoute(LatLon newFinalLocation, List<LatLon> newIntermediatePoints) { public synchronized void clearCurrentRoute(LatLon newFinalLocation, List<LatLon> newIntermediatePoints) {
@ -227,7 +227,7 @@ public class RoutingHelper {
} }
public Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation) { public Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation) {
return setCurrentLocation(currentLocation, returnUpdatedLocation, route); return setCurrentLocation(currentLocation, returnUpdatedLocation, route, false);
} }
public double getRouteDeviation(){ public double getRouteDeviation(){
@ -240,7 +240,8 @@ public class RoutingHelper {
return getOrthogonalDistance(lastFixedLocation, routeNodes.get(route.currentRoute -1), routeNodes.get(route.currentRoute)); return getOrthogonalDistance(lastFixedLocation, routeNodes.get(route.currentRoute -1), routeNodes.get(route.currentRoute));
} }
private Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation, RouteCalculationResult previousRoute) { private Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation,
RouteCalculationResult previousRoute, boolean targetPointsChanged) {
Location locationProjection = currentLocation; Location locationProjection = currentLocation;
if (finalLocation == null || currentLocation == null) { if (finalLocation == null || currentLocation == null) {
isDeviatedFromRoute = false; isDeviatedFromRoute = false;
@ -316,7 +317,7 @@ public class RoutingHelper {
if (calculateRoute) { if (calculateRoute) {
recalculateRouteInBackground(false, currentLocation, finalLocation, intermediatePoints, currentGPXRoute, recalculateRouteInBackground(false, currentLocation, finalLocation, intermediatePoints, currentGPXRoute,
previousRoute.isCalculated() ? previousRoute : null, false); previousRoute.isCalculated() ? previousRoute : null, false, !targetPointsChanged);
} else { } else {
Thread job = currentRunningJob; Thread job = currentRunningJob;
if(job instanceof RouteRecalculationThread) { if(job instanceof RouteRecalculationThread) {
@ -772,11 +773,12 @@ public class RoutingHelper {
} }
public void recalculateRouteDueToSettingsChange() { public void recalculateRouteDueToSettingsChange() {
recalculateRouteInBackground(true, lastFixedLocation, finalLocation, intermediatePoints, currentGPXRoute, route, true); recalculateRouteInBackground(true, lastFixedLocation, finalLocation, intermediatePoints, currentGPXRoute, route,
true, false);
} }
private void recalculateRouteInBackground(boolean force, final Location start, final LatLon end, final List<LatLon> intermediates, private void recalculateRouteInBackground(boolean force, final Location start, final LatLon end, final List<LatLon> intermediates,
final GPXRouteParamsBuilder gpxRoute, final RouteCalculationResult previousRoute, boolean paramsChanged){ final GPXRouteParamsBuilder gpxRoute, final RouteCalculationResult previousRoute, boolean paramsChanged, boolean onlyStartPointChanged){
if (start == null || end == null) { if (start == null || end == null) {
return; return;
} }
@ -788,6 +790,7 @@ public class RoutingHelper {
params.end = end; params.end = end;
params.intermediates = intermediates; params.intermediates = intermediates;
params.gpxRoute = gpxRoute == null ? null : gpxRoute.build(start, settings); params.gpxRoute = gpxRoute == null ? null : gpxRoute.build(start, settings);
params.onlyStartPointChanged = onlyStartPointChanged;
params.previousToRecalculate = previousRoute; params.previousToRecalculate = previousRoute;
params.leftSide = settings.DRIVING_REGION.get().leftHandDriving; params.leftSide = settings.DRIVING_REGION.get().leftHandDriving;
params.fast = settings.FAST_ROUTE_MODE.getModeValue(mode); params.fast = settings.FAST_ROUTE_MODE.getModeValue(mode);