Ejemplo n.º 1
0
        public async Task VaultTimeoutAsync(bool promptOptions = true, int newTimeout = 0)
        {
            var oldTimeout = _vaultTimeout;

            var options = _vaultTimeouts.Select(
                o => o.Key == _vaultTimeoutDisplayValue ? $"✓ {o.Key}" : o.Key).ToArray();

            if (promptOptions)
            {
                var selection = await Page.DisplayActionSheet(AppResources.VaultTimeout,
                                                              AppResources.Cancel, null, options);

                if (selection == null || selection == AppResources.Cancel)
                {
                    return;
                }
                var cleanSelection  = selection.Replace("✓ ", string.Empty);
                var selectionOption = _vaultTimeouts.FirstOrDefault(o => o.Key == cleanSelection);
                _vaultTimeoutDisplayValue = selectionOption.Key;
                newTimeout = selectionOption.Value.GetValueOrDefault();
            }

            if (_vaultTimeoutPolicy != null)
            {
                var maximumTimeout = _policyService.GetPolicyInt(_vaultTimeoutPolicy, "minutes");

                if (newTimeout > maximumTimeout)
                {
                    await _platformUtilsService.ShowDialogAsync(AppResources.VaultTimeoutToLarge, AppResources.Warning);

                    var timeout = await _vaultTimeoutService.GetVaultTimeout();

                    _vaultTimeoutDisplayValue = _vaultTimeouts.FirstOrDefault(o => o.Value == timeout).Key ??
                                                AppResources.Custom;
                    return;
                }
            }

            await _vaultTimeoutService.SetVaultTimeoutOptionsAsync(newTimeout,
                                                                   GetVaultTimeoutActionFromKey(_vaultTimeoutActionDisplayValue));

            if (newTimeout != CustomVaultTimeoutValue)
            {
                _vaultTimeout = newTimeout;
            }
            if (oldTimeout != newTimeout)
            {
                await Device.InvokeOnMainThreadAsync(BuildList);
            }
        }
Ejemplo n.º 2
0
        public async Task VaultTimeoutAsync()
        {
            var options = _vaultTimeouts.Select(
                o => o.Key == _vaultTimeoutDisplayValue ? $"✓ {o.Key}" : o.Key).ToArray();
            var selection = await Page.DisplayActionSheet(AppResources.VaultTimeout,
                                                          AppResources.Cancel, null, options);

            if (selection == null || selection == AppResources.Cancel)
            {
                return;
            }
            var cleanSelection  = selection.Replace("✓ ", string.Empty);
            var selectionOption = _vaultTimeouts.FirstOrDefault(o => o.Key == cleanSelection);

            _vaultTimeoutDisplayValue = selectionOption.Key;
            await _vaultTimeoutService.SetVaultTimeoutOptionsAsync(selectionOption.Value,
                                                                   GetVaultTimeoutActionFromKey(_vaultTimeoutActionDisplayValue));

            BuildList();
        }