Example #1
0
        public async void ShowBackgroundActivityDialog()
        {
            if (await _viewModel.IsRunning())
            {
                string messageCombined = INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_MESSAGE_PART1 + "\n\n" +
                                         INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_MESSAGE_PART2 + "\n\n" +
                                         INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_MESSAGE_PART3;
                View     dialogView  = LayoutInflater.Inflate(Resource.Layout.background_activity_dialog, null);
                TextView headerText  = dialogView.FindViewById <TextView>(Resource.Id.background_activity_dialog_header);
                TextView messageText = dialogView.FindViewById <TextView>(Resource.Id.background_activity_dialog_message);
                headerText.Text      = INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_TITLE;
                messageText.Text     = messageCombined;
                _positiveButton      = dialogView.FindViewById <Button>(Resource.Id.background_activity_dialog_button_yes);
                _negativeButton      = dialogView.FindViewById <Button>(Resource.Id.background_activity_dialog_button_no);
                _dontShowButton      = dialogView.FindViewById <Button>(Resource.Id.background_activity_dialog_button_dont_show);
                _positiveButton.Text = INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_OK_BUTTON.ToUpper();
                _negativeButton.Text = INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_NOK_BUTTON.ToUpper();
                _dontShowButton.Text = INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_DONT_SHOW_BUTTON.ToUpper();

                AlertDialog builder = new AlertDialog.Builder(this)
                                      .SetView(dialogView)
                                      .SetCancelable(false)
                                      .Create();
                SetIsBackgroundActivityDialogShowEnableNewUser(false);
                _positiveButton.Click += new SingleClick((sender, args) =>
                {
                    StopBatteryOptimizationSetting(this);
                    builder.Dismiss();
                }).Run;
                _negativeButton.Click += new SingleClick((sender, args) =>
                {
                    IsAppLaunchedToShowDialog = false;
                    builder.Dismiss();
                }).Run;

                _dontShowButton.Click += new SingleClick((sender, args) =>
                {
                    SetIsBackgroundActivityDialogShowEnable(false);
                    builder.Dismiss();
                }).Run;
                builder.Show();
                AdjustLines(_dontShowButton, _positiveButton, _negativeButton);
            }
        }