Search in sources :

Example 6 with NavigationSession

use of net.osmand.plus.auto.NavigationSession in project Osmand by osmandapp.

the class MapActivity method setupOpenGLView.

private void setupOpenGLView(boolean init) {
    OsmandMapTileView mapView = getMapView();
    NavigationSession carNavigationSession = app.getCarNavigationSession();
    View androidAutoPlaceholder = findViewById(R.id.AndroidAutoPlaceholder);
    boolean useAndroidAuto = carNavigationSession != null && carNavigationSession.hasStarted() && InAppPurchaseHelper.isAndroidAutoAvailable(app);
    if (settings.USE_OPENGL_RENDER.get() && NativeCoreContext.isInit()) {
        ViewStub stub = findViewById(R.id.atlasMapRendererViewStub);
        if (atlasMapRendererView == null) {
            atlasMapRendererView = (AtlasMapRendererView) stub.inflate();
            atlasMapRendererView.setAzimuth(0);
            atlasMapRendererView.setElevationAngle(app.getSettings().getLastKnownMapElevation());
            NativeCoreContext.getMapRendererContext().setMapRendererView(atlasMapRendererView);
        }
        OsmAndMapLayersView ml = findViewById(R.id.MapLayersView);
        if (useAndroidAuto) {
            ml.setVisibility(View.GONE);
            ml.setMapView(null);
            androidAutoPlaceholder.setVisibility(View.VISIBLE);
        } else {
            ml.setVisibility(View.VISIBLE);
            ml.setMapView(mapView);
            androidAutoPlaceholder.setVisibility(View.GONE);
        }
        getMapViewTrackingUtilities().setMapView(mapView);
        mapView.setMapRender(atlasMapRendererView);
        OsmAndMapSurfaceView surf = findViewById(R.id.MapView);
        surf.setVisibility(View.GONE);
    } else {
        OsmAndMapSurfaceView surf = findViewById(R.id.MapView);
        if (useAndroidAuto) {
            surf.setVisibility(View.GONE);
            surf.setMapView(null);
            androidAutoPlaceholder.setVisibility(View.VISIBLE);
        } else {
            surf.setVisibility(View.VISIBLE);
            surf.setMapView(mapView);
            androidAutoPlaceholder.setVisibility(View.GONE);
        }
    }
}
Also used : ViewStub(android.view.ViewStub) OsmAndMapSurfaceView(net.osmand.plus.views.OsmAndMapSurfaceView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) OsmAndMapLayersView(net.osmand.plus.views.OsmAndMapLayersView) NavigationSession(net.osmand.plus.auto.NavigationSession) AtlasMapRendererView(net.osmand.core.android.AtlasMapRendererView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) View(android.view.View) TextView(android.widget.TextView) OsmAndMapSurfaceView(net.osmand.plus.views.OsmAndMapSurfaceView) OsmAndMapLayersView(net.osmand.plus.views.OsmAndMapLayersView)

Example 7 with NavigationSession

use of net.osmand.plus.auto.NavigationSession in project Osmand by osmandapp.

the class MapActivity method onDestroy.

@Override
protected void onDestroy() {
    super.onDestroy();
    app.getOsmandMap().removeListener(this);
    getMapLayers().setMapActivity(null);
    getMapView().setMapActivity(null);
    mapContextMenu.setMapActivity(null);
    mapRouteInfoMenu.setMapActivity(null);
    trackDetailsMenu.setMapActivity(null);
    unregisterReceiver(screenOffReceiver);
    app.getAidlApi().onDestroyMapActivity(this);
    FailSafeFuntions.quitRouteRestoreDialog();
    OsmandPlugin.onMapActivityDestroy(this);
    getMyApplication().unsubscribeInitListener(initListener);
    NavigationSession carNavigationSession = app.getCarNavigationSession();
    if (carNavigationSession == null) {
        getMapViewTrackingUtilities().setMapView(null);
    }
    if (atlasMapRendererView != null) {
        atlasMapRendererView.handleOnDestroy();
    }
    lockHelper.setLockUIAdapter(null);
    extendedMapActivity.onDestroy(this);
    mIsDestroyed = true;
}
Also used : NavigationSession(net.osmand.plus.auto.NavigationSession)

