示例#1
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            Forms.Init();
            InitApp();
            if (App.Migration.MigrationHelpers.NeedsMigration())
            {
                var task = App.Migration.MigrationHelpers.PerformMigrationAsync();
                Task.Delay(5000).Wait();
            }

            _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
            _messagingService    = ServiceContainer.Resolve <IMessagingService>("messagingService");
            _broadcasterService  = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService");
            _storageService      = ServiceContainer.Resolve <IStorageService>("storageService");
            _lockService         = ServiceContainer.Resolve <ILockService>("lockService");
            _eventService        = ServiceContainer.Resolve <IEventService>("eventService");

            LoadApplication(new App.App(null));
            iOSCoreHelpers.AppearanceAdjustments();
            ZXing.Net.Mobile.Forms.iOS.Platform.Init();

            _broadcasterService.Subscribe(nameof(AppDelegate), async(message) =>
            {
                if (message.Command == "scheduleLockTimer")
                {
                    LockTimer((int)message.Data);
                }
                else if (message.Command == "cancelLockTimer")
                {
                    CancelLockTimer();
                }
                else if (message.Command == "startEventTimer")
                {
                    StartEventTimer();
                }
                else if (message.Command == "stopEventTimer")
                {
                    var task = StopEventTimerAsync();
                }
                else if (message.Command == "updatedTheme")
                {
                    // ThemeManager.SetThemeStyle(message.Data as string);
                }
                else if (message.Command == "copiedToClipboard")
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        var task = ClearClipboardTimerAsync(message.Data as Tuple <string, int?, bool>);
                    });
                }
                else if (message.Command == "listenYubiKeyOTP")
                {
                    ListenYubiKey((bool)message.Data);
                }
                else if (message.Command == "unlocked")
                {
                    var needsAutofillReplacement = await _storageService.GetAsync <bool?>(
                        Core.Constants.AutofillNeedsIdentityReplacementKey);
                    if (needsAutofillReplacement.GetValueOrDefault())
                    {
                        await ASHelpers.ReplaceAllIdentities();
                    }
                }
                else if (message.Command == "showAppExtension")
                {
                    Device.BeginInvokeOnMainThread(() => ShowAppExtension((ExtensionPageViewModel)message.Data));
                }
                else if (message.Command == "showStatusBar")
                {
                    Device.BeginInvokeOnMainThread(() =>
                                                   UIApplication.SharedApplication.SetStatusBarHidden(!(bool)message.Data, false));
                }
                else if (message.Command == "syncCompleted")
                {
                    if (message.Data is Dictionary <string, object> data && data.ContainsKey("successfully"))
                    {
                        var success = data["successfully"] as bool?;
                        if (success.GetValueOrDefault() && _deviceActionService.SystemMajorVersion() >= 12)
                        {
                            await ASHelpers.ReplaceAllIdentities();
                        }
                    }
                }
                else if (message.Command == "addedCipher" || message.Command == "editedCipher")
                {
                    if (_deviceActionService.SystemMajorVersion() >= 12)
                    {
                        if (await ASHelpers.IdentitiesCanIncremental())
                        {
                            var cipherId = message.Data as string;
                            if (message.Command == "addedCipher" && !string.IsNullOrWhiteSpace(cipherId))
                            {
                                var identity = await ASHelpers.GetCipherIdentityAsync(cipherId);
                                if (identity == null)
                                {
                                    return;
                                }
                                await ASCredentialIdentityStore.SharedStore?.SaveCredentialIdentitiesAsync(
                                    new ASPasswordCredentialIdentity[] { identity });
                                return;
                            }
                        }
                        await ASHelpers.ReplaceAllIdentities();
                    }
                }
                else if (message.Command == "deletedCipher")
                {
                    if (_deviceActionService.SystemMajorVersion() >= 12)
                    {
                        if (await ASHelpers.IdentitiesCanIncremental())
                        {
                            var identity = ASHelpers.ToCredentialIdentity(
                                message.Data as Bit.Core.Models.View.CipherView);
                            if (identity == null)
                            {
                                return;
                            }
                            await ASCredentialIdentityStore.SharedStore?.RemoveCredentialIdentitiesAsync(
                                new ASPasswordCredentialIdentity[] { identity });
                            return;
                        }
                        await ASHelpers.ReplaceAllIdentities();
                    }
                }
                else if (message.Command == "loggedOut")
                {
                    if (_deviceActionService.SystemMajorVersion() >= 12)
                    {
                        await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
                    }
                }
            });

            return(base.FinishedLaunching(app, options));
        }
