Add turnInfo for aidl
This commit is contained in:
parent
5b4420eb42
commit
7b7e3fc6fe
2 changed files with 65 additions and 20 deletions
|
@ -10,17 +10,20 @@ public class AppInfoParams extends AidlParams {
|
||||||
|
|
||||||
private ALatLon lastKnownLocation;
|
private ALatLon lastKnownLocation;
|
||||||
private ALatLon mapLocation;
|
private ALatLon mapLocation;
|
||||||
private int time;
|
|
||||||
private long eta;
|
private Bundle turnInfo;
|
||||||
|
private int leftTime;
|
||||||
private int leftDistance;
|
private int leftDistance;
|
||||||
|
private long arrivalTime;
|
||||||
private boolean mapVisible;
|
private boolean mapVisible;
|
||||||
|
|
||||||
public AppInfoParams(ALatLon lastKnownLocation, ALatLon mapLocation, int time, long eta, int leftDistance, boolean mapVisible) {
|
public AppInfoParams(ALatLon lastKnownLocation, ALatLon mapLocation, Bundle turnInfo, int leftTime, int leftDistance, long arrivalTime, boolean mapVisible) {
|
||||||
this.lastKnownLocation = lastKnownLocation;
|
this.lastKnownLocation = lastKnownLocation;
|
||||||
this.mapLocation = mapLocation;
|
this.mapLocation = mapLocation;
|
||||||
this.time = time;
|
this.leftTime = leftTime;
|
||||||
this.eta = eta;
|
|
||||||
this.leftDistance = leftDistance;
|
this.leftDistance = leftDistance;
|
||||||
|
this.arrivalTime = arrivalTime;
|
||||||
|
this.turnInfo = turnInfo;
|
||||||
this.mapVisible = mapVisible;
|
this.mapVisible = mapVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,12 +51,12 @@ public class AppInfoParams extends AidlParams {
|
||||||
return mapLocation;
|
return mapLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTime() {
|
public int getLeftTime() {
|
||||||
return time;
|
return leftTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getEta() {
|
public long getArrivalTime() {
|
||||||
return eta;
|
return arrivalTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLeftDistance() {
|
public int getLeftDistance() {
|
||||||
|
@ -64,23 +67,29 @@ public class AppInfoParams extends AidlParams {
|
||||||
return mapVisible;
|
return mapVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Bundle getTurnInfo() {
|
||||||
|
return turnInfo;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToBundle(Bundle bundle) {
|
public void writeToBundle(Bundle bundle) {
|
||||||
bundle.putParcelable("location", lastKnownLocation);
|
bundle.putParcelable("lastKnownLocation", lastKnownLocation);
|
||||||
bundle.putParcelable("mapLocation", mapLocation);
|
bundle.putParcelable("mapLocation", mapLocation);
|
||||||
bundle.putInt("time", time);
|
bundle.putInt("leftTime", leftTime);
|
||||||
bundle.putLong("eta", eta);
|
bundle.putLong("arrivalTime", arrivalTime);
|
||||||
bundle.putInt("leftDistance", leftDistance);
|
bundle.putInt("leftDistance", leftDistance);
|
||||||
|
bundle.putBundle("turnInfo", turnInfo);
|
||||||
bundle.putBoolean("mapVisible", mapVisible);
|
bundle.putBoolean("mapVisible", mapVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readFromBundle(Bundle bundle) {
|
protected void readFromBundle(Bundle bundle) {
|
||||||
lastKnownLocation = bundle.getParcelable("location");
|
lastKnownLocation = bundle.getParcelable("lastKnownLocation");
|
||||||
mapLocation = bundle.getParcelable("mapLocation");
|
mapLocation = bundle.getParcelable("mapLocation");
|
||||||
time = bundle.getInt("time");
|
leftTime = bundle.getInt("leftTime");
|
||||||
eta = bundle.getLong("eta");
|
arrivalTime = bundle.getLong("arrivalTime");
|
||||||
leftDistance = bundle.getInt("leftDistance");
|
leftDistance = bundle.getInt("leftDistance");
|
||||||
|
turnInfo = bundle.getBundle("turnInfo");
|
||||||
mapVisible = bundle.getBoolean("mapVisible");
|
mapVisible = bundle.getBoolean("mapVisible");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -73,6 +73,7 @@ import net.osmand.plus.quickaction.QuickActionRegistry;
|
||||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||||
import net.osmand.plus.routing.IRoutingDataUpdateListener;
|
import net.osmand.plus.routing.IRoutingDataUpdateListener;
|
||||||
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
|
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
|
||||||
|
import net.osmand.plus.routing.RouteDirectionInfo;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.routing.VoiceRouter;
|
import net.osmand.plus.routing.VoiceRouter;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
|
@ -103,6 +104,7 @@ import java.io.InputStream;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -127,6 +129,11 @@ import static net.osmand.aidlapi.OsmandAidlConstants.COPY_FILE_PART_SIZE_LIMIT_E
|
||||||
import static net.osmand.aidlapi.OsmandAidlConstants.COPY_FILE_UNSUPPORTED_FILE_TYPE_ERROR;
|
import static net.osmand.aidlapi.OsmandAidlConstants.COPY_FILE_UNSUPPORTED_FILE_TYPE_ERROR;
|
||||||
import static net.osmand.aidlapi.OsmandAidlConstants.COPY_FILE_WRITE_LOCK_ERROR;
|
import static net.osmand.aidlapi.OsmandAidlConstants.COPY_FILE_WRITE_LOCK_ERROR;
|
||||||
import static net.osmand.aidlapi.OsmandAidlConstants.OK_RESPONSE;
|
import static net.osmand.aidlapi.OsmandAidlConstants.OK_RESPONSE;
|
||||||
|
import static net.osmand.plus.helpers.ExternalApiHelper.PARAM_NT_DIRECTION_LANES;
|
||||||
|
import static net.osmand.plus.helpers.ExternalApiHelper.PARAM_NT_DIRECTION_NAME;
|
||||||
|
import static net.osmand.plus.helpers.ExternalApiHelper.PARAM_NT_DIRECTION_TURN;
|
||||||
|
import static net.osmand.plus.helpers.ExternalApiHelper.PARAM_NT_DISTANCE;
|
||||||
|
import static net.osmand.plus.helpers.ExternalApiHelper.PARAM_NT_IMMINENT;
|
||||||
|
|
||||||
public class OsmandAidlApi {
|
public class OsmandAidlApi {
|
||||||
|
|
||||||
|
@ -1734,17 +1741,46 @@ public class OsmandAidlApi {
|
||||||
mapVisible = mapActivity.isMapVisible();
|
mapVisible = mapActivity.isMapVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
int time = 0;
|
int leftTime = 0;
|
||||||
long eta = 0;
|
long arrivalTime = 0;
|
||||||
int leftDistance = 0;
|
int leftDistance = 0;
|
||||||
|
Bundle turnInfo = null;
|
||||||
|
|
||||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||||
if (routingHelper.isRouteCalculated()) {
|
if (routingHelper.isRouteCalculated()) {
|
||||||
time = routingHelper.getLeftTime();
|
leftTime = routingHelper.getLeftTime();
|
||||||
eta = time + System.currentTimeMillis() / 1000;
|
arrivalTime = leftTime + System.currentTimeMillis() / 1000;
|
||||||
leftDistance = routingHelper.getLeftDistance();
|
leftDistance = routingHelper.getLeftDistance();
|
||||||
|
|
||||||
|
NextDirectionInfo directionInfo = routingHelper.getNextRouteDirectionInfo(new NextDirectionInfo(), true);
|
||||||
|
turnInfo = new Bundle();
|
||||||
|
if (directionInfo.distanceTo > 0) {
|
||||||
|
updateTurnInfo("next_", turnInfo, directionInfo);
|
||||||
|
directionInfo = routingHelper.getNextRouteDirectionInfoAfter(directionInfo, new NextDirectionInfo(), true);
|
||||||
|
if (directionInfo.distanceTo > 0) {
|
||||||
|
updateTurnInfo("after_next", turnInfo, directionInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
routingHelper.getNextRouteDirectionInfo(new NextDirectionInfo(), false);
|
||||||
|
if (directionInfo.distanceTo > 0) {
|
||||||
|
updateTurnInfo("no_speak_next_", turnInfo, directionInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new AppInfoParams(lastKnownLocation, mapLocation, turnInfo, leftTime, leftDistance, arrivalTime, mapVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTurnInfo(String prefix, Bundle bundle, NextDirectionInfo ni) {
|
||||||
|
bundle.putInt(prefix + PARAM_NT_DISTANCE, ni.distanceTo);
|
||||||
|
bundle.putInt(prefix + PARAM_NT_IMMINENT, ni.imminent);
|
||||||
|
if (ni.directionInfo != null && ni.directionInfo.getTurnType() != null) {
|
||||||
|
TurnType tt = ni.directionInfo.getTurnType();
|
||||||
|
RouteDirectionInfo a = ni.directionInfo;
|
||||||
|
bundle.putString(prefix + PARAM_NT_DIRECTION_NAME, RoutingHelper.formatStreetName(a.getStreetName(), a.getRef(), a.getDestinationName(), ""));
|
||||||
|
bundle.putString(prefix + PARAM_NT_DIRECTION_TURN, tt.toXmlString());
|
||||||
|
if (tt.getLanes() != null) {
|
||||||
|
bundle.putString(prefix + PARAM_NT_DIRECTION_LANES, Arrays.toString(tt.getLanes()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new AppInfoParams(lastKnownLocation, mapLocation, time, eta, leftDistance, mapVisible);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean search(final String searchQuery, final int searchType, final double latitude, final double longitude,
|
boolean search(final String searchQuery, final int searchType, final double latitude, final double longitude,
|
||||||
|
|
Loading…
Reference in a new issue