private void ImageView_Click(object sender, EventArgs e) { UpdateFiles(); lastReqIntent = AndroidUtils.CreateMultiSourceImagePickerIntent(true, outputFileUri, this); // Requires both camera and storage permissions AndroidUtils.CallWithPermission(new string[] { global::Android.Manifest.Permission.Camera, global::Android.Manifest.Permission.ReadExternalStorage, global::Android.Manifest.Permission.WriteExternalStorage }, new string[] { Resources.GetString(Resource.String.permissionCameraTitle), Resources.GetString(Resource.String.permissionFilesTitle), Resources.GetString(Resource.String.permissionFilesTitle) }, new string[] { Resources.GetString(Resource.String.permissionPhotoExplanation), Resources.GetString(Resource.String.permissionFilesExplanation), Resources.GetString(Resource.String.permissionFilesExplanation) }, lastReqIntent, PhotoRequestCode, PermRequestCode, this); }
private void Adapter_OpenLocationClick(object sender, int position) { LearningActivity thisAct = adapter.Collection.Activities[position - 1]; Place thisPlace = thisAct.Places?.FirstOrDefault(); if (thisPlace == null) { return; } using (var lastReqIntent = new Intent(this, typeof(LocationHuntActivity))) { lastReqIntent.PutExtra("Target", JsonConvert.SerializeObject( new LocationHuntLocation((double)thisPlace.Latitude, (double)thisPlace.Longitude, 15.0f, true))); lastReqIntent.PutExtra("Description", thisAct.Name); AndroidUtils.CallWithPermission(new string[] { global::Android.Manifest.Permission.AccessFineLocation }, new string[] { base.Resources.GetString(Resource.String.permissionLocationTitle) }, new string[] { base.Resources.GetString(Resource.String.permissionLocationExplanation) }, lastReqIntent, thisAct.Id, PermReqId, this); } }
private void OnItemClick(object sender, int position) { // If Finish button clicked if (position == adapter.ItemCount - 1) { PackageForUpload(); return; } string json = JsonConvert.SerializeObject(adapter.Items[position], new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Objects, ReferenceLoopHandling = ReferenceLoopHandling.Serialize, MaxDepth = 5 }); string taskType = adapter.Items[position].TaskType.IdName; switch (taskType) { case "TAKE_VIDEO": case "TAKE_PHOTO": case "MATCH_PHOTO": { lastReqIntent = new Intent(this, typeof(CameraActivity)); lastReqIntent.PutExtra("JSON", json); lastReqIntent.PutExtra("ACTID", learningActivity.Id); List <string> perms = new List <string> { global::Android.Manifest.Permission.Camera, global::Android.Manifest.Permission.AccessFineLocation }; List <string> titles = new List <string> { base.Resources.GetString(Resource.String.permissionCameraTitle), base.Resources.GetString(Resource.String.permissionLocationTitle) }; List <string> explanations = new List <string> { base.Resources.GetString(Resource.String.permissionPhotoExplanation), base.Resources.GetString(Resource.String.permissionLocationExplanation) }; // Video tasks also require the microphone if (taskType == "TAKE_VIDEO") { perms.Add(global::Android.Manifest.Permission.RecordAudio); titles.Add(base.Resources.GetString(Resource.String.permissionMicTitle)); explanations.Add(base.Resources.GetString(Resource.String.permissionMicExplanation)); } AndroidUtils.CallWithPermission(perms.ToArray(), titles.ToArray(), explanations.ToArray(), lastReqIntent, adapter.Items[position].Id, PermReqId, this); break; } case "DRAW": case "DRAW_PHOTO": { Intent drawActivity = new Intent(this, typeof(DrawingActivity)); drawActivity.PutExtra("JSON", json); if (taskType == "DRAW_PHOTO" && adapter.Items[position].JsonData.StartsWith("TASK::", StringComparison.OrdinalIgnoreCase)) { int id = -1; int.TryParse(adapter.Items[position].JsonData.Substring(6), out id); string[] paths = JsonConvert.DeserializeObject <string[]>(adapter.GetTaskWithId(id).CompletionData.JsonData); drawActivity.PutExtra("PREVIOUS_PHOTO", paths[0]); drawActivity.PutExtra("ACTIVITY_ID", learningActivity.Id); } StartActivityForResult(drawActivity, adapter.Items[position].Id); break; } case "MAP_MARK": lastReqIntent = new Intent(this, typeof(LocationMarkerActivity)); lastReqIntent.PutExtra("JSON", json); AndroidUtils.CallWithPermission(new string[] { global::Android.Manifest.Permission.AccessFineLocation }, new string[] { base.Resources.GetString(Resource.String.permissionLocationTitle) }, new string[] { base.Resources.GetString(Resource.String.permissionLocationExplanation) }, lastReqIntent, adapter.Items[position].Id, PermReqId, this); break; case "LOC_HUNT": lastReqIntent = new Intent(this, typeof(LocationHuntActivity)); lastReqIntent.PutExtra("JSON", json); AndroidUtils.CallWithPermission(new string[] { global::Android.Manifest.Permission.AccessFineLocation }, new string[] { base.Resources.GetString(Resource.String.permissionLocationTitle) }, new string[] { base.Resources.GetString(Resource.String.permissionLocationExplanation) }, lastReqIntent, adapter.Items[position].Id, PermReqId, this); break; case "SCAN_QR": lastReqIntent = new Intent(this, typeof(ScanningActivity)); lastReqIntent.PutExtra("JSON", json); StartActivityForResult(lastReqIntent, adapter.Items[position].Id); break; case "REC_AUDIO": lastReqIntent = new Intent(this, typeof(RecordAudioActivity)); lastReqIntent.PutExtra("JSON", json); AndroidUtils.CallWithPermission(new string[] { global::Android.Manifest.Permission.RecordAudio }, new string[] { base.Resources.GetString(Resource.String.permissionMicTitle) }, new string[] { base.Resources.GetString(Resource.String.permissionMicExplanation) }, lastReqIntent, adapter.Items[position].Id, PermReqId, this); break; case "LISTEN_AUDIO": ShowMedia(position, -1); break; case "INFO": AdditionalInfoData data = JsonConvert.DeserializeObject <AdditionalInfoData>(adapter.Items[position].JsonData); global::Android.Net.Uri uri = global::Android.Net.Uri.Parse(data.ExternalUrl); Intent intent = new Intent(Intent.ActionView, uri); StartActivity(intent); break; default: Toast.MakeText(this, "Unknown task type! :(", ToastLength.Short).Show(); break; } }