示例#2
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            await LoadOnAppearedAsync(_scrollView, true, async() =>
            {
                var success = await _vm.LoadAsync(_appOptions);
                if (!success)
                {
                    await Navigation.PopModalAsync();
                }
                else if (!_vm.EditMode && string.IsNullOrWhiteSpace(_vm.Cipher.Name))
                {
                    RequestFocus(_nameEntry);
                }
            });

            if (_vm.EditMode && Device.RuntimePlatform == Device.Android)
            {
                if (_vm.Cipher.OrganizationId == null)
                {
                    if (ToolbarItems.Contains(_collectionsItem))
                    {
                        ToolbarItems.Remove(_collectionsItem);
                    }
                    if (!ToolbarItems.Contains(_shareItem))
                    {
                        ToolbarItems.Insert(2, _shareItem);
                    }
                }
                else
                {
                    if (ToolbarItems.Contains(_shareItem))
                    {
                        ToolbarItems.Remove(_shareItem);
                    }
                    if (!ToolbarItems.Contains(_collectionsItem))
                    {
                        ToolbarItems.Insert(2, _collectionsItem);
                    }
                }
            }
            if (!_vm.EditMode)
            {
                var addLoginShown = await _storageService.GetAsync <bool?>(Constants.AddSitePromptShownKey);

                if (_vm.Cipher.Type == CipherType.Login && !_fromAutofill && !addLoginShown.GetValueOrDefault())
                {
                    await _storageService.SaveAsync(Constants.AddSitePromptShownKey, true);

                    if (Device.RuntimePlatform == Device.iOS)
                    {
                        if (_deviceActionService.SystemMajorVersion() < 12)
                        {
                            await DisplayAlert(AppResources.BitwardenAppExtension,
                                               AppResources.BitwardenAppExtensionAlert2, AppResources.Ok);
                        }
                        else
                        {
                            await DisplayAlert(AppResources.PasswordAutofill,
                                               AppResources.BitwardenAutofillAlert2, AppResources.Ok);
                        }
                    }
                    else if (Device.RuntimePlatform == Device.Android &&
                             !_deviceActionService.AutofillAccessibilityServiceRunning() &&
                             !_deviceActionService.AutofillServiceEnabled())
                    {
                        await DisplayAlert(AppResources.BitwardenAutofillService,
                                           AppResources.BitwardenAutofillServiceAlert2, AppResources.Ok);
                    }
                }
            }
        }
