public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); var view = inflater.Inflate(Resource.Layout.SubmittedFragment, container, false); View header = Activity.LayoutInflater.Inflate(Resource.Layout.SubmittedHeader, null); exportList = view.FindViewById<ListView>(Resource.Id.submitted_list); exportList.AddHeaderView(header, null, false); LoadData(); exportList.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs args) { // The list's header borks indexing res = results[args.Position - 1]; View alertView = Activity.LayoutInflater.Inflate(Resource.Layout.SubmittedAlert, null); Button feedbackBtn = alertView.FindViewById<Button>(Resource.Id.submittedAlert_feedbackBtn); feedbackBtn.Click += feedbackBtn_Click; Button permissionsBtn = alertView.FindViewById<Button>(Resource.Id.submittedAlert_permission); permissionsBtn.Click += permissionsBtn_Click; Android.Support.V7.App.AlertDialog alert = new Android.Support.V7.App.AlertDialog.Builder(Activity) .SetTitle("What would you like to do with this submission?") .SetView(alertView) .SetCancelable(true) .SetNegativeButton("Delete", (EventHandler<DialogClickEventArgs>)null) .SetNeutralButton("Close", (s, a) => { }) .Create(); alert.Show(); // A second alert dialogue, confirming the decision to delete Button deleteBtn = alert.GetButton((int)DialogButtonType.Negative); deleteBtn.Click += delegate(object s, EventArgs e) { Android.Support.V7.App.AlertDialog.Builder confirm = new Android.Support.V7.App.AlertDialog.Builder(Activity); confirm.SetTitle("Are you sure?"); confirm.SetMessage("The recorded data will be deleted from the server and irrecoverably lost. Continue?"); confirm.SetPositiveButton("Delete", (senderAlert, confArgs) => { ServerData.PushResultDeletion(res); exportList.Adapter = null; LoadData(); alert.Dismiss(); }); confirm.SetNegativeButton("Cancel", (senderAlert, confArgs) => { }); confirm.Show(); }; }; return view; }
private void StopAction(bool stopRec = true, bool popup = false) { RunOnUiThread(() => { modeLayouts[currentMode].Visibility = ViewStates.Gone; startBtn.Text = "Start!"; }); if (stopRec) audioManager.StopRecording(); if (!popup) return; Android.Net.Uri passedUri = Android.Net.Uri.FromFile(new Java.IO.File(AppData.TempRecording.Path)); Android.Support.V7.App.AlertDialog alert = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("Session complete!") .SetMessage("Would you like to listen to your speech?") .SetPositiveButton("Listen", (EventHandler<DialogClickEventArgs>) null) .SetNeutralButton("Share recording", (EventHandler<DialogClickEventArgs>) null) .SetNegativeButton("Close", (arg1, arg2) => { }) .Create(); alert.Show(); alert.GetButton((int) DialogButtonType.Positive).Click += (sender, e) => { Intent intent = new Intent(); intent.SetAction(Intent.ActionView); intent.SetDataAndType(passedUri, "audio/*"); StartActivity(intent); }; alert.GetButton((int) DialogButtonType.Neutral).Click += (sender, e) => { Intent intent = new Intent(); intent.SetAction(Intent.ActionSend); intent.SetType("audio/*"); intent.PutExtra(Intent.ExtraStream, passedUri); StartActivity(intent); }; }
private void recordButton_Click(object sender, EventArgs e) { if (!recording) { recordButton.Text = "Stop recording!"; audioManager.StartRecording(recFile); recordButton.SetBackgroundResource(Resource.Drawable.recordButtonRed); } else { recordButton.Text = "Recording complete!"; audioManager.StopRecording(); recordButton.SetBackgroundResource(Resource.Drawable.recordButtonBlue); Android.Support.V7.App.AlertDialog alert = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("Recording complete!") .SetMessage("You completed a new voice entry about " + placeName + ". Would you like to try again or export this recording?") .SetNegativeButton("Restart", (EventHandler<DialogClickEventArgs>) null) .SetPositiveButton("Export", (s, args) => { ExportRecordings(); }) .Create(); alert.Show(); // A second alert dialogue, confirming the decision to restart Button negative = alert.GetButton((int) DialogButtonType.Negative); negative.Click += delegate { Android.Support.V7.App.AlertDialog.Builder confirm = new Android.Support.V7.App.AlertDialog.Builder(this); confirm.SetTitle("Are you sure?"); confirm.SetMessage("Restarting will wipe your current progress. Restart the scenario?"); confirm.SetPositiveButton("Restart", (senderAlert, confArgs) => { recordButton.Text = "Start recording!"; alert.Dismiss(); }); confirm.SetNegativeButton("Cancel", (senderAlert, confArgs) => { }); confirm.Show(); }; } recording = !recording; }
public void OnItemTap(object sender, AdapterView.ItemClickEventArgs args) { if(progressDialog == null) { progressDialog = new ProgressDialog(this); progressDialog.SetMessage("Uploading your content. Please wait."); progressDialog.SetButton("Cancel Upload", (arg1, arg2) => { if (cancelTokenSource != null) cancelTokenSource.Cancel(); }); progressDialog.Indeterminate = true; } Android.Support.V7.App.AlertDialog alert = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("Scenario Complete!") .SetMessage("What would you like to do with the results of this scenario?") .SetCancelable(true) .SetNegativeButton("Delete", (EventHandler<DialogClickEventArgs>)null) .SetPositiveButton("Upload", (s, a) => { IResultItem toUpload = AppData.Session.ResultsToUpload[args.Position - 1]; progressDialog.Show(); cancelTokenSource = new CancellationTokenSource(); ServerData.PushResult(toUpload, RefreshList, OnUploadComplete, cancelTokenSource.Token); }) .SetNeutralButton("Cancel", (s, a) => { }) .Create(); alert.Show(); // A second alert dialogue, confirming the decision to delete Button negative = alert.GetButton((int)DialogButtonType.Negative); negative.Click += delegate(object s, EventArgs e) { Android.Support.V7.App.AlertDialog.Builder confirm = new Android.Support.V7.App.AlertDialog.Builder(this); confirm.SetTitle("Are you sure?"); confirm.SetMessage("The recorded data will be irrecoverably lost."); confirm.SetPositiveButton("Delete", (senderAlert, confArgs) => { AppData.Session.DeleteResult(AppData.Session.ResultsToUpload[args.Position - 1]); RefreshList(); alert.Dismiss(); }); confirm.SetNegativeButton("Cancel", (senderAlert, confArgs) => { }); confirm.Show(); }; }