#pragma warning disable CS4014 public override async void ViewDidLoad() { base.ViewDidLoad(); // Sanity check for permissions - if we're here, it should be safe bool hasPerm = await AppUtils.AuthorizeCamera(); if (!hasPerm) { AppUtils.ShowSimpleDialog(this, "Requires Camera", "Please grant OurPlace camera access in the system settings to complete this task!", "Ok"); NavigationController.PopViewController(true); return; } if (thisTask == null) { AppUtils.ShowSimpleDialog(this, "ERROR", "Error loading task data", "Ok"); NavigationController.PopViewController(true); return; } folderName = Common.LocalData.Storage.GetCacheFolder(thisActivity.Id.ToString()); devices = new List <AVCaptureDevice>(discSession.Devices); SwapCameraButton.Enabled &= (devices != null && devices.Count != 0); if (thisTask.TaskType.IdName == "MATCH_PHOTO") { // Load target photo OverlayImageView.Alpha = 0.6f; string localRes = Common.LocalData.Storage.GetCacheFilePath( thisTask.JsonData, thisActivity.Id, ServerUtils.GetFileExtension(thisTask.TaskType.IdName)); ImageService.Instance.LoadFile(localRes).Into(OverlayImageView); } else if (thisTask.TaskType.IdName == "TAKE_VIDEO") { isMovie = true; ImageService.Instance.LoadCompiledResource("RecordButton").IntoAsync(ShutterButton); hasPerm = await AppUtils.AuthorizeMic(); if (!hasPerm) { AppUtils.ShowSimpleDialog(this, "Requires Microphone", "Please grant OurPlace microphone access in the system settings to complete this task!", "Ok"); NavigationController.PopViewController(true); return; } } else { OverlayImageView.Alpha = 0; } SetupLiveCameraStream(); }
private async void StartTask(AppTask taskData) { switch (taskData.TaskType.IdName) { case "DRAW": case "DRAW_PHOTO": DrawingViewController drawingController = Storyboard.InstantiateViewController("DrawingController") as DrawingViewController; drawingController.StartTask(DisplayedActivity, taskData, TaskResultReturned, NavigationController); // check to see if should draw on previous task's result if (taskData.JsonData.StartsWith("TASK::", StringComparison.OrdinalIgnoreCase)) { int id = -1; int.TryParse(taskData.JsonData.Substring(6), out id); string[] paths = JsonConvert.DeserializeObject <string[]>( ((TaskViewSource)TableView.Source).GetWithId(id)?.CompletionData.JsonData); if (paths != null && paths.Length > 0) { drawingController.previousImage = paths[0]; } } break; case "LISTEN_AUDIO": ResultMediaViewerController listenAudioController = Storyboard.InstantiateViewController("MediaViewerController") as ResultMediaViewerController; listenAudioController.FilePath = GetCacheFilePath(taskData.JsonData, DisplayedActivity.Id, ServerUtils.GetFileExtension(taskData.TaskType.IdName));; listenAudioController.Task = taskData; listenAudioController.DeleteResult = null; NavigationController.PushViewController(listenAudioController, true); // Mark as complete TaskResultReturned(null, taskData.Id); break; case "MAP_MARK": MapMarkingViewController mapMarkController = Storyboard.InstantiateViewController("MapMarkController") as MapMarkingViewController; mapMarkController.StartTask(DisplayedActivity, taskData, TaskResultReturned, NavigationController); break; case "LOC_HUNT": LocationHuntViewController locHuntController = Storyboard.InstantiateViewController("LocationHuntController") as LocationHuntViewController; locHuntController.StartTask(DisplayedActivity, taskData, TaskResultReturned, NavigationController); break; case "ENTER_TEXT": EnterTextViewController textController = Storyboard.InstantiateViewController("EnterTextController") as EnterTextViewController; textController.StartTask(DisplayedActivity, taskData, TaskResultReturned, NavigationController); break; case "MULT_CHOICE": MultipleChoiceController mcController = Storyboard.InstantiateViewController("MultipleChoiceController") as MultipleChoiceController; mcController.StartTask(DisplayedActivity, taskData, TaskResultReturned, NavigationController); break; case "TAKE_VIDEO": bool hasMicPerms = await AppUtils.AuthorizeMic(); if (!hasMicPerms) { AppUtils.ShowSimpleDialog(this, "Requires Microphone", "Please grant OurPlace microphone access in the system settings to complete this task!", "Ok"); return; } goto case "TAKE_PHOTO"; // eew C# why u do dis case "MATCH_PHOTO": case "TAKE_PHOTO": bool hasCamPerms = await AppUtils.AuthorizeCamera(); if (!hasCamPerms) { AppUtils.ShowSimpleDialog(this, "Requires Camera", "Please grant OurPlace camera access in the system settings to complete this task!", "Ok"); return; } CameraViewController camController = Storyboard.InstantiateViewController("PhotoTaskViewController") as CameraViewController; camController.StartTask(DisplayedActivity, taskData, TaskResultReturned, NavigationController); break; case "REC_AUDIO": hasMicPerms = await AppUtils.AuthorizeMic(); if (!hasMicPerms) { AppUtils.ShowSimpleDialog(this, "Requires Microphone", "Please grant OurPlace microphone access in the system settings to complete this task!", "Ok"); return; } RecordAudioController audioController = Storyboard.InstantiateViewController("RecordAudioController") as RecordAudioController; audioController.StartTask(DisplayedActivity, taskData, TaskResultReturned, NavigationController); break; case "SCAN_QR": StartScanning(taskData); break; default: Console.WriteLine("Unknown task type: " + taskData.TaskType.IdName); break; } }