2019-05-15 19:09:49 +02:00
|
|
|
|
using Bit.App.Abstractions;
|
|
|
|
|
using Bit.App.Resources;
|
2019-05-15 15:14:49 +02:00
|
|
|
|
using Bit.Core.Abstractions;
|
|
|
|
|
using Bit.Core.Utilities;
|
2019-05-14 15:09:35 +02:00
|
|
|
|
using System;
|
2019-03-29 04:52:33 +01:00
|
|
|
|
using System.Collections.Generic;
|
2019-05-15 15:14:49 +02:00
|
|
|
|
using System.Threading.Tasks;
|
2019-04-05 22:13:17 +02:00
|
|
|
|
using Xamarin.Forms;
|
2019-03-29 04:52:33 +01:00
|
|
|
|
|
|
|
|
|
namespace Bit.App.Pages
|
|
|
|
|
{
|
|
|
|
|
public class SettingsPageViewModel : BaseViewModel
|
|
|
|
|
{
|
2019-05-15 15:14:49 +02:00
|
|
|
|
private readonly IPlatformUtilsService _platformUtilsService;
|
2019-05-15 18:54:48 +02:00
|
|
|
|
private readonly ICryptoService _cryptoService;
|
|
|
|
|
private readonly IUserService _userService;
|
2019-05-15 19:09:49 +02:00
|
|
|
|
private readonly IDeviceActionService _deviceActionService;
|
2019-05-15 15:14:49 +02:00
|
|
|
|
|
2019-03-29 04:52:33 +01:00
|
|
|
|
public SettingsPageViewModel()
|
|
|
|
|
{
|
2019-05-15 15:14:49 +02:00
|
|
|
|
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
|
2019-05-15 18:54:48 +02:00
|
|
|
|
_cryptoService = ServiceContainer.Resolve<ICryptoService>("cryptoService");
|
|
|
|
|
_userService = ServiceContainer.Resolve<IUserService>("userService");
|
2019-05-15 19:09:49 +02:00
|
|
|
|
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
2019-04-05 22:13:17 +02:00
|
|
|
|
|
2019-05-15 15:14:49 +02:00
|
|
|
|
PageTitle = AppResources.Settings;
|
2019-05-14 17:53:41 +02:00
|
|
|
|
BuildList();
|
2019-03-29 04:52:33 +01:00
|
|
|
|
}
|
2019-04-05 22:13:17 +02:00
|
|
|
|
|
2019-05-14 17:53:41 +02:00
|
|
|
|
public List<SettingsPageListGroup> GroupedItems { get; set; }
|
|
|
|
|
|
2019-05-15 15:14:49 +02:00
|
|
|
|
public async Task AboutAsync()
|
|
|
|
|
{
|
|
|
|
|
var debugText = string.Format("{0}: {1}", AppResources.Version,
|
|
|
|
|
_platformUtilsService.GetApplicationVersion());
|
|
|
|
|
var text = string.Format("© 8bit Solutions LLC 2015-{0}\n\n{1}", DateTime.Now.Year, debugText);
|
|
|
|
|
var copy = await _platformUtilsService.ShowDialogAsync(text, AppResources.Bitwarden, AppResources.Copy,
|
|
|
|
|
AppResources.Close);
|
|
|
|
|
if(copy)
|
|
|
|
|
{
|
|
|
|
|
await _platformUtilsService.CopyToClipboardAsync(debugText);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-15 18:54:48 +02:00
|
|
|
|
public void Help()
|
|
|
|
|
{
|
|
|
|
|
_platformUtilsService.LaunchUri("https://help.bitwarden.com/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task FingerprintAsync()
|
|
|
|
|
{
|
|
|
|
|
var fingerprint = await _cryptoService.GetFingerprintAsync(await _userService.GetUserIdAsync());
|
|
|
|
|
var phrase = string.Join("-", fingerprint);
|
2019-05-15 18:55:52 +02:00
|
|
|
|
var text = string.Format("{0}:\n\n{1}", AppResources.YourAccountsFingerprint, phrase);
|
2019-05-15 18:54:48 +02:00
|
|
|
|
var learnMore = await _platformUtilsService.ShowDialogAsync(text, AppResources.FingerprintPhrase,
|
|
|
|
|
AppResources.LearnMore, AppResources.Close);
|
|
|
|
|
if(learnMore)
|
|
|
|
|
{
|
|
|
|
|
_platformUtilsService.LaunchUri("https://help.bitwarden.com/article/fingerprint-phrase/");
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-15 19:09:49 +02:00
|
|
|
|
|
|
|
|
|
public void Rate()
|
|
|
|
|
{
|
|
|
|
|
_deviceActionService.RateApp();
|
|
|
|
|
}
|
2019-05-15 18:54:48 +02:00
|
|
|
|
|
2019-05-14 17:53:41 +02:00
|
|
|
|
private void BuildList()
|
|
|
|
|
{
|
|
|
|
|
var doUpper = Device.RuntimePlatform != Device.Android;
|
|
|
|
|
var manageItems = new List<SettingsPageListItem>
|
|
|
|
|
{
|
|
|
|
|
new SettingsPageListItem { Name = AppResources.Folders },
|
|
|
|
|
new SettingsPageListItem { Name = AppResources.Sync }
|
|
|
|
|
};
|
|
|
|
|
var securityItems = new List<SettingsPageListItem>
|
|
|
|
|
{
|
|
|
|
|
new SettingsPageListItem { Name = AppResources.LockOptions },
|
|
|
|
|
new SettingsPageListItem { Name = string.Format(AppResources.UnlockWith, AppResources.Fingerprint) },
|
|
|
|
|
new SettingsPageListItem { Name = AppResources.UnlockWithPIN },
|
|
|
|
|
new SettingsPageListItem { Name = AppResources.Lock },
|
|
|
|
|
new SettingsPageListItem { Name = AppResources.TwoStepLogin }
|
|
|
|
|
};
|
|
|
|
|
var accountItems = new List<SettingsPageListItem>
|
|
|
|
|
{
|
|
|
|
|
new SettingsPageListItem { Name = AppResources.ChangeMasterPassword },
|
2019-05-15 18:54:48 +02:00
|
|
|
|
new SettingsPageListItem { Name = AppResources.FingerprintPhrase },
|
2019-05-14 17:53:41 +02:00
|
|
|
|
new SettingsPageListItem { Name = AppResources.LogOut }
|
|
|
|
|
};
|
|
|
|
|
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 = new List<SettingsPageListGroup>
|
|
|
|
|
{
|
|
|
|
|
new SettingsPageListGroup(manageItems, AppResources.Manage, doUpper),
|
|
|
|
|
new SettingsPageListGroup(securityItems, AppResources.Security, doUpper),
|
|
|
|
|
new SettingsPageListGroup(accountItems, AppResources.Account, doUpper),
|
|
|
|
|
new SettingsPageListGroup(otherItems, AppResources.Other, doUpper)
|
|
|
|
|
};
|
|
|
|
|
}
|
2019-03-29 04:52:33 +01:00
|
|
|
|
}
|
|
|
|
|
}
|