From d7e2f1ff8ca6b502b48a56a744de5bd4b601c2f0 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Wed, 20 Oct 2021 22:37:57 +0200 Subject: [PATCH] make use of onSetNavigationInfo() in osmand receiver. This is not implemented anywhere, purely preparing for further experiments --- .../externalevents/OsmandEventReceiver.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/OsmandEventReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/OsmandEventReceiver.java index cd617f2a3..6b4fdc5fe 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/OsmandEventReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/OsmandEventReceiver.java @@ -24,6 +24,8 @@ import org.slf4j.LoggerFactory; import java.util.List; +import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.model.NavigationInfoSpec; import nodomain.freeyourgadget.gadgetbridge.util.GB; public class OsmandEventReceiver { @@ -35,6 +37,8 @@ public class OsmandEventReceiver { private final Application app; private IOsmAndAidlInterface mIOsmAndAidlInterface; + private NavigationInfoSpec navigationInfoSpec = new NavigationInfoSpec(); + private final IOsmAndAidlCallback.Stub mIOsmAndAidlCallback = new IOsmAndAidlCallback.Stub() { @Override public void onSearchComplete(List resultSet) { @@ -54,6 +58,10 @@ public class OsmandEventReceiver { @Override public void updateNavigationInfo(ADirectionInfo directionInfo) { + navigationInfoSpec.nextAction = directionInfo.getTurnType(); + navigationInfoSpec.distanceToTurn = directionInfo.getDistanceTo(); + GBApplication.deviceService().onSetNavigationInfo(navigationInfoSpec); + LOG.error("Distance: " + directionInfo.getDistanceTo() + " turnType: " + directionInfo.getTurnType()); } @@ -63,11 +71,13 @@ public class OsmandEventReceiver { @Override public void onVoiceRouterNotify(OnVoiceNavigationParams params) { - List played = params.getPlayed(); - for (String play : played) { - LOG.error("played: " + play); + List played = params.getPlayed(); + for (String instuction : played) { + navigationInfoSpec.instruction = instuction; + LOG.error("instruction: " + instuction); + // only first one for now + break; } - } @Override