示例#1
0
        private void Init()
        {
            WebsiteIconsCell = new ExtendedSwitchCell
            {
                Text = AppResources.DisableWebsiteIcons,
                On   = _appSettings.DisableWebsiteIcons
            };

            var websiteIconsTable = new FormTableView(this, true)
            {
                Root = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        WebsiteIconsCell
                    }
                }
            };

            CopyTotpCell = new ExtendedSwitchCell
            {
                Text = AppResources.DisableAutoTotpCopy,
                On   = _settings.GetValueOrDefault(Constants.SettingDisableTotpCopy, false)
            };

            var totpTable = new FormTableView(this)
            {
                Root = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        CopyTotpCell
                    }
                }
            };

            CopyTotpLabel = new FormTableLabel(this)
            {
                Text = AppResources.DisableAutoTotpCopyDescription
            };

            WebsiteIconsLabel = new FormTableLabel(this)
            {
                Text = AppResources.DisableWebsiteIconsDescription
            };

            StackLayout = new RedrawableStackLayout
            {
                Children =
                {
                    websiteIconsTable, WebsiteIconsLabel,
                    totpTable,         CopyTotpLabel
                },
                Spacing = 0
            };

            if (Device.RuntimePlatform == Device.Android)
            {
                AutofillAlwaysCell = new ExtendedSwitchCell
                {
                    Text = AppResources.AutofillAlways,
                    On   = !_appSettings.AutofillPersistNotification && !_appSettings.AutofillPasswordField
                };

                var autofillAlwaysTable = new FormTableView(this, true)
                {
                    Root = new TableRoot
                    {
                        new TableSection(AppResources.AutofillAccessibilityService)
                        {
                            AutofillAlwaysCell
                        }
                    }
                };

                AutofillAlwaysLabel = new FormTableLabel(this)
                {
                    Text = AppResources.AutofillAlwaysDescription
                };

                AutofillPersistNotificationCell = new ExtendedSwitchCell
                {
                    Text = AppResources.AutofillPersistNotification,
                    On   = _appSettings.AutofillPersistNotification
                };

                var autofillPersistNotificationTable = new FormTableView(this)
                {
                    Root = new TableRoot
                    {
                        new TableSection(Helpers.GetEmptyTableSectionTitle())
                        {
                            AutofillPersistNotificationCell
                        }
                    }
                };

                AutofillPersistNotificationLabel = new FormTableLabel(this)
                {
                    Text = AppResources.AutofillPersistNotificationDescription
                };

                AutofillPasswordFieldCell = new ExtendedSwitchCell
                {
                    Text = AppResources.AutofillPasswordField,
                    On   = _appSettings.AutofillPasswordField
                };

                var autofillPasswordFieldTable = new FormTableView(this)
                {
                    Root = new TableRoot
                    {
                        new TableSection(Helpers.GetEmptyTableSectionTitle())
                        {
                            AutofillPasswordFieldCell
                        }
                    }
                };

                AutofillPasswordFieldLabel = new FormTableLabel(this)
                {
                    Text = AppResources.AutofillPasswordFieldDescription
                };

                StackLayout.Children.Add(autofillAlwaysTable);
                StackLayout.Children.Add(AutofillAlwaysLabel);
                StackLayout.Children.Add(autofillPasswordFieldTable);
                StackLayout.Children.Add(AutofillPasswordFieldLabel);
                StackLayout.Children.Add(autofillPersistNotificationTable);
                StackLayout.Children.Add(AutofillPersistNotificationLabel);
            }

            var scrollView = new ScrollView
            {
                Content = StackLayout
            };

            if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.UWP)
            {
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
            }

            Title   = AppResources.Options;
            Content = scrollView;
        }