示例#3
0
        public void BuildList()
        {
            var doUpper       = Device.RuntimePlatform != Device.Android;
            var autofillItems = new List <SettingsPageListItem>();

            if (Device.RuntimePlatform == Device.Android)
            {
                autofillItems.Add(new SettingsPageListItem
                {
                    Name     = AppResources.AutofillServices,
                    SubLabel = _deviceActionService.AutofillServicesEnabled() ?
                               AppResources.Enabled : AppResources.Disabled
                });
            }
            else
            {
                if (_deviceActionService.SystemMajorVersion() >= 12)
                {
                    autofillItems.Add(new SettingsPageListItem {
                        Name = AppResources.PasswordAutofill
                    });
                }
                autofillItems.Add(new SettingsPageListItem {
                    Name = AppResources.AppExtension
                });
            }
            var manageItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.Folders
                },
                new SettingsPageListItem {
                    Name = AppResources.Sync, SubLabel = _lastSyncDate
                }
            };
            var securityItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.VaultTimeout, SubLabel = _vaultTimeoutDisplayValue
                },
                new SettingsPageListItem
                {
                    Name     = AppResources.VaultTimeoutAction,
                    SubLabel = _vaultTimeoutActionDisplayValue
                },
                new SettingsPageListItem
                {
                    Name     = AppResources.UnlockWithPIN,
                    SubLabel = _pin ? AppResources.Enabled : AppResources.Disabled
                },
                new SettingsPageListItem {
                    Name = AppResources.LockNow
                },
                new SettingsPageListItem {
                    Name = AppResources.TwoStepLogin
                }
            };

            if (_supportsBiometric || _biometric)
            {
                var biometricName = AppResources.Biometrics;
                if (Device.RuntimePlatform == Device.iOS)
                {
                    biometricName = _deviceActionService.SupportsFaceBiometric() ? AppResources.FaceID :
                                    AppResources.TouchID;
                }
                var item = new SettingsPageListItem
                {
                    Name     = string.Format(AppResources.UnlockWith, biometricName),
                    SubLabel = _biometric ? AppResources.Enabled : AppResources.Disabled
                };
                securityItems.Insert(2, item);
            }
            if (_vaultTimeoutDisplayValue == AppResources.Custom)
            {
                securityItems.Insert(1, new SettingsPageListItem
                {
                    Name = AppResources.Custom,
                    Time = TimeSpan.FromMinutes(Math.Abs((double)_vaultTimeout.GetValueOrDefault())),
                });
            }
            if (_vaultTimeoutPolicy != null)
            {
                var maximumTimeout = _policyService.GetPolicyInt(_vaultTimeoutPolicy, "minutes").GetValueOrDefault();
                securityItems.Insert(0, new SettingsPageListItem
                {
                    Name = string.Format(AppResources.VaultTimeoutPolicyInEffect,
                                         Math.Floor((float)maximumTimeout / 60),
                                         maximumTimeout % 60),
                    UseFrame = true,
                });
            }
            var accountItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.FingerprintPhrase
                },
                new SettingsPageListItem {
                    Name = AppResources.LogOut
                }
            };

            if (_showChangeMasterPassword)
            {
                accountItems.Insert(0, new SettingsPageListItem {
                    Name = AppResources.ChangeMasterPassword
                });
            }
            var toolsItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.ImportItems
                },
                new SettingsPageListItem {
                    Name = AppResources.ExportVault
                }
            };

            if (IncludeLinksWithSubscriptionInfo())
            {
                toolsItems.Add(new SettingsPageListItem {
                    Name = AppResources.LearnOrg
                });
                toolsItems.Add(new SettingsPageListItem {
                    Name = AppResources.WebVault
                });
            }
            var otherItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.Options
                },
                new SettingsPageListItem {
                    Name = AppResources.About
                },
                new SettingsPageListItem {
                    Name = AppResources.HelpAndFeedback
                },
                new SettingsPageListItem {
                    Name = AppResources.RateTheApp
                },
                new SettingsPageListItem {
                    Name = AppResources.DeleteAccount
                }
            };

            // TODO: improve this. Leaving this as is to reduce error possibility on the hotfix.
            var settingsListGroupItems = new List <SettingsPageListGroup>()
            {
                new SettingsPageListGroup(autofillItems, AppResources.Autofill, doUpper, true),
                new SettingsPageListGroup(manageItems, AppResources.Manage, doUpper),
                new SettingsPageListGroup(securityItems, AppResources.Security, doUpper),
                new SettingsPageListGroup(accountItems, AppResources.Account, doUpper),
                new SettingsPageListGroup(toolsItems, AppResources.Tools, doUpper),
                new SettingsPageListGroup(otherItems, AppResources.Other, doUpper)
            };

            // TODO: refactor this
            if (Device.RuntimePlatform == Device.Android
                ||
                GroupedItems.Any())
            {
                var items = new List <ISettingsPageListItem>();
                foreach (var itemGroup in settingsListGroupItems)
                {
                    items.Add(new SettingsPageHeaderListItem(itemGroup.Name));
                    items.AddRange(itemGroup);
                }

                GroupedItems.ReplaceRange(items);
            }
            else
            {
                // HACK: we need this on iOS, so that it doesn't crash when adding coming from an empty list
                var first = true;
                var items = new List <ISettingsPageListItem>();
                foreach (var itemGroup in settingsListGroupItems)
                {
                    if (!first)
                    {
                        items.Add(new SettingsPageHeaderListItem(itemGroup.Name));
                    }
                    else
                    {
                        first = false;
                    }
                    items.AddRange(itemGroup);
                }

                if (settingsListGroupItems.Any())
                {
                    GroupedItems.ReplaceRange(new List <ISettingsPageListItem> {
                        new SettingsPageHeaderListItem(settingsListGroupItems[0].Name)
                    });
                    GroupedItems.AddRange(items);
                }
                else
                {
                    GroupedItems.Clear();
                }
            }
        }
