public override void ViewDidLoad()
        {
            base.ViewDidLoad();


            // set data model
            dataModel = SetDataModel();

            btnGo.SetTitle(NSBundle.MainBundle.LocalizedString("Vernacular_P0_dialog_accept", null).ToUpper(), UIControlState.Normal);
            btnGo.SetTitleColor(StyleSettings.TextOnDarkColor(), UIControlState.Normal);
            btnGo.BackgroundColor = StyleSettings.ThemePrimaryColor();

            // Set pickerview data model
            TypePickerViewModel model = new TypePickerViewModel();

            pickerView.Model = model;
            model.dataModel  = this.dataModel;
            pickerView.ShowSelectionIndicator = true;

            // set default selected row

            // btn handlers
            btnGo.TouchUpInside += (object sender, EventArgs e) => {
                var selected = SetSelectedType(pickerView.SelectedRowInComponent(0));
                this.DismissViewController(true, () => {
                    Settings.LastNumberOfPeople = selected;
                    parentVC.InitRecording();
                });
            };
        }
        private void SetUiState(bool completed)
        {
            String instructions = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_5_instructions", null).PrepareForLabel();
            String confirmation = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_5_confirmation", null).PrepareForLabel();

            new System.Threading.Thread(new System.Threading.ThreadStart(() => {
                InvokeOnMainThread(() => {
                    if (!completed)
                    {
                        Log.Debug("calibration has not completed");
                        lblBody2.Text        = instructions;
                        btnCalibrate.Hidden  = false;
                        btnCalibrate.Enabled = true;
                    }
                    else
                    {
                        Log.Debug("calibration has completed");
                        lblBody2.Text        = confirmation;
                        lblBody2.Font        = UIFont.BoldSystemFontOfSize(16.0f);
                        lblBody2.TextColor   = StyleSettings.LightGrayColor();
                        btnCalibrate.Hidden  = true;
                        btnCalibrate.Enabled = false;
                    }
                });
            })).Start();
        }
        public void UpdateCell(UserLog.LogEntry data)
        {
            this.BackgroundColor = StyleSettings.ThemePrimaryDarkLightenedColor();

            lblTime.Text      = data.Timestamp.ToString("T");
            lblTime.TextColor = StyleSettings.ThemePrimaryColor();

            lblText.Text      = data.Message;
            lblText.TextColor = StyleSettings.TextOnDarkColor();

            if (data.Icon != UserLog.Icon.None)
            {
                imgAlert.Hidden = false;
                switch (data.Icon)
                {
                case UserLog.Icon.Warning:
                    imgAlert.Image = UIImage.FromBundle("ic_warning_white");
                    break;

                case UserLog.Icon.Error:
                    imgAlert.Image = UIImage.FromBundle("ic_error_white");
                    break;

                default:
                    imgAlert.Image = UIImage.FromBundle("ic_error_white");
                    break;
                }
            }
            else
            {
                imgAlert.Hidden = true;
            }
        }
            public override UIView GetView(UIPickerView pickerView, nint row, nint component, UIView view)
            {
                UILabel lbl = new UILabel(new RectangleF(0, 0, 200f, 40f));

                lbl.TextColor     = StyleSettings.ThemePrimaryColor();
                lbl.TextAlignment = UITextAlignment.Center;
                lbl.Text          = GetTitle(pickerView, row, component);
                return(lbl);
            }
        public static UIColor GetTitleColor(this InformationMessage message)
        {
            switch (message)
            {
            case InformationMessage.UploadFailure:
            case InformationMessage.InternalEngineError:
                return(StyleSettings.ErrorColor());

            default:
                return(StyleSettings.ThemePrimaryColor());
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.
            // Set Nav Bar Style
            this.NavigationBar.BarStyle        = UIBarStyle.BlackOpaque;
            this.NavigationBar.BarTintColor    = StyleSettings.ThemePrimaryColor();
            this.NavigationBar.TintColor       = UIColor.White;
            this.NavigationBar.BackgroundColor = StyleSettings.ThemePrimaryColor();
            this.NavigationBar.Opaque          = true;
            this.NavigationBar.Translucent     = false;
        }
 /// <summary>
 /// Instantaneously updates the measurements display.
 /// Assumes the ViewModel is available.
 /// </summary>
 private void UpdateMeasurementsDisplay()
 {
     if (RVM.IsReporting)
     {
         lblCenter.Text = string.Format(MeasurementFormat, RVM.CurrentPpe);
         double range = RVM.MaximumPpe - RVM.MinimumPpe;
         double perc  = (RVM.CurrentPpe - RVM.MinimumPpe) / range;
         lblCenter.TextColor = StyleSettings.InterpolateTextColor(StyleSettings.QualityGoodColor(), StyleSettings.QualityBadColor(), (float)perc);
     }
     else
     {
         Log.Debug("RVM is not reporting");
         lblCenter.Text      = NSBundle.MainBundle.LocalizedString("Vernacular_P0_unknown_ppe_value", null);
         lblCenter.TextColor = StyleSettings.TextOnBrightColor();
     }
 }
Beispiel #8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Set Localized Strings
            String title = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_1_title", null).PrepareForLabel();

            lblTitle.Text = title;

            String body = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_1_text_1", null).PrepareForLabel();

            lblBody.Text = body;

            // Set UI elements
            View.BackgroundColor = StyleSettings.ThemePrimaryDarkLightenedColor();
            lblTitle.TextColor   = StyleSettings.ThemePrimaryColor();
            lblBody.TextColor    = StyleSettings.TextOnDarkColor();
        }
