Skip to content

Commit

Permalink
show aa navigation screen when starting navigation from phone; remove…
Browse files Browse the repository at this point in the history
…d debug logs
  • Loading branch information
Corwin-Kh committed Nov 22, 2024
1 parent 47a11b3 commit d864ed3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
26 changes: 9 additions & 17 deletions OsmAnd/src/net/osmand/plus/auto/NavigationSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ private void processNavigationIntent(@NonNull Uri uri) {
});
} else {
String text = point.isGeoAddress() ? point.getQuery() : uri.toString();
screenManager.pushForResult(new SearchResultsScreen(context, settingsAction, text), (obj) -> {});
screenManager.pushForResult(new SearchResultsScreen(context, settingsAction, text), (obj) -> {
});
}
}
}
Expand Down Expand Up @@ -435,9 +436,7 @@ public void startNavigationScreen() {
// navigation already started
if (routingHelper.isFollowingMode() && routingHelper.isRouteCalculated() && !carNavigationShouldBeActive) {
startCarNavigation();
}
if (routingHelper.isRouteCalculated()) {
routingHelper.resumeNavigation(); // to update navigate session immediately with location
updateCarNavigation(getApp().getLocationProvider().getLastKnownLocation());
}
}

Expand Down Expand Up @@ -468,7 +467,12 @@ public void updateLocation(Location location) {

@Override
public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) {
showRoutePreview();
if (routingHelper.isFollowingMode() && routingHelper.isRouteCalculated()) {
startNavigationScreen();
updateCarNavigation(getApp().getLocationProvider().getLastKnownLocation());
} else {
showRoutePreview();
}
}

@Override
Expand Down Expand Up @@ -597,15 +601,12 @@ private boolean useOnlyGPS() {
*/
public void setCarContext(@Nullable CarContext carContext) {
this.carContext = carContext;
Log.d("AA_navigation", "setCarContext " + carContext);
if (carContext != null) {
this.tripHelper = new TripHelper(getApp());
this.navigationManager = carContext.getCarService(NavigationManager.class);
Log.d("AA_navigation", "setCarContext navManager " + navigationManager);
this.navigationManager.setNavigationManagerCallback(new NavigationManagerCallback() {
@Override
public void onStopNavigation() {
Log.d("AA_navigation", "onStopNavigation " + routingHelper.isRouteCalculated() + "__" + routingHelper.isFollowingMode());
if (routingHelper.isRouteCalculated() && routingHelper.isFollowingMode()) {
routingHelper.pauseNavigation();
} else {
Expand All @@ -624,12 +625,10 @@ public void onAutoDriveEnabled() {
}
}
});
Log.d("AA_navigation", "setCarContext carNavigationShouldBeActive " + carNavigationShouldBeActive);
if (carNavigationShouldBeActive) {
navigationManager.navigationStarted();
}
} else {
Log.d("AA_navigation", "setCarContext navManager=null");
this.navigationManager = null;
}
}
Expand All @@ -638,7 +637,6 @@ public void onAutoDriveEnabled() {
* Clears the currently used {@link CarContext}.
*/
public void clearCarContext() {
Log.d("AA_navigation", "public void clearCarContext()");
carContext = null;
if (navigationManager != null) {
navigationManager.clearNavigationManagerCallback();
Expand All @@ -651,7 +649,6 @@ public void clearCarContext() {
* Starts navigation.
*/
public void startCarNavigation() {
Log.d("AA_navigation", "startCarNavigation " + navigationManager);
if (navigationManager != null) {
navigationManager.navigationStarted();
}
Expand All @@ -663,7 +660,6 @@ public void startCarNavigation() {
*/
public void stopCarNavigation() {
getApp().runInUIThread(() -> {
Log.d("AA_navigation", "stopCarNavigation navManager " + navigationManager);
if (navigationManager != null) {
NavigationSession carNavigationSession = getApp().getCarNavigationSession();
if (carNavigationSession != null) {
Expand All @@ -682,10 +678,6 @@ public void stopCarNavigation() {
public void updateCarNavigation(Location currentLocation) {
OsmandApplication app = getApp();
TripHelper tripHelper = this.tripHelper;
Log.d("AA_navigation", "Nav session active=" + carNavigationShouldBeActive +
" manager=" + navigationManager + " tripHelp=" + tripHelper +
" calculated=" + routingHelper.isRouteCalculated() +
" isFollowing=" + routingHelper.isFollowingMode());
if (carNavigationShouldBeActive && navigationManager != null && tripHelper != null
&& routingHelper.isRouteCalculated() && routingHelper.isFollowingMode()) {
NavigationSession carNavigationSession = app.getCarNavigationSession();
Expand Down
1 change: 0 additions & 1 deletion OsmAnd/src/net/osmand/plus/auto/screens/LandingScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class LandingScreen(
init {
lifecycle.addObserver(object : DefaultLifecycleObserver {
override fun onResume(owner: LifecycleOwner) {
Log.d("AA_navigation", "LandingScreen onResume: ")
app.carNavigationSession?.updateCarNavigation(app.locationProvider.lastKnownLocation)
}
})
Expand Down
4 changes: 0 additions & 4 deletions OsmAnd/src/net/osmand/plus/auto/screens/NavigationScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,12 @@ public Template onGetTemplate() {
builder.setDestinationTravelEstimate(destinationTravelEstimate);
}
if (isRerouting()) {
Log.d("AA_navigation", "onGetTemplate: isRerouting()");
builder.setNavigationInfo(new RoutingInfo.Builder().setLoading(true).build());
} else if (arrived) {
Log.d("AA_navigation", "onGetTemplate: arrived");
MessageInfo messageInfo = new MessageInfo.Builder(
getCarContext().getString(R.string.arrived_at_destination)).build();
builder.setNavigationInfo(messageInfo);
} else if (!Algorithms.isEmpty(steps)) {
Log.d("AA_navigation", "onGetTemplate: !isEmpty(steps)");
RoutingInfo.Builder info = new RoutingInfo.Builder();
Step firstStep = steps.get(0);
Step.Builder currentStep = new Step.Builder();
Expand Down Expand Up @@ -437,7 +434,6 @@ private void compassClick() {
}

private void goBack() {
Log.d("AA_navigation", "NavScreen goBack: ");
finish();
// Test
//getScreenManager().pushForResult(new SearchResultsScreen(getCarContext(), settingsAction, surfaceRenderer, "cafe"), (obj) -> { });
Expand Down

0 comments on commit d864ed3

Please sign in to comment.