示例#1
0
            private void TagsButton_Click(object sender, EventArgs e)
            {
                var dialog = new AlertDialog.Builder(_context,
                                                     _context.GetThemedResourceId(Resource.Attribute.Dialog_Theme)).Create();
                var dialogView = _context.LayoutInflater.Inflate(Resource.Layout.View_List, null);
                var recycler   = dialogView.FindViewById <RecyclerView>(Resource.Id.List_RecyclerView);

                dialog.SetView(dialogView);

                var tags = _presenter.GetMediaTags().OrderBy(x => x.Name).Select(x =>
                                                                                 new CheckBoxItemRecyclerAdapter.CheckBoxItem
                {
                    Title       = x.Name,
                    Description = x.Description,
                    IsChecked   = _selectedTags?.Any(y => y == x.Name) == true
                }).ToList();

                var adapter = new CheckBoxItemRecyclerAdapter(_context, tags)
                {
                    ToggleDescription = true
                };

                recycler.SetAdapter(adapter);

                dialog.Show();

                dialog.DismissEvent += (disSender, disArgs) =>
                {
                    _selectedTags = adapter.Items.Where(x => x.IsChecked).Select(x => x.Title).ToList();
                    SetupTagsButton(_tagsButton);
                };
            }
示例#2
0
            private void StreamingOnButton_Click(object sender, EventArgs e)
            {
                var dialog = new AlertDialog.Builder(_context,
                                                     _context.GetThemedResourceId(Resource.Attribute.Dialog_Theme)).Create();
                var dialogView = _context.LayoutInflater.Inflate(Resource.Layout.View_List, null);
                var recycler   = dialogView.FindViewById <RecyclerView>(Resource.Id.List_RecyclerView);

                dialog.SetView(dialogView);


                var licensees = AniListEnum.GetEnumValues <MediaLicensee>().Select(x =>
                                                                                   new CheckBoxItemRecyclerAdapter.CheckBoxItem
                {
                    Title     = x.DisplayValue,
                    IsChecked = _selectedStreamingOn?.Any(y => y == x.DisplayValue) == true
                }).ToList();

                var adapter = new CheckBoxItemRecyclerAdapter(_context, licensees);

                recycler.SetAdapter(adapter);

                dialog.Show();

                dialog.DismissEvent += (disSender, disArgs) =>
                {
                    _selectedStreamingOn = adapter.Items.Where(x => x.IsChecked).Select(x => x.Title).ToList();
                    SetupStreamingOnButton(_streamingOnButton);
                };
            }
示例#3
0
        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);
        }
示例#4
0
            private void GenresButton_Click(object sender, EventArgs e)
            {
                var dialog = new AlertDialog.Builder(_context,
                                                     _context.GetThemedResourceId(Resource.Attribute.Dialog_Theme)).Create();
                var dialogView = _context.LayoutInflater.Inflate(Resource.Layout.View_List, null);
                var recycler   = dialogView.FindViewById <RecyclerView>(Resource.Id.List_RecyclerView);

                dialog.SetView(dialogView);

                var genres = _genres.OrderBy(x => x).Select(x =>
                                                            new CheckBoxItemRecyclerAdapter.CheckBoxItem
                {
                    Title     = x,
                    IsChecked = _selectedGenres?.Any(y => y == x) == true
                }).ToList();

                var adapter = new CheckBoxItemRecyclerAdapter(_context, genres);

                recycler.SetAdapter(adapter);

                dialog.Show();

                dialog.DismissEvent += (disSender, disArgs) =>
                {
                    _selectedGenres = adapter.Items.Where(x => x.IsChecked).Select(x => x.Title).ToList();
                    SetupGenresButton(_genresButton);
                };
            }
示例#5
0
        public void ShowMessageDialog(string title, string message)
        {
            AlertDialog ad = new AlertDialog.Builder(this)
                             .SetTitle(title)
                             .SetMessage(message)
                             .Create();

            ad.Show();
        }
示例#6
0
        public void OnReceiveMessage(string message)
        {
            System.Diagnostics.Debug.WriteLine($"{nameof(OnReceiveMessage)}");

            var alert = new AlertDialog.Builder(this)
                        .SetTitle("Message")
                        .SetMessage(message)
                        .SetPositiveButton("OK", (sender, args) => { })
                        .Create();

            alert.Show();
        }
示例#7
0
        private async Task Init()
        {
            var cameraStatus = await Permissions.RequestAsync <Permissions.Camera>();

            var micStatus = await Permissions.RequestAsync <Permissions.Microphone>();

            _webRtcClient = new WebRtcClient(this, _remoteView, _localView, this);

            var dialogTcs = new TaskCompletionSource <string>();

            var linearLayout = new LinearLayout(this);

            linearLayout.Orientation = Orientation.Vertical;
            linearLayout.SetPadding(48, 24, 48, 24);
            var ipAddr = new EditText(this)
            {
                Hint = "IP Address", Text = "192.168.1.119"
            };
            var port = new EditText(this)
            {
                Hint = "Port", Text = "8080"
            };

            linearLayout.AddView(ipAddr);
            linearLayout.AddView(port);

            var alert = new AlertDialog.Builder(this)
                        .SetTitle("Socket Address")
                        .SetView(linearLayout)
                        .SetPositiveButton("OK", (sender, args) =>
            {
                dialogTcs.TrySetResult($"ws://{ipAddr.Text}:{port.Text}");
            })
                        .Create();

            alert.Show();

            var wsUrl = await dialogTcs.Task;

            var okHttpClient = new OkHttpClient.Builder()
                               .ReadTimeout(0, Java.Util.Concurrent.TimeUnit.Milliseconds)
                               .Build();
            var request = new Request.Builder()
                          .Url(wsUrl)
                          .Build();

            _socket = okHttpClient.NewWebSocket(
                request,
                new WebSocketObserver(ReadMessage));
        }
示例#8
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();
            }
示例#9
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();
         }
     }
 }
示例#10
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();
            }
示例#11
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();
                };
            }
示例#12
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));
        }