예제 #1
0
        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();
            }
        }
    protected virtual void ConfigureDialogBuilder(AndroidX_AlertDialog.Builder builder)
    {
        if (ShouldConfigureToBuilder(nameof(Config.Title)))
        {
            builder.SetTitle(Config.Title);
        }

        if (ShouldConfigureToBuilder(nameof(Config.Message)))
        {
            builder.SetMessage(Config.Message);
        }
    }
예제 #3
0
            void OnPromptRequested(Page sender, PromptArguments arguments)
            {
                // Verify that the page making the request is part of this activity
                if (!PageIsInThisContext(sender))
                {
                    return;
                }

                AlertDialog alertDialog = new AlertDialog.Builder(Activity).Create();

                alertDialog.SetTitle(arguments.Title);
                alertDialog.SetMessage(arguments.Message);

                var frameLayout = new FrameLayout(Activity);
                var editText    = new EditText(Activity)
                {
                    Hint = arguments.Placeholder, Text = arguments.InitialValue
                };
                var layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)
                {
                    LeftMargin  = (int)(22 * Activity.Resources.DisplayMetrics.Density),
                    RightMargin = (int)(22 * Activity.Resources.DisplayMetrics.Density)
                };

                editText.LayoutParameters = layoutParams;
                editText.InputType        = arguments.Keyboard.ToInputType();
                if (arguments.Keyboard == Keyboard.Numeric)
                {
                    editText.KeyListener = LocalizedDigitsKeyListener.Create(editText.InputType);
                }

                if (arguments.MaxLength > -1)
                {
                    editText.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(arguments.MaxLength) });
                }

                frameLayout.AddView(editText);
                alertDialog.SetView(frameLayout);

                alertDialog.SetButton((int)DialogButtonType.Positive, arguments.Accept, (o, args) => arguments.SetResult(editText.Text));
                alertDialog.SetButton((int)DialogButtonType.Negative, arguments.Cancel, (o, args) => arguments.SetResult(null));
                alertDialog.CancelEvent += (o, args) => { arguments.SetResult(null); };

                alertDialog.Window.SetSoftInputMode(SoftInput.StateVisible);
                alertDialog.Show();
                editText.RequestFocus();
            }
예제 #4
0
 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();
         }
     }
 }
예제 #5
0
        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();
        }
예제 #6
0
            void OnAlertRequested(Page sender, AlertArguments arguments)
            {
                // Verify that the page making the request is part of this activity
                if (!PageIsInThisContext(sender))
                {
                    return;
                }

                AlertDialog alert = new AlertDialog.Builder(Activity).Create();

                alert.SetTitle(arguments.Title);
                alert.SetMessage(arguments.Message);
                if (arguments.Accept != null)
                {
                    alert.SetButton((int)DialogButtonType.Positive, arguments.Accept, (o, args) => arguments.SetResult(true));
                }
                alert.SetButton((int)DialogButtonType.Negative, arguments.Cancel, (o, args) => arguments.SetResult(false));
                alert.CancelEvent += (o, args) => { arguments.SetResult(false); };
                alert.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();
        }
예제 #8
0
            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();
                };
            }
예제 #9
0
        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));
        }