示例#4
0
        public void BuildList()
        {
            //TODO: Refactor this once navigation is abstracted so that it doesn't depend on Page, e.g. Page.Navigation.PushModalAsync...

            var doUpper       = Device.RuntimePlatform != Device.Android;
            var autofillItems = new List <SettingsPageListItem>();

            if (Device.RuntimePlatform == Device.Android)
            {
                autofillItems.Add(new SettingsPageListItem
                {
                    Name         = AppResources.AutofillServices,
                    SubLabel     = _deviceActionService.AutofillServicesEnabled() ? AppResources.On : AppResources.Off,
                    ExecuteAsync = () => Page.Navigation.PushModalAsync(new NavigationPage(new AutofillServicesPage(Page as SettingsPage)))
                });
            }
            else
            {
                if (_deviceActionService.SystemMajorVersion() >= 12)
                {
                    autofillItems.Add(new SettingsPageListItem
                    {
                        Name         = AppResources.PasswordAutofill,
                        ExecuteAsync = () => Page.Navigation.PushModalAsync(new NavigationPage(new AutofillPage()))
                    });
                }
                autofillItems.Add(new SettingsPageListItem
                {
                    Name         = AppResources.AppExtension,
                    ExecuteAsync = () => Page.Navigation.PushModalAsync(new NavigationPage(new ExtensionPage()))
                });
            }
            var manageItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem
                {
                    Name         = AppResources.Folders,
                    ExecuteAsync = () => Page.Navigation.PushModalAsync(new NavigationPage(new FoldersPage()))
                },
                new SettingsPageListItem
                {
                    Name         = AppResources.Sync,
                    SubLabel     = _lastSyncDate,
                    ExecuteAsync = () => Page.Navigation.PushModalAsync(new NavigationPage(new SyncPage()))
                }
            };
            var securityItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem
                {
                    Name         = AppResources.VaultTimeout,
                    SubLabel     = _vaultTimeoutDisplayValue,
                    ExecuteAsync = () => VaultTimeoutAsync()
                },
                new SettingsPageListItem
                {
                    Name         = AppResources.VaultTimeoutAction,
                    SubLabel     = _vaultTimeoutActionDisplayValue,
                    ExecuteAsync = () => VaultTimeoutActionAsync()
                },
                new SettingsPageListItem
                {
                    Name         = AppResources.UnlockWithPIN,
                    SubLabel     = _pin ? AppResources.On : AppResources.Off,
                    ExecuteAsync = () => UpdatePinAsync()
                },
                new SettingsPageListItem
                {
                    Name         = AppResources.LockNow,
                    ExecuteAsync = () => LockAsync()
                },
                new SettingsPageListItem
                {
                    Name         = AppResources.TwoStepLogin,
                    ExecuteAsync = () => TwoStepAsync()
                }
            };

            if (_supportsBiometric || _biometric)
            {
                var biometricName = AppResources.Biometrics;
                if (Device.RuntimePlatform == Device.iOS)
                {
                    biometricName = _deviceActionService.SupportsFaceBiometric() ? AppResources.FaceID :
                                    AppResources.TouchID;
                }
                var item = new SettingsPageListItem
                {
                    Name         = string.Format(AppResources.UnlockWith, biometricName),
                    SubLabel     = _biometric ? AppResources.On : AppResources.Off,
                    ExecuteAsync = () => UpdateBiometricAsync()
                };
                securityItems.Insert(2, item);
            }
            if (_vaultTimeoutDisplayValue == AppResources.Custom)
            {
                securityItems.Insert(1, new SettingsPageListItem
                {
                    Name = AppResources.Custom,
                    Time = TimeSpan.FromMinutes(Math.Abs((double)_vaultTimeout.GetValueOrDefault())),
                });
            }
            if (_vaultTimeoutPolicy != null)
            {
                var maximumTimeout = _policyService.GetPolicyInt(_vaultTimeoutPolicy, "minutes").GetValueOrDefault();
                securityItems.Insert(0, new SettingsPageListItem
                {
                    Name = string.Format(AppResources.VaultTimeoutPolicyInEffect,
                                         Math.Floor((float)maximumTimeout / 60),
                                         maximumTimeout % 60),
                    UseFrame = true,
                });
            }
            if (Device.RuntimePlatform == Device.Android)
            {
                securityItems.Add(new SettingsPageListItem
                {
                    Name         = AppResources.AllowScreenCapture,
                    SubLabel     = _screenCaptureAllowed ? AppResources.On : AppResources.Off,
                    ExecuteAsync = () => SetScreenCaptureAllowedAsync()
                });
            }
            var accountItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem
                {
                    Name         = AppResources.FingerprintPhrase,
                    ExecuteAsync = () => FingerprintAsync()
                },
                new SettingsPageListItem
                {
                    Name         = AppResources.LogOut,
                    ExecuteAsync = () => LogOutAsync()
                }
            };

            if (_showChangeMasterPassword)
            {
                accountItems.Insert(0, new SettingsPageListItem
                {
                    Name         = AppResources.ChangeMasterPassword,
                    ExecuteAsync = () => ChangePasswordAsync()
                });
            }
            var toolsItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem
                {
                    Name         = AppResources.ImportItems,
                    ExecuteAsync = () => Device.InvokeOnMainThreadAsync(() => Import())
                },
                new SettingsPageListItem
                {
                    Name         = AppResources.ExportVault,
                    ExecuteAsync = () => Page.Navigation.PushModalAsync(new NavigationPage(new ExportVaultPage()))
                }
            };

            if (IncludeLinksWithSubscriptionInfo())
            {
                toolsItems.Add(new SettingsPageListItem
                {
                    Name         = AppResources.LearnOrg,
                    ExecuteAsync = () => ShareAsync()
                });
                toolsItems.Add(new SettingsPageListItem
                {
                    Name         = AppResources.WebVault,
                    ExecuteAsync = () => Device.InvokeOnMainThreadAsync(() => WebVault())
                });
            }

            var otherItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem
                {
                    Name         = AppResources.Options,
                    ExecuteAsync = () => Page.Navigation.PushModalAsync(new NavigationPage(new OptionsPage()))
                },
                new SettingsPageListItem
                {
                    Name         = AppResources.About,
                    ExecuteAsync = () => AboutAsync()
                },
                new SettingsPageListItem
                {
                    Name         = AppResources.HelpAndFeedback,
                    ExecuteAsync = () => Device.InvokeOnMainThreadAsync(() => Help())
                },
