async Task ConfigureCurrentTripUserInterface() { // Configure map mapDelegate = new TripMapViewDelegate(true); tripMapView.Delegate = mapDelegate; tripMapView.ShowsUserLocation = false; tripMapView.Camera.Altitude = 5000; // Setup record button recordButton.Hidden = false; recordButton.Layer.CornerRadius = recordButton.Frame.Width / 2; recordButton.Layer.MasksToBounds = true; recordButton.Layer.BorderColor = UIColor.White.CGColor; recordButton.Layer.BorderWidth = 0; recordButton.TouchUpInside += RecordButton_TouchUpInside; // Hide slider tripSlider.Hidden = true; wayPointA.Hidden = true; wayPointB.Hidden = true; UpdateRecordButton(false); tripInfoView.Alpha = 0; ResetTripInfoView(); CurrentTripViewModel = new CurrentTripViewModel(); CurrentTripViewModel.Geolocator.PositionChanged += Geolocator_PositionChanged; }
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { var builder = new NotificationCompat.Builder(this); var newIntent = new Intent(this, typeof(MainActivity)); newIntent.PutExtra("tracking", true); newIntent.AddFlags(ActivityFlags.ClearTop); newIntent.AddFlags(ActivityFlags.SingleTop); var pendingIntent = PendingIntent.GetActivity(this, 0, newIntent, 0); var notification = builder.SetContentIntent(pendingIntent) .SetSmallIcon(Resource.Drawable.ic_notification) .SetAutoCancel(false) .SetTicker("MyDriving is recording.") .SetContentTitle("MyDriving") .SetContentText("MyDriving is recording your current trip.") .Build(); StartForeground((int)NotificationFlags.ForegroundService, notification); ViewModel = new CurrentTripViewModel(); return(StartCommandResult.Sticky); }
async void RecordButton_TouchUpInside(object sender, EventArgs e) { if (!CurrentTripViewModel.Geolocator.IsGeolocationEnabled) { Acr.UserDialogs.UserDialogs.Instance.Alert( "Please ensure that geolocation is enabled and permissions are allowed for MyDriving to start a recording.", "Geolocation Disabled", "OK"); return; } if (!CurrentTripViewModel.IsRecording) { if (!await CurrentTripViewModel.StartRecordingTrip()) { return; } UpdateRecordButton(true); ResetTripInfoView(); AnimateTripInfoView(); if (CurrentTripViewModel.CurrentTrip.HasSimulatedOBDData) { NavigationItem.Title = "Current Trip (Sim OBD)"; } var endpoint = "A"; var annotation = new WaypointAnnotation(CurrentTripViewModel.CurrentPosition.ToCoordinate(), endpoint); tripMapView.AddAnnotation(annotation); } else { if (await CurrentTripViewModel.StopRecordingTrip()) { ResetMapViewState(); InvokeOnMainThread(delegate { mapDelegate = new TripMapViewDelegate(true); tripMapView.Delegate = mapDelegate; }); UpdateRecordButton(false); tripInfoView.Alpha = 0; NavigationItem.Title = "Current Trip"; await CurrentTripViewModel.SaveRecordingTripAsync(); var vc = Storyboard.InstantiateViewController("tripSummaryViewController") as TripSummaryViewController; vc.ViewModel = CurrentTripViewModel; PresentModalViewController(vc, true); } } }
public CurrentTripView() { InitializeComponent(); ViewModel = new CurrentTripViewModel(); Locations = new List <BasicGeoposition>(); if (Logger.BingMapsAPIKey != "Ar6iuHZYgX1BrfJs6SRJaXWbpU_HKdoe7G-OO9b2kl3rWvcawYx235GGx5FPM76O") { MyMap.MapServiceToken = Logger.BingMapsAPIKey; } MyMap.Loaded += MyMap_Loaded; DataContext = this; recordButtonImage = new BitmapImage(new Uri("ms-appx:///Assets/StartRecord.png", UriKind.Absolute)); OnPropertyChanged(nameof(RecordButtonImage)); StartRecordBtn.Click += StartRecordBtn_Click; }
public CurrentTripView() { InitializeComponent(); ViewModel = new CurrentTripViewModel(); Locations = new List <BasicGeoposition>(); /*1 * if (Logger.BingMapsAPIKey != "____BingMapsAPIKey____") * { * MyMap.MapServiceToken = Logger.BingMapsAPIKey; * } * * MyMap.Loaded += MyMap_Loaded;*/ DataContext = this; recordButtonImage = new BitmapImage(new Uri("ms-appx:///Assets/StartRecord.png", UriKind.Absolute)); OnPropertyChanged(nameof(RecordButtonImage)); StartRecordBtn.Click += StartRecordBtn_Click; }
public override async void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); PopRecordButtonAnimation(); if (CurrentTripViewModel != null) { await CurrentTripViewModel.ExecuteStartTrackingTripCommandAsync().ContinueWith(async(task) => { // If we don't have permission from the user, prompt a dialog requesting permission. await PromptPermissionsChangeDialog(); }); if (!CurrentTripViewModel.Geolocator.IsGeolocationEnabled) { tripMapView.Camera.CenterCoordinate = new CLLocationCoordinate2D(47.6204, -122.3491); tripMapView.Camera.Altitude = 5000; } } }
void OnLocationServiceConnected(object sender, ServiceConnectedEventArgs e) { viewModel = GeolocationHelper.Current.LocationService.ViewModel; viewModel.PropertyChanged += OnPropertyChanged; ResetTrip(); }