Merge branch 'r3.3' of https://github.com/osmandapp/Osmand into r3.3

This commit is contained in:
crimean 2019-03-21 18:28:35 +03:00
commit 99e818e12c
22 changed files with 236 additions and 110 deletions

View file

@ -92,7 +92,7 @@ public class TransportRoutingConfiguration {
maxRouteTime = router.getIntAttribute("maxRouteTime", maxRouteTime);
finishTimeSeconds = router.getIntAttribute("delayForAlternativesRoutes", finishTimeSeconds);
String mn = params.get("max_num_changes");
maxNumberOfChanges = RoutingConfiguration.parseSilentInt(mn, maxNumberOfChanges);
maxNumberOfChanges = (int) RoutingConfiguration.parseSilentFloat(mn, maxNumberOfChanges);
walkSpeed = router.getFloatAttribute("minDefaultSpeed", this.walkSpeed * 3.6f) / 3.6f;
defaultTravelSpeed = router.getFloatAttribute("maxDefaultSpeed", this.defaultTravelSpeed * 3.6f) / 3.6f;

View file

@ -4,6 +4,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.data.MapObject;
import net.osmand.data.QuadPoint;

View file

@ -11,6 +11,11 @@
Thx - Hardy
-->
<string name="shared_string_degrees">Degrees</string>
<string name="shared_string_milliradians">Milliradians</string>
<string name="angular_measeurement">Angular measurement units</string>
<string name="angular_measeurement_descr">Change what azimuth is measured in.</string>
<string name="quick_action_day_night_mode">%s mode</string>
<string name="avoid_pt_types_descr">Select a public transport types you want to avoid during navigation:</string>
<string name="avoid_pt_types">Avoid transport types…</string>
<string name="shared_string_walk">Walk</string>

View file

@ -9,6 +9,7 @@
<!-- ListPreference android:key="map_preferred_locale" android:title="@string/map_preferred_locale" android:summary="@string/map_preferred_locale_descr"></ListPreference -->
<ListPreference android:key="default_metric_system" android:title="@string/unit_of_length" android:summary="@string/unit_of_length_descr"></ListPreference>
<ListPreference android:key="coordinates_format" android:title="@string/coords_format" android:summary="@string/coords_format_descr"></ListPreference>
<ListPreference android:key="angular_measurement" android:title="@string/angular_measeurement" android:summary="@string/angular_measeurement_descr"></ListPreference>
</PreferenceCategory>

View file

@ -9,6 +9,7 @@ import net.osmand.osm.AbstractPoiType;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandSettings.AngularConstants;
import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.OsmandSettings.SpeedConstants;
import net.osmand.util.Algorithms;
@ -166,6 +167,22 @@ public class OsmAndFormatter {
return df.format(meters / mainUnitInMeters) + " " + app.getString(mainUnitStr);
}
public static String getFormattedAzimuth(float bearing, OsmandApplication app) {
int azimuth;
if (bearing < 0.0) {
azimuth = (int) (360 + bearing);
} else {
azimuth = (int) bearing;
}
if (app.getSettings().ANGULAR_UNITS.get() == AngularConstants.MILLIRADS) {
return (int) (azimuth * 17.4533) + " " + AngularConstants.MILLIRADS.getUnitSymbol();
} else {
return azimuth + AngularConstants.DEGREES.getUnitSymbol();
}
}
public static String getFormattedDistance(float meters, OsmandApplication ctx) {
return getFormattedDistance(meters, ctx, true);
}

View file

@ -930,6 +930,17 @@ public class OsmandSettings {
;
}.makeGlobal();
//public final OsmandPreference<Integer> COORDINATES_FORMAT = new IntPreference("coordinates_format", PointDescription.FORMAT_DEGREES).makeGlobal();
public final OsmandPreference<AngularConstants> ANGULAR_UNITS = new EnumIntPreference<AngularConstants>(
"angular_measurement", AngularConstants.DEGREES, AngularConstants.values()) {
@Override
protected AngularConstants getValue(Object prefs, AngularConstants defaultValue) {
return super.getValue(prefs, defaultValue);
}
}.makeGlobal();
public final OsmandPreference<SpeedConstants> SPEED_SYSTEM = new EnumIntPreference<SpeedConstants>(
"default_speed_system", SpeedConstants.KILOMETERS_PER_HOUR, SpeedConstants.values()) {
@ -2900,6 +2911,27 @@ public class OsmandSettings {
}
public enum AngularConstants {
DEGREES(R.string.shared_string_degrees, "°"),
MILLIRADS(R.string.shared_string_milliradians, "mil");
private final int key;
private final String unit;
AngularConstants(int key, String unit) {
this.key = key;
this.unit = unit;
}
public String toHumanString(Context ctx) {
return ctx.getString(key);
}
public String getUnitSymbol() {
return unit;
}
}
public enum AutoZoomMap {
FARTHEST(R.string.auto_zoom_farthest, 1f, 15.5f),
FAR(R.string.auto_zoom_far, 1.4f, 17f),

View file

@ -443,6 +443,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
@Override
public void start() {
setupRouteCalculationProgressBar(pb);
mapRouteInfoMenu.routeCalculationStarted();
}
@Override
@ -1499,8 +1500,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
if (zoom != null) {
z = Integer.parseInt(zoom);
}
settings.setMapLocationToShow(lt, ln, z, new PointDescription(
PointDescription.POINT_TYPE_MARKER, getString(R.string.shared_location)));
settings.setMapLocationToShow(lt, ln, z, new PointDescription(lt, ln));
} catch (NumberFormatException e) {
LOG.error("error", e);
}

View file

@ -38,6 +38,7 @@ import net.osmand.osm.io.NetworkUtils;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.AngularConstants;
import net.osmand.plus.OsmandSettings.DrivingRegion;
import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.R;
@ -209,6 +210,13 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
entries[4] = PointDescription.formatToHumanString(this, PointDescription.OLC_FORMAT);
registerListPreference(settings.COORDINATES_FORMAT, screen, entries, cvls);
AngularConstants[] ac = AngularConstants.values();
entries = new String[ac.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = ac[i].toHumanString(getMyApplication());
}
registerListPreference(settings.ANGULAR_UNITS, screen, entries, ac);
// See language list and statistics at: https://hosted.weblate.org/projects/osmand/main/
// Hardy maintenance 2016-05-29:
// - Include languages if their translation is >= ~10% (but any language will be visible if it is the device's system locale)

View file

@ -137,13 +137,13 @@ public class GeoIntentActivity extends OsmandListActivity {
}
settings.setMapLocationToShow(p.getLatitude(), p.getLongitude(),
settings.getLastKnownMapZoom(), pd); //$NON-NLS-1$
MapActivity.launchMapActivityMoveToTop(GeoIntentActivity.this);
} else {
Uri uri = intent.getData();
String searchString = p != null && p.isGeoAddress() ? p.getQuery() : uri.toString();
settings.setSearchRequestToShow(searchString);
MapActivity.launchMapActivityMoveToTop(GeoIntentActivity.this);
}
MapActivity.launchMapActivityMoveToTop(GeoIntentActivity.this);
GeoIntentActivity.this.finish();
} catch (Exception e) {
e.printStackTrace();
}
@ -151,8 +151,6 @@ public class GeoIntentActivity extends OsmandListActivity {
}
@Override
protected void onStop() {
dismiss();

View file

@ -63,11 +63,6 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TargetPoint start = targetPointsHelper.getPointToStart();
if (start != null) {
targetPointsHelper.navigateToPoint(new LatLon(start.getLatitude(), start.getLongitude()),
false, 0, start.getOriginalPointDescription());
}
targetPointsHelper.setStartPoint(latLon, true, name);
dismiss();
}