#if !FDROID
                new SettingsPageListItem
                {
                    Name         = AppResources.SubmitCrashLogs,
                    SubLabel     = _reportLoggingEnabled ? AppResources.On : AppResources.Off,
                    ExecuteAsync = () => LoggerReportingAsync()
                },
#endif
                new SettingsPageListItem
                {
                    Name         = AppResources.RateTheApp,
                    ExecuteAsync = () => Device.InvokeOnMainThreadAsync(() => Rate())
                },
                new SettingsPageListItem
                {
                    Name         = AppResources.DeleteAccount,
                    ExecuteAsync = () => Page.Navigation.PushModalAsync(new NavigationPage(new DeleteAccountPage()))
                }
            };

            // TODO: improve this. Leaving this as is to reduce error possibility on the hotfix.
            var settingsListGroupItems = new List <SettingsPageListGroup>()
            {
                new SettingsPageListGroup(autofillItems, AppResources.Autofill, doUpper, true),
                new SettingsPageListGroup(manageItems, AppResources.Manage, doUpper),
                new SettingsPageListGroup(securityItems, AppResources.Security, doUpper),
                new SettingsPageListGroup(accountItems, AppResources.Account, doUpper),
                new SettingsPageListGroup(toolsItems, AppResources.Tools, doUpper),
                new SettingsPageListGroup(otherItems, AppResources.Other, doUpper)
            };

            // TODO: refactor this
            if (Device.RuntimePlatform == Device.Android
                ||
                GroupedItems.Any())
            {
                var items = new List <ISettingsPageListItem>();
                foreach (var itemGroup in settingsListGroupItems)
                {
                    items.Add(new SettingsPageHeaderListItem(itemGroup.Name));
                    items.AddRange(itemGroup);
                }

                GroupedItems.ReplaceRange(items);
            }
            else
            {
                // HACK: we need this on iOS, so that it doesn't crash when adding coming from an empty list
                var first = true;
                var items = new List <ISettingsPageListItem>();
                foreach (var itemGroup in settingsListGroupItems)
                {
                    if (!first)
                    {
                        items.Add(new SettingsPageHeaderListItem(itemGroup.Name));
                    }
                    else
                    {
                        first = false;
                    }
                    items.AddRange(itemGroup);
                }

                if (settingsListGroupItems.Any())
                {
                    GroupedItems.ReplaceRange(new List <ISettingsPageListItem> {
                        new SettingsPageHeaderListItem(settingsListGroupItems[0].Name)
                    });
                    GroupedItems.AddRange(items);
                }
                else
                {
                    GroupedItems.Clear();
                }
            }
        }
        public void BuildList()
        {
            var doUpper       = Device.RuntimePlatform != Device.Android;
            var autofillItems = new List <SettingsPageListItem>();

            if (Device.RuntimePlatform == Device.Android)
            {
                autofillItems.Add(new SettingsPageListItem
                {
                    Name     = AppResources.AutofillServices,
                    SubLabel = _deviceActionService.AutofillServicesEnabled() ?
                               AppResources.Enabled : AppResources.Disabled
                });
            }
            else
            {
                if (_deviceActionService.SystemMajorVersion() >= 12)
                {
                    autofillItems.Add(new SettingsPageListItem {
                        Name = AppResources.PasswordAutofill
                    });
                }
                autofillItems.Add(new SettingsPageListItem {
                    Name = AppResources.AppExtension
                });
            }
            var manageItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.Folders
                },
                new SettingsPageListItem {
                    Name = AppResources.Sync, SubLabel = _lastSyncDate
                }
            };
            var securityItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.VaultTimeout, SubLabel = _vaultTimeoutDisplayValue
                },
                new SettingsPageListItem
                {
                    Name     = AppResources.VaultTimeoutAction,
                    SubLabel = _vaultTimeoutActionDisplayValue
                },
                new SettingsPageListItem
                {
                    Name     = AppResources.UnlockWithPIN,
                    SubLabel = _pin ? AppResources.Enabled : AppResources.Disabled
                },
                new SettingsPageListItem {
                    Name = AppResources.LockNow
                },
                new SettingsPageListItem {
                    Name = AppResources.TwoStepLogin
                }
            };

            if (_supportsBiometric || _biometric)
            {
                var biometricName = AppResources.Biometrics;
                if (Device.RuntimePlatform == Device.iOS)
                {
                    biometricName = _deviceActionService.SupportsFaceBiometric() ? AppResources.FaceID :
                                    AppResources.TouchID;
                }
                var item = new SettingsPageListItem
                {
                    Name     = string.Format(AppResources.UnlockWith, biometricName),
                    SubLabel = _biometric ? AppResources.Enabled : AppResources.Disabled
                };
                securityItems.Insert(2, item);
            }
            if (_vaultTimeoutDisplayValue == AppResources.Custom)
            {
                securityItems.Insert(1, new SettingsPageListItem
                {
                    Name = AppResources.Custom,
                    Time = TimeSpan.FromMinutes(Math.Abs((double)_vaultTimeout.GetValueOrDefault())),
                });
            }
            if (_vaultTimeoutPolicy != null)
            {
                var maximumTimeout = _policyService.GetPolicyInt(_vaultTimeoutPolicy, "minutes").GetValueOrDefault();
                securityItems.Insert(0, new SettingsPageListItem
                {
                    Name = string.Format(AppResources.VaultTimeoutPolicyInEffect,
                                         Math.Floor((float)maximumTimeout / 60),
                                         maximumTimeout % 60),
                    UseFrame = true,
                });
            }
            var accountItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.FingerprintPhrase
                },
                new SettingsPageListItem {
                    Name = AppResources.LogOut
                }
            };

            if (_showChangeMasterPassword)
            {
                accountItems.Insert(0, new SettingsPageListItem {
                    Name = AppResources.ChangeMasterPassword
                });
            }
            var toolsItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.ImportItems
                },
                new SettingsPageListItem {
                    Name = AppResources.ExportVault
                }
            };

            if (IncludeLinksWithSubscriptionInfo())
            {
                toolsItems.Add(new SettingsPageListItem {
                    Name = AppResources.LearnOrg
                });
                toolsItems.Add(new SettingsPageListItem {
                    Name = AppResources.WebVault
                });
            }
            var otherItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.Options
                },
                new SettingsPageListItem {
                    Name = AppResources.About
                },
                new SettingsPageListItem {
                    Name = AppResources.HelpAndFeedback
                },
                new SettingsPageListItem {
                    Name = AppResources.RateTheApp
                },
                new SettingsPageListItem {
                    Name = AppResources.DeleteAccount
                }
            };

            GroupedItems.ResetWithRange(new List <SettingsPageListGroup>
            {
                new SettingsPageListGroup(autofillItems, AppResources.Autofill, doUpper, true),
                new SettingsPageListGroup(manageItems, AppResources.Manage, doUpper),
                new SettingsPageListGroup(securityItems, AppResources.Security, doUpper),
                new SettingsPageListGroup(accountItems, AppResources.Account, doUpper),
                new SettingsPageListGroup(toolsItems, AppResources.Tools, doUpper),
                new SettingsPageListGroup(otherItems, AppResources.Other, doUpper)
            });
        }
