mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +03:00
disable website icons option
This commit is contained in:
parent
37974c7ec8
commit
05f4036309
9 changed files with 103 additions and 13 deletions
|
@ -9,6 +9,7 @@ namespace Bit.App.Abstractions
|
||||||
DateTime LastCacheClear { get; set; }
|
DateTime LastCacheClear { get; set; }
|
||||||
bool AutofillPersistNotification { get; set; }
|
bool AutofillPersistNotification { get; set; }
|
||||||
bool AutofillPasswordField { get; set; }
|
bool AutofillPasswordField { get; set; }
|
||||||
|
bool DisableWebsiteIcons { get; set; }
|
||||||
string SecurityStamp { get; set; }
|
string SecurityStamp { get; set; }
|
||||||
string BaseUrl { get; set; }
|
string BaseUrl { get; set; }
|
||||||
string WebVaultUrl { get; set; }
|
string WebVaultUrl { get; set; }
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
public const string SettingPinUnlockOn = "setting:pinUnlockOn";
|
public const string SettingPinUnlockOn = "setting:pinUnlockOn";
|
||||||
public const string SettingLockSeconds = "setting:lockSeconds";
|
public const string SettingLockSeconds = "setting:lockSeconds";
|
||||||
public const string SettingGaOptOut = "setting:googleAnalyticsOptOut";
|
public const string SettingGaOptOut = "setting:googleAnalyticsOptOut";
|
||||||
|
public const string SettingDisableWebsiteIcons = "setting:disableWebsiteIcons";
|
||||||
public const string SettingDisableTotpCopy = "setting:disableAutoCopyTotp";
|
public const string SettingDisableTotpCopy = "setting:disableAutoCopyTotp";
|
||||||
public const string AutofillPersistNotification = "setting:persistNotification";
|
public const string AutofillPersistNotification = "setting:persistNotification";
|
||||||
public const string AutofillPasswordField = "setting:autofillPasswordField";
|
public const string AutofillPasswordField = "setting:autofillPasswordField";
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Bit.App.Models.Page
|
||||||
{
|
{
|
||||||
public class Cipher
|
public class Cipher
|
||||||
{
|
{
|
||||||
public Cipher(Models.Cipher cipher)
|
public Cipher(Models.Cipher cipher, bool imageEnabled)
|
||||||
{
|
{
|
||||||
Id = cipher.Id;
|
Id = cipher.Id;
|
||||||
Shared = !string.IsNullOrWhiteSpace(cipher.OrganizationId);
|
Shared = !string.IsNullOrWhiteSpace(cipher.OrganizationId);
|
||||||
|
@ -38,17 +38,17 @@ namespace Bit.App.Models.Page
|
||||||
{
|
{
|
||||||
Icon = "apple.png";
|
Icon = "apple.png";
|
||||||
}
|
}
|
||||||
else if(!hostnameUri.Contains("://") && hostnameUri.Contains("."))
|
else if(imageEnabled && !hostnameUri.Contains("://") && hostnameUri.Contains("."))
|
||||||
{
|
{
|
||||||
hostnameUri = $"http://{hostnameUri}";
|
hostnameUri = $"http://{hostnameUri}";
|
||||||
isWebsite = true;
|
isWebsite = true;
|
||||||
}
|
}
|
||||||
else if(true)
|
else if(imageEnabled)
|
||||||
{
|
{
|
||||||
isWebsite = hostnameUri.StartsWith("http") && hostnameUri.Contains(".");
|
isWebsite = hostnameUri.StartsWith("http") && hostnameUri.Contains(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isWebsite && Uri.TryCreate(LoginUri, UriKind.Absolute, out Uri u))
|
if(imageEnabled && isWebsite && Uri.TryCreate(LoginUri, UriKind.Absolute, out Uri u))
|
||||||
{
|
{
|
||||||
Icon = "https://icons.bitwarden.com/" + u.Host + "/icon.png";
|
Icon = "https://icons.bitwarden.com/" + u.Host + "/icon.png";
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,8 @@ namespace Bit.App.Models.Page
|
||||||
|
|
||||||
public class AutofillCipher : Cipher
|
public class AutofillCipher : Cipher
|
||||||
{
|
{
|
||||||
public AutofillCipher(Models.Cipher cipher, bool fuzzy = false)
|
public AutofillCipher(Models.Cipher cipher, bool imageEnabled, bool fuzzy = false)
|
||||||
: base(cipher)
|
: base(cipher, imageEnabled)
|
||||||
{
|
{
|
||||||
Fuzzy = fuzzy;
|
Fuzzy = fuzzy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ namespace Bit.App.Pages
|
||||||
private Label CopyTotpLabel { get; set; }
|
private Label CopyTotpLabel { get; set; }
|
||||||
private ExtendedSwitchCell AnalyticsCell { get; set; }
|
private ExtendedSwitchCell AnalyticsCell { get; set; }
|
||||||
private Label AnalyticsLabel { get; set; }
|
private Label AnalyticsLabel { get; set; }
|
||||||
|
private ExtendedSwitchCell WebsiteIconsCell { get; set; }
|
||||||
|
private Label WebsiteIconsLabel { get; set; }
|
||||||
private ExtendedSwitchCell AutofillPersistNotificationCell { get; set; }
|
private ExtendedSwitchCell AutofillPersistNotificationCell { get; set; }
|
||||||
private Label AutofillPersistNotificationLabel { get; set; }
|
private Label AutofillPersistNotificationLabel { get; set; }
|
||||||
private ExtendedSwitchCell AutofillPasswordFieldCell { get; set; }
|
private ExtendedSwitchCell AutofillPasswordFieldCell { get; set; }
|
||||||
|
@ -37,13 +39,30 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
private void Init()
|
private void Init()
|
||||||
{
|
{
|
||||||
|
WebsiteIconsCell = new ExtendedSwitchCell
|
||||||
|
{
|
||||||
|
Text = AppResources.DisableWebsiteIcons,
|
||||||
|
On = _appSettings.DisableWebsiteIcons
|
||||||
|
};
|
||||||
|
|
||||||
|
var websiteIconsTable = new FormTableView(true)
|
||||||
|
{
|
||||||
|
Root = new TableRoot
|
||||||
|
{
|
||||||
|
new TableSection(" ")
|
||||||
|
{
|
||||||
|
WebsiteIconsCell
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
CopyTotpCell = new ExtendedSwitchCell
|
CopyTotpCell = new ExtendedSwitchCell
|
||||||
{
|
{
|
||||||
Text = AppResources.DisableAutoTotpCopy,
|
Text = AppResources.DisableAutoTotpCopy,
|
||||||
On = _settings.GetValueOrDefault(Constants.SettingDisableTotpCopy, false)
|
On = _settings.GetValueOrDefault(Constants.SettingDisableTotpCopy, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
var totpTable = new FormTableView(true)
|
var totpTable = new FormTableView
|
||||||
{
|
{
|
||||||
Root = new TableRoot
|
Root = new TableRoot
|
||||||
{
|
{
|
||||||
|
@ -81,9 +100,19 @@ namespace Bit.App.Pages
|
||||||
Text = AppResources.DisableGADescription
|
Text = AppResources.DisableGADescription
|
||||||
};
|
};
|
||||||
|
|
||||||
|
WebsiteIconsLabel = new FormTableLabel(this)
|
||||||
|
{
|
||||||
|
Text = AppResources.DisableWebsiteIconsDescription
|
||||||
|
};
|
||||||
|
|
||||||
StackLayout = new StackLayout
|
StackLayout = new StackLayout
|
||||||
{
|
{
|
||||||
Children = { totpTable, CopyTotpLabel, analyticsTable, AnalyticsLabel },
|
Children =
|
||||||
|
{
|
||||||
|
websiteIconsTable, WebsiteIconsLabel,
|
||||||
|
totpTable, CopyTotpLabel,
|
||||||
|
analyticsTable, AnalyticsLabel
|
||||||
|
},
|
||||||
Spacing = 0
|
Spacing = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -170,8 +199,9 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows)
|
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows)
|
||||||
{
|
{
|
||||||
analyticsTable.RowHeight = -1;
|
analyticsTable.RowHeight = websiteIconsTable.RowHeight = totpTable.RowHeight = -1;
|
||||||
analyticsTable.EstimatedRowHeight = 70;
|
analyticsTable.EstimatedRowHeight = websiteIconsTable.EstimatedRowHeight =
|
||||||
|
totpTable.EstimatedRowHeight = 70;
|
||||||
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
|
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,6 +214,7 @@ namespace Bit.App.Pages
|
||||||
base.OnAppearing();
|
base.OnAppearing();
|
||||||
|
|
||||||
AnalyticsCell.OnChanged += AnalyticsCell_Changed;
|
AnalyticsCell.OnChanged += AnalyticsCell_Changed;
|
||||||
|
WebsiteIconsCell.OnChanged += WebsiteIconsCell_Changed;
|
||||||
CopyTotpCell.OnChanged += CopyTotpCell_OnChanged;
|
CopyTotpCell.OnChanged += CopyTotpCell_OnChanged;
|
||||||
StackLayout.LayoutChanged += Layout_LayoutChanged;
|
StackLayout.LayoutChanged += Layout_LayoutChanged;
|
||||||
|
|
||||||
|
@ -200,6 +231,7 @@ namespace Bit.App.Pages
|
||||||
base.OnDisappearing();
|
base.OnDisappearing();
|
||||||
|
|
||||||
AnalyticsCell.OnChanged -= AnalyticsCell_Changed;
|
AnalyticsCell.OnChanged -= AnalyticsCell_Changed;
|
||||||
|
WebsiteIconsCell.OnChanged -= WebsiteIconsCell_Changed;
|
||||||
CopyTotpCell.OnChanged -= CopyTotpCell_OnChanged;
|
CopyTotpCell.OnChanged -= CopyTotpCell_OnChanged;
|
||||||
StackLayout.LayoutChanged -= Layout_LayoutChanged;
|
StackLayout.LayoutChanged -= Layout_LayoutChanged;
|
||||||
|
|
||||||
|
@ -214,6 +246,7 @@ namespace Bit.App.Pages
|
||||||
private void Layout_LayoutChanged(object sender, EventArgs e)
|
private void Layout_LayoutChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
AnalyticsLabel.WidthRequest = StackLayout.Bounds.Width - AnalyticsLabel.Bounds.Left * 2;
|
AnalyticsLabel.WidthRequest = StackLayout.Bounds.Width - AnalyticsLabel.Bounds.Left * 2;
|
||||||
|
WebsiteIconsLabel.WidthRequest = StackLayout.Bounds.Width - WebsiteIconsLabel.Bounds.Left * 2;
|
||||||
CopyTotpLabel.WidthRequest = StackLayout.Bounds.Width - CopyTotpLabel.Bounds.Left * 2;
|
CopyTotpLabel.WidthRequest = StackLayout.Bounds.Width - CopyTotpLabel.Bounds.Left * 2;
|
||||||
|
|
||||||
if(AutofillAlwaysLabel != null)
|
if(AutofillAlwaysLabel != null)
|
||||||
|
@ -233,6 +266,17 @@ namespace Bit.App.Pages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void WebsiteIconsCell_Changed(object sender, ToggledEventArgs e)
|
||||||
|
{
|
||||||
|
var cell = sender as ExtendedSwitchCell;
|
||||||
|
if(cell == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_appSettings.DisableWebsiteIcons = cell.On;
|
||||||
|
}
|
||||||
|
|
||||||
private void AnalyticsCell_Changed(object sender, ToggledEventArgs e)
|
private void AnalyticsCell_Changed(object sender, ToggledEventArgs e)
|
||||||
{
|
{
|
||||||
var cell = sender as ExtendedSwitchCell;
|
var cell = sender as ExtendedSwitchCell;
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace Bit.App.Pages
|
||||||
private readonly IDeviceInfoService _deviceInfoService;
|
private readonly IDeviceInfoService _deviceInfoService;
|
||||||
private readonly IDeviceActionService _clipboardService;
|
private readonly IDeviceActionService _clipboardService;
|
||||||
private readonly ISettingsService _settingsService;
|
private readonly ISettingsService _settingsService;
|
||||||
|
private readonly IAppSettingsService _appSettingsService;
|
||||||
private CancellationTokenSource _filterResultsCancellationTokenSource;
|
private CancellationTokenSource _filterResultsCancellationTokenSource;
|
||||||
private readonly string _name;
|
private readonly string _name;
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ namespace Bit.App.Pages
|
||||||
_clipboardService = Resolver.Resolve<IDeviceActionService>();
|
_clipboardService = Resolver.Resolve<IDeviceActionService>();
|
||||||
_settingsService = Resolver.Resolve<ISettingsService>();
|
_settingsService = Resolver.Resolve<ISettingsService>();
|
||||||
UserDialogs = Resolver.Resolve<IUserDialogs>();
|
UserDialogs = Resolver.Resolve<IUserDialogs>();
|
||||||
|
_appSettingsService = Resolver.Resolve<IAppSettingsService>();
|
||||||
GoogleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
|
GoogleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
@ -159,13 +161,15 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
var cts = new CancellationTokenSource();
|
var cts = new CancellationTokenSource();
|
||||||
_filterResultsCancellationTokenSource?.Cancel();
|
_filterResultsCancellationTokenSource?.Cancel();
|
||||||
|
var websiteIconsEnabled = !_appSettingsService.DisableWebsiteIcons;
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var autofillGroupings = new List<VaultListPageModel.AutofillGrouping>();
|
var autofillGroupings = new List<VaultListPageModel.AutofillGrouping>();
|
||||||
var ciphers = await _cipherService.GetAllAsync(Uri);
|
var ciphers = await _cipherService.GetAllAsync(Uri);
|
||||||
|
|
||||||
var normalLogins = ciphers?.Item1.Select(l => new VaultListPageModel.AutofillCipher(l, false))
|
var normalLogins = ciphers?.Item1.Select(l => new VaultListPageModel.AutofillCipher(
|
||||||
|
l, websiteIconsEnabled, false))
|
||||||
.OrderBy(s => s.Name)
|
.OrderBy(s => s.Name)
|
||||||
.ThenBy(s => s.Subtitle)
|
.ThenBy(s => s.Subtitle)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
@ -174,7 +178,8 @@ namespace Bit.App.Pages
|
||||||
autofillGroupings.Add(new VaultListPageModel.AutofillGrouping(normalLogins, AppResources.MatchingItems));
|
autofillGroupings.Add(new VaultListPageModel.AutofillGrouping(normalLogins, AppResources.MatchingItems));
|
||||||
}
|
}
|
||||||
|
|
||||||
var fuzzyLogins = ciphers?.Item2.Select(l => new VaultListPageModel.AutofillCipher(l, true))
|
var fuzzyLogins = ciphers?.Item2.Select(l => new VaultListPageModel.AutofillCipher(
|
||||||
|
l, websiteIconsEnabled, true))
|
||||||
.OrderBy(s => s.Name)
|
.OrderBy(s => s.Name)
|
||||||
.ThenBy(s => s.LoginUsername)
|
.ThenBy(s => s.LoginUsername)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace Bit.App.Pages
|
||||||
private readonly IPushNotificationService _pushNotification;
|
private readonly IPushNotificationService _pushNotification;
|
||||||
private readonly IDeviceInfoService _deviceInfoService;
|
private readonly IDeviceInfoService _deviceInfoService;
|
||||||
private readonly ISettings _settings;
|
private readonly ISettings _settings;
|
||||||
|
private readonly IAppSettingsService _appSettingsService;
|
||||||
private readonly IGoogleAnalyticsService _googleAnalyticsService;
|
private readonly IGoogleAnalyticsService _googleAnalyticsService;
|
||||||
private readonly bool _favorites;
|
private readonly bool _favorites;
|
||||||
private CancellationTokenSource _filterResultsCancellationTokenSource;
|
private CancellationTokenSource _filterResultsCancellationTokenSource;
|
||||||
|
@ -46,6 +47,7 @@ namespace Bit.App.Pages
|
||||||
_pushNotification = Resolver.Resolve<IPushNotificationService>();
|
_pushNotification = Resolver.Resolve<IPushNotificationService>();
|
||||||
_deviceInfoService = Resolver.Resolve<IDeviceInfoService>();
|
_deviceInfoService = Resolver.Resolve<IDeviceInfoService>();
|
||||||
_settings = Resolver.Resolve<ISettings>();
|
_settings = Resolver.Resolve<ISettings>();
|
||||||
|
_appSettingsService = Resolver.Resolve<IAppSettingsService>();
|
||||||
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
|
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
|
||||||
|
|
||||||
var cryptoService = Resolver.Resolve<ICryptoService>();
|
var cryptoService = Resolver.Resolve<ICryptoService>();
|
||||||
|
@ -309,6 +311,7 @@ namespace Bit.App.Pages
|
||||||
}
|
}
|
||||||
|
|
||||||
_filterResultsCancellationTokenSource?.Cancel();
|
_filterResultsCancellationTokenSource?.Cancel();
|
||||||
|
var websiteIconsEnabled = !_appSettingsService.DisableWebsiteIcons;
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
|
@ -325,7 +328,7 @@ namespace Bit.App.Pages
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
Ciphers = ciphers
|
Ciphers = ciphers
|
||||||
.Select(s => new VaultListPageModel.Cipher(s))
|
.Select(s => new VaultListPageModel.Cipher(s, websiteIconsEnabled))
|
||||||
.OrderBy(s => s.Name)
|
.OrderBy(s => s.Name)
|
||||||
.ThenBy(s => s.Subtitle)
|
.ThenBy(s => s.Subtitle)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
18
src/App/Resources/AppResources.Designer.cs
generated
18
src/App/Resources/AppResources.Designer.cs
generated
|
@ -925,6 +925,24 @@ namespace Bit.App.Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Disable Website Icons.
|
||||||
|
/// </summary>
|
||||||
|
public static string DisableWebsiteIcons {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("DisableWebsiteIcons", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Website Icons provide a recognizable image next to each login item in your vault..
|
||||||
|
/// </summary>
|
||||||
|
public static string DisableWebsiteIconsDescription {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("DisableWebsiteIconsDescription", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Downloading....
|
/// Looks up a localized string similar to Downloading....
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1176,4 +1176,10 @@
|
||||||
<data name="Expiration" xml:space="preserve">
|
<data name="Expiration" xml:space="preserve">
|
||||||
<value>Expiration</value>
|
<value>Expiration</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="DisableWebsiteIcons" xml:space="preserve">
|
||||||
|
<value>Disable Website Icons</value>
|
||||||
|
</data>
|
||||||
|
<data name="DisableWebsiteIconsDescription" xml:space="preserve">
|
||||||
|
<value>Website Icons provide a recognizable image next to each login item in your vault.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -74,6 +74,18 @@ namespace Bit.App.Services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool DisableWebsiteIcons
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _settings.GetValueOrDefault(Constants.SettingDisableWebsiteIcons, false);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_settings.AddOrUpdateValue(Constants.SettingDisableWebsiteIcons, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string SecurityStamp
|
public string SecurityStamp
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
Loading…
Reference in a new issue