View file

@ -705,11 +705,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
}
private List<TransportStopRoute> filterNearbyTransportRoutes(List<TransportStopRoute> routes, List<TransportStopRoute> filterFromRoutes) {
if (filterFromRoutes == null) {
return routes;
List<TransportStopRoute> nearbyFilteredTransportStopRoutes = filterTransportRoutes(routes);
if (filterFromRoutes == null || filterFromRoutes.isEmpty()) {
return nearbyFilteredTransportStopRoutes;
}
List<TransportStopRoute> filteredRoutes = new ArrayList<>();
for (TransportStopRoute route : routes) {
for (TransportStopRoute route : nearbyFilteredTransportStopRoutes) {
if (!containsRef(filterFromRoutes, route.route)) {
filteredRoutes.add(route);
}

View file

@ -360,9 +360,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
measurementLayer.setOnMeasureDistanceToCenterListener(new MeasurementToolLayer.OnMeasureDistanceToCenter() {
@Override
public void onMeasure(float distance) {
public void onMeasure(float distance, float bearing) {
String distStr = OsmAndFormatter.getFormattedDistance(distance, mapActivity.getMyApplication());
distanceToCenterTv.setText(" " + distStr);
String azimuthStr = OsmAndFormatter.getFormattedAzimuth(bearing, getMyApplication());
distanceToCenterTv.setText(String.format(" %s • %s", distStr, azimuthStr));
}
});

View file

@ -7,6 +7,7 @@ import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadPoint;
@ -201,12 +202,16 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
drawCenterIcon(canvas, tb, tb.getCenterPixelPoint(), settings.isNightMode());
if (measureDistanceToCenterListener != null) {
float distance = 0;
float bearing = 0;
if (editingCtx.getPointsCount() > 0) {
WptPt lastPoint = editingCtx.getPoints().get(editingCtx.getPointsCount() - 1);
LatLon centerLatLon = tb.getCenterLatLon();
distance = (float) MapUtils.getDistance(lastPoint.lat, lastPoint.lon, centerLatLon.getLatitude(), centerLatLon.getLongitude());
distance = (float) MapUtils.getDistance(
lastPoint.lat, lastPoint.lon, centerLatLon.getLatitude(), centerLatLon.getLongitude());
bearing = getLocationFromLL(lastPoint.lat, lastPoint.lon)
.bearingTo(getLocationFromLL(centerLatLon.getLatitude(), centerLatLon.getLongitude()));
}
measureDistanceToCenterListener.onMeasure(distance);
measureDistanceToCenterListener.onMeasure(distance, bearing);
}
}
@ -411,6 +416,13 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
return false;
}
private Location getLocationFromLL(double lat, double lon) {
Location l = new Location("");
l.setLatitude(lat);
l.setLongitude(lon);
return l;
}
interface OnSingleTapListener {
void onAddPoint();
@ -423,6 +435,6 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
}
interface OnMeasureDistanceToCenter {
void onMeasure(float distance);
void onMeasure(float distance, float bearing);
}
}

View file

@ -13,6 +13,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.Location;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
@ -31,6 +32,7 @@ public class MeasurementToolAdapter extends RecyclerView.Adapter<MeasurementTool
private MeasurementAdapterListener listener;
private boolean nightMode;
private final ActionType actionType;
private final static String BULLET = "";
public MeasurementToolAdapter(MapActivity mapActivity, List<WptPt> points, ActionType actionType) {
this.mapActivity = mapActivity;
@ -88,15 +90,29 @@ public class MeasurementToolAdapter extends RecyclerView.Adapter<MeasurementTool
if (!TextUtils.isEmpty(pointDesc)) {
holder.descr.setText(pointDesc);
} else {
String text = "";
Location l1;
Location l2;
if (pos < 1) {
holder.descr.setText(mapActivity.getString(R.string.shared_string_control_start));
text = mapActivity.getString(R.string.shared_string_control_start);
if (mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() != null) {
l1 = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
l2 = getLocationFromLL(points.get(0).lat, points.get(0).lon);
text = text
+ BULLET + OsmAndFormatter.getFormattedDistance(l1.distanceTo(l2), mapActivity.getMyApplication())
+ BULLET + OsmAndFormatter.getFormattedAzimuth(l1.bearingTo(l2), mapActivity.getMyApplication());
}
holder.descr.setText(text);
} else {
float dist = 0;
for (int i = 1; i <= pos; i++) {
dist += MapUtils.getDistance(points.get(i - 1).lat, points.get(i - 1).lon,
points.get(i).lat, points.get(i).lon);
l1 = getLocationFromLL(points.get(i - 1).lat, points.get(i - 1).lon);
l2 = getLocationFromLL(points.get(i).lat, points.get(i).lon);
dist += l1.distanceTo(l2);
text = OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication())
+ BULLET + OsmAndFormatter.getFormattedAzimuth(l1.bearingTo(l2), mapActivity.getMyApplication());
}
holder.descr.setText(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication()));
holder.descr.setText(text);
}
}
if (actionType == ActionType.EDIT_SEGMENT) {
@ -131,6 +147,13 @@ public class MeasurementToolAdapter extends RecyclerView.Adapter<MeasurementTool
});
}
private Location getLocationFromLL(double lat, double lon) {
Location l = new Location("");
l.setLatitude(lat);
l.setLongitude(lon);
return l;
}
@Override
public int getItemCount() {
return points.size();

View file

@ -7,6 +7,7 @@ import android.view.ViewGroup;
import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.DayNightMode;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.quickaction.QuickAction;
@ -20,23 +21,10 @@ public class DayNightModeAction extends QuickAction {
@Override
public void execute(MapActivity activity) {
switch (activity.getMyApplication().getSettings().DAYNIGHT_MODE.get()){
case DAY: {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.NIGHT);
break;
}
case NIGHT: {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY);
break;
}
case AUTO: {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY);
break;
}
case SENSOR: {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY);
break;
}
if (activity.getMyApplication().getDaynightHelper().isNightMode()) {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY);
} else {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.NIGHT);
}
}
@ -44,33 +32,28 @@ public class DayNightModeAction extends QuickAction {
public void drawUI(ViewGroup parent, MapActivity activity) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.quick_action_with_text, parent, false);
((TextView) view.findViewById(R.id.text))
.setText(R.string.quick_action_switch_day_night_descr);
parent.addView(view);
}
@Override
public int getIconRes(Context context) {
if(context instanceof MapActivity) {
switch (((MapActivity) context).getMyApplication().getSettings().DAYNIGHT_MODE.get()) {
case NIGHT: {
return R.drawable.ic_action_map_night;
}
case AUTO: {
return R.drawable.ic_action_map_sunst;
}
case SENSOR: {
return R.drawable.ic_action_map_light_sensor;
}
}
if (context instanceof MapActivity
&& ((MapActivity) context).getMyApplication().getDaynightHelper().isNightMode()) {
return R.drawable.ic_action_map_day;
}
return R.drawable.ic_action_map_day;
return R.drawable.ic_action_map_night;
}
@Override
public String getActionText(OsmandApplication application) {
return application.getSettings().DAYNIGHT_MODE.get().toHumanString(application) + " Mode";
if (application.getDaynightHelper().isNightMode()) {
return String.format(application.getString(R.string.quick_action_day_night_mode),
DayNightMode.DAY.toHumanString(application));
} else {
return String.format(application.getString(R.string.quick_action_day_night_mode),
DayNightMode.NIGHT.toHumanString(application));
}
}
}

