/// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            //Do this to fix animation when navigating to screen
            assignmentViewModel.Assignments = null;

            if (!timerLoaded)
            {
                await assignmentViewModel.LoadTimerEntryAsync();

                await assignmentViewModel.LoadAssignmentsAsync();

                activeAssignment.Visibility = assignmentViewModel.ActiveAssignment != null ? Visibility.Visible : Visibility.Collapsed;
                timerLoaded = true;
            }
            else
            {
                await assignmentViewModel.LoadAssignmentsAsync();

                activeAssignment.Visibility = assignmentViewModel.ActiveAssignment != null ? Visibility.Visible : Visibility.Collapsed;
            }
            //toggle button state changed isn't being called unless is checked changes, this does not call the record button by setting this property
            //this was the only way at the moment to get the toggle button to have its recording state changed when navigating to and from this screen.
            record.IsChecked = !assignmentViewModel.Recording;
            record.IsChecked = assignmentViewModel.Recording;
        }
Beispiel #2
0
        public void LoadTimerEntry()
        {
            var task = viewModel.LoadTimerEntryAsync();

            task.Wait();

            Assert.That((int)viewModel.Hours.TotalHours, Is.EqualTo(1));
        }
Beispiel #3
0
        /// <summary>
        /// Set the active assignment at the top of the list.
        /// </summary>
        /// <param name="visible">boolean to set the layout visible or not</param>
        void SetActiveAssignmentVisible(bool visible)
        {
            if (!visible)
            {
                assignmentActiveLayout.Visibility = ViewStates.Gone;
                return;
            }

            assignmentActiveLayout.Visibility = ViewStates.Visible;
            assignment = assignmentViewModel.ActiveAssignment;

            buttonLayout.Visibility = ViewStates.Gone;
            timerLayout.Visibility  = ViewStates.Visible;

            var adapter = new SpinnerAdapter <AssignmentStatus> (assignmentViewModel.AvailableStatuses, this, Resource.Layout.SimpleSpinnerItem);

            adapter.TextColor     = Resources.GetColor(Resource.Color.greyspinnertext);
            adapter.Background    = Resources.GetColor(Resource.Color.assignmentblue);
            activeSpinner.Adapter = adapter;
            activeSpinner.SetSelection(assignmentViewModel.AvailableStatuses.ToList().IndexOf(assignment.Status));
            activeSpinner.SetBackgroundResource(Resource.Drawable.triangleblue);
            spinnerImage.SetImageResource(Resource.Drawable.EnrouteImage);

            number.Text    = assignment.Priority.ToString();
            job.Text       = string.Format("#{0} {1}\n{2}", assignment.JobNumber, assignment.StartDate.ToShortDateString(), assignment.CompanyName);
            name.Text      = assignment.ContactName;
            phone.Text     = assignment.ContactPhone;
            address.Text   = string.Format("{0}\n{1}, {2} {3}", assignment.Address, assignment.City, assignment.State, assignment.Zip);
            timerText.Text = assignmentViewModel.Hours.ToString(@"hh\:mm\:ss");

            assignmentViewModel.LoadTimerEntryAsync().ContinueWith(_ => {
                RunOnUiThread(() => {
                    timer.Checked = assignmentViewModel.Recording;
                });
            });
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create your application here
            SetContentView(Resource.Layout.MapViewLayout);

            assignmentMapViewLayout        = FindViewById <LinearLayout> (Resource.Id.mapViewAssignmentLayout);
            assignmentMapViewLayout.Click += (sender, e) => {
                var intent      = new Intent(this, typeof(SummaryActivity));
                var tabActivity = (AssignmentTabActivity)Parent;
                tabActivity.MapData = null;
                assignmentViewModel.SelectedAssignment = assignmentViewModel.ActiveAssignment;
                menuViewModel.MenuIndex = Constants.Navigation.IndexOf("Map");
                StartActivity(intent);
            };
//            mapView = FindViewById<MapView> (Resource.Id.googleMapsView);
//
//            myLocation = new MyLocationOverlay (this, mapView);
//
//            mapView.Overlays.Add (myLocation);
//            mapView.Clickable = true;
//            mapView.Enabled = true;
//            mapView.SetBuiltInZoomControls (true);


            //View containing the active assignment
            var            view     = new View(this);
            LayoutInflater inflator = (LayoutInflater)GetSystemService(Context.LayoutInflaterService);

            view = inflator.Inflate(Resource.Layout.AssignmentItemLayout, null);
            assignmentMapViewLayout.AddView(view);
            view.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
            view.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.active_assignment_selector));
            number        = view.FindViewById <TextView> (Resource.Id.assignmentItemNumber);
            job           = view.FindViewById <TextView> (Resource.Id.assignmentJob);
            name          = view.FindViewById <TextView> (Resource.Id.assignmentName);
            phone         = view.FindViewById <TextView> (Resource.Id.assignmentPhone);
            address       = view.FindViewById <TextView> (Resource.Id.assignmentAddress);
            buttonLayout  = view.FindViewById <LinearLayout> (Resource.Id.assignmentButtonLayout);
            timerLayout   = view.FindViewById <LinearLayout> (Resource.Id.assignmentTimerLayout);
            activeSpinner = view.FindViewById <Spinner> (Resource.Id.assignmentStatus);
            spinnerImage  = view.FindViewById <ImageView> (Resource.Id.assignmentStatusImage);
            timer         = view.FindViewById <ToggleButton> (Resource.Id.assignmentTimer);
            timerText     = view.FindViewById <TextView> (Resource.Id.assignmentTimerText);
            phoneButton   = view.FindViewById <RelativeLayout> (Resource.Id.assignmentPhoneLayout);
            mapButton     = view.FindViewById <RelativeLayout> (Resource.Id.assignmentAddressLayout);

            phoneButton.Click += (sender, e) => {
                Extensions.MakePhoneCall(this, phone.Text);
            };

            mapButton.Click += (sender, e) => {
                var intent      = new Intent(this, typeof(SummaryActivity));
                var tabActivity = (AssignmentTabActivity)Parent;
                tabActivity.MapData = null;
                assignmentViewModel.SelectedAssignment = assignmentViewModel.ActiveAssignment;
                menuViewModel.MenuIndex = 0;
                StartActivity(intent);
            };

            assignmentViewModel.LoadTimerEntryAsync().ContinueWith(_ => {
                RunOnUiThread(() => {
                    if (assignmentViewModel.Recording)
                    {
                        timer.Checked = true;
                    }
                    else
                    {
                        timer.Checked = false;
                    }
                });
            });

            timer.CheckedChange += (sender, e) => {
                if (e.IsChecked != assignmentViewModel.Recording)
                {
                    if (assignmentViewModel.Recording)
                    {
                        assignmentViewModel.PauseAsync();
                    }
                    else
                    {
                        assignmentViewModel.RecordAsync();
                    }
                }
            };

            activeSpinner.ItemSelected += (sender, e) => {
                if (assignment != null)
                {
                    var selected = assignmentViewModel.AvailableStatuses.ElementAtOrDefault(e.Position);
                    if (selected != assignment.Status)
                    {
                        switch (selected)
                        {
                        case AssignmentStatus.Hold:
                            assignment.Status = selected;
                            assignmentViewModel.SaveAssignmentAsync(assignment).ContinueWith(_ => {
                                RunOnUiThread(() => {
                                    SetAssignment(false);
//                                        mapView.Overlays.Clear ();
//                                        mapView.Overlays.Add (myLocation);
                                    UpdateLocations();
                                });
                            });
                            break;

                        case AssignmentStatus.Complete:
                            //go to confirmations
                            var intent = new Intent(this, typeof(SummaryActivity));
                            menuViewModel.MenuIndex = Constants.Navigation.IndexOf(Constants.Confirmations);
                            StartActivity(intent);
                            break;

                        default:
                            break;
                        }
                    }
                }
            };
        }