public static void ShowLoading(Context context) { alert = new global::Android.Support.V7.App.AlertDialog.Builder(context); alert.SetView(Resource.Layout.loading); alert.SetCancelable(false); alertDialog = alert.Show(); }
private void StartSearch() { #pragma warning disable CA2000 // Dispose objects before losing scope EditText codeInput = new EditText(this); #pragma warning restore CA2000 // Dispose objects before losing scope using (global::Android.Support.V7.App.AlertDialog.Builder builder = new global::Android.Support.V7.App.AlertDialog.Builder(this)) using (TextView message = new TextView(this)) using (LinearLayout dialogLayout = new LinearLayout(this) { Orientation = Orientation.Vertical }) { builder.SetTitle(Resource.String.searchAlertTitle); int px = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 16, Resources.DisplayMetrics); message.SetText(Resource.String.createCollectionAddActivityEnterCode); dialogLayout.AddView(message); dialogLayout.AddView(codeInput); dialogLayout.SetPadding(px, px, px, px); builder.SetView(dialogLayout); builder.SetPositiveButton(Resource.String.MenuSearch, (a, b) => { GetAndReturnWithActivity(codeInput.Text); codeInput.Dispose(); }); builder.SetNeutralButton(Resource.String.dialog_cancel, (a, b) => { }); builder.Show(); } }
private void StartSearch() { global::Android.Support.V7.App.AlertDialog.Builder builder = new global::Android.Support.V7.App.AlertDialog.Builder(this); builder.SetTitle(Resource.String.searchAlertTitle); int px = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 16, Resources.DisplayMetrics); TextView message = new TextView(this); message.SetText(Resource.String.searchAlertMessage); EditText codeInput = new EditText(this); LinearLayout dialogLayout = new LinearLayout(this) { Orientation = Orientation.Vertical }; dialogLayout.AddView(message); dialogLayout.AddView(codeInput); dialogLayout.SetPadding(px, px, px, px); builder.SetView(dialogLayout); builder.SetPositiveButton(Resource.String.MenuSearch, (a, b) => { GetAndOpenActivity(codeInput.Text); }); builder.SetNeutralButton(Resource.String.dialog_cancel, (a, b) => { }); builder.Show(); }
private void ShowNameEntry(bool continueToFinish = false) { global::Android.Support.V7.App.AlertDialog.Builder builder = new global::Android.Support.V7.App.AlertDialog.Builder(this); builder.SetTitle(Resource.String.actEnterUsernameTitle); int px = (int)global::Android.Util.TypedValue.ApplyDimension( global::Android.Util.ComplexUnitType.Dip, 16, base.Resources.DisplayMetrics); TextView message = new TextView(this); message.SetText(Resource.String.actEnterUsername); EditText nameInput = new EditText(this) { Text = enteredName }; LinearLayout dialogLayout = new LinearLayout(this) { Orientation = Orientation.Vertical }; dialogLayout.AddView(message); dialogLayout.AddView(nameInput); dialogLayout.SetPadding(px, px, px, px); builder.SetView(dialogLayout); builder.SetNeutralButton(Resource.String.dialog_cancel, (a, b) => { }); builder.SetPositiveButton(Resource.String.dialog_ok, (a, b) => { if (string.IsNullOrWhiteSpace(nameInput.Text)) { // If nothing has been entered and nothing has been previously // entered, show the dialog again if (string.IsNullOrWhiteSpace(enteredName)) { ShowNameEntry(); } } else { enteredName = nameInput.Text; adapter.UpdateNames(enteredName); dbManager.SaveActivityProgress(learningActivity, adapter.Items, enteredName); if (continueToFinish) { PackageForUpload(); } } }); if (!string.IsNullOrWhiteSpace(enteredName)) { builder.SetNeutralButton(Resource.String.dialog_cancel, (a, b) => { }); } builder.Show(); }
private void ShowHelp() { using (global::Android.Support.V7.App.AlertDialog.Builder alert = new global::Android.Support.V7.App.AlertDialog.Builder(this)) { alert.SetMessage(Resource.String.createCollectionAddActivityHelp); alert.SetPositiveButton(Resource.String.dialog_ok, (a, b) => { }); alert.Show(); } }
public void OnClick(View v) { global::Android.Support.V7.App.AlertDialog.Builder builder = new global::Android.Support.V7.App.AlertDialog.Builder(_city.Context) .SetTitle($"{ResourcesTexts.MSCS}") .SetItems(new string[] { $"{ResourcesTexts.AddFace}" }, HandleOptionClicked); builder.Show(); }
public void OnClick(View v) { global::Android.Support.V7.App.AlertDialog.Builder builder = new global::Android.Support.V7.App.AlertDialog.Builder(_city.Context) .SetTitle("Microsoft Cognitive Services") .SetItems(new string[] { "Add Face" }, HandleOptionClicked); builder.Show(); }
public static async void CallWithPermission(string[] perms, string[] explanationTitles, string[] explanations, Intent toCall, int intentId, int permReqId, Activity activity) { List <string> neededPerms = new List <string>(); int accountedFor = 0; for (int i = 0; i < perms.Length; i++) { if (ContextCompat.CheckSelfPermission(activity, perms[i]) != Permission.Granted) { // Haven't got the permision yet string thisPerm = perms[i]; // Show an explanation of why it's needed if necessary if (ActivityCompat.ShouldShowRequestPermissionRationale(activity, perms[i])) { global::Android.Support.V7.App.AlertDialog dialog = new global::Android.Support.V7.App.AlertDialog.Builder(activity) .SetTitle(explanationTitles[i]) .SetMessage(explanations[i]) .SetPositiveButton("Got it", (s, e) => { neededPerms.Add(thisPerm); accountedFor++; }) .Create(); dialog.Show(); } else { // No explanation needed, just ask neededPerms.Add(perms[i]); accountedFor++; } } else { accountedFor++; } } while (accountedFor < perms.Length) { await Task.Delay(20).ConfigureAwait(false); } if (!neededPerms.Any()) { activity?.StartActivityForResult(toCall, intentId); } else { ActivityCompat.RequestPermissions(activity, neededPerms.ToArray(), permReqId); } }
public override bool OnOptionsItemSelected(IMenuItem item) { mPaint.SetXfermode(null); mPaint.Alpha = 0xFF; switch (item.ItemId) { case Save: global::Android.Support.V7.App.AlertDialog.Builder editalert = new global::Android.Support.V7.App.AlertDialog.Builder(this); editalert.SetTitle("Please Enter the name with which you want to Save"); EditText input = new EditText(this); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); input.LayoutParameters = lp; editalert.SetView(input); editalert.SetPositiveButton("OK", delegate { string name = input.Text; Bitmap bitmap = mv.DrawingCache; Bitmap image = Bitmap.CreateBitmap(bgImage.LayoutParameters.Width, bgImage.LayoutParameters.Height, Bitmap.Config.Argb8888); Canvas c = new Canvas(image); bgImage.Layout(bgImage.Left, bgImage.Top, bgImage.Right, bgImage.Bottom); bgImage.Draw(c); string sdCardPath = global::Android.OS.Environment.GetExternalStoragePublicDirectory(global::Android.OS.Environment.DirectoryDownloads).AbsolutePath; string filePath = System.IO.Path.Combine(sdCardPath, name + ".png"); try { var stream = new FileStream(filePath, FileMode.Create); bitmap.Compress(Bitmap.CompressFormat.Jpeg, 80, stream); stream.Close(); } catch (Exception e) { System.Console.WriteLine(e.Message); } finally { mv.DrawingCacheEnabled = false; } }); editalert.Show(); return(true); } return(base.OnOptionsItemSelected(item)); }
async void BtnVerify_Click(object sender, System.EventArgs e) { if (CrossMedia.Current.IsPickPhotoSupported) { try { var result = await CrossMedia.Current.PickPhotoAsync(); if (result == null) { return; } AndHUD.Shared.Show(this, ResourcesTexts.Searching); var persons = await Service.Instance.FindSimilarFace(result.GetStream()); AndHUD.Shared.Dismiss(this); if (persons == null || persons.Count == 0) { AndHUD.Shared.Dismiss(this); global::Android.Support.V7.App.AlertDialog.Builder message = new global::Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle(ResourcesTexts.MSCS) .SetPositiveButton($"{ResourcesTexts.Ok}", (sender1, e1) => { }) .SetMessage($"{ResourcesTexts.NotFound}"); message.Show(); return; } await Task.Delay(1000); string personsString = ""; foreach (var item in persons) { personsString += item.Name + ", \n"; } global::Android.Support.V7.App.AlertDialog.Builder builder = new global::Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle(ResourcesTexts.MSCS) .SetPositiveButton($"{ResourcesTexts.Ok}", (sender1, e1) => { }) .SetMessage(personsString); builder.Show(); } catch (Exception ex) { AndHUD.Shared.Dismiss(this); } } }
async void BtnAnalyze_Click(object sender, System.EventArgs e) { if (CrossMedia.Current.IsPickPhotoSupported) { try { var result = await CrossMedia.Current.PickPhotoAsync(); if (result == null) { return; } AndHUD.Shared.Show(this, ResourcesTexts.Analyzing); var face = await Service.Instance.AnalyzeFace(result.GetStream()); if (face == null) { AndHUD.Shared.Dismiss(this); return; } AndHUD.Shared.Dismiss(this); await Task.Delay(1000); var stringData = $"{ResourcesTexts.Gender}: {face.FaceAttributes.Gender}" + Environment.NewLine; stringData += $"{ResourcesTexts.Age}: {face.FaceAttributes.Age}" + Environment.NewLine; stringData += $"{ResourcesTexts.Glasses}: {face.FaceAttributes.Glasses.ToString()}" + Environment.NewLine; stringData += $"{ResourcesTexts.Beard}: {face.FaceAttributes.FacialHair.Beard}" + Environment.NewLine; stringData += $"{ResourcesTexts.Moustache}: {face.FaceAttributes.FacialHair.Moustache}" + Environment.NewLine; stringData += $"{ResourcesTexts.Sideburns}: {face.FaceAttributes.FacialHair.Sideburns}" + Environment.NewLine; stringData += $"{ResourcesTexts.Smile}: {face.FaceAttributes.Smile}"; global::Android.Support.V7.App.AlertDialog.Builder builder = new global::Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle(ResourcesTexts.MSCS) .SetPositiveButton(ResourcesTexts.Ok, (sender1, e1) => { }) .SetMessage(stringData); builder.Show(); } catch { AndHUD.Shared.Dismiss(this); } } }
private void PlaybackAcceptPopup() { View dialogLayout = LayoutInflater.Inflate(Resource.Layout.DialogButton, null); playBtn = dialogLayout.FindViewById <Button>(Resource.Id.dialogBtn); playBtn.Text = Resources.GetString(Resource.String.ListenBtn); playBtn.Click += (e, o) => { if (player.IsPlaying) { player.Stop(); player.Reset(); playBtn.Text = Resources.GetString(Resource.String.ListenBtn); } else { player.SetDataSource(filePath); player.Prepare(); player.Start(); playBtn.Text = Resources.GetString(Resource.String.StopBtn); } }; global::Android.Support.V7.App.AlertDialog.Builder dialog = new global::Android.Support.V7.App.AlertDialog.Builder(this); dialog.SetTitle("Use this recording?"); dialog.SetMessage("Do you want to use this recording, or try recording another clip?"); dialog.SetView(dialogLayout); dialog.SetCancelable(false); dialog.SetNegativeButton("Record another", (s, e) => { player.Stop(); player.Reset(); }); dialog.SetPositiveButton("Use this", (s, e) => { player.Stop(); player.Reset(); ReturnWithFile(); }); dialog.Show(); }
public static void CheckGetPermission(string permission, Activity context, int requestId, string title, string message) { if (ContextCompat.CheckSelfPermission(context, permission) != Permission.Granted) { // Show an explanation of why it's needed if necessary if (ActivityCompat.ShouldShowRequestPermissionRationale(context, permission)) { global::Android.Support.V7.App.AlertDialog dialog = new global::Android.Support.V7.App.AlertDialog.Builder(context) .SetTitle(title) .SetMessage(message) .SetPositiveButton("Got it", (s, e) => { ActivityCompat.RequestPermissions(context, new string[] { permission }, requestId); }) .Create(); dialog.Show(); } else { // No explanation needed, just ask ActivityCompat.RequestPermissions(context, new string[] { permission }, requestId); } } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); string jsonData = Intent.GetStringExtra("JSON") ?? ""; learningActivity = JsonConvert.DeserializeObject <LearningActivity>(jsonData, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }); if (learningActivity == null) { using (var alert = new global::Android.Support.V7.App.AlertDialog.Builder(this)) { alert.SetTitle(Resource.String.ErrorTitle) .SetMessage(Resource.String.ErrorTitle) .SetOnDismissListener(new OnDismissListener(Finish)); alert.Show(); } return; } dbManager = await Storage.GetDatabaseManager(); // Load this activity's progress from the database if available ActivityProgress progress = dbManager.GetProgress(learningActivity); List <AppTask> appTasks = null; try { if (progress != null) { enteredName = progress.EnteredUsername; appTasks = JsonConvert.DeserializeObject <List <AppTask> >(progress.AppTaskJson); } } catch (Exception e) { Console.WriteLine(e.Message); Toast.MakeText(this, Resource.String.errorCache, ToastLength.Long).Show(); appTasks = null; } if (appTasks == null) { appTasks = learningActivity.LearningTasks.Select(t => new AppTask(t)).ToList(); } bool curatorControls = learningActivity.IsPublic && !learningActivity.Approved && dbManager.CurrentUser.Trusted; adapter = new TaskAdapter(this, learningActivity.Id, appTasks, learningActivity.Description, curatorControls, learningActivity.RequireUsername); adapter.ItemClick += OnItemClick; adapter.TextEntered += Adapter_TextEntered; adapter.ShowMedia += ShowMedia; adapter.Approved += Adapter_Approved; adapter.SpeakText += Adapter_SpeakText; adapter.ChangeName += Adapter_EditName; SetContentView(Resource.Layout.RecyclerViewActivity); recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); toolbar = FindViewById <global::Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); LoadHeaderImage(learningActivity.ImageUrl); SetupContent(); if (!string.IsNullOrWhiteSpace(enteredName)) { adapter.UpdateNames(enteredName); } }
public override bool OnOptionsItemSelected(IMenuItem item) { switch (item?.ItemId) { case Resource.Id.menuhelp: using (global::Android.Support.V7.App.AlertDialog.Builder alert = new global::Android.Support.V7.App.AlertDialog.Builder(this)) { alert.SetMessage(Resource.String.createCollectionHelp); alert.SetPositiveButton(Resource.String.dialog_ok, (a, b) => { }); alert.Show(); } return(true); case Resource.Id.menudelete: using (var builder = new global::Android.Support.V7.App.AlertDialog.Builder(this)) { builder.SetTitle(Resource.String.deleteTitle) .SetMessage(Resource.String.deleteMessage) .SetNegativeButton(Resource.String.dialog_cancel, (a, e) => { }) .SetPositiveButton(Resource.String.DeleteBtn, async(a, e) => { if (editingSubmitted) { using (ProgressDialog prog = new ProgressDialog(this)) { prog.SetMessage(Resources.GetString(Resource.String.PleaseWait)); prog.Show(); ServerResponse <string> resp = await ServerUtils.Delete <string>("/api/activitycollections?id=" + newCollection.Id).ConfigureAwait(false); RunOnUiThread(() => prog.Dismiss()); if (resp == null) { var suppress = AndroidUtils.ReturnToSignIn(this); RunOnUiThread(() => Toast.MakeText(this, Resource.String.ForceSignOut, ToastLength.Long).Show()); } else if (resp.Success) { RunOnUiThread(() => Toast.MakeText(this, Resource.String.uploadsUploadSuccessTitle, ToastLength.Long).Show()); MainMyCreationsFragment.ForceRefresh = true; Finish(); } else { RunOnUiThread(() => Toast.MakeText(this, Resource.String.ConnectionError, ToastLength.Long).Show()); } } } else { DatabaseManager db = await AndroidUtils.GetDbManager().ConfigureAwait(false); var localCollections = JsonConvert.DeserializeObject <List <ActivityCollection> >(db.CurrentUser.LocalCreatedCollectionsJson); localCollections.Remove(localCollections.FirstOrDefault(act => act.Id == newCollection.Id)); db.CurrentUser.LocalCreatedCollectionsJson = JsonConvert.SerializeObject(localCollections); db.AddUser(db.CurrentUser); MainMyCreationsFragment.ForceRefresh = true; Finish(); } }) .Show(); } return(true); default: return(base.OnOptionsItemSelected(item)); } }