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(); } }
public static Task <JwtLoginCredentials> GetInputAsync(string title) { var context = GetContext(); var tcs = new TaskCompletionSource <JwtLoginCredentials>(); var result = new JwtLoginCredentials(); AlertDialog dialog = null; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetTitle(title); var viewInflated = LayoutInflater.From(context).Inflate(Resource.Layout.login_view, null, false); var userInput = viewInflated.FindViewById <AppCompatEditText>(Resource.Id.input_user); var passwordInput = viewInflated.FindViewById <AppCompatEditText>(Resource.Id.input_password); builder.SetView(viewInflated); builder.SetOnCancelListener(new DialogInterfaceOnCancelListener(() => tcs.TrySetResult(null))); builder.SetOnDismissListener(new DialogInterfaceOnDismissListener(() => tcs.TrySetResult(null))); builder.SetPositiveButton(Android.Resource.String.Ok, (sender, args) => { result.User = userInput.Text; result.Password = passwordInput.Text; tcs.TrySetResult(result); dialog.Dismiss(); }); builder.SetNegativeButton(Android.Resource.String.Cancel, (sender, args) => { tcs.TrySetResult(null); dialog.Cancel(); }); dialog = builder.Show(); return(tcs.Task); }
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(); }
public void SetPositiveButton(string text, EventHandler <DialogClickEventArgs> handler) { if (_useAppCompat) { _appcompatBuilder.SetPositiveButton(text, handler); } else { _legacyBuilder.SetPositiveButton(text, handler); } }
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 EnableDeviceAdmin_Click(object sender, EventArgs e) { if (Checkers.IsThisAppADeviceAdministrator()) { ComponentName devAdminReceiver = new ComponentName(Application.Context, Java.Lang.Class.FromType(typeof(AdminReceiver))); DevicePolicyManager dpm = (DevicePolicyManager)GetSystemService(Context.DevicePolicyService); dpm.RemoveActiveAdmin(devAdminReceiver); } else { using (AlertDialog.Builder builder = new AlertDialog.Builder(this)) { builder.SetMessage(Resource.String.dialogfordeviceaccessdescription); builder.SetPositiveButton(Resource.String.dialogallowbutton, new EventHandler <DialogClickEventArgs>(OnDialogPositiveButtonEventArgs)); builder.SetNegativeButton(Resource.String.dialogcancelbutton, null as EventHandler <DialogClickEventArgs>); builder.Show(); } } }
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(); }
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(); }
private void SetupDeleteButton(View deleteButton) { if (_mediaList == null) { deleteButton.Visibility = ViewStates.Gone; return; } deleteButton.Click += (sender, args) => { var confirmation = new AlertDialog.Builder(Activity, Activity.GetThemedResourceId(Resource.Attribute.Dialog_Theme)); confirmation.SetMessage( "Do you really wish to delete this item from your lists? This action CAN NOT be undone!"); confirmation.SetTitle($"Delete {_media.Title.UserPreferred}"); confirmation.SetNegativeButton("Cancel", (cancelSender, cancelArgs) => { }); confirmation.SetPositiveButton("Delete", async(delSender, delArgs) => await DeleteMediaListItem()); confirmation.Show(); }; }
public override bool OnOptionsItemSelected(IMenuItem item) { int id = item.ItemId; switch (id) { case Resource.Id.action_settings: using (Intent intent = new Intent(this, typeof(SettingsActivity))) { intent.AddFlags(ActivityFlags.NewDocument); StartActivity(intent); } return(true); case Resource.Id.action_sendtestnotification: if (isApplicationHealthy) { AwakeHelper.TurnOffScreen(); using (NotificationSlave slave = NotificationSlave.NotificationSlaveInstance()) { var notificationtext = Resources.GetString(Resource.String.testnotificationtext); if (Build.VERSION.SdkInt > BuildVersionCodes.NMr1) { slave.PostNotification(7, "LiveDisplay", notificationtext, true, NotificationImportance.Max); } else { slave.PostNotification(1, "LiveDisplay", notificationtext, true, NotificationPriority.Max); } //NotificationSlave.SendDumbNotification(); } using (Intent intent = new Intent(Application.Context, typeof(LockScreenActivity))) { StartActivity(intent); return(true); } } else { Toast.MakeText(Application.Context, "You dont have the required permissions yet", ToastLength.Long).Show(); } break; case Resource.Id.action_help: using (AlertDialog.Builder builder = new AlertDialog.Builder(this)) { builder.SetMessage(Resource.String.helptext); builder.SetPositiveButton("ok, cool", null as EventHandler <DialogClickEventArgs>); builder.Show(); } break; default: break; } return(base.OnOptionsItemSelected(item)); }