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 {
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) {
this.useOldVersion = useOldVersion;
@ -336,9 +336,13 @@ public class RoutePlannerFrontEnd {
List<RouteSegmentResult> prev = ctx.previouslyCalculatedRoute;
long id = points.get(1).getRoad().id;
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++) {
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);
restPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(prev.size() - i);
for (int k = 0; k < prev.size(); k++) {
@ -348,10 +352,12 @@ public class RoutePlannerFrontEnd {
restPartRecalculatedRoute.add(prev.get(k));
}
}
System.out.println("Recalculate only first part of the route");
break;
}
}
}
}
List<RouteSegmentResult> results = new ArrayList<RouteSegmentResult>();
for (int i = 0; i < points.size() - 1; i++) {
RoutingContext local = new RoutingContext(ctx);

View file

@ -224,7 +224,7 @@ public class ConfigureMapMenu {
final String[] txtNames = new String[txtValues.length];
for (int i = 0; i < txtNames.length; i++) {
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;
}
}
@ -235,6 +235,7 @@ public class ConfigureMapMenu {
refreshMapComplete(activity);
adapter.setItemDescription(pos, getScale(activity));
ad.notifyDataSetInvalidated();
dialog.dismiss();
}
});
b.show();

View file

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

View file

@ -1,8 +1,11 @@
package net.osmand.plus.download;
import java.io.File;
import java.text.Collator;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
@ -264,6 +267,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
@Override
protected void onPostExecute(List<LocalIndexInfo> result) {
this.result = result;
listAdapter.sortData();
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
getDownloadActivity().setLocalIndexInfos(result);
}
@ -760,6 +765,19 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
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){
for(LocalIndexInfo i : category){
if(i.isBackupedData() == backuped && val.getType() == i.getType() &&
@ -1017,7 +1035,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
name = fileName.substring(0, ls);
}
if (name.endsWith("-roads")){
if (name.endsWith("-roads")) {
return ctx.getString(R.string.download_roads_only_item);
}

View file

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

View file

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

View file

@ -138,7 +138,7 @@ public class RoutingHelper {
RouteCalculationResult previousRoute = route;
clearCurrentRoute(finalLocation, intermediatePoints);
// to update route
setCurrentLocation(currentLocation, false, previousRoute);
setCurrentLocation(currentLocation, false, previousRoute, true);
}
public synchronized void clearCurrentRoute(LatLon newFinalLocation, List<LatLon> newIntermediatePoints) {
@ -227,7 +227,7 @@ public class RoutingHelper {
}
public Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation) {
return setCurrentLocation(currentLocation, returnUpdatedLocation, route);
return setCurrentLocation(currentLocation, returnUpdatedLocation, route, false);
}
public double getRouteDeviation(){
@ -240,7 +240,8 @@ public class RoutingHelper {
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;
if (finalLocation == null || currentLocation == null) {
isDeviatedFromRoute = false;
@ -316,7 +317,7 @@ public class RoutingHelper {
if (calculateRoute) {
recalculateRouteInBackground(false, currentLocation, finalLocation, intermediatePoints, currentGPXRoute,
previousRoute.isCalculated() ? previousRoute : null, false);
previousRoute.isCalculated() ? previousRoute : null, false, !targetPointsChanged);
} else {
Thread job = currentRunningJob;
if(job instanceof RouteRecalculationThread) {
@ -772,29 +773,31 @@ public class RoutingHelper {
}
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,
final GPXRouteParamsBuilder gpxRoute, final RouteCalculationResult previousRoute, boolean paramsChanged){
final GPXRouteParamsBuilder gpxRoute, final RouteCalculationResult previousRoute, boolean paramsChanged, boolean onlyStartPointChanged){
if (start == null || end == null) {
return;
}
if(currentRunningJob == null){
if (currentRunningJob == null) {
// do not evaluate very often
if (force || System.currentTimeMillis() - lastTimeEvaluatedRoute > evalWaitInterval) {
RouteCalculationParams params = new RouteCalculationParams();
params.start = start;
params.end = end;
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.leftSide = settings.DRIVING_REGION.get().leftHandDriving;
params.fast = settings.FAST_ROUTE_MODE.getModeValue(mode);
params.type = settings.ROUTER_SERVICE.getModeValue(mode);
params.mode = mode;
params.ctx = app;
if(previousRoute == null && params.type == RouteService.OSMAND) {
if (previousRoute == null && params.type == RouteService.OSMAND) {
params.calculationProgress = new RouteCalculationProgress();
updateProgress(params.calculationProgress);
}