Example 8 with NavigationSession

use of net.osmand.plus.auto.NavigationSession in project Osmand by osmandapp.

the class NavigationService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    final OsmandApplication app = getApp();
    settings = app.getSettings();
    usedBy = intent.getIntExtra(USAGE_INTENT, 0);
    locationProvider = app.getLocationProvider();
    locationServiceHelper = app.createLocationServiceHelper();
    app.setNavigationService(this);
    NavigationSession carNavigationSession = app.getCarNavigationSession();
    if (carNavigationSession != null) {
        setCarContext(carNavigationSession.getCarContext());
    }
    Notification notification = app.getNotificationHelper().buildTopNotification();
    if (notification != null) {
        if (isUsedByNavigation()) {
            startCarNavigation();
        }
        startForeground(OsmandNotification.TOP_NOTIFICATION_SERVICE_ID, notification);
        app.getNotificationHelper().refreshNotifications();
    } else {
        notification = app.getNotificationHelper().buildErrorNotification();
        startForeground(OsmandNotification.TOP_NOTIFICATION_SERVICE_ID, notification);
        stopSelf();
        return START_NOT_STICKY;
    }
    requestLocationUpdates();
    return START_REDELIVER_INTENT;
}
Also used : NavigationSession(net.osmand.plus.auto.NavigationSession) OsmandNotification(net.osmand.plus.notifications.OsmandNotification) Notification(android.app.Notification)

Example 9 with NavigationSession

use of net.osmand.plus.auto.NavigationSession in project Osmand by osmandapp.

the class NavigationService method stopCarNavigation.

/**
 * Stops navigation.
 */
public void stopCarNavigation() {
    if (navigationManager != null) {
        NavigationSession carNavigationSession = getApp().getCarNavigationSession();
        if (carNavigationSession != null) {
            NavigationScreen navigationScreen = carNavigationSession.getNavigationScreen();
            if (navigationScreen != null) {
                navigationScreen.stopTrip();
            }
        }
        carNavigationActive = false;
        navigationManager.navigationEnded();
    }
}
Also used : NavigationScreen(net.osmand.plus.auto.NavigationScreen) NavigationSession(net.osmand.plus.auto.NavigationSession)

Example 10 with NavigationSession

use of net.osmand.plus.auto.NavigationSession in project Osmand by osmandapp.

the class OsmandApplication method showShortToastMessage.

public void showShortToastMessage(final String msg) {
    uiHandler.post(() -> {
        Toast.makeText(OsmandApplication.this, msg, Toast.LENGTH_SHORT).show();
        NavigationSession carNavigationSession = this.carNavigationSession;
        if (carNavigationSession != null && carNavigationSession.hasStarted()) {
            CarToast.makeText(carNavigationSession.getCarContext(), msg, CarToast.LENGTH_SHORT).show();
        }
    });
}
Also used : NavigationSession(net.osmand.plus.auto.NavigationSession)

Aggregations

NavigationSession (net.osmand.plus.auto.NavigationSession)16 RoutingHelper (net.osmand.plus.routing.RoutingHelper)3 Location (net.osmand.Location)2 NavigationService (net.osmand.plus.NavigationService)2 NavigationScreen (net.osmand.plus.auto.NavigationScreen)2 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)2 Notification (android.app.Notification)1 PendingIntent (android.app.PendingIntent)1 ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 View (android.view.View)1 ViewStub (android.view.ViewStub)1 TextView (android.widget.TextView)1 Destination (androidx.car.app.navigation.model.Destination)1 TravelEstimate (androidx.car.app.navigation.model.TravelEstimate)1 Trip (androidx.car.app.navigation.model.Trip)1 CarAppExtender (androidx.car.app.notification.CarAppExtender)1 CarPendingIntent (androidx.car.app.notification.CarPendingIntent)1 BigTextStyle (androidx.core.app.NotificationCompat.BigTextStyle)1