Ejemplo n.º 1
0
        private async void ShowDebugString()
        {
            var result = await VoIPConnection.Current.GetDebugStringAsync();

            if (result != null && result.Item1 != null)
            {
                var text = new TextBlock();
                text.Text   = result.Item1;
                text.Margin = new Thickness(12, 16, 12, 0);
                text.Style  = Application.Current.Resources["BodyTextBlockStyle"] as Style;

                var scroll = new ScrollViewer();
                scroll.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                scroll.VerticalScrollMode          = ScrollMode.Auto;
                scroll.Content = text;

                var dialog = new ContentDialog {
                    Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style
                };
                dialog.Title             = $"libtgvoip v{result.Item2}";
                dialog.Content           = scroll;
                dialog.PrimaryButtonText = "OK";
                dialog.Closed           += (s, args) =>
                {
                    _debugDialog = null;
                    _debugTimer.Stop();
                };

                _debugDialog = dialog;
                _debugTimer.Start();

                await dialog.ShowQueuedAsync();
            }
        }
Ejemplo n.º 2
0
        private async void Verbosity_Click(object sender, RoutedEventArgs e)
        {
            var level = SettingsService.Current.VerbosityLevel;

            var dialog = new ContentDialog {
                Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style
            };
            var stack = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = 0, Content = "Assert", IsChecked = level == 0
            });
            stack.Children.Add(new RadioButton {
                Tag = 1, Content = "Error", IsChecked = level == 1
            });
            stack.Children.Add(new RadioButton {
                Tag = 2, Content = "Warning", IsChecked = level == 2
            });
            stack.Children.Add(new RadioButton {
                Tag = 3, Content = "Info", IsChecked = level == 3
            });
            stack.Children.Add(new RadioButton {
                Tag = 4, Content = "Debug", IsChecked = level == 4
            });
            stack.Children.Add(new RadioButton {
                Tag = 5, Content = "Verbose", IsChecked = level == 5
            });

            dialog.Title               = "Verbosity Level";
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var newLevel = 1;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        newLevel = (int)current.Tag;
                        break;
                    }
                }

                SettingsService.Current.VerbosityLevel = newLevel;
                Telegram.Td.Log.SetVerbosityLevel(newLevel);

                Verbosity.Badge = Enum.GetName(typeof(VerbosityLevel), (VerbosityLevel)SettingsService.Current.VerbosityLevel);
            }
        }
        private async void ClearPaymentsExecute()
        {
            var dialog = new ContentDialog {
                Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style
            };
            var stack         = new StackPanel();
            var checkShipping = new CheckBox {
                Content = Strings.Resources.PrivacyClearShipping, IsChecked = true
            };
            var checkPayment = new CheckBox {
                Content = Strings.Resources.PrivacyClearPayment, IsChecked = true
            };

            var toggle = new RoutedEventHandler((s, args) =>
            {
                dialog.IsPrimaryButtonEnabled = checkShipping.IsChecked == true || checkPayment.IsChecked == true;
            });

            checkShipping.Checked   += toggle;
            checkShipping.Unchecked += toggle;
            checkPayment.Checked    += toggle;
            checkPayment.Unchecked  += toggle;

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(checkShipping);
            stack.Children.Add(checkPayment);

            dialog.Title               = Strings.Resources.PrivacyPayments;
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.ClearButton;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var info       = checkShipping.IsChecked == true;
                var credential = checkPayment.IsChecked == true;

                if (info)
                {
                    ProtoService.Send(new DeleteSavedOrderInfo());
                }

                if (credential)
                {
                    ProtoService.Send(new DeleteSavedCredentials());
                }
            }
        }