示例#2
0
        private void Init()
        {
            SubscribeYubiKey(true);
            if (_providers.Count > 1)
            {
                var sendEmailTask = SendEmailAsync(false);
            }

            ToolbarItems.Clear();
            var scrollView = new ScrollView();

            var anotherMethodButton = new ExtendedButton
            {
                Text            = AppResources.UseAnotherTwoStepMethod,
                Style           = (Style)Application.Current.Resources["btn-primaryAccent"],
                Margin          = new Thickness(15, 0, 15, 25),
                Command         = new Command(() => AnotherMethodAsync()),
                Uppercase       = false,
                BackgroundColor = Color.Transparent,
                VerticalOptions = LayoutOptions.Start
            };

            var instruction = new Label
            {
                LineBreakMode           = LineBreakMode.WordWrap,
                Margin                  = new Thickness(15),
                HorizontalTextAlignment = TextAlignment.Center
            };

            RememberCell = new ExtendedSwitchCell
            {
                Text = AppResources.RememberMe,
                On   = false
            };

            if (!_providerType.HasValue)
            {
                instruction.Text = AppResources.NoTwoStepAvailable;

                var layout = new StackLayout
                {
                    Children = { instruction, anotherMethodButton },
                    Spacing  = 0
                };

                scrollView.Content = layout;

                Title   = AppResources.LoginUnavailable;
                Content = scrollView;
            }
            else if (_providerType.Value == TwoFactorProviderType.Authenticator ||
                     _providerType.Value == TwoFactorProviderType.Email)
            {
                var continueToolbarItem = new ToolbarItem(AppResources.Continue, Helpers.ToolbarImage("login.png"), async() =>
                {
                    var token = TokenCell?.Entry.Text.Trim().Replace(" ", "");
                    await LogInAsync(token);
                }, ToolbarItemOrder.Default, 0);

                var padding = Helpers.OnPlatform(
                    iOS: new Thickness(15, 20),
                    Android: new Thickness(15, 8),
                    Windows: new Thickness(10, 8));

                TokenCell = new FormEntryCell(AppResources.VerificationCode, useLabelAsPlaceholder: true,
                                              imageSource: "lock", containerPadding: padding);

                TokenCell.Entry.Keyboard   = Keyboard.Numeric;
                TokenCell.Entry.ReturnType = ReturnType.Go;

                var table = new TwoFactorTable(
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                {
                    TokenCell,
                    RememberCell
                });

                var layout = new RedrawableStackLayout
                {
                    Children = { instruction, table },
                    Spacing  = 0
                };

                table.WrappingStackLayout = () => layout;
                scrollView.Content        = layout;

                switch (_providerType.Value)
                {
                case TwoFactorProviderType.Authenticator:
                    instruction.Text = AppResources.EnterVerificationCodeApp;
                    layout.Children.Add(anotherMethodButton);
                    break;

                case TwoFactorProviderType.Email:
                    var emailParams   = _providers[TwoFactorProviderType.Email];
                    var redactedEmail = emailParams["Email"].ToString();

                    instruction.Text = string.Format(AppResources.EnterVerificationCodeEmail, redactedEmail);
                    var resendEmailButton = new ExtendedButton
                    {
                        Text            = AppResources.SendVerificationCodeAgain,
                        Style           = (Style)Application.Current.Resources["btn-primaryAccent"],
                        Margin          = new Thickness(15, 0, 15, 0),
                        Command         = new Command(async() => await SendEmailAsync(true)),
                        Uppercase       = false,
                        BackgroundColor = Color.Transparent,
                        VerticalOptions = LayoutOptions.Start
                    };

                    layout.Children.Add(resendEmailButton);
                    layout.Children.Add(anotherMethodButton);
                    break;

                default:
                    break;
                }

                ToolbarItems.Add(continueToolbarItem);
                Title = AppResources.VerificationCode;

                Content = scrollView;
                TokenCell.Entry.FocusWithDelay();
            }
            else if (_providerType == TwoFactorProviderType.Duo)
            {
                var duoParams = _providers[TwoFactorProviderType.Duo];

                var host = WebUtility.UrlEncode(duoParams["Host"].ToString());
                var req  = WebUtility.UrlEncode(duoParams["Signature"].ToString());

                var webVaultUrl = "https://vault.bitwarden.com";
                if (!string.IsNullOrWhiteSpace(_appSettingsService.BaseUrl))
                {
                    webVaultUrl = _appSettingsService.BaseUrl;
                }
                else if (!string.IsNullOrWhiteSpace(_appSettingsService.WebVaultUrl))
                {
                    webVaultUrl = _appSettingsService.WebVaultUrl;
                }

                var webView = new HybridWebView
                {
                    Uri = $"{webVaultUrl}/duo-connector.html?host={host}&request={req}",
                    HorizontalOptions    = LayoutOptions.FillAndExpand,
                    VerticalOptions      = LayoutOptions.FillAndExpand,
                    MinimumHeightRequest = 400
                };
                webView.RegisterAction(async(sig) =>
                {
                    await LogInAsync(sig);
                });

                var table = new TwoFactorTable(
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                {
                    RememberCell
                });

                var layout = new RedrawableStackLayout
                {
                    Children = { webView, table, anotherMethodButton },
                    Spacing  = 0
                };

                table.WrappingStackLayout = () => layout;
                scrollView.Content        = layout;

                Title   = "Duo";
                Content = scrollView;
            }
            else if (_providerType == TwoFactorProviderType.YubiKey)
            {
                instruction.Text = AppResources.YubiKeyInstruction;

                var image = new CachedImage
                {
                    Source            = "yubikey",
                    VerticalOptions   = LayoutOptions.Start,
                    HorizontalOptions = LayoutOptions.Center,
                    WidthRequest      = 266,
                    HeightRequest     = 160,
                    Margin            = new Thickness(0, 0, 0, 25)
                };

                var table = new TwoFactorTable(
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                {
                    RememberCell
                });

                var layout = new RedrawableStackLayout
                {
                    Children = { instruction, image, table, anotherMethodButton },
                    Spacing  = 0
                };

                table.WrappingStackLayout = () => layout;
                scrollView.Content        = layout;

                Title   = AppResources.YubiKeyTitle;
                Content = scrollView;
            }
        }