Beispiel #9
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            storyboard = UIStoryboard.FromName("MainStoryboard", null);

            // Perform any additional setup after loading the view, typically from a nib.
            MenuTableSource          = new MenuTableSource(tableView, this);
            tableView.Source         = MenuTableSource;
            tableView.SeparatorColor = StyleSettings.ThemePrimaryDarkLightenedColor();

            UIView view = new UIView(new CGRect(0, 0, 1, 1));

            tableView.TableFooterView = view;

            lblTitle.Text = _appName;
        }
Beispiel #10
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            // Set Localized Strings
            String title = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_6_title", null).PrepareForLabel();

            lblTitle.Text = title;

            String body1 = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_6_text", null).PrepareForLabel();

            lblText.Text = body1;

            // Set UI elements
            View.BackgroundColor = StyleSettings.ThemePrimaryDarkLightenedColor();
            lblTitle.TextColor   = StyleSettings.ThemePrimaryColor();
            lblText.TextColor    = StyleSettings.TextOnDarkColor();
        }
        private UIButton SetSupportButton(UIButton btn)
        {
            btn.ClipsToBounds = true;
            btn.ContentMode   = UIViewContentMode.ScaleAspectFit;

            // Anchorage type
            if (Settings.LastAnchorageType == AnchorageType.MobileBracket)
            {
                btn.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_bracket", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
            }
            else if (Settings.LastAnchorageType == AnchorageType.MobileMat)
            {
                btn.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_mat", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
            }
            else if (Settings.LastAnchorageType == AnchorageType.Pocket)
            {
                btn.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_pocket", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
            }
            return(btn);
        }
        public void UpdateCell(UploadQueueViewModel.UploadQueueItem data)
        {
            this.BackgroundColor = StyleSettings.ThemePrimaryDarkLightenedColor();

            lblFileName.Text      = data.Filename;
            lblFileName.TextColor = StyleSettings.TextOnDarkColor();

            lblRecorded.Text      = NSBundle.MainBundle.LocalizedString("Vernacular_P0_label_file_creation", null).PrepareForLabel();
            lblRecorded.TextColor = StyleSettings.SubtleTextOnBrightColor();

            lblDate.Text      = data.Created.ToString("ddd dd MMMMM yyyy hh:mm");
            lblDate.TextColor = StyleSettings.TextOnDarkColor();

            lblSize.Text      = NSBundle.MainBundle.LocalizedString("Vernacular_P0_label_file_size", null).PrepareForLabel();
            lblSize.TextColor = StyleSettings.SubtleTextOnBrightColor();

            int ksize = (int)Math.Ceiling(data.FileSize / 1024.0);

            lblSizeData.Text      = string.Format(NSBundle.MainBundle.LocalizedString("Vernacular_P0_label_file_size_value", null).PrepareForLabel(), ksize);
            lblSizeData.TextColor = StyleSettings.TextOnDarkColor();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            String weekText = NSBundle.MainBundle.LocalizedString("Vernacular_P0_stats_week_label", null).PrepareForLabel();

            lblWeekText.Text      = weekText;
            lblWeekText.TextColor = StyleSettings.TextOnDarkColor();

            String overallText = NSBundle.MainBundle.LocalizedString("Vernacular_P0_stats_overall_label", null).PrepareForLabel();

            lblOverallText.Text      = overallText;
            lblOverallText.TextColor = StyleSettings.TextOnDarkColor();

            String lastTrackText = NSBundle.MainBundle.LocalizedString("Vernacular_P0_stats_last_track_label", null).PrepareForLabel();

            lblLastTrackText.Text      = lastTrackText;
            lblLastTrackText.TextColor = StyleSettings.TextOnDarkColor();

            try
            {
                using (var conn = DatabaseUtility.OpenConnection())
                {
                    var week    = StatisticHelper.GetPeriodSummary(conn, StatisticPeriod.Week);
                    var overall = StatisticHelper.GetPeriodSummary(conn, StatisticPeriod.Overall);
                    var last    = StatisticHelper.GetLastTrack(conn);

                    UpdateKmCounter(lblLastTrack, last?.DistanceTraveled);
                    UpdateKmCounter(lblWeek, week.Distance);
                    UpdateKmCounter(lblOverall, overall.Distance);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Failed to load statistics");
            }

            // TODO: add share button
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Init navigation items
            UIBarButtonItem update = new UIBarButtonItem(
                UIBarButtonSystemItem.Refresh,
                (s, e) => {
                RefreshLog();
            }
                );

            UIBarButtonItem trash = new UIBarButtonItem(
                UIBarButtonSystemItem.Trash,
                (s, e) => {
                // Empty log
                UserLog.Clear();
                RefreshLog();
            }
                );

            // Add button to item array
            barButtonItems[0] = update;
            barButtonItems[1] = trash;

            // add navigation items to navigation bar
            NavigationItem.RightBarButtonItems = barButtonItems;

            // set data handler
            UserLog.NewEntryAdded += HandleUserLogNewEntry;

            // Perform any additional setup after loading the view, typically from a nib.
            tableView.SeparatorColor = StyleSettings.SubtleTextOnDarkColor();
            //tableView.SetContentOffset (new CGPoint(0, float.MaxValue), false);
            UIView view = new UIView(new CGRect(0, 0, 1, 1));

            tableView.TableFooterView = view;

            RefreshLog();
        }
        private UIButton SetVehicleButton(UIButton btn)
        {
            // Set button backgrounds
            btn.ClipsToBounds = true;
            btn.ContentMode   = UIViewContentMode.ScaleAspectFit;

            // Vehicle type
            if (Settings.LastVehicleType == VehicleType.Motorcycle)
            {
                btn.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_motorcycle", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
            }
            else if (Settings.LastVehicleType == VehicleType.Car)
            {
                btn.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_car", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
            }
            else if (Settings.LastVehicleType == VehicleType.Truck)
            {
                btn.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_bus", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
            }

            return(btn);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Set Localized Strings
            String title = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_5_title", null).PrepareForLabel();

            lblTitle.Text = title;

            String body1 = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_5_explanation", null).PrepareForLabel();

            lblBody1.Text = body1;

            String btn = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_5_calibrate", null).ToUpper().PrepareForLabel();

            btnCalibrate.SetTitle(btn, UIControlState.Normal);

            // Set UI elements
            View.BackgroundColor = StyleSettings.ThemePrimaryDarkLightenedColor();
            lblTitle.TextColor   = StyleSettings.ThemePrimaryColor();
            lblBody1.TextColor   = StyleSettings.TextOnDarkColor();
            lblBody2.TextColor   = StyleSettings.TextOnDarkColor();
            btnCalibrate.SetTitleColor(StyleSettings.TextOnDarkColor(), UIControlState.Normal);
            btnCalibrate.BackgroundColor    = StyleSettings.ThemePrimaryColor();
            btnCalibrate.Layer.CornerRadius = 5;

            // Init calibrator
            _calibrator = Calibrator.Create();

            btnCalibrate.TouchUpInside += (object sender, EventArgs e) => {
                if (_calibrating)
                {
                    return;
                }
                _calibrating = true;
                Calibrate();
            };
        }
Beispiel #17
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            lblTitle.Text      = NSBundle.MainBundle.LocalizedString("Vernacular_P0_dialog_blablacar_title", null);
            lblTitle.TextColor = StyleSettings.TextOnDarkColor();

            lblBody1.Text      = NSBundle.MainBundle.LocalizedString("Vernacular_P0_dialog_blablacar_description", null).PrepareForLabel();
            lblBody1.TextColor = StyleSettings.TextOnDarkColor();

            lblBody2.Text      = "";
            lblBody2.TextColor = StyleSettings.TextOnDarkColor();

            lblBody3.Text      = NSBundle.MainBundle.LocalizedString("Vernacular_P0_dialog_blablacar_action_hint", null);
            lblBody3.TextColor = StyleSettings.TextOnDarkColor();

            btnContinue.SetTitle(NSBundle.MainBundle.LocalizedString("Vernacular_P0_dialog_blablacar_ignore", null).ToUpper(), UIControlState.Normal);
            btnContinue.SetTitleColor(StyleSettings.TextOnDarkColor(), UIControlState.Normal);
            btnContinue.BackgroundColor = StyleSettings.ThemePrimaryColor();

            btnBlaBla.BackgroundColor = StyleSettings.LightGrayPressedColor();

            btnBlaBla.TouchUpInside += (sender, e) => {
                // Open app if available, else website
                this.DismissViewController(true, () =>
                {
                    OpenBlaBlaCar();
                    parentVC.StartRecordingCommands();
                });
            };

            btnContinue.TouchUpInside += (sender, e) => {
                // Start registration
                this.DismissViewController(true, parentVC.StartRecordingCommands);
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // set UI
            backgroundView.Layer.CornerRadius = 10;
            backgroundView.Layer.BorderColor  = StyleSettings.LightGrayColor().CGColor;
            backgroundView.Layer.BorderWidth  = 1;
            horView.Layer.BackgroundColor     = StyleSettings.LightGrayColor().CGColor;
            vertView.Layer.BackgroundColor    = StyleSettings.LightGrayColor().CGColor;
            btnOk.SetTitle(NSBundle.MainBundle.LocalizedString("Vernacular_P0_dialog_accept", null), UIControlState.Normal);
            btnCancel.SetTitle(NSBundle.MainBundle.LocalizedString("Vernacular_P0_dialog_cancel", null), UIControlState.Normal);

            // set data model
            dataModel = SetDataModel(pickerType);

            // Set pickerview data model
            TypePickerViewModel model = new TypePickerViewModel();

            pickerView.Model = model;
            model.dataModel  = this.dataModel;
            pickerView.ShowSelectionIndicator = true;

            // set default selected row

            // btn handlers
            btnOk.TouchUpInside += (object sender, EventArgs e) => {
                SetSelectedType(pickerView.SelectedRowInComponent(0), this.pickerType);
                this.DismissViewController(true, () => {
                    SettingsVC.SetButtonTexts();
                });
            };

            btnCancel.TouchUpInside += (object sender, EventArgs e) => {
                this.DismissViewController(true, null);
            };
        }
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     View.BackgroundColor = StyleSettings.ThemePrimaryDarkLightenedColor();
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Set Localized Strings
            String title = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_7_title", null).PrepareForLabel();

            lblTitle.Text = title;

            String body1 = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_7_text_1", null).PrepareForLabel();

            lblBody1.Text = body1;

            String body2 = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_7_text_2", null).PrepareForLabel();

            lblBody2.Text = body2;

            String btn = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_done", null).ToUpper().PrepareForLabel();

            btnGo.SetTitle(btn, UIControlState.Normal);

            String calibrationLabel = NSBundle.MainBundle.LocalizedString("Vernacular_P0_calibration_not_done", null);

            lblCalibration.Text   = calibrationLabel;
            lblCalibration.Hidden = false;

            // Set UI elements
            View.BackgroundColor     = StyleSettings.ThemePrimaryDarkLightenedColor();
            lblTitle.TextColor       = StyleSettings.ThemePrimaryColor();
            lblBody1.TextColor       = StyleSettings.TextOnDarkColor();
            lblBody2.TextColor       = StyleSettings.TextOnDarkColor();
            lblCalibration.TextColor = StyleSettings.LightGrayColor();
            btnGo.SetTitleColor(StyleSettings.TextOnDarkColor(), UIControlState.Normal);
            btnGo.Layer.CornerRadius = 5;
#if DEBUG
            btnGo.Enabled = true;
#else
            btnGo.Enabled = false;
#endif
            btnGo.BackgroundColor = StyleSettings.LightGrayColor();

            if (Settings.CalibrationDone)
            {
                btnGo.Enabled         = true;
                btnGo.BackgroundColor = StyleSettings.ThemePrimaryColor();
                lblCalibration.Hidden = true;
            }

            btnGo.TouchUpInside += (object sender, EventArgs e) => {
                if (NSUserDefaults.StandardUserDefaults.BoolForKey(PreferencesSettings.FirstLaunchKey))
                {
                    IntroVC.DismissViewController(true, null);
                }
                else
                {
                    NSUserDefaults.StandardUserDefaults.SetBool(true, PreferencesSettings.FirstLaunchKey);
                    var window = UIApplication.SharedApplication.KeyWindow;
                    window.RootViewController = new RootViewController();
                }
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Set Localized Strings
            String title = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_4_title", null).PrepareForLabel();

            lblTitle.Text = title;

            String body1 = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_4_question", null).PrepareForLabel();

            lblBody1.Text = body1;

            String matString   = NSBundle.MainBundle.LocalizedString("Vernacular_P0_anchorage_mat", null).PrepareForLabel();
            String staffString = NSBundle.MainBundle.LocalizedString("Vernacular_P0_anchorage_bracket", null).PrepareForLabel();
            String otherString = NSBundle.MainBundle.LocalizedString("Vernacular_P0_anchorage_pocket", null).PrepareForLabel();

            lblBody2.Text = staffString;

            String bottom = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_bottom_question_notice", null).PrepareForLabel();

            lblBottom.Text = bottom;

            // Set UI elements
            View.BackgroundColor = StyleSettings.ThemePrimaryDarkLightenedColor();
            lblTitle.TextColor   = StyleSettings.ThemePrimaryColor();
            lblBody1.TextColor   = StyleSettings.TextOnDarkColor();
            lblBody2.TextColor   = StyleSettings.ThemePrimaryColor();
            lblBottom.TextColor  = StyleSettings.SubduedTextOnDarkColor();
            btnMat.SetTitle("", UIControlState.Normal);
            btnStaff.SetTitle("", UIControlState.Normal);
            btnOther.SetTitle("", UIControlState.Normal);

            // Set button backgrounds
            btnStaff.ClipsToBounds = true;
            btnStaff.ContentMode   = UIViewContentMode.ScaleAspectFit;
            btnStaff.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_bracket", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
            btnMat.ClipsToBounds = true;
            btnMat.ContentMode   = UIViewContentMode.ScaleAspectFit;
            btnMat.SetBackgroundImage(UIImage.FromBundle("icon_mat"), UIControlState.Normal);
            btnOther.ClipsToBounds = true;
            btnOther.ContentMode   = UIViewContentMode.ScaleAspectFit;
            btnOther.SetBackgroundImage(UIImage.FromBundle("icon_pocket"), UIControlState.Normal);

            // Button handlers

            // car button
            btnMat.TouchUpInside += delegate {
                btnMat.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_mat", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
                btnStaff.SetBackgroundImage(UIImage.FromBundle("icon_bracket"), UIControlState.Normal);
                btnOther.SetBackgroundImage(UIImage.FromBundle("icon_pocket"), UIControlState.Normal);

                lblBody2.Text = matString;
                selectAnchorage(AnchorageType.MobileMat);
            };

            // motorcycle button
            btnStaff.TouchUpInside += delegate {
                btnStaff.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_bracket", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
                btnMat.SetBackgroundImage(UIImage.FromBundle("icon_mat"), UIControlState.Normal);
                btnOther.SetBackgroundImage(UIImage.FromBundle("icon_pocket"), UIControlState.Normal);

                lblBody2.Text = staffString;
                selectAnchorage(AnchorageType.MobileBracket);
            };

            // truck button
            btnOther.TouchUpInside += delegate {
                btnOther.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_pocket", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
                btnStaff.SetBackgroundImage(UIImage.FromBundle("icon_bracket"), UIControlState.Normal);
                btnMat.SetBackgroundImage(UIImage.FromBundle("icon_mat"), UIControlState.Normal);

                lblBody2.Text = otherString;
                selectAnchorage(AnchorageType.Pocket);
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var storyboard = UIStoryboard.FromName("MainStoryboard", null);

            // Set texts
            lblOffline.Text     = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_title_offline_mode", null);
            lblOfflineText.Text = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_description_offline_mode", null);

            lblPosition.Text            = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_title_anchorage", null);
            lblPositionDescription.Text = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_description_anchorage", null);

            lblRecording.Text = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_section_setup", null).ToUpper();

            lblUseWifi.Text     = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_title_prefer_unmetered", null);
            lblUseWifiText.Text = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_description_prefer_unmetered", null);

            lblVehicle.Text            = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_title_vehicle", null);
            lblVehicleDescription.Text = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_description_vehicle", null);

            lblCalibration.Text = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_section_calibration", null).ToUpper();
            btnCalibrate.SetTitle(NSBundle.MainBundle.LocalizedString("Vernacular_P0_calibration_forget", null), UIControlState.Normal);

            lblIntroduction.Text = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_section_introduction", null).ToUpper();
            btnIntro.SetTitle(NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_redo", null), UIControlState.Normal);

            lblPreferences.Text = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_section_preferences", null).ToUpper();

            lblDisableSuspention.Text      = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_title_disable_suspension", null);
            _lblDisableSuspentionText.Text = NSBundle.MainBundle.LocalizedString("Vernacular_P0_settings_description_disable_suspension", null);

            SetButtonTexts();

            RefreshCalibrationInfo();

            // Set text colors
            lblPreferences.TextColor  = StyleSettings.ThemePrimaryColor();
            lblRecording.TextColor    = StyleSettings.ThemePrimaryColor();
            lblCalibration.TextColor  = StyleSettings.ThemePrimaryColor();
            lblIntroduction.TextColor = StyleSettings.ThemePrimaryColor();
            btnIntro.SetTitleColor(StyleSettings.TextOnDarkColor(), UIControlState.Normal);
            btnIntro.BackgroundColor    = StyleSettings.ThemePrimaryColor();
            btnIntro.Layer.CornerRadius = 5;
            btnCalibrate.SetTitleColor(StyleSettings.TextOnDarkColor(), UIControlState.Normal);
            btnCalibrate.BackgroundColor    = StyleSettings.ThemePrimaryColor();
            btnCalibrate.Layer.CornerRadius = 5;

            // Set button image size
            btnPosition.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
            btnVehicle.ImageView.ContentMode  = UIViewContentMode.ScaleAspectFit;

            // Set switch status
            switchWifi.On       = NSUserDefaults.StandardUserDefaults.BoolForKey(_stringPreferUnmeteredConnection);
            switchOffline.On    = NSUserDefaults.StandardUserDefaults.BoolForKey(_stringOfflineMode);
            switchSuspention.On = NSUserDefaults.StandardUserDefaults.BoolForKey(_stringSuspention);

            // Init calibrator
            _calibrator = Calibrator.Create();

            // Set wifi mode
            switchWifi.ValueChanged += (object sender, EventArgs e) => {
                if (switchWifi.On)
                {
                    Settings.PreferUnmeteredConnection = true;
                    NSUserDefaults.StandardUserDefaults.SetBool(true, _stringPreferUnmeteredConnection);
                }
                else
                {
                    Settings.PreferUnmeteredConnection = false;
                    NSUserDefaults.StandardUserDefaults.SetBool(false, _stringPreferUnmeteredConnection);
                }
            };

            // Set offline mode
            switchOffline.ValueChanged += (object sender, EventArgs e) => {
                if (switchOffline.On)
                {
                    Settings.OfflineMode = true;
                    NSUserDefaults.StandardUserDefaults.SetBool(true, _stringOfflineMode);
                }
                else
                {
                    Settings.OfflineMode = false;
                    NSUserDefaults.StandardUserDefaults.SetBool(false, _stringOfflineMode);
                }
            };

            // Set suspension status
            switchSuspention.ValueChanged += (object sender, EventArgs e) => {
                if (switchSuspention.On)
                {
                    Settings.SuspensionDisabled = true;
                    NSUserDefaults.StandardUserDefaults.SetBool(true, _stringSuspention);
                }
                else
                {
                    Settings.SuspensionDisabled = false;
                    NSUserDefaults.StandardUserDefaults.SetBool(false, _stringSuspention);
                }
            };

            // change vehicle type
            btnVehicle.TouchUpInside += (object sender, EventArgs e) => {
                var SelectVehicleVC = storyboard.InstantiateViewController("CustomPickerViewController") as CustomPickerViewController;
                SelectVehicleVC.pickerType             = PreferencesSettings.VehicleTypePicker;
                SelectVehicleVC.SettingsVC             = this;
                SelectVehicleVC.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
                SelectVehicleVC.ModalTransitionStyle   = UIModalTransitionStyle.CoverVertical;
                this.PresentViewController(SelectVehicleVC, true, null);
            };

            // change anchorage type
            btnPosition.TouchUpInside += (object sender, EventArgs e) => {
                var SelectAnchorageVC = storyboard.InstantiateViewController("CustomPickerViewController") as CustomPickerViewController;
                SelectAnchorageVC.pickerType             = PreferencesSettings.AnchorageTypePicker;
                SelectAnchorageVC.SettingsVC             = this;
                SelectAnchorageVC.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
                SelectAnchorageVC.ModalTransitionStyle   = UIModalTransitionStyle.CoverVertical;
                this.PresentViewController(SelectAnchorageVC, true, null);
            };

            // Show intro
            btnIntro.TouchUpInside += (object sender, EventArgs e) => {
                IntroductionPageViewController introductionVC = storyboard.InstantiateViewController("IntroductionPageViewController") as IntroductionPageViewController;
                this.NavigationController.PresentViewController(introductionVC, true, null);
            };

            // Re-calibrate
            btnCalibrate.TouchUpInside += (object sender, EventArgs e) => {
                if (_calibrating)
                {
                    return;
                }
                else
                {
                    _calibrating = true;
                    ReCalibrate();
                }
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Initialize Recorder
            RVM = new RecordingViewModel();

            // Perform any additional setup after loading the view, typically from a nib.
            // Init audio session
            AudioSession.Initialize(null, NSRunLoop.NSDefaultRunLoopMode);
            AudioSession.AudioRouteChanged += AudioSession_AudioRouteChanged;

            // Init call event handler
            callcenter.CallEventHandler += callState.CallEvent;

            // Set menu button
            UIImageView menuImageView = new UIImageView();

            menuImageView.Bounds = new CGRect(0, 0, 20, 20);
            menuImageView.Image  = UIImage.FromBundle("threelines");

            menuButton = new UIBarButtonItem(
                menuImageView.Image,
                UIBarButtonItemStyle.Plain,
                (s, e) => {
                System.Diagnostics.Debug.WriteLine("menu button tapped");
                if (RVM.IsRecording)
                {
                    SidebarController.ToggleMenu();
                    var okAlertController = UIAlertController.Create("", UiStrings.MainNotificationSuspendUserAction, UIAlertControllerStyle.Alert);
                    //Add Action
                    okAlertController.AddAction(UIAlertAction.Create(NSBundle.MainBundle.GetLocalizedString("Vernacular_P0_dialog_ok"), UIAlertActionStyle.Default, alert => {
                        RVM.StopRecordingCommand.Execute(null);
                    }));

                    PresentViewController(okAlertController, true, null);
                }
                else
                {
                    SidebarController.ToggleMenu();
                }
            }
                );

            // Add button to item array
            barButtonItems [0] = menuButton;
            NavigationItem.LeftBarButtonItem = menuButton;

            // Set bottom view labels
            lblTitle.Text = "";
            lblBody.Text  = "";

            // Set start button style
            btnStart.SetBackgroundImage(UIImage.FromBundle("CarButton"), UIControlState.Normal);
            View.BackgroundColor = StyleSettings.ThemePrimaryDarkLightenedColor();
            btnStart.SetTitle("", UIControlState.Normal);

            // Add square to stop || TODO: change to image
            UIView stopSquare = new UIView(new RectangleF(
                                               (float)(btnStop.Bounds.X + 15),
                                               (float)(btnStop.Bounds.Y + 15),
                                               (float)(btnStop.Bounds.Width - 30),
                                               (float)(btnStop.Bounds.Height - 30))
                                           );

            // Set stop button attributes
            stopButtonTranslation      = btnStopBottomConstraint.Constant;
            stopSquare.BackgroundColor = UIColor.White;
            btnStop.SetBackgroundImage(UIImage.FromBundle("srs-stop-btn"), UIControlState.Normal);
            btnStop.Layer.CornerRadius = btnStop.Bounds.Width / 2;

            lblLeft.Hidden   = true;
            lblCenter.Hidden = true;
            lblRight.Hidden  = true;

            // Set initial status of vehicle type & support
            btnSupport.Hidden        = true;
            btnVehicle.Hidden        = true;
            lblCalibration.Hidden    = true;
            lblCalibration.Text      = NSBundle.MainBundle.LocalizedString("Vernacular_P0_label_setup", null);
            lblCalibration.TextColor = StyleSettings.SubduedTextOnDarkColor();

            // Logic
            btnStart.TouchUpInside += (object sender, EventArgs e) => {
                if (Settings.CalibrationDone)
                {
                    if (RVM.IsRecording)
                    {
                        return;
                    }

                    var passengerNumberPickerVC = Storyboard.InstantiateViewController("PassengerNumberPickerViewController") as PassengerNumberPickerViewController;
                    passengerNumberPickerVC.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
                    passengerNumberPickerVC.ModalTransitionStyle   = UIModalTransitionStyle.CoverVertical;
                    passengerNumberPickerVC.parentVC = this;
                    NavigationController.PresentViewController(passengerNumberPickerVC, true, null);
                }
                else
                {
                    // TODO: warn user that calibration has to be done
                }
            };

            btnStop.TouchUpInside += (object sender, EventArgs e) => {
                UnbindFromService();
                AnimateStopButton();
                RVM.OnDestroy();
                StopRecording();
                UpdateRecordButtonUi();
                UploadData();
                lblCenter.Hidden = true;
            };

            btnVehicle.TouchUpInside += (object sender, EventArgs e) => {
                OpenSettingsVC();
            };

            btnSupport.TouchUpInside += (object sender, EventArgs e) => {
                OpenSettingsVC();
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Localized texts
            String title = NSBundle.MainBundle.LocalizedString("Vernacular_P0_app_name", null).PrepareForLabel();

            lblTitle.Text      = title;
            lblTitle.TextColor = StyleSettings.TextOnDarkColor();

            lblVersion.Text      = String.Format("{0}.{1}", App.Version.Major, App.Version.Minor);
            lblVersion.TextColor = StyleSettings.ThemePrimaryColor();

            String developed = NSBundle.MainBundle.LocalizedString("Vernacular_P0_about_developed_by", null).ToUpper().PrepareForLabel();

            lblDeveloped.Text      = developed;
            lblDeveloped.TextColor = StyleSettings.ThemePrimaryColor();

            String developedWithC4rs = NSBundle.MainBundle.LocalizedString("Vernacular_P0_about_c4rs", null).PrepareForLabel();

            lblDevelopedWith.Text      = developedWithC4rs;
            lblDevelopedWith.TextColor = StyleSettings.TextOnDarkColor();

            String university = NSBundle.MainBundle.LocalizedString("Vernacular_P0_about_author", null).PrepareForLabel();

            lblUniversity.Text      = university;
            lblUniversity.TextColor = StyleSettings.TextOnDarkColor();

            String collaborators = NSBundle.MainBundle.LocalizedString("Vernacular_P0_about_contributors", null).ToUpper().PrepareForLabel();

            lblCollaborators.Text      = collaborators;
            lblCollaborators.TextColor = StyleSettings.ThemePrimaryColor();

            String collaboratorList = NSBundle.MainBundle.LocalizedString("Vernacular_P0_about_authors", null).PrepareForLabel();

            lblCollaboratorList.Text      = collaboratorList;
            lblCollaboratorList.TextColor = StyleSettings.TextOnDarkColor();

            String design = NSBundle.MainBundle.LocalizedString("Vernacular_P0_about_icon_design", null).ToUpper().PrepareForLabel();

            lblDesign.Text      = design;
            lblDesign.TextColor = StyleSettings.ThemePrimaryColor();

            String designInfo = NSBundle.MainBundle.LocalizedString("Vernacular_P0_about_icon_design_text", null).PrepareForLabel();

            lblDesignInfo.Text      = designInfo;
            lblDesignInfo.TextColor = StyleSettings.TextOnDarkColor();

            String comments = NSBundle.MainBundle.LocalizedString("Vernacular_P0_about_feedback", null).ToUpper().PrepareForLabel();

            lblComments.Text      = comments;
            lblComments.TextColor = StyleSettings.ThemePrimaryColor();

            String email = NSBundle.MainBundle.LocalizedString("Vernacular_P0_mail_address", null).PrepareForLabel();

            btnEmail.SetTitle(email, UIControlState.Normal);
            btnEmail.SetTitleColor(StyleSettings.TextOnDarkColor(), UIControlState.Normal);

            lblAppInfo.Text      = App.ApplicationInformation + ".";
            lblAppInfo.TextColor = StyleSettings.SubtleTextOnDarkColor();

            btnEmail.TouchUpInside += (object sender, EventArgs e) => {
                // Send Email
                MFMailComposeViewController mailController;

                if (MFMailComposeViewController.CanSendMail)
                {
                    Log.Debug("opening mail controller");
                    // Set mail composer
                    mailController = new MFMailComposeViewController();

                    // populate email
                    mailController.SetToRecipients(new string[] { NSBundle.MainBundle.LocalizedString("Vernacular_P0_mail_address", null) });
                    mailController.SetSubject(NSBundle.MainBundle.LocalizedString("Vernacular_P0_app_name", null));

                    // activate send button
                    mailController.Finished += (object s, MFComposeResultEventArgs args) => {
                        Console.WriteLine(args.Result.ToString());
                        args.Controller.DismissViewController(true, null);
                    };

                    // present view controller
                    this.PresentViewController(mailController, true, null);
                }
                else
                {
                    Log.Debug("failed opening mail controller");

                    String errorTitle = NSBundle.MainBundle.LocalizedString("Vernacular_P0_information_message_title_engine_error", null).PrepareForLabel();
                    String errorBody  = NSBundle.MainBundle.LocalizedString("Vernacular_P0_error_send_mail_not_configured", null).PrepareForLabel();

                    //Create Alert
                    var errorAlertController = UIAlertController.Create(errorTitle, errorBody, UIAlertControllerStyle.Alert);

                    //Add Actions
                    errorAlertController.AddAction(UIAlertAction.Create(NSBundle.MainBundle.LocalizedString("Vernacular_P0_dialog_ok", null), UIAlertActionStyle.Default, null));

                    //Present Alert
                    PresentViewController(errorAlertController, true, null);
                }
            };
        }
Beispiel #25
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Set Localized Strings
            String title = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_3_title", null).PrepareForLabel();

            lblTitle.Text = title;

            String body1 = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_3_question", null).PrepareForLabel();

            lblBody1.Text = body1;

            String motorcycleString = NSBundle.MainBundle.LocalizedString("Vernacular_P0_vehicle_motorcycle", null).PrepareForLabel();
            String carString        = NSBundle.MainBundle.LocalizedString("Vernacular_P0_vehicle_car", null).PrepareForLabel();
            String truckString      = NSBundle.MainBundle.LocalizedString("Vernacular_P0_vehicle_truck", null).PrepareForLabel();

            lblBody2.Text = carString;

            String bottom = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_bottom_question_notice", null).PrepareForLabel();

            lblBottom.Text = bottom;

            // Set UI String elements
            View.BackgroundColor = StyleSettings.ThemePrimaryDarkLightenedColor();
            lblTitle.TextColor   = StyleSettings.ThemePrimaryColor();
            lblBody1.TextColor   = StyleSettings.TextOnDarkColor();
            lblBody2.TextColor   = StyleSettings.ThemePrimaryColor();
            lblBottom.TextColor  = StyleSettings.SubduedTextOnDarkColor();
            btnCar.SetTitle("", UIControlState.Normal);
            btnMotorcycle.SetTitle("", UIControlState.Normal);
            btnTruck.SetTitle("", UIControlState.Normal);

            // Set button backgrounds
            btnMotorcycle.ClipsToBounds = true;
            btnMotorcycle.ContentMode   = UIViewContentMode.ScaleAspectFit;
            btnMotorcycle.SetBackgroundImage(UIImage.FromBundle("icon_motorcycle"), UIControlState.Normal);
            btnCar.ClipsToBounds = true;
            btnCar.ContentMode   = UIViewContentMode.ScaleAspectFit;
            btnCar.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_car", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
            btnTruck.ClipsToBounds = true;
            btnTruck.ContentMode   = UIViewContentMode.ScaleAspectFit;
            btnTruck.SetBackgroundImage(UIImage.FromBundle("icon_bus"), UIControlState.Normal);

            // Button handlers

            // car button
            btnCar.TouchUpInside += delegate {
                btnCar.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_car", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
                btnMotorcycle.SetBackgroundImage(UIImage.FromBundle("icon_motorcycle"), UIControlState.Normal);
                btnTruck.SetBackgroundImage(UIImage.FromBundle("icon_bus"), UIControlState.Normal);

                lblBody2.Text = carString;
                selectVehicle(VehicleType.Car);
            };

            // motorcycle button
            btnMotorcycle.TouchUpInside += delegate {
                btnMotorcycle.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_motorcycle", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
                btnCar.SetBackgroundImage(UIImage.FromBundle("icon_car"), UIControlState.Normal);
                btnTruck.SetBackgroundImage(UIImage.FromBundle("icon_bus"), UIControlState.Normal);

                lblBody2.Text = motorcycleString;
                selectVehicle(VehicleType.Motorcycle);
            };

            // truck button
            btnTruck.TouchUpInside += delegate {
                btnTruck.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_bus", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
                btnMotorcycle.SetBackgroundImage(UIImage.FromBundle("icon_motorcycle"), UIControlState.Normal);
                btnCar.SetBackgroundImage(UIImage.FromBundle("icon_car"), UIControlState.Normal);

                lblBody2.Text = truckString;
                selectVehicle(VehicleType.Truck);
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            UIBarButtonItem trash = new UIBarButtonItem(
                UIBarButtonSystemItem.Trash,
                (s, e) => {
                //Create Alert
                var title = NSBundle.MainBundle.LocalizedString("Vernacular_P0_title_queue", null).PrepareForLabel();
                var body  = NSBundle.MainBundle.LocalizedString("Vernacular_P0_dialog_queue_clear_description", null).PrepareForLabel();
                var okCancelAlertController = UIAlertController.Create(title, body, UIAlertControllerStyle.Alert);

                //Add Actions
                var okString     = NSBundle.MainBundle.LocalizedString("Vernacular_P0_dialog_queue_clear_delete_all", null).PrepareForLabel();
                var cancelString = NSBundle.MainBundle.LocalizedString("Vernacular_P0_dialog_cancel", null).PrepareForLabel();

                okCancelAlertController.AddAction(UIAlertAction.Create(okString, UIAlertActionStyle.Default, alert => {
                    if (ViewModel != null)
                    {
                        ViewModel.ClearUploadQueueCommand.Execute(null);
                        RefreshList();
                    }
                }
                                                                       ));
                okCancelAlertController.AddAction(UIAlertAction.Create(cancelString, UIAlertActionStyle.Cancel, null));

                //Present Alert
                PresentViewController(okCancelAlertController, true, null);
            }
                );

            // Add button to item array
            barButtonItems[0] = trash;

            // add navigation items to navigation bar
            NavigationItem.RightBarButtonItems = barButtonItems;

            // Perform any additional setup after loading the view, typically from a nib.
            tableView.SeparatorColor = StyleSettings.SubtleTextOnDarkColor();
            UIView view = new UIView(new CGRect(0, 0, 1, 1));

            tableView.TableFooterView = view;

            String noData = NSBundle.MainBundle.LocalizedString("Vernacular_P0_status_no_files_in_queue", null).PrepareForLabel();

            lblNoData.Text = noData;

            String forceUpload = NSBundle.MainBundle.LocalizedString("Vernacular_P0_action_force_upload", null).PrepareForLabel().ToUpper();

            btnPushData.SetTitle(forceUpload, UIControlState.Normal);

            btnPushData.BackgroundColor = StyleSettings.ThemePrimaryColor();
            btnPushData.SetTitleColor(StyleSettings.TextOnDarkColor(), UIControlState.Normal);
            btnPushData.Layer.CornerRadius = 2;

            // Initialize data
            //View model setup
            ViewModel = new UploadQueueViewModel();
            ViewModel.OnCreate();

            ViewModel.UploadQueueUpdated += HandleUploadQueueUpdated;
            ViewModel.IsUploadingChanged += HandleIsUploadingChanged;

            ViewModel.RefreshQueueCommand.Execute(null);

            // Add table source
            tableSource      = new DataTableSource(this.tableView, this);
            tableSource.data = ViewModel;
            tableView.Source = tableSource;

            // handle force upload button click
            btnPushData.TouchUpInside += (object sender, EventArgs e) => {
                TryDataUpload();
            };

            ViewModel.IsUploadingChanged += (object sender, EventArgs e) => {
                if (ViewModel.IsUploading)
                {
                    btnPushData.Enabled = false;

                    // derive the center x and y
                    nfloat centerX = this.View.Frame.Width / 2;
                    nfloat centerY = this.View.Frame.Height / 2;

                    // create the activity spinner, center it horizontall and put it 5 points above center x
                    activitySpinner       = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge);
                    activitySpinner.Frame = new RectangleF(
                        (float)(centerX - (activitySpinner.Frame.Width / 2)),
                        (float)(centerY - activitySpinner.Frame.Height - 20),
                        (float)activitySpinner.Frame.Width,
                        (float)activitySpinner.Frame.Height);
                    activitySpinner.AutoresizingMask = UIViewAutoresizing.All;
                    this.View.AddSubview(activitySpinner);
                    activitySpinner.StartAnimating();
                }
                else
                {
                    btnPushData.Enabled = true;
                    activitySpinner.RemoveFromSuperview();
                }
            };
        }