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);
}
}
}
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;
}
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;
}
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();
}
}
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();
}
});
}
Aggregations