示例#3
0
        private void Init()
        {
            MessagingCenter.Send(Application.Current, "ShowStatusBar", true);

            var padding = Helpers.OnPlatform(
                iOS: new Thickness(15, 20),
                Android: new Thickness(15, 8),
                Windows: new Thickness(10, 8));

            PasswordCell = new FormEntryCell(AppResources.MasterPassword, isPassword: true,
                                             useLabelAsPlaceholder: true, imageSource: "lock.png", containerPadding: padding);
            EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: PasswordCell.Entry,
                                          entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope.png",
                                          containerPadding: padding);

            var lastLoginEmail = _settings.GetValueOrDefault(Constants.LastLoginEmail, string.Empty);

            if (!string.IsNullOrWhiteSpace(_email))
            {
                EmailCell.Entry.Text = _email;
            }
            else if (!string.IsNullOrWhiteSpace(lastLoginEmail))
            {
                EmailCell.Entry.Text = lastLoginEmail;
            }

            PasswordCell.Entry.ReturnType = Enums.ReturnType.Go;

            var table = new ExtendedTableView
            {
                Intent          = TableIntent.Settings,
                EnableScrolling = false,
                HasUnevenRows   = true,
                EnableSelection = true,
                NoFooter        = true,
                VerticalOptions = LayoutOptions.Start,
                Root            = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        EmailCell,
                        PasswordCell
                    }
                }
            };

            var forgotPasswordButton = new ExtendedButton
            {
                Text            = AppResources.GetPasswordHint,
                Style           = (Style)Application.Current.Resources["btn-primaryAccent"],
                Command         = new Command(async() => await ForgotPasswordAsync()),
                VerticalOptions = LayoutOptions.End,
                Uppercase       = false,
                BackgroundColor = Color.Transparent
            };

            var layout = new RedrawableStackLayout
            {
                Children = { table, forgotPasswordButton },
                Spacing  = 10
            };

            table.WrappingStackLayout = () => layout;

            var scrollView = new ScrollView {
                Content = layout
            };

            if (Device.RuntimePlatform == Device.iOS)
            {
                table.RowHeight          = -1;
                table.EstimatedRowHeight = 70;
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel, () =>
                {
                    MessagingCenter.Send(Application.Current, "ShowStatusBar", false);
                }));
            }

            var loginToolbarItem = new ToolbarItem(AppResources.LogIn, Helpers.ToolbarImage("ion_chevron_right.png"), async() =>
            {
                await LogIn();
            }, ToolbarItemOrder.Default, 0);

            ToolbarItems.Add(loginToolbarItem);
            Title   = AppResources.Bitwarden;
            Content = scrollView;
            NavigationPage.SetBackButtonTitle(this, AppResources.LogIn);
        }
        public void Init()
        {
            var padding = Helpers.OnPlatform(
                iOS: new Thickness(15, 20),
                Android: new Thickness(15, 8),
                Windows: new Thickness(10, 8));

            PasswordCell = new FormEntryCell(AppResources.MasterPassword, isPassword: true,
                                             useLabelAsPlaceholder: true, imageSource: "lock.png", containerPadding: padding);

            PasswordCell.Entry.TargetReturnType = Enums.ReturnType.Go;

            var table = new ExtendedTableView
            {
                Intent          = TableIntent.Settings,
                EnableScrolling = false,
                HasUnevenRows   = true,
                EnableSelection = false,
                VerticalOptions = LayoutOptions.Start,
                NoFooter        = true,
                Root            = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        PasswordCell
                    }
                }
            };

            var logoutButton = new ExtendedButton
            {
                Text            = AppResources.LogOut,
                Command         = new Command(async() => await LogoutAsync()),
                VerticalOptions = LayoutOptions.End,
                Style           = (Style)Application.Current.Resources["btn-primaryAccent"],
                BackgroundColor = Color.Transparent,
                Uppercase       = false
            };

            var stackLayout = new RedrawableStackLayout
            {
                Spacing  = 10,
                Children = { table, logoutButton }
            };

            table.WrappingStackLayout = () => stackLayout;

            var scrollView = new ScrollView {
                Content = stackLayout
            };

            if (Device.RuntimePlatform == Device.iOS)
            {
                table.RowHeight          = -1;
                table.EstimatedRowHeight = 70;
            }

            var loginToolbarItem = new ToolbarItem(AppResources.Submit, Helpers.ToolbarImage("ion_chevron_right.png"), async() =>
            {
                await CheckPasswordAsync();
            }, ToolbarItemOrder.Default, 0);

            ToolbarItems.Add(loginToolbarItem);
            Title   = AppResources.VerifyMasterPassword;
            Content = scrollView;
        }
示例#5
0
        private void Init()
        {
            MessagingCenter.Send(Application.Current, "ShowStatusBar", true);

            var padding = Helpers.OnPlatform(
                iOS: new Thickness(15, 20),
                Android: new Thickness(15, 8),
                Windows: new Thickness(10, 8));

            PasswordHintCell = new FormEntryCell(AppResources.MasterPasswordHint, useLabelAsPlaceholder: true,
                                                 imageSource: "lightbulb.png", containerPadding: padding);
            ConfirmPasswordCell = new FormEntryCell(AppResources.RetypeMasterPassword, isPassword: true,
                                                    nextElement: PasswordHintCell.Entry, useLabelAsPlaceholder: true, imageSource: "lock.png",
                                                    containerPadding: padding);
            PasswordCell = new FormEntryCell(AppResources.MasterPassword, isPassword: true,
                                             nextElement: ConfirmPasswordCell.Entry, useLabelAsPlaceholder: true, imageSource: "lock.png",
                                             containerPadding: padding);
            EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: PasswordCell.Entry,
                                          entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope.png",
                                          containerPadding: padding);

            PasswordHintCell.Entry.ReturnType = Enums.ReturnType.Done;

            var table = new FormTableView(this)
            {
                Root = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        EmailCell,
                        PasswordCell
                    }
                }
            };

            PasswordLabel = new Label
            {
                Text          = AppResources.MasterPasswordDescription,
                LineBreakMode = LineBreakMode.WordWrap,
                FontSize      = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                Style         = (Style)Application.Current.Resources["text-muted"],
                Margin        = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25)
            };

            var table2 = new FormTableView(this)
            {
                NoHeader = true,
                Root     = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        ConfirmPasswordCell,
                        PasswordHintCell
                    }
                }
            };

            HintLabel = new Label
            {
                Text          = AppResources.MasterPasswordHintDescription,
                LineBreakMode = LineBreakMode.WordWrap,
                FontSize      = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                Style         = (Style)Application.Current.Resources["text-muted"],
                Margin        = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25)
            };

            StackLayout = new RedrawableStackLayout
            {
                Children = { table, PasswordLabel, table2, HintLabel },
                Spacing  = 0
            };

            var scrollView = new ScrollView
            {
                Content = StackLayout
            };

            var loginToolbarItem = new ToolbarItem(AppResources.Submit, Helpers.ToolbarImage("ion_chevron_right.png"), async() =>
            {
                await Register();
            }, ToolbarItemOrder.Default, 0);

            if (Device.RuntimePlatform == Device.iOS)
            {
                table.RowHeight          = table2.RowHeight = -1;
                table.EstimatedRowHeight = table2.EstimatedRowHeight = 70;
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel, () =>
                {
                    MessagingCenter.Send(Application.Current, "ShowStatusBar", false);
                }));
            }

            ToolbarItems.Add(loginToolbarItem);
            Title   = AppResources.CreateAccount;
            Content = scrollView;
        }
示例#6
0
        private void Init()
        {
            var padding = Helpers.OnPlatform(
                iOS: new Thickness(15, 20),
                Android: new Thickness(15, 8),
                Windows: new Thickness(10, 8));

            EmailCell = new FormEntryCell(AppResources.EmailAddress, entryKeyboard: Keyboard.Email,
                                          useLabelAsPlaceholder: true, imageSource: "envelope.png", containerPadding: padding);

            EmailCell.Entry.ReturnType = Enums.ReturnType.Go;

            var table = new ExtendedTableView
            {
                Intent          = TableIntent.Settings,
                EnableScrolling = false,
                HasUnevenRows   = true,
                EnableSelection = true,
                NoFooter        = true,
                VerticalOptions = LayoutOptions.Start,
                Root            = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        EmailCell
                    }
                }
            };

            var hintLabel = new Label
            {
                Text          = AppResources.EnterEmailForHint,
                LineBreakMode = LineBreakMode.WordWrap,
                FontSize      = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                Style         = (Style)Application.Current.Resources["text-muted"],
                Margin        = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25)
            };

            var layout = new RedrawableStackLayout
            {
                Children = { table, hintLabel },
                Spacing  = 0
            };

            table.WrappingStackLayout = () => layout;
            var scrollView = new ScrollView {
                Content = layout
            };

            if (Device.RuntimePlatform == Device.iOS)
            {
                table.RowHeight          = -1;
                table.EstimatedRowHeight = 70;
            }

            var submitToolbarItem = new ToolbarItem(AppResources.Submit, Helpers.ToolbarImage("ion_chevron_right.png"), async() =>
            {
                await SubmitAsync();
            }, ToolbarItemOrder.Default, 0);

            ToolbarItems.Add(submitToolbarItem);
            Title   = AppResources.PasswordHint;
            Content = scrollView;
        }
示例#7
0
        private void Init()
        {
            _canUseAttachments = _cryptoService.EncKey != null;

            SubscribeFileResult(true);
            var selectButton = new ExtendedButton
            {
                Text     = AppResources.ChooseFile,
                Command  = new Command(async() => await _deviceActionService.SelectFileAsync()),
                Style    = (Style)Application.Current.Resources["btn-primaryAccent"],
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button))
            };

            FileLabel = new Label
            {
                Text     = AppResources.NoFileChosen,
                Style    = (Style)Application.Current.Resources["text-muted"],
                FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                HorizontalTextAlignment = TextAlignment.Center
            };

            AddNewStackLayout = new StackLayout
            {
                Children        = { selectButton, FileLabel },
                Orientation     = StackOrientation.Vertical,
                Padding         = new Thickness(20, Helpers.OnPlatform(iOS: 10, Android: 20), 20, 20),
                VerticalOptions = LayoutOptions.Start
            };

            NewTable = new ExtendedTableView
            {
                Intent              = TableIntent.Settings,
                HasUnevenRows       = true,
                NoFooter            = true,
                EnableScrolling     = false,
                EnableSelection     = false,
                VerticalOptions     = LayoutOptions.Start,
                Margin              = new Thickness(0, Helpers.OnPlatform(iOS: 10, Android: 30), 0, 0),
                WrappingStackLayout = () => NoDataStackLayout,
                Root = new TableRoot
                {
                    new TableSection(AppResources.AddNewAttachment)
                    {
                        new ExtendedViewCell
                        {
                            View            = AddNewStackLayout,
                            BackgroundColor = Color.White
                        }
                    }
                }
            };

            ListView = new ExtendedListView(ListViewCachingStrategy.RecycleElement)
            {
                ItemsSource     = PresentationAttchments,
                HasUnevenRows   = true,
                ItemTemplate    = new DataTemplate(() => new VaultAttachmentsViewCell()),
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            NoDataLabel = new Label
            {
                Text = AppResources.NoAttachments,
                HorizontalTextAlignment = TextAlignment.Center,
                FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                Style    = (Style)Application.Current.Resources["text-muted"]
            };

            NoDataStackLayout = new RedrawableStackLayout
            {
                VerticalOptions = LayoutOptions.Start,
                Spacing         = 0,
                Margin          = new Thickness(0, 40, 0, 0)
            };

            SaveToolbarItem = new ToolbarItem(AppResources.Save, Helpers.ToolbarImage("envelope.png"), async() =>
            {
                if (_lastAction.LastActionWasRecent() || _cipher == null)
                {
                    return;
                }
                _lastAction = DateTime.UtcNow;


                if (!_canUseAttachments)
                {
                    await ShowUpdateKeyAsync();
                    return;
                }

                if (!_connectivity.IsConnected)
                {
                    AlertNoConnection();
                    return;
                }

                if (_fileBytes == null)
                {
                    await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired,
                                                                                      AppResources.File), AppResources.Ok);
                    return;
                }

                await _deviceActionService.ShowLoadingAsync(AppResources.Saving);
                var saveTask = await _cipherService.EncryptAndSaveAttachmentAsync(_cipher, _fileBytes, FileLabel.Text);
                await _deviceActionService.HideLoadingAsync();

                if (saveTask.Succeeded)
                {
                    _fileBytes     = null;
                    FileLabel.Text = AppResources.NoFileChosen;
                    _deviceActionService.Toast(AppResources.AttachementAdded);
                    _googleAnalyticsService.TrackAppEvent("AddedAttachment");
                    await LoadAttachmentsAsync();
                }
                else if (saveTask.Errors.Count() > 0)
                {
                    await DisplayAlert(AppResources.AnErrorHasOccurred, saveTask.Errors.First().Message, AppResources.Ok);
                }
                else
                {
                    await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok);
                }
            }, ToolbarItemOrder.Default, 0);

            Title   = AppResources.Attachments;
            Content = ListView;

            if (Device.RuntimePlatform == Device.iOS)
            {
                ListView.RowHeight          = -1;
                NewTable.RowHeight          = -1;
                NewTable.EstimatedRowHeight = 44;
                NewTable.HeightRequest      = 180;
                ListView.BackgroundColor    = Color.Transparent;
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
            }
            else if (Device.RuntimePlatform == Device.Android)
            {
                ListView.BottomPadding = 50;
            }
        }
        private void Init()
        {
            MessagingCenter.Send(Application.Current, "ShowStatusBar", true);

            IconsUrlCell            = new FormEntryCell(AppResources.IconsUrl, entryKeyboard: Keyboard.Url);
            IconsUrlCell.Entry.Text = _appSettings.IconsUrl;

            IdentityUrlCell = new FormEntryCell(AppResources.IdentityUrl, nextElement: IconsUrlCell.Entry,
                                                entryKeyboard: Keyboard.Url);
            IdentityUrlCell.Entry.Text = _appSettings.IdentityUrl;

            ApiUrlCell = new FormEntryCell(AppResources.ApiUrl, nextElement: IdentityUrlCell.Entry,
                                           entryKeyboard: Keyboard.Url);
            ApiUrlCell.Entry.Text = _appSettings.ApiUrl;

            WebVaultUrlCell = new FormEntryCell(AppResources.WebVaultUrl, nextElement: ApiUrlCell.Entry,
                                                entryKeyboard: Keyboard.Url);
            WebVaultUrlCell.Entry.Text = _appSettings.WebVaultUrl;

            BaseUrlCell = new FormEntryCell(AppResources.ServerUrl, nextElement: WebVaultUrlCell.Entry,
                                            entryKeyboard: Keyboard.Url);
            BaseUrlCell.Entry.Text = _appSettings.BaseUrl;

            var table = new FormTableView(this)
            {
                Root = new TableRoot
                {
                    new TableSection(AppResources.SelfHostedEnvironment)
                    {
                        BaseUrlCell
                    }
                }
            };

            SelfHostLabel = new Label
            {
                Text          = AppResources.SelfHostedEnvironmentFooter,
                LineBreakMode = LineBreakMode.WordWrap,
                FontSize      = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                Style         = (Style)Application.Current.Resources["text-muted"],
                Margin        = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 5)
            };

            var table2 = new FormTableView(this)
            {
                Root = new TableRoot
                {
                    new TableSection(AppResources.CustomEnvironment)
                    {
                        WebVaultUrlCell,
                        ApiUrlCell,
                        IdentityUrlCell,
                        IconsUrlCell
                    }
                }
            };

            CustomLabel = new Label
            {
                Text          = AppResources.CustomEnvironmentFooter,
                LineBreakMode = LineBreakMode.WordWrap,
                FontSize      = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                Style         = (Style)Application.Current.Resources["text-muted"],
                Margin        = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 5)
            };

            StackLayout = new RedrawableStackLayout
            {
                Children = { table, SelfHostLabel, table2, CustomLabel },
                Spacing  = 0
            };

            var scrollView = new ScrollView
            {
                Content = StackLayout
            };

            var toolbarItem = new ToolbarItem(AppResources.Save, Helpers.ToolbarImage("envelope.png"), async() => await SaveAsync(),
                                              ToolbarItemOrder.Default, 0);

            if (Device.RuntimePlatform == Device.iOS)
            {
                table.RowHeight          = table2.RowHeight = -1;
                table.EstimatedRowHeight = table2.EstimatedRowHeight = 70;
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close, () =>
                {
                    MessagingCenter.Send(Application.Current, "ShowStatusBar", false);
                }));
            }

            ToolbarItems.Add(toolbarItem);
            Title   = AppResources.Settings;
            Content = scrollView;
        }
        public void Init()
        {
            EmailCell = new ExtendedTextCell
            {
                Text            = AppResources.EmailUs,
                ShowDisclousure = true
            };

            var emailTable = new CustomTableView(this)
            {
                Root = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        EmailCell
                    }
                }
            };

            EmailLabel = new CustomLabel(this)
            {
                Text = AppResources.EmailUsDescription
            };

            WebsiteCell = new ExtendedTextCell
            {
                Text            = AppResources.VisitOurWebsite,
                ShowDisclousure = true
            };

            var websiteTable = new CustomTableView(this)
            {
                NoHeader = true,
                Root     = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        WebsiteCell
                    }
                }
            };

            WebsiteLabel = new CustomLabel(this)
            {
                Text = AppResources.VisitOurWebsiteDescription
            };

            BugCell = new ExtendedTextCell
            {
                Text            = AppResources.FileBugReport,
                ShowDisclousure = true
            };

            var bugTable = new CustomTableView(this)
            {
                NoHeader = true,
                Root     = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        BugCell
                    }
                }
            };

            BugLabel = new CustomLabel(this)
            {
                Text = AppResources.FileBugReportDescription
            };

            StackLayout = new RedrawableStackLayout
            {
                Children = { emailTable, EmailLabel, websiteTable, WebsiteLabel, bugTable, BugLabel },
                Spacing  = 0
            };

            if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.UWP)
            {
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
            }

            Title   = AppResources.HelpAndFeedback;
            Content = new ScrollView {
                Content = StackLayout
            };
        }
示例#10
0
        public void Init()
        {
            Password = new Label
            {
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                Margin   = new Thickness(15, 30, 15, 30),
                HorizontalTextAlignment = TextAlignment.Center,
                FontFamily      = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", Windows: "Courier"),
                LineBreakMode   = LineBreakMode.TailTruncation,
                VerticalOptions = LayoutOptions.Start,
                TextColor       = Color.Black
            };

            Tgr = new TapGestureRecognizer();
            Password.GestureRecognizers.Add(Tgr);
            Password.SetBinding(Label.TextProperty, nameof(PasswordGeneratorPageModel.Password));

            SliderCell = new SliderViewCell(this, _passwordGenerationService, _settings);

            RegenerateCell = new ExtendedTextCell
            {
                Text      = AppResources.RegeneratePassword,
                TextColor = Colors.Primary
            };
            CopyCell = new ExtendedTextCell {
                Text = AppResources.CopyPassword, TextColor = Colors.Primary
            };

            UppercaseCell = new ExtendedSwitchCell
            {
                Text = "A-Z",
                On   = _settings.GetValueOrDefault(Constants.PasswordGeneratorUppercase, true)
            };

            LowercaseCell = new ExtendedSwitchCell
            {
                Text = "a-z",
                On   = _settings.GetValueOrDefault(Constants.PasswordGeneratorLowercase, true)
            };

            SpecialCell = new ExtendedSwitchCell
            {
                Text = "!@#$%^&*",
                On   = _settings.GetValueOrDefault(Constants.PasswordGeneratorSpecial, true)
            };

            NumbersCell = new ExtendedSwitchCell
            {
                Text = "0-9",
                On   = _settings.GetValueOrDefault(Constants.PasswordGeneratorNumbers, true)
            };

            AvoidAmbiguousCell = new ExtendedSwitchCell
            {
                Text = AppResources.AvoidAmbiguousCharacters,
                On   = !_settings.GetValueOrDefault(Constants.PasswordGeneratorAmbiguous, false)
            };

            NumbersMinCell = new StepperCell(AppResources.MinNumbers,
                                             _settings.GetValueOrDefault(Constants.PasswordGeneratorMinNumbers, 1), 0, 5, 1, () =>
            {
                _settings.AddOrUpdateValue(Constants.PasswordGeneratorMinNumbers,
                                           Convert.ToInt32(NumbersMinCell.Stepper.Value));
                Model.Password = _passwordGenerationService.GeneratePassword();
            });

            SpecialMinCell = new StepperCell(AppResources.MinSpecial,
                                             _settings.GetValueOrDefault(Constants.PasswordGeneratorMinSpecial, 1), 0, 5, 1, () =>
            {
                _settings.AddOrUpdateValue(Constants.PasswordGeneratorMinSpecial,
                                           Convert.ToInt32(SpecialMinCell.Stepper.Value));
                Model.Password = _passwordGenerationService.GeneratePassword();
            });

            var table = new ExtendedTableView
            {
                VerticalOptions = LayoutOptions.Start,
                EnableScrolling = false,
                Intent          = TableIntent.Settings,
                HasUnevenRows   = true,
                NoHeader        = true,
                Root            = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        RegenerateCell,
                        CopyCell
                    },
                    new TableSection(AppResources.Options)
                    {
                        SliderCell,
                        UppercaseCell,
                        LowercaseCell,
                        NumbersCell,
                        SpecialCell
                    },
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        NumbersMinCell,
                        SpecialMinCell
                    },
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        AvoidAmbiguousCell
                    }
                }
            };

            if (Device.RuntimePlatform == Device.iOS)
            {
                table.RowHeight          = -1;
                table.EstimatedRowHeight = 44;

                if (_passwordValueAction != null)
                {
                    ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
                }
            }
            else if (Device.RuntimePlatform == Device.Android)
            {
                table.BottomPadding = 50;
            }

            var stackLayout = new RedrawableStackLayout
            {
                Orientation     = StackOrientation.Vertical,
                Children        = { Password, table },
                VerticalOptions = LayoutOptions.FillAndExpand,
                Spacing         = 0
            };

            table.WrappingStackLayout = () => stackLayout;

            var scrollView = new ScrollView
            {
                Content         = stackLayout,
                Orientation     = ScrollOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            if (_passwordValueAction != null)
            {
                var selectToolBarItem = new ToolbarItem(AppResources.Select, Helpers.ToolbarImage("ion_chevron_right.png"), async() =>
                {
                    if (_fromAutofill)
                    {
                        _googleAnalyticsService.TrackExtensionEvent("SelectedGeneratedPassword");
                    }
                    else
                    {
                        _googleAnalyticsService.TrackAppEvent("SelectedGeneratedPassword");
                    }

                    _passwordValueAction(Password.Text);
                    await Navigation.PopForDeviceAsync();
                }, ToolbarItemOrder.Default, 0);

                ToolbarItems.Add(selectToolBarItem);
            }

            Title          = AppResources.PasswordGenerator;
            Content        = scrollView;
            BindingContext = Model;
        }
        public void Init()
        {
            var logo = new CachedImage
            {
                Source            = "logo.png",
                HorizontalOptions = LayoutOptions.Center,
                WidthRequest      = 282,
                HeightRequest     = 44
            };

            var versionLabel = new Label
            {
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                Text     = $@"{AppResources.Version} {_appInfoService.Version} ({_appInfoService.Build})
© 8bit Solutions LLC 2015-{DateTime.Now.Year}",
                HorizontalTextAlignment = TextAlignment.Center
            };

            var logoVersionStackLayout = new StackLayout
            {
                Children = { logo, versionLabel },
                Spacing  = 20,
                Padding  = new Thickness(0, 40, 0, 0)
            };

            CreditsCell = new ExtendedTextCell
            {
                Text            = AppResources.Credits,
                ShowDisclousure = true
            };

            var table = new ExtendedTableView
            {
                VerticalOptions = LayoutOptions.Start,
                EnableScrolling = false,
                Intent          = TableIntent.Settings,
                HasUnevenRows   = true,
                Root            = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        CreditsCell
                    }
                }
            };

            if (Device.RuntimePlatform == Device.iOS)
            {
                table.RowHeight          = -1;
                table.EstimatedRowHeight = 44;
            }

            var stackLayout = new RedrawableStackLayout
            {
                Children = { logoVersionStackLayout, table },
                Spacing  = 0
            };

            table.WrappingStackLayout = () => stackLayout;

            if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.UWP)
            {
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
            }

            Title   = AppResources.About;
            Content = new ScrollView {
                Content = stackLayout
            };
        }