Ejemplo n.º 4
0
        private async void AutolockExecute()
        {
            var timeout = AutolockTimeout + 0;

            var dialog = new ContentDialog {
                Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style
            };
            var stack = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = 0, Content = LocaleHelper.FormatAutoLock(0), IsChecked = timeout == 0
            });
            stack.Children.Add(new RadioButton {
                Tag = 1 * 60, Content = LocaleHelper.FormatAutoLock(1 * 60), IsChecked = timeout == 1 * 60
            });
            stack.Children.Add(new RadioButton {
                Tag = 5 * 60, Content = LocaleHelper.FormatAutoLock(5 * 60), IsChecked = timeout == 5 * 60
            });
            stack.Children.Add(new RadioButton {
                Tag = 1 * 60 * 60, Content = LocaleHelper.FormatAutoLock(1 * 60 * 60), IsChecked = timeout == 1 * 60 * 60
            });
            stack.Children.Add(new RadioButton {
                Tag = 5 * 60 * 60, Content = LocaleHelper.FormatAutoLock(5 * 60 * 60), IsChecked = timeout == 5 * 60 * 60
            });

            dialog.Title               = Strings.Android.AutoLock;
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Android.OK;
            dialog.SecondaryButtonText = Strings.Android.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var mode = 1;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        mode = (int)current.Tag;
                        break;
                    }
                }

                AutolockTimeout = mode;
                InactivityHelper.Initialize(mode);
            }
        }
Ejemplo n.º 5
0
        private async void ChangeTtlExecute()
        {
            var enabled = CacheService.GetOption <OptionValueBoolean>("use_storage_optimizer")?.Value ?? false;
            var ttl     = CacheService.GetOption <OptionValueInteger>("storage_max_time_from_last_access")?.Value ?? 0;

            var dialog = new ContentDialog {
                Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style
            };
            var stack = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = 3, Content = Locale.Declension("Days", 3), IsChecked = enabled && ttl == 3 * 60 * 60 * 24
            });
            stack.Children.Add(new RadioButton {
                Tag = 7, Content = Locale.Declension("Weeks", 1), IsChecked = enabled && ttl == 7 * 60 * 60 * 24
            });
            stack.Children.Add(new RadioButton {
                Tag = 30, Content = Locale.Declension("Months", 1), IsChecked = enabled && ttl == 30 * 60 * 60 * 24
            });
            stack.Children.Add(new RadioButton {
                Tag = 0, Content = Strings.Resources.KeepMediaForever, IsChecked = !enabled
            });

            dialog.Title               = Strings.Resources.KeepMedia;
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var mode = 0;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        mode = (int)current.Tag;
                        break;
                    }
                }

                ProtoService.Send(new SetOption("storage_max_time_from_last_access", new OptionValueInteger(mode * 60 * 60 * 24)));
                ProtoService.Send(new SetOption("use_storage_optimizer", new OptionValueBoolean(mode > 0)));

                RaisePropertyChanged(() => FilesTtl);
            }
        }
        public static async Task<ContentDialogResult> NavigateModalAsync(this INavigationService service, ContentDialog dialog)
        {
            var viewModel = dialog.DataContext as INavigable;
            if (viewModel != null)
            {
                viewModel.NavigationService = service;
                dialog.Opened += async (s, args) =>
                {
                    await viewModel.OnNavigatedToAsync(null, NavigationMode.New, null);
                };
            }

            _currentDialog = dialog;
            return await dialog.ShowQueuedAsync();
        }
        private async void ClearPaymentsExecute()
        {
            var dialog        = new ContentDialog();
            var stack         = new StackPanel();
            var checkShipping = new CheckBox {
                Content = "Shipping info", IsChecked = true
            };
            var checkPayment = new CheckBox {
                Content = "Payment info", IsChecked = true
            };

            var toggle = new RoutedEventHandler((s, args) =>
            {
                dialog.IsPrimaryButtonEnabled = checkShipping.IsChecked == true || checkPayment.IsChecked == true;
            });

            checkShipping.Checked   += toggle;
            checkShipping.Unchecked += toggle;
            checkPayment.Checked    += toggle;
            checkPayment.Unchecked  += toggle;

            stack.Margin = new Thickness(0, 16, 0, 0);
            stack.Children.Add(checkShipping);
            stack.Children.Add(checkPayment);

            dialog.Title               = "Payments";
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = "Clear";
            dialog.SecondaryButtonText = "Cancel";

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var info       = checkShipping.IsChecked == true;
                var credential = checkPayment.IsChecked == true;
                var response   = await ProtoService.ClearSavedInfoAsync(info, credential);

                if (response.IsSucceeded)
                {
                }
                else
                {
                }
            }
        }
