Merge branch 'master' of ssh://github.com/osmandapp/Osmand into measurement_tools

This commit is contained in:
Alexander Sytnyk 2017-07-31 17:08:00 +03:00
commit 9b1743ec6d
4 changed files with 20 additions and 13 deletions

View file

@ -236,7 +236,11 @@ public class TrackSegmentFragment extends OsmAndListFragment {
}
private GPXFile getGpx() {
return getTrackActivity().getGpx();
TrackActivity activity = getTrackActivity();
if (activity == null) {
return null;
}
return activity.getGpx();
}
private GpxDataItem getGpxDataItem() {

View file

@ -96,7 +96,7 @@ public class UploadOpenstreetmapPointAsyncTask
@Override
protected void onPostExecute(Map<OsmPoint, String> loadErrorsMap) {
if (progress != null) {
progress.dismiss();
progress.dismissAllowingStateLoss();
}
listener.uploadEnded(loadErrorsMap);
}

View file

@ -5,7 +5,6 @@ import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Handler;
@ -19,14 +18,13 @@ import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.RulerMode;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import java.util.ArrayList;
import gnu.trove.list.array.TIntArrayList;
public class RulerControlLayer extends OsmandMapLayer {
private static final long DRAW_TIME = 2000;
@ -49,14 +47,13 @@ public class RulerControlLayer extends OsmandMapLayer {
private int acceptableTouchRadius;
private QuadPoint cacheCenter;
private float cacheMapDensity;
private OsmandSettings.OsmandPreference<Float> mapDensity;
private int cacheIntZoom;
private double cacheTileX;
private double cacheTileY;
private long cacheMultiTouchEndTime;
private ArrayList<String> cacheDistances;
private Path distancePath;
private TIntArrayList tx;
private TIntArrayList ty;
private LatLon touchPointLatLon;
private PointF touchPoint;
private long touchStartTime;
@ -93,13 +90,12 @@ public class RulerControlLayer extends OsmandMapLayer {
public void initLayer(final OsmandMapTileView view) {
app = mapActivity.getMyApplication();
this.view = view;
mapDensity = mapActivity.getMyApplication().getSettings().MAP_DENSITY;
cacheMapDensity = mapDensity.get();
cacheDistances = new ArrayList<>();
cacheCenter = new QuadPoint();
maxRadiusInDp = mapActivity.getResources().getDimensionPixelSize(R.dimen.map_ruler_width);
rightWidgetsPanel = mapActivity.findViewById(R.id.map_right_widgets_panel);
distancePath = new Path();
tx = new TIntArrayList();
ty = new TIntArrayList();
touchPoint = new PointF();
acceptableTouchRadius = mapActivity.getResources().getDimensionPixelSize(R.dimen.acceptable_touch_radius);
@ -307,12 +303,13 @@ public class RulerControlLayer extends OsmandMapLayer {
}
boolean move = tb.getZoom() != cacheIntZoom || Math.abs(tb.getCenterTileX() - cacheTileX) > 1 ||
Math.abs(tb.getCenterTileY() - cacheTileY) > 1;
Math.abs(tb.getCenterTileY() - cacheTileY) > 1 || mapDensity.get() != cacheMapDensity;
if (!tb.isZoomAnimated() && move) {
cacheIntZoom = tb.getZoom();
cacheTileX = tb.getCenterTileX();
cacheTileY = tb.getCenterTileY();
cacheMapDensity = mapDensity.get();
cacheDistances.clear();
updateDistance(tb);
}

View file

@ -1048,6 +1048,8 @@ public class RouteInfoWidgetsFactory {
private MapActivity ma;
private String cacheRulerText;
private int maxWidth;
private float cacheMapDensity;
private OsmandSettings.OsmandPreference<Float> mapDensity;
private int cacheRulerZoom;
private double cacheRulerTileX;
private double cacheRulerTileY;
@ -1061,6 +1063,8 @@ public class RouteInfoWidgetsFactory {
textShadow = (TextView) ma.findViewById(R.id.map_ruler_text_shadow);
maxWidth = ma.getResources().getDimensionPixelSize(R.dimen.map_ruler_width);
orientationPortrait = AndroidUiHelper.isOrientationPortrait(ma);
mapDensity = ma.getMyApplication().getSettings().MAP_DENSITY;
cacheMapDensity = mapDensity.get();
}
public void updateTextSize(boolean isNight, int textColor, int textShadowColor, int shadowRadius) {
@ -1077,10 +1081,12 @@ public class RouteInfoWidgetsFactory {
} else if (!orientationPortrait && ma.getRoutingHelper().isRoutePlanningMode()) {
visible = false;
} else if (!tb.isZoomAnimated() && (tb.getZoom() != cacheRulerZoom || Math.abs(tb.getCenterTileX() - cacheRulerTileX) > 1 || Math
.abs(tb.getCenterTileY() - cacheRulerTileY) > 1) && tb.getPixWidth() > 0 && maxWidth > 0) {
.abs(tb.getCenterTileY() - cacheRulerTileY) > 1 || mapDensity.get() != cacheMapDensity) &&
tb.getPixWidth() > 0 && maxWidth > 0) {
cacheRulerZoom = tb.getZoom();
cacheRulerTileX = tb.getCenterTileX();
cacheRulerTileY = tb.getCenterTileY();
cacheMapDensity = mapDensity.get();
final double dist = tb.getDistance(0, tb.getPixHeight() / 2, tb.getPixWidth(), tb.getPixHeight() / 2);
double pixDensity = tb.getPixWidth() / dist;
double roundedDist = OsmAndFormatter.calculateRoundedDist(maxWidth /