private void ItemOptionsClick(object sender, int position) { if (position < 0) { return; } var builder = new AlertDialog.Builder(this); builder.SetItems(Resource.Array.authContextMenu, (alertSender, args) => { switch (args.Which) { case 0: OpenRenameDialog(position); break; case 1: OpenIconDialog(position); break; case 2: OpenCategoriesDialog(position); break; case 3: OpenDeleteDialog(position); break; } }); var dialog = builder.Create(); dialog.Show(); }
private async Task Init() { try { _connection = await Database.Connect(this); InitCategories(); InitAuthenticators(); await UpdateCategories(false); await UpdateAuthenticators(false); CreateTimer(); } catch (SQLiteException) { var builder = new AlertDialog.Builder(this); builder.SetMessage(Resource.String.databaseError); builder.SetTitle(Resource.String.warning); builder.SetPositiveButton(Resource.String.quit, (sender, args) => { Finish(); }); builder.SetCancelable(true); var dialog = builder.Create(); dialog.Show(); } }
/// <summary> /// Show Reaction dialog when user long click on react button /// </summary> public void LongClickDialog(GlobalClickEventArgs postData, NativePostAdapter nativeFeedAdapter, string namePage = "") { try { PostData = postData; NamePage = namePage; NativeFeedAdapter = nativeFeedAdapter; //Show Dialog With 6 React AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(Context); //Irrelevant code for customizing the buttons and title LayoutInflater inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService); View dialogView = inflater.Inflate(Resource.Layout.XReactDialogLayout, null); InitializingReactImages(dialogView); SetReactionsArray(); ResetReactionsIcons(); ClickImageButtons(); dialogBuilder.SetView(dialogView); MReactAlertDialog = dialogBuilder.Create(); MReactAlertDialog.Window?.SetBackgroundDrawableResource(MReactDialogShape); Window window = MReactAlertDialog.Window; window?.SetLayout(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); MReactAlertDialog.Show(); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
void OnActionSheetRequested(Page sender, ActionSheetArguments arguments) { // Verify that the page making the request is part of this activity if (!PageIsInThisContext(sender)) { return; } var builder = new AlertDialog.Builder(Activity); builder.SetTitle(arguments.Title); string[] items = arguments.Buttons.ToArray(); builder.SetItems(items, (o, args) => arguments.Result.TrySetResult(items[args.Which])); if (arguments.Cancel != null) { builder.SetPositiveButton(arguments.Cancel, (o, args) => arguments.Result.TrySetResult(arguments.Cancel)); } if (arguments.Destruction != null) { builder.SetNegativeButton(arguments.Destruction, (o, args) => arguments.Result.TrySetResult(arguments.Destruction)); } AlertDialog dialog = builder.Create(); builder.Dispose(); //to match current functionality of renderer we set cancelable on outside //and return null dialog.SetCanceledOnTouchOutside(true); dialog.CancelEvent += (o, e) => arguments.SetResult(null); dialog.Show(); }
/// <summary> /// ShowMessage /// </summary> /// <param name="message"></param> /// <param name="title"></param> /// <param name="firstButtonContent"></param> /// <param name="nextButtonContent"></param> /// <param name="lastButtonContent"></param> /// <returns></returns> public async Task <ButtonDialog> ShowMessage(string title, string message, string firstButtonContent, string nextButtonContent, string lastButtonContent) { var tcs = new TaskCompletionSource <ButtonDialog>(); var builder = new AlertDialog.Builder(CrossCurrentActivity.Current.Activity, Resource.Style.AppCompatAlertDialogStyle); builder.SetTitle(title) .SetMessage(message) .SetCancelable(false) .SetPositiveButton(firstButtonContent, (s, args) => { tcs.TrySetResult(ButtonDialog.Primary); }) .SetNeutralButton(lastButtonContent, (s, args) => { tcs.TrySetResult(ButtonDialog.Close); }) .SetNegativeButton(nextButtonContent, (s, args) => { tcs.TrySetResult(ButtonDialog.Secondary); }); var alert = builder.Create(); alert.Show(); var btnPositive = alert.GetButton((int)DialogButtonType.Positive); var btnNegative = alert.GetButton((int)DialogButtonType.Negative); var btnNeutral = alert.GetButton((int)DialogButtonType.Neutral); var layoutParams = (LinearLayout.LayoutParams)btnPositive.LayoutParameters; layoutParams.Gravity = GravityFlags.Center; btnPositive.LayoutParameters = layoutParams; btnNegative.LayoutParameters = layoutParams; btnNeutral.LayoutParameters = layoutParams; return(await tcs.Task); }
/// <summary> /// Show Reaction dialog when user long click on react button /// </summary> public void ClickDialog(CommentReplyClickEventArgs postData) { try { PostData = postData; //Show Dialog With 6 React AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(MainContext); //Irrelevant code for customizing the buttons and title LayoutInflater inflater = (LayoutInflater)MainContext.GetSystemService(Context.LayoutInflaterService); View dialogView = inflater?.Inflate(Resource.Layout.XReactDialogLayout, null); InitializingReactImages(dialogView); ClickImageButtons(); dialogBuilder.SetView(dialogView); MReactAlertDialog = dialogBuilder.Create(); MReactAlertDialog.Window?.SetBackgroundDrawableResource(MReactDialogShape); Window window = MReactAlertDialog.Window; window?.SetLayout(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); MReactAlertDialog.Show(); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public Task <bool> ShowAlertAsync(string title, string message, string okButtonText, string?cancelButtonText = null) { var tcs = new TaskCompletionSource <bool>(); Execute.BeginOnUIThread(() => { var context = Dependencies.Container.Resolve <IContextProvider>().CurrentActivity; var builder = new AlertDialog.Builder(context) .SetTitle(title) .SetMessage(message); SetPositiveButton(builder, okButtonText, tcs, true); if (cancelButtonText != null) { SetNegativeButton(builder, cancelButtonText, tcs, false); } var dialog = builder.Create(); var dismissCommand = new RelayCommand <TaskCompletionSource <bool> >(x => { x.TrySetResult(false); }); dialog.SetCommand(nameof(dialog.DismissEvent), dismissCommand, tcs); dialog.Show(); }); return(tcs.Task); }
public Dialog Build(AppCompatActivity activity, PromptConfig config) { var txt = new EditText(activity) { Id = Int32.MaxValue, Hint = config.Placeholder }; if (config.Text != null) { txt.Text = config.Text; txt.SetSelection(config.Text.Length); } if (config.MaxLength != null) { txt.SetFilters(new[] { new InputFilterLengthFilter(config.MaxLength.Value) }); } SetInputType(txt, config.InputType); if (config.AutoCorrectionConfig != AutoCorrectionConfig.Default) { switch (config.AutoCorrectionConfig) { case AutoCorrectionConfig.No: txt.InputType |= InputTypes.TextFlagNoSuggestions; // Add Flag break; case AutoCorrectionConfig.Yes: txt.InputType &= ~InputTypes.TextFlagNoSuggestions; // Remove Flag break; default: break; } } var builder = new AppCompatAlertDialog.Builder(activity, config.AndroidStyleId ?? 0) .SetCancelable(false) .SetMessage(config.Message) .SetTitle(config.Title) .SetView(txt) .SetPositiveButton(config.OkText, (s, a) => config.OnAction(new PromptResult(true, txt.Text.Trim())) ); if (config.IsCancellable) { builder.SetNegativeButton(config.CancelText, (s, a) => config.OnAction(new PromptResult(false, txt.Text.Trim())) ); } var dialog = builder.Create(); this.HookTextChanged(dialog, txt, config); return(dialog); }
public FlexibleAlertDialog Create() { if (_useAppCompat) { return(new FlexibleAlertDialog(_appcompatBuilder.Create())); } return(new FlexibleAlertDialog(_legacyBuilder.Create())); }
/// <summary> /// ShowMessage /// </summary> /// <returns></returns> public async Task <string> ShowInputDialog(string title, string hint = null, string messageInput = null, // ReSharper disable once MethodOverloadWithOptionalParameter DialogInputType type = DialogInputType.None, bool isEmpty = false) { var tcs = new TaskCompletionSource <string>(); CrossCurrentActivity.Current.Activity.RunOnUiThread(() => { var builder = new AlertDialog.Builder(CrossCurrentActivity.Current.Activity); var input = new EditText(CrossCurrentActivity.Current.Activity); var lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); lp.SetMargins((int)ConvertScreenValue.ConvertDpToPixel(20, CrossCurrentActivity.Current.Activity), 0, (int)ConvertScreenValue.ConvertDpToPixel(20, CrossCurrentActivity.Current.Activity), 0); input.LayoutParameters = lp; input.SetMaxLines(1); input.SetSingleLine(true); input.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(25) }); input.Text = string.IsNullOrEmpty(messageInput) || isEmpty ? string.Empty : messageInput; input.Hint = string.IsNullOrEmpty(messageInput) && !string.IsNullOrEmpty(hint) ? hint : string.Empty; input.InputType = GetInputType(type); var view = new LinearLayout(CrossCurrentActivity.Current.Activity); var lpView = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); view.LayoutParameters = lpView; view.AddView(input); view.Touch += (sender, args) => KeyboardManager.HideKeyboard(CrossCurrentActivity.Current.Activity, view); view.Click += (sender, args) => KeyboardManager.HideKeyboard(CrossCurrentActivity.Current.Activity, view); var dlg = new Dialog(CrossCurrentActivity.Current.Activity); var dlg1 = dlg; builder.SetTitle(title) .SetView(view) .SetPositiveButton("OK", (s, args) => { KeyboardManager.HideKeyboard(CrossCurrentActivity.Current.Activity, view); tcs.TrySetResult(input.Text); dlg1.Dismiss(); }) .SetNegativeButton("Cancel", (s, args) => { KeyboardManager.HideKeyboard(CrossCurrentActivity.Current.Activity, view); tcs.TrySetResult(null); dlg1.Dismiss(); }); dlg = builder.Create(); dlg.Show(); }); return(await tcs.Task); }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { var alert = new AlertDialog.Builder(Activity); alert.SetTitle(Resource.String.chooseCategories); alert.SetCancelable(false); alert.SetPositiveButton(Resource.String.ok, (EventHandler <DialogClickEventArgs>)null); var view = Activity.LayoutInflater.Inflate(Resource.Layout.dialogChooseCategories, null); _categoryList = view.FindViewById <RecyclerView>(Resource.Id.dialogChooseCategories_list); alert.SetView(view); var dialog = alert.Create(); dialog.Show(); var layout = new LinearLayoutManager(Context); var decoration = new DividerItemDecoration(Context, layout.Orientation); _categoryList.AddItemDecoration(decoration); _categoryList.SetLayoutManager(layout); _categoryAdapter = new ChooseCategoriesAdapter(_categorySource); _categoryAdapter.ItemClick += _itemClick; _categoryList.SetAdapter(_categoryAdapter); _categoryList.HasFixedSize = true; _categoryList.SetItemViewCacheSize(20); var okButton = dialog.GetButton((int)DialogButtonType.Positive); okButton.Click += _onClose.Invoke; var emptyText = view.FindViewById <TextView>(Resource.Id.dialogChooseCategories_empty); if (_categorySource.Count() == 0) { emptyText.Visibility = ViewStates.Visible; _categoryList.Visibility = ViewStates.Gone; } foreach (var category in _checkedCategories) { var index = _categorySource.Categories.FindIndex(c => c.Id == category); _categoryAdapter.CheckedStatus[index] = true; } return(dialog); }
private void ShowDialogButton_Click(object sender, EventArgs e) { _builder = new AndroidX.AppCompat.App.AlertDialog.Builder(this); LayoutInflater inflater = this.LayoutInflater; View dialogView = inflater.Inflate(Resource.Layout.layout_loading_dialog, null); _builder.SetView(dialogView); _loadingDialog = _builder.Create(); _loadingProgressMessageTextView = dialogView.FindViewById <TextView>(Resource.Id.loadingProgressMessageTextView); _loadingProgressMessageTextView.Text = "This is loading"; MoveDialogToRightTopCorner(); _loadingDialog.Show(); }
/// <summary> /// ShowMessage /// </summary> /// <param name="message"></param> /// <param name="title"></param> /// <param name="firstButtonContent"></param> /// <returns></returns> public async Task <bool?> ShowMessage(string title, string message, string firstButtonContent) { var tcs = new TaskCompletionSource <bool?>(); var builder = new AlertDialog.Builder(CrossCurrentActivity.Current.Activity, Resource.Style.AppCompatAlertDialogStyle); builder.SetTitle(title) .SetMessage(message) .SetCancelable(false) .SetPositiveButton(firstButtonContent, (s, args) => { tcs.TrySetResult(true); }); builder.Create().Show(); return(await tcs.Task); }
private void OpenDeleteDialog(int position) { var builder = new AlertDialog.Builder(this); builder.SetMessage(Resource.String.confirmAuthenticatorDelete); builder.SetTitle(Resource.String.warning); builder.SetPositiveButton(Resource.String.delete, async(sender, args) => { await _authSource.Delete(position); _authAdapter.NotifyItemRemoved(position); CheckEmptyState(); }); builder.SetNegativeButton(Resource.String.cancel, (sender, args) => { }); builder.SetCancelable(true); var dialog = builder.Create(); dialog.Show(); }
public override Android.App.Dialog OnCreateDialog(Bundle savedInstanceState) { var alert = new AlertDialog.Builder(Activity); alert.SetTitle(Resource.String.changeIcon); alert.SetNegativeButton(Resource.String.cancel, (EventHandler <DialogClickEventArgs>)null); alert.SetCancelable(false); var view = Activity.LayoutInflater.Inflate(Resource.Layout.dialogChangeIcon, null); _searchText = view.FindViewById <EditText>(Resource.Id.editSearch); _iconList = view.FindViewById <RecyclerView>(Resource.Id.list); alert.SetView(view); var dialog = alert.Create(); dialog.Show(); _searchText.TextChanged += OnSearchChanged; _iconListAdapter = new IconListAdapter(Context, _iconSource); _iconListAdapter.ItemClick += OnItemClick; _iconListAdapter.HasStableIds = true; _iconList.SetAdapter(_iconListAdapter); _iconList.HasFixedSize = true; _iconList.SetItemViewCacheSize(20); var layout = new FixedGridLayoutManager(Context, 6); _iconList.SetLayoutManager(layout); var cancelButton = dialog.GetButton((int)DialogButtonType.Negative); cancelButton.Click += (sender, e) => { dialog.Dismiss(); }; return(dialog); }
public Dialog Build(AppCompatActivity activity, PromptConfig config) { var txt = new EditText(activity) { Id = Int32.MaxValue, Hint = config.Placeholder }; if (config.Text != null) { txt.Text = config.Text; txt.SetSelection(config.Text.Length); } if (config.MaxLength != null) { txt.SetFilters(new[] { new InputFilterLengthFilter(config.MaxLength.Value) }); } SetInputType(txt, config.InputType); var builder = new AppCompatAlertDialog.Builder(activity, config.AndroidStyleId ?? 0) .SetCancelable(false) .SetMessage(config.Message) .SetTitle(config.Title) .SetView(txt) .SetPositiveButton(config.OkText, (s, a) => config.OnAction(new PromptResult(true, txt.Text.Trim())) ); if (config.IsCancellable) { builder.SetNegativeButton(config.CancelText, (s, a) => config.OnAction(new PromptResult(false, txt.Text.Trim())) ); } var dialog = builder.Create(); this.HookTextChanged(dialog, txt, config); return(dialog); }
private void OnDeleteClick(object item, int position) { var builder = new AlertDialog.Builder(this); builder.SetMessage(Resource.String.confirmCategoryDelete); builder.SetTitle(Resource.String.warning); builder.SetCancelable(true); builder.SetPositiveButton(Resource.String.delete, async(sender, args) => { await _categorySource.Delete(position); _categoryAdapter.NotifyItemRemoved(position); CheckEmptyState(); }); builder.SetNegativeButton(Resource.String.cancel, (sender, args) => { }); var dialog = builder.Create(); dialog.Show(); }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { var alert = new AlertDialog.Builder(Activity); alert.SetTitle(Resource.String.changeIcon); alert.SetNegativeButton(Resource.String.cancel, (EventHandler <DialogClickEventArgs>)null); alert.SetCancelable(false); var view = Activity.LayoutInflater.Inflate(Resource.Layout.dialogIcon, null); _searchText = view.FindViewById <EditText>(Resource.Id.dialogIcon_search); _iconList = view.FindViewById <RecyclerView>(Resource.Id.dialogIcon_list); alert.SetView(view); var dialog = alert.Create(); dialog.Show(); dialog.Window.SetSoftInputMode(SoftInput.StateAlwaysVisible); _searchText.TextChanged += SearchChanged; _iconAdapter = new IconAdapter(Context, _iconSource); _iconAdapter.ItemClick += ItemClick; _iconAdapter.SetHasStableIds(true); _iconList.SetAdapter(_iconAdapter); _iconList.HasFixedSize = true; _iconList.SetItemViewCacheSize(20); var layout = new AuthListGridLayoutManager(Context, 6); _iconList.SetLayoutManager(layout); var cancelButton = dialog.GetButton((int)DialogButtonType.Negative); cancelButton.Click += _negativeButtonEvent.Invoke; return(dialog); }
public Dialog Build(AppCompatActivity activity, ActionSheetConfig config) { var dlg = new AppCompatAlertDialog.Builder(activity, config.AndroidStyleId ?? 0) .SetTitle(config.Title); //.SetCustomTitle(new TextView(activity) { // Text = config.Title, // TextSize = 18.0f //}); if (config.ItemIcon != null || config.Options.Any(x => x.ItemIcon != null)) { var adapter = new ActionSheetListAdapter(activity, Android.Resource.Layout.SelectDialogItem, Android.Resource.Id.Text1, config); dlg.SetAdapter(adapter, (s, a) => config.Options[a.Which].Action?.Invoke()); } else { var array = config .Options .Select(x => x.Text) .ToArray(); dlg.SetItems(array, (s, args) => config.Options[args.Which].Action?.Invoke()); } if (config.Destructive != null) { dlg.SetNegativeButton(config.Destructive.Text, (s, a) => config.Destructive.Action?.Invoke()); } if (config.Cancel != null) { dlg.SetNeutralButton(config.Cancel.Text, (s, a) => config.Cancel.Action?.Invoke()); } return(dlg.Create()); }