Ejemplo n.º 8
0
        private async void ChangeTtlExecute()
        {
            var dialog = new ContentDialog {
                Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style
            };
            var stack = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = 3, Content = Locale.Declension("Days", 3), IsChecked = FilesTtl == 3
            });
            stack.Children.Add(new RadioButton {
                Tag = 7, Content = Locale.Declension("Weeks", 1), IsChecked = FilesTtl == 7
            });
            stack.Children.Add(new RadioButton {
                Tag = 30, Content = Locale.Declension("Months", 1), IsChecked = FilesTtl == 30
            });
            stack.Children.Add(new RadioButton {
                Tag = 0, Content = Strings.Resources.KeepMediaForever, IsChecked = FilesTtl == 0
            });

            dialog.Title               = Strings.Resources.KeepMedia;
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var mode = 1;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        mode = (int)current.Tag;
                        break;
                    }
                }

                FilesTtl = mode;
            }
        }
        private async void PeerToPeerExecute()
        {
            var dialog = new ContentDialog {
                Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style
            };
            var stack = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = 0, Content = Strings.Android.LastSeenEverybody, IsChecked = PeerToPeerMode == 0
            });
            stack.Children.Add(new RadioButton {
                Tag = 1, Content = Strings.Android.LastSeenContacts, IsChecked = PeerToPeerMode == 1
            });
            stack.Children.Add(new RadioButton {
                Tag = 2, Content = Strings.Android.LastSeenNobody, IsChecked = PeerToPeerMode == 2
            });

            dialog.Title               = Strings.Android.PrivacyCallsP2PTitle;
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Android.OK;
            dialog.SecondaryButtonText = Strings.Android.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var mode = 1;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        mode = (int)current.Tag;
                        break;
                    }
                }

                PeerToPeerMode = mode;
            }
        }
Ejemplo n.º 10
0
        private async void SuggestExecute()
        {
            var dialog = new ContentDialog {
                Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style
            };
            var stack = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = StickersSuggestionMode.All, Content = Strings.Resources.SuggestStickersAll, IsChecked = SuggestStickers == StickersSuggestionMode.All
            });
            stack.Children.Add(new RadioButton {
                Tag = StickersSuggestionMode.Installed, Content = Strings.Resources.SuggestStickersInstalled, IsChecked = SuggestStickers == StickersSuggestionMode.Installed
            });
            stack.Children.Add(new RadioButton {
                Tag = StickersSuggestionMode.None, Content = Strings.Resources.SuggestStickersNone, IsChecked = SuggestStickers == StickersSuggestionMode.None
            });

            dialog.Title               = Strings.Resources.SuggestStickers;
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var mode = StickersSuggestionMode.All;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        mode = (StickersSuggestionMode)current.Tag;
                        break;
                    }
                }

                SuggestStickers = mode;
            }
        }
        private async void UseLessDataExecute()
        {
            var dialog = new ContentDialog {
                Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style
            };
            var stack = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = 0, Content = Strings.Resources.UseLessDataNever, IsChecked = UseLessData == libtgvoip.DataSavingMode.Never
            });
            stack.Children.Add(new RadioButton {
                Tag = 1, Content = Strings.Resources.UseLessDataOnMobile, IsChecked = UseLessData == libtgvoip.DataSavingMode.MobileOnly
            });
            stack.Children.Add(new RadioButton {
                Tag = 2, Content = Strings.Resources.UseLessDataAlways, IsChecked = UseLessData == libtgvoip.DataSavingMode.Always
            });

            dialog.Title               = Strings.Resources.VoipUseLessData;
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var mode = 1;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        mode = (int)current.Tag;
                        break;
                    }
                }

                UseLessData = (libtgvoip.DataSavingMode)mode;
            }
        }
        private async void AccountTTLExecute()
        {
            var dialog = new ContentDialog {
                Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style
            };
            var stack = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = 30, Content = LocaleHelper.Declension("Months", 1)
            });
            stack.Children.Add(new RadioButton {
                Tag = 90, Content = LocaleHelper.Declension("Months", 3)
            });
            stack.Children.Add(new RadioButton {
                Tag = 180, Content = LocaleHelper.Declension("Months", 6)
            });
            stack.Children.Add(new RadioButton {
                Tag = 365, Content = LocaleHelper.Declension("Years", 1)
            });

            RadioButton GetSelectedPeriod(UIElementCollection periods, RadioButton defaultPeriod)
            {
                if (_accountTTL == 0)
                {
                    return(stack.Children[2] as RadioButton);
                }

                RadioButton period = null;

                var max = 2147483647;

                foreach (RadioButton current in stack.Children)
                {
                    var days = (int)current.Tag;
                    int abs  = Math.Abs(_accountTTL - days);
                    if (abs < max)
                    {
                        max    = abs;
                        period = current;
                    }
                }

                return(period ?? stack.Children[2] as RadioButton);
            };

            var selected = GetSelectedPeriod(stack.Children, stack.Children[2] as RadioButton);

            if (selected != null)
            {
                selected.IsChecked = true;
            }

            dialog.Title               = Strings.Android.DeleteAccountTitle;
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Android.OK;
            dialog.SecondaryButtonText = Strings.Android.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var days = 180;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        days = (int)current.Tag;
                        break;
                    }
                }

                var response = await ProtoService.SetAccountTTLAsync(new TLAccountDaysTTL { Days = days });

                if (response.IsSucceeded)
                {
                    AccountTTL = days;
                }
                else
                {
                }
            }
        }
