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 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(); } }
public static bool IsContentVersionCompatible(FeedItem content, Activity context) { if (content == null) { throw new System.Exception("Content is null"); } if (context == null) { throw new System.Exception("Unable to access app context"); } int thisVersion = context.PackageManager.GetPackageInfo(context.PackageName, 0).VersionCode; if (content.AppVersionNumber > thisVersion) { context.RunOnUiThread(() => { using (var builder = new global::Android.Support.V7.App.AlertDialog.Builder(context)) { builder.SetTitle(Resource.String.updateTitle) .SetMessage(Resource.String.updateMessage) .SetPositiveButton(Resource.String.dialog_ok, (a, b) => { }) .Show(); } }); return(false); } return(true); }
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 ShowErrorAlert(string message) { global::Android.Support.V7.App.AlertDialog.Builder alert = new global::Android.Support.V7.App.AlertDialog.Builder(this); alert.SetTitle("Error"); alert.SetMessage(message); Dialog dialog = alert.Create(); dialog.Show(); }
private void ShowSessionExpiredError() { global::Android.Support.V7.App.AlertDialog.Builder alert = new global::Android.Support.V7.App.AlertDialog.Builder(this); alert.SetTitle("Aviso"); alert.SetMessage("Su sesión ha expirado, por favor ingrese sus credenciales nuevamente"); Dialog dialog = alert.Create(); dialog.Show(); }
private void OnEventCreated() { global::Android.Support.V7.App.AlertDialog.Builder builder = new global::Android.Support.V7.App.AlertDialog.Builder(this); builder.SetTitle("Aviso"); builder.SetMessage(editMode ? "El evento ha sido editado con éxito" : "El evento ha sido creado con éxito"); builder.SetPositiveButton("OK", OkAction); builder.SetCancelable(false); Dialog dialog = builder.Create(); dialog.Show(); }
private void OnFeatureModified() { global::Android.Support.V7.App.AlertDialog.Builder builder = new global::Android.Support.V7.App.AlertDialog.Builder(this); builder.SetTitle("Aviso"); builder.SetMessage("No puedes modificar una novedad de la que no eres autor."); builder.SetPositiveButton("OK", OkAction); builder.SetCancelable(false); Dialog dialog = builder.Create(); dialog.Show(); }
private void OnFeatureModified() { global::Android.Support.V7.App.AlertDialog.Builder builder = new global::Android.Support.V7.App.AlertDialog.Builder(this); builder.SetTitle("Aviso"); builder.SetMessage("No tienes guardias activas."); builder.SetPositiveButton("OK", OkAction); builder.SetCancelable(false); Dialog dialog = builder.Create(); dialog.Show(); }
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)); }
/// <summary> /// Warns the user prior to starting upload if file sizes are significant /// </summary> private void UploadAfterWarning(object sender, int position) { if (!uploads.Any() || position >= uploads.Count) { return; } files = JsonConvert.DeserializeObject <List <FileUpload> >(uploads[position].FilesJson); float totalFileSizeMb = 0; foreach (FileUpload up in files) { if (!string.IsNullOrWhiteSpace(up.RemoteFilePath)) { continue; } FileInfo fInfo = new FileInfo(up.LocalFilePath); if (fInfo.Exists) { totalFileSizeMb += fInfo.Length / 1000000f; } } if (totalFileSizeMb > 10) { string unit = (totalFileSizeMb > 1000) ? "GB" : "MB"; float amount = (totalFileSizeMb > 1000) ? totalFileSizeMb / 1000 : totalFileSizeMb; using (var builder = new global::Android.Support.V7.App.AlertDialog.Builder(this)) { builder.SetTitle(Resource.String.uploadsSizeWarningTitle) .SetMessage(string.Format(CultureInfo.InvariantCulture, base.Resources.GetString(Resource.String.uploadsSizeWarningMessage), amount.ToString("0.0", CultureInfo.InvariantCulture), unit)) .SetNegativeButton(Resource.String.dialog_cancel, (a, b) => { }) .SetCancelable(true) .SetPositiveButton(Resource.String.Continue, (a, b) => { StartUploads(position); }) .Show(); } } else { StartUploads(position); } }
private void ShowErrorAlert(string message) { if (string.IsNullOrEmpty(message)) { return; } global::Android.Support.V7.App.AlertDialog.Builder alert = new global::Android.Support.V7.App.AlertDialog.Builder(Activity); alert.SetTitle("Error"); alert.SetMessage(message); Dialog dialog = alert.Create(); dialog.Show(); }
private void Adapter_DeleteItemClick(object sender, int position) { using (var diag = new global::Android.Support.V7.App.AlertDialog.Builder(this)) { diag.SetTitle(Resource.String.deleteTitle) .SetMessage(Resource.String.deleteMessage) .SetNegativeButton(Resource.String.dialog_cancel, (a, e) => { }) .SetPositiveButton(Resource.String.DeleteBtn, (a, b) => { position--; adapter.Collection.Activities.RemoveAt(position); adapter.NotifyDataSetChanged(); SaveProgress(); }) .Show(); } }
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 override Dialog OnCreateDialog(global::Android.OS.Bundle savedInstanceState) { _contextWeak.TryGetTarget(out Context context); var alertBuilder = new global::Android.Support.V7.App.AlertDialog.Builder(context); alertBuilder.SetTitle(_title); if (_message != null) { alertBuilder.SetMessage(_message); } _textInput = new EditText(context); _textInput.AddTextChangedListener(this); alertBuilder.SetView(_textInput); if (_hint != null) { _textInput.Text = _hint; _textInput.SelectAll(); } alertBuilder.SetCancelable(false); alertBuilder.SetNegativeButton(_cancelButton ?? "Cancel", delegate { Tcs.TrySetResult(null); }); alertBuilder.SetPositiveButton(_actionButton ?? "Ok", (EventHandler <DialogClickEventArgs>)null); var alert = alertBuilder.Create(); alert.SetOnShowListener(this); return(alert); }
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) { if (item.ItemId == global::Android.Resource.Id.Home) { OnBackPressed(); return(true); } if (item.ItemId != Resource.Id.menudelete) { return(base.OnOptionsItemSelected(item)); } 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/learningactivities?id=" + newActivity.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 localActivities = JsonConvert.DeserializeObject <List <LearningActivity> >(db.CurrentUser.LocalCreatedActivitiesJson); localActivities.Remove(localActivities.FirstOrDefault(act => act.Id == newActivity.Id)); db.CurrentUser.LocalCreatedActivitiesJson = JsonConvert.SerializeObject(localActivities); db.AddUser(db.CurrentUser); MainMyCreationsFragment.ForceRefresh = true; Finish(); } }) .Show(); } return(true); }
private async void StartUploads(int position) { uploadProgress = new ProgressDialog(this); uploadProgress.SetTitle("Uploading"); uploadProgress.Indeterminate = false; uploadProgress.SetCancelable(false); uploadProgress.Max = 100; uploadProgress.Progress = 0; uploadProgress.SetTitle(Resource.String.uploadsUploadingFiles); uploadProgress.Show(); try { bool success = await Storage.UploadFiles( JsonConvert.DeserializeObject <List <FileUpload> >( uploads[position].FilesJson), position, (percentage) => { uploadProgress.Progress = percentage; }, (listPos, jsonData) => { uploads[listPos].FilesJson = jsonData; dbManager.UpdateUpload(uploads[listPos]); }, Storage.GetUploadsFolder()).ConfigureAwait(false); if (!success) { uploadProgress.Dismiss(); using (var builder = new global::Android.Support.V7.App.AlertDialog.Builder(this)) { builder.SetTitle(Resource.String.ErrorTitle) .SetMessage(Resource.String.ConnectionError) .SetPositiveButton(Resource.String.dialog_ok, (a, b) => { }) .Show(); } return; } } catch (Exception e) { // Refresh token not valid Console.WriteLine(e.Message); var suppress = AndroidUtils.ReturnToSignIn(this); Toast.MakeText(this, Resource.String.ForceSignOut, ToastLength.Long).Show(); return; } ServerResponse <string> resp = new ServerResponse <string>(); UploadType type = uploads[position].UploadType; if (type == UploadType.NewActivity || type == UploadType.UpdatedActivity) { resp = await ServerUtils.UploadActivity(uploads[position], type == UploadType.UpdatedActivity).ConfigureAwait(false); } else if (type == UploadType.NewCollection || type == UploadType.UpdatedCollection) { resp = await ServerUtils.UploadCollection(uploads[position], type == UploadType.UpdatedCollection).ConfigureAwait(false); } else { // Uploading activity results AppTask[] results = JsonConvert.DeserializeObject <AppTask[]>(uploads[position].JsonData) ?? new AppTask[0]; files = JsonConvert.DeserializeObject <List <FileUpload> >(uploads[position].FilesJson); resp = await ServerUtils.UpdateAndPostResults(results, files, uploads[position].UploadRoute).ConfigureAwait(false); } RunOnUiThread(() => uploadProgress.Dismiss()); if (resp == null) { var suppress = AndroidUtils.ReturnToSignIn(this); RunOnUiThread(() => Toast.MakeText(this, Resource.String.ForceSignOut, ToastLength.Long).Show()); return; } if (!resp.Success) { RunOnUiThread(() => { using (var builder = new global::Android.Support.V7.App.AlertDialog.Builder(this)) { builder.SetTitle(Resource.String.ErrorTitle) .SetMessage(resp.Message) .SetPositiveButton(Resource.String.dialog_ok, (a, b) => { }) .Show(); } }); return; } dbManager.DeleteUpload(uploads[position]); RunOnUiThread(() => { adapter.Data.RemoveAt(position); adapter.NotifyDataSetChanged(); using (var builder = new global::Android.Support.V7.App.AlertDialog.Builder(this)) { builder.SetTitle(Resource.String.uploadsUploadSuccessTitle) .SetMessage(Resource.String.uploadsUploadSuccessMessage) .SetCancelable(false) .SetPositiveButton(Resource.String.dialog_ok, (a, b) => { if (!adapter.Data.Any()) { OnBackPressed(); } }).Show(); } }); }