示例#6
0
        public void BuildList()
        {
            var doUpper       = Device.RuntimePlatform != Device.Android;
            var autofillItems = new List <SettingsPageListItem>();

            if (Device.RuntimePlatform == Device.Android)
            {
                autofillItems.Add(new SettingsPageListItem
                {
                    Name     = AppResources.AutofillServices,
                    SubLabel = _deviceActionService.AutofillServicesEnabled() ?
                               AppResources.Enabled : AppResources.Disabled
                });
            }
            else
            {
                if (_deviceActionService.SystemMajorVersion() >= 12)
                {
                    autofillItems.Add(new SettingsPageListItem {
                        Name = AppResources.PasswordAutofill
                    });
                }
                autofillItems.Add(new SettingsPageListItem {
                    Name = AppResources.AppExtension
                });
            }
            var manageItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.Folders
                },
                new SettingsPageListItem {
                    Name = AppResources.Sync, SubLabel = _lastSyncDate
                }
            };
            var securityItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.VaultTimeout, SubLabel = _vaultTimeoutDisplayValue
                },
                new SettingsPageListItem
                {
                    Name     = AppResources.VaultTimeoutAction,
                    SubLabel = _vaultTimeoutActionDisplayValue
                },
                new SettingsPageListItem
                {
                    Name     = AppResources.UnlockWithPIN,
                    SubLabel = _pin ? AppResources.Enabled : AppResources.Disabled
                },
                new SettingsPageListItem {
                    Name = AppResources.LockNow
                },
                new SettingsPageListItem {
                    Name = AppResources.TwoStepLogin
                }
            };

            if (_supportsBiometric || _biometric)
            {
                var biometricName = AppResources.Biometrics;
                if (Device.RuntimePlatform == Device.iOS)
                {
                    biometricName = _deviceActionService.SupportsFaceBiometric() ? AppResources.FaceID :
                                    AppResources.TouchID;
                }
                var item = new SettingsPageListItem
                {
                    Name     = string.Format(AppResources.UnlockWith, biometricName),
                    SubLabel = _biometric ? AppResources.Enabled : AppResources.Disabled
                };
                securityItems.Insert(2, item);
            }
            var accountItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.ChangeMasterPassword
                },
                new SettingsPageListItem {
                    Name = AppResources.FingerprintPhrase
                },
                new SettingsPageListItem {
                    Name = AppResources.LogOut
                }
            };
            var toolsItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.ImportItems
                },
                new SettingsPageListItem {
                    Name = AppResources.ExportVault
                },
                new SettingsPageListItem {
                    Name = AppResources.ShareVault
                },
                new SettingsPageListItem {
                    Name = AppResources.WebVault
                }
            };
            var otherItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.Options
                },
                new SettingsPageListItem {
                    Name = AppResources.About
                },
                new SettingsPageListItem {
                    Name = AppResources.HelpAndFeedback
                },
                new SettingsPageListItem {
                    Name = AppResources.RateTheApp
                }
            };

            GroupedItems.ResetWithRange(new List <SettingsPageListGroup>
            {
                new SettingsPageListGroup(autofillItems, AppResources.Autofill, doUpper, true),
                new SettingsPageListGroup(manageItems, AppResources.Manage, doUpper),
                new SettingsPageListGroup(securityItems, AppResources.Security, doUpper),
                new SettingsPageListGroup(accountItems, AppResources.Account, doUpper),
                new SettingsPageListGroup(toolsItems, AppResources.Tools, doUpper),
                new SettingsPageListGroup(otherItems, AppResources.Other, doUpper)
            });
        }