View file

@ -382,6 +382,17 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
}
}
public void routeCalculationStarted() {
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
MapRouteInfoMenuFragment fragment = fragmentRef != null ? fragmentRef.get() : null;
if (fragmentRef != null && fragment.isVisible()) {
setRouteCalculationInProgress(true);
fragment.updateRouteCalculationProgress(0);
fragment.updateControlButtons();
fragment.updateInfo();
}
}
public void updateRouteCalculationProgress(int progress) {
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
MapRouteInfoMenuFragment fragment = fragmentRef != null ? fragmentRef.get() : null;
@ -397,12 +408,17 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
public void routeCalculationFinished() {
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
MapRouteInfoMenuFragment fragment = fragmentRef != null ? fragmentRef.get() : null;
if (fragmentRef != null && fragment.isVisible()) {
setRouteCalculationInProgress(false);
fragment.hideRouteCalculationProgressBar();
fragment.updateControlButtons();
fragment.updateInfo();
fragment.openMenuHalfScreen();
OsmandApplication app = getApp();
if (app != null && fragmentRef != null && fragment.isVisible()) {
boolean routeCalculating = app.getRoutingHelper().isRouteBeingCalculated() || app.getTransportRoutingHelper().isRouteBeingCalculated();
if (setRouteCalculationInProgress(routeCalculating)) {
fragment.updateControlButtons();
fragment.updateInfo();
if (!routeCalculationInProgress) {
fragment.hideRouteCalculationProgressBar();
fragment.openMenuHalfScreen();
}
}
}
}
@ -460,7 +476,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
mainView = main;
OsmandApplication app = mapActivity.getMyApplication();
nightMode = app.getDaynightHelper().isNightModeForMapControls();
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
updateStartPointView();
updateWaypointsView();
@ -470,11 +485,26 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
updateApplicationModesOptions();
updateOptionsButtons();
updateCards();
}
private void updateCards() {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
OsmandApplication app = mapActivity.getMyApplication();
nightMode = app.getDaynightHelper().isNightModeForMapControls();
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
RoutingHelper routingHelper = app.getRoutingHelper();
menuCards.clear();
boolean bottomShadowVisible = true;
if (isBasicRouteCalculated()) {
GPXFile gpx = GpxUiHelper.makeGpxFromRoute(app.getRoutingHelper().getRoute(), app);
GPXFile gpx = GpxUiHelper.makeGpxFromRoute(routingHelper.getRoute(), app);
if (gpx != null) {
SimpleRouteCard simpleRouteCard = new SimpleRouteCard(mapActivity, gpx);
simpleRouteCard.setListener(this);
@ -494,8 +524,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
}
bottomShadowVisible = routes.size() == 0;
} else if (routeCalculationInProgress) {
WarningCard warningCard = new WarningCard(mapActivity);
menuCards.add(warningCard);
if (app.getTargetPointsHelper().hasTooLongDistanceToNavigate() || routingHelper.isPublicTransportMode()) {
// WarningCard card
WarningCard warningCard = new WarningCard(mapActivity);
menuCards.add(warningCard);
}
} else {
// Home/work card
HomeWorkCard homeWorkCard = new HomeWorkCard(mapActivity);

View file

@ -627,6 +627,11 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
boolean canceled = false;
@Override
public void onAnimationStart(Animator animation) {
moving = true;
}
@Override
public void onAnimationCancel(Animator animation) {
canceled = true;
@ -634,6 +639,7 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
@Override
public void onAnimationEnd(Animator animation) {
moving = false;
if (!canceled) {
if (needCloseMenu) {
menu.hide();
@ -796,7 +802,9 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
if (menu != null) {
menu.updateInfo(view);
applyDayNightMode();
runLayoutListener();
if (!moving) {
runLayoutListener();
}
}
}
@ -834,9 +842,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
}
TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr);
textViewExProgress.percent = progress / 100f;
int color = nightMode ? R.color.main_font_dark : R.color.card_and_list_background_light;
textViewExProgress.color1 = ContextCompat.getColor(mapActivity, color);
textViewExProgress.color2 = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons);
textViewExProgress.invalidate();
}

View file

@ -1496,7 +1496,10 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
public static CumulativeInfo getRouteDirectionCumulativeInfo(int position, List<RouteDirectionInfo> routeDirections) {
CumulativeInfo cumulativeInfo = new CumulativeInfo();
for (int i = position; i < routeDirections.size(); i++) {
if (position >= routeDirections.size()) {
return cumulativeInfo;
}
for (int i = 0; i < position; i++) {
RouteDirectionInfo routeDirectionInfo = routeDirections.get(i);
cumulativeInfo.time += routeDirectionInfo.getExpectedTime();
cumulativeInfo.distance += routeDirectionInfo.distance;

View file

@ -64,6 +64,7 @@ public class RoutingHelper {
private String lastRouteCalcErrorShort;
private long recalculateCountInInterval = 0;
private int evalWaitInterval = 0;
private boolean waitingNextJob;
private ApplicationMode mode;
private OsmandSettings settings;
@ -872,6 +873,7 @@ public class RoutingHelper {
public void run() {
synchronized (RoutingHelper.this) {
currentRunningJob = this;
waitingNextJob = prevRunningJob != null;
}
if(prevRunningJob != null) {
while(prevRunningJob.isAlive()){
@ -883,6 +885,7 @@ public class RoutingHelper {
}
synchronized (RoutingHelper.this) {
currentRunningJob = this;
waitingNextJob = false;
}
}
lastRouteCalcError = null;
@ -1086,8 +1089,8 @@ public class RoutingHelper {
return mode == ApplicationMode.PUBLIC_TRANSPORT;
}
public boolean isRouteBeingCalculated(){
return currentRunningJob instanceof RouteRecalculationThread;
public boolean isRouteBeingCalculated() {
return currentRunningJob instanceof RouteRecalculationThread || waitingNextJob;
}
private void showMessage(final String msg){

View file

@ -63,6 +63,7 @@ public class TransportRoutingHelper {
private String lastRouteCalcError;
private String lastRouteCalcErrorShort;
private long lastTimeEvaluatedRoute = 0;
private boolean waitingNextJob;
private TransportRouteCalculationProgressCallback progressRoute;
@ -253,7 +254,7 @@ public class TransportRoutingHelper {
}
public boolean isRouteBeingCalculated() {
return currentRunningJob instanceof RouteRecalculationThread;
return currentRunningJob instanceof RouteRecalculationThread || waitingNextJob;
}
private void setNewRoute(final List<TransportRouteResult> res) {
@ -584,6 +585,7 @@ public class TransportRoutingHelper {
public void run() {
synchronized (TransportRoutingHelper.this) {
currentRunningJob = this;
waitingNextJob = prevRunningJob != null;
}
if (prevRunningJob != null) {
while (prevRunningJob.isAlive()) {
@ -595,6 +597,7 @@ public class TransportRoutingHelper {
}
synchronized (TransportRoutingHelper.this) {
currentRunningJob = this;
waitingNextJob = false;
}
}

View file

@ -73,6 +73,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
private boolean isLayerOn;
private boolean nightMode;
private boolean currentWidgetState;
public MapQuickActionLayer(MapActivity activity, ContextMenuLayer contextMenuLayer) {
this.mapActivity = activity;
@ -199,35 +200,36 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
return quickActionsWidget.getVisibility() == View.VISIBLE;
}
/**
* @param showWidget
* @return true, if state was changed
*/
public boolean setLayerState(boolean showWidget) {
if (isWidgetVisible() == showWidget) // check if state change is needed
return false;
/**
* @param showWidget
* @return true, if state was changed
*/
public boolean setLayerState(boolean showWidget) {
currentWidgetState = showWidget;
if (isWidgetVisible() == showWidget) // check if state change is needed
return false;
updateQuickActionButton(showWidget);
if (settings.DO_NOT_USE_ANIMATIONS.get()) {
quickActionsWidget.setVisibility(!showWidget ? View.GONE : View.VISIBLE);
} else {
quickActionsWidget.setVisibility(!showWidget ? View.GONE : View.VISIBLE);
} else {
animateWidget(showWidget);
}
mapActivity.updateStatusBarColor();
}
mapActivity.updateStatusBarColor();
if (!showWidget) {
quitMovingMarker();
quickActionRegistry.setUpdatesListener(null);
quickActionsWidget.setSelectionListener(null);
} else {
enterMovingMode(mapActivity.getMapView().getCurrentRotatedTileBox());
quickActionsWidget.setActions(quickActionRegistry.getFilteredQuickActions());
quickActionRegistry.setUpdatesListener(MapQuickActionLayer.this);
quickActionsWidget.setSelectionListener(MapQuickActionLayer.this);
}
if (!showWidget) {
quitMovingMarker();
quickActionRegistry.setUpdatesListener(null);
quickActionsWidget.setSelectionListener(null);
} else {
enterMovingMode(mapActivity.getMapView().getCurrentRotatedTileBox());
quickActionsWidget.setActions(quickActionRegistry.getFilteredQuickActions());
quickActionRegistry.setUpdatesListener(MapQuickActionLayer.this);
quickActionsWidget.setSelectionListener(MapQuickActionLayer.this);
}
return true;
}
return true;
}
private void animateWidget(final boolean show) {
AnimatorSet set = new AnimatorSet();
@ -370,19 +372,19 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
return py <= quickActionsWidget.getHeight();
}
@Override
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings settings) {
boolean nightMode = settings != null && settings.isNightMode();
if (isInMovingMarkerMode()) {
canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight());
contextMarker.draw(canvas);
}
@Override
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings settings) {
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
if (isInMovingMarkerMode()) {
canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight());
contextMarker.draw(canvas);
}
if (this.nightMode != nightMode) {
this.nightMode = nightMode;
updateQuickActionButton(isWidgetVisible());
updateQuickActionButton(currentWidgetState);
}
setupQuickActionBtnVisibility();
}
setupQuickActionBtnVisibility();
}
private void setupQuickActionBtnVisibility() {
MapContextMenu contextMenu = mapActivity.getContextMenu();

View file

@ -681,7 +681,7 @@ public class RouteInfoWidgetsFactory {
if (degreesChanged(cachedDegrees, b) || modeChanged) {
cachedDegrees = b;
if (b != -1000) {
setText(String.valueOf(b) + "°" + (relative ? "" : " M"), null);
setText(OsmAndFormatter.getFormattedAzimuth(b, getOsmandApplication()) + (relative ? "" : " M"), null);
} else {
setText(null, null);
}