Ejemplo n.º 13
0
        private async void ReportExecute()
        {
            var user = Item as TLUser;

            if (user != null)
            {
                var opt1 = new RadioButton {
                    Content = Strings.Android.ReportChatSpam, Margin = new Thickness(0, 8, 0, 8), HorizontalAlignment = HorizontalAlignment.Stretch
                };
                var opt2 = new RadioButton {
                    Content = Strings.Android.ReportChatViolence, Margin = new Thickness(0, 8, 0, 8), HorizontalAlignment = HorizontalAlignment.Stretch
                };
                var opt3 = new RadioButton {
                    Content = Strings.Android.ReportChatPornography, Margin = new Thickness(0, 8, 0, 8), HorizontalAlignment = HorizontalAlignment.Stretch
                };
                var opt4 = new RadioButton {
                    Content = Strings.Android.ReportChatOther, Margin = new Thickness(0, 8, 0, 8), HorizontalAlignment = HorizontalAlignment.Stretch, IsChecked = true
                };
                var stack = new StackPanel();
                stack.Children.Add(opt1);
                stack.Children.Add(opt2);
                stack.Children.Add(opt3);
                stack.Children.Add(opt4);
                stack.Margin = new Thickness(12, 16, 12, 0);

                var dialog = new ContentDialog {
                    Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style
                };
                dialog.Content = stack;
                dialog.Title   = Strings.Android.ReportChat;
                dialog.IsPrimaryButtonEnabled   = true;
                dialog.IsSecondaryButtonEnabled = true;
                dialog.PrimaryButtonText        = Strings.Android.OK;
                dialog.SecondaryButtonText      = Strings.Android.Cancel;

                var dialogResult = await dialog.ShowQueuedAsync();

                if (dialogResult == ContentDialogResult.Primary)
                {
                    var reason = opt1.IsChecked == true
                        ? new TLInputReportReasonSpam()
                        : (opt2.IsChecked == true
                            ? new TLInputReportReasonViolence()
                            : (opt3.IsChecked == true
                                ? new TLInputReportReasonPornography()
                                : (TLReportReasonBase) new TLInputReportReasonOther()));

                    if (reason is TLInputReportReasonOther other)
                    {
                        var input = new InputDialog();
                        input.Title                    = Strings.Android.ReportChat;
                        input.PlaceholderText          = Strings.Android.ReportChatDescription;
                        input.IsPrimaryButtonEnabled   = true;
                        input.IsSecondaryButtonEnabled = true;
                        input.PrimaryButtonText        = Strings.Android.OK;
                        input.SecondaryButtonText      = Strings.Android.Cancel;

                        var inputResult = await input.ShowQueuedAsync();

                        if (inputResult == ContentDialogResult.Primary)
                        {
                            other.Text = input.Text;
                        }
                        else
                        {
                            return;
                        }
                    }

                    var result = await ProtoService.ReportPeerAsync(user.ToInputPeer(), reason);

                    if (result.IsSucceeded && result.Result)
                    {
                        await new TLMessageDialog("Resources.ReportSpamNotification", "Unigram").ShowQueuedAsync();
                    }
                }
            }
        }
        private async void DownloadLocationExecute()
        {
            var dialog = new ContentDialog {
                Style = BootStrapper.Current.Resources["ModernContentDialogStyle"] as Style
            };
            var stack = new StackPanel();

            stack.Margin = new Thickness(12, 16, 12, 0);
            stack.Children.Add(new RadioButton {
                Tag = 1, Content = "Temp folder, cleared on logout or uninstall", IsChecked = FilesDirectory == null
            });
            stack.Children.Add(new RadioButton {
                Tag = 2, Content = "Custom folder, cleared only manually", IsChecked = FilesDirectory != null
            });

            dialog.Title               = "Choose download location";
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = Strings.Resources.OK;
            dialog.SecondaryButtonText = Strings.Resources.Cancel;

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var mode = 1;
                var path = FilesDirectory + string.Empty;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        mode = (int)current.Tag;
                        break;
                    }
                }

                switch (mode)
                {
                case 0:
                    break;

                case 1:
                    FilesDirectory = null;
                    break;

                case 2:
                    var picker = new FolderPicker();
                    picker.SuggestedStartLocation = PickerLocationId.Downloads;
                    picker.FileTypeFilter.Add("*");

                    var folder = await picker.PickSingleFolderAsync();

                    if (folder != null)
                    {
                        StorageApplicationPermissions.FutureAccessList.AddOrReplace("FilesDirectory", folder);
                        FilesDirectory = folder.Path;
                    }

                    break;
                }

                if (string.Equals(path, FilesDirectory, StringComparison.OrdinalIgnoreCase))
                {
                    return;
                }

                ProtoService.Send(new Close());
            }
        }
Ejemplo n.º 15
0
        private async void ReportExecute()
        {
            var user = Item as TLUser;

            if (user != null)
            {
                var opt1 = new RadioButton {
                    Content = "Spam", Margin = new Thickness(0, 8, 0, 8), HorizontalAlignment = HorizontalAlignment.Stretch
                };
                var opt2 = new RadioButton {
                    Content = "Violence", Margin = new Thickness(0, 8, 0, 8), HorizontalAlignment = HorizontalAlignment.Stretch
                };
                var opt3 = new RadioButton {
                    Content = "Pornography", Margin = new Thickness(0, 8, 0, 8), HorizontalAlignment = HorizontalAlignment.Stretch
                };
                var opt4 = new RadioButton {
                    Content = "Other", Margin = new Thickness(0, 8, 0, 8), HorizontalAlignment = HorizontalAlignment.Stretch, IsChecked = true
                };
                var stack = new StackPanel();
                stack.Children.Add(opt1);
                stack.Children.Add(opt2);
                stack.Children.Add(opt3);
                stack.Children.Add(opt4);
                stack.Margin = new Thickness(0, 16, 0, 0);
                var dialog = new ContentDialog();
                dialog.Content = stack;
                dialog.Title   = "Resources.Report";
                dialog.IsPrimaryButtonEnabled   = true;
                dialog.IsSecondaryButtonEnabled = true;
                dialog.PrimaryButtonText        = "Resources.OK";
                dialog.SecondaryButtonText      = "Resources.Cancel";

                var dialogResult = await dialog.ShowQueuedAsync();

                if (dialogResult == ContentDialogResult.Primary)
                {
                    var reason = opt1.IsChecked == true
                        ? new TLInputReportReasonSpam()
                        : (opt2.IsChecked == true
                            ? new TLInputReportReasonViolence()
                            : (opt3.IsChecked == true
                                ? new TLInputReportReasonPornography()
                                : (TLReportReasonBase) new TLInputReportReasonOther()));

                    if (reason.TypeId == TLType.InputReportReasonOther)
                    {
                        var input = new InputDialog();
                        input.Title                    = "Resources.Report";
                        input.PlaceholderText          = "Resources.Description";
                        input.IsPrimaryButtonEnabled   = true;
                        input.IsSecondaryButtonEnabled = true;
                        input.PrimaryButtonText        = "Resources.OK";
                        input.SecondaryButtonText      = "Resources.Cancel";

                        var inputResult = await input.ShowQueuedAsync();

                        if (inputResult == ContentDialogResult.Primary)
                        {
                            reason = new TLInputReportReasonOther {
                                Text = input.Text
                            };
                        }
                        else
                        {
                            return;
                        }
                    }

                    var result = await ProtoService.ReportPeerAsync(user.ToInputPeer(), reason);

                    if (result.IsSucceeded && result.Result)
                    {
                        await new TLMessageDialog("Resources.ReportSpamNotification", "Unigram").ShowQueuedAsync();
                    }
                }
            }
        }
        private async void AccountTTLExecute()
        {
            var dialog = new ContentDialog();
            var stack  = new StackPanel();

            stack.Margin = new Thickness(0, 16, 0, 0);
            stack.Children.Add(new RadioButton {
                Tag = 30, Content = Language.Declension(1, AppResources.MonthNominativeSingular, AppResources.MonthNominativePlural, AppResources.MonthGenitiveSingular, AppResources.MonthGenitivePlural, null, null)
            });
            stack.Children.Add(new RadioButton {
                Tag = 90, Content = Language.Declension(3, AppResources.MonthNominativeSingular, AppResources.MonthNominativePlural, AppResources.MonthGenitiveSingular, AppResources.MonthGenitivePlural, null, null)
            });
            stack.Children.Add(new RadioButton {
                Tag = 180, Content = Language.Declension(6, AppResources.MonthNominativeSingular, AppResources.MonthNominativePlural, AppResources.MonthGenitiveSingular, AppResources.MonthGenitivePlural, null, null)
            });
            stack.Children.Add(new RadioButton {
                Tag = 365, Content = Language.Declension(1, AppResources.YearNominativeSingular, AppResources.YearNominativePlural, AppResources.YearGenitiveSingular, AppResources.YearGenitivePlural, null, null)
            });

            RadioButton GetSelectedPeriod(UIElementCollection periods, RadioButton defaultPeriod)
            {
                if (_accountTTL == 0)
                {
                    return(stack.Children[2] as RadioButton);
                }

                RadioButton period = null;

                var max = 2147483647;

                foreach (RadioButton current in stack.Children)
                {
                    var days = (int)current.Tag;
                    int abs  = Math.Abs(_accountTTL - days);
                    if (abs < max)
                    {
                        max    = abs;
                        period = current;
                    }
                }

                return(period ?? stack.Children[2] as RadioButton);
            };

            var selected = GetSelectedPeriod(stack.Children, stack.Children[2] as RadioButton);

            if (selected != null)
            {
                selected.IsChecked = true;
            }

            dialog.Title               = "Account self-destructs";
            dialog.Content             = stack;
            dialog.PrimaryButtonText   = "OK";
            dialog.SecondaryButtonText = "Cancel";

            var confirm = await dialog.ShowQueuedAsync();

            if (confirm == ContentDialogResult.Primary)
            {
                var days = 180;
                foreach (RadioButton current in stack.Children)
                {
                    if (current.IsChecked == true)
                    {
                        days = (int)current.Tag;
                        break;
                    }
                }

                var response = await ProtoService.SetAccountTTLAsync(new TLAccountDaysTTL { Days = days });

                if (response.IsSucceeded)
                {
                    AccountTTL = days;
                }
                else
                {
                }
            }
        }