示例#7
0
        public void BuildList()
        {
            var doUpper       = Device.RuntimePlatform != Device.Android;
            var autofillItems = new List <SettingsPageListItem>();

            if (Device.RuntimePlatform == Device.Android)
            {
                if (_deviceActionService.SupportsAutofillService())
                {
                    autofillItems.Add(new SettingsPageListItem
                    {
                        Name     = AppResources.AutofillService,
                        SubLabel = _deviceActionService.AutofillServiceEnabled() ?
                                   AppResources.Enabled : AppResources.Disabled
                    });
                }

                var accessibilityEnabled = _deviceActionService.AutofillAccessibilityServiceRunning() &&
                                           _deviceActionService.AutofillAccessibilityOverlayPermitted();
                autofillItems.Add(new SettingsPageListItem
                {
                    Name     = AppResources.AutofillAccessibilityService,
                    SubLabel = accessibilityEnabled ?
                               AppResources.Enabled : AppResources.Disabled
                });
            }
            else
            {
                if (_deviceActionService.SystemMajorVersion() >= 12)
                {
                    autofillItems.Add(new SettingsPageListItem {
                        Name = AppResources.PasswordAutofill
                    });
                }
                autofillItems.Add(new SettingsPageListItem {
                    Name = AppResources.AppExtension
                });
            }
            var manageItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.Folders
                },
                new SettingsPageListItem {
                    Name = AppResources.Sync, SubLabel = _lastSyncDate
                }
            };
            var securityItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.LockOptions, SubLabel = _lockOptionValue
                },
                new SettingsPageListItem
                {
                    Name     = AppResources.UnlockWithPIN,
                    SubLabel = _pin ? AppResources.Enabled : AppResources.Disabled
                },
                new SettingsPageListItem {
                    Name = AppResources.LockNow
                },
                new SettingsPageListItem {
                    Name = AppResources.TwoStepLogin
                }
            };

            if (_supportsFingerprint || _fingerprint)
            {
                var fingerprintName = AppResources.Fingerprint;
                if (Device.RuntimePlatform == Device.iOS)
                {
                    fingerprintName = _deviceActionService.SupportsFaceBiometric() ? AppResources.FaceID :
                                      AppResources.TouchID;
                }
                else if (Device.RuntimePlatform == Device.Android && _deviceActionService.UseNativeBiometric())
                {
                    fingerprintName = AppResources.Biometrics;
                }
                var item = new SettingsPageListItem
                {
                    Name     = string.Format(AppResources.UnlockWith, fingerprintName),
                    SubLabel = _fingerprint ? AppResources.Enabled : AppResources.Disabled
                };
                securityItems.Insert(1, item);
            }
            var accountItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.ChangeMasterPassword
                },
                new SettingsPageListItem {
                    Name = AppResources.FingerprintPhrase
                },
                new SettingsPageListItem {
                    Name = AppResources.LogOut
                }
            };
            var toolsItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.ImportItems
                },
                new SettingsPageListItem {
                    Name = AppResources.ExportVault
                },
                new SettingsPageListItem {
                    Name = AppResources.ShareVault
                },
                new SettingsPageListItem {
                    Name = AppResources.WebVault
                }
            };
            var otherItems = new List <SettingsPageListItem>
            {
                new SettingsPageListItem {
                    Name = AppResources.Options
                },
                new SettingsPageListItem {
                    Name = AppResources.About
                },
                new SettingsPageListItem {
                    Name = AppResources.HelpAndFeedback
                },
                new SettingsPageListItem {
                    Name = AppResources.RateTheApp
                }
            };

            GroupedItems.ResetWithRange(new List <SettingsPageListGroup>
            {
                new SettingsPageListGroup(autofillItems, AppResources.Autofill, doUpper, true),
                new SettingsPageListGroup(manageItems, AppResources.Manage, doUpper),
                new SettingsPageListGroup(securityItems, AppResources.Security, doUpper),
                new SettingsPageListGroup(accountItems, AppResources.Account, doUpper),
                new SettingsPageListGroup(toolsItems, AppResources.Tools, doUpper),
                new SettingsPageListGroup(otherItems, AppResources.Other, doUpper)
            });
        }