diff --git a/src/Android/MainApplication.cs b/src/Android/MainApplication.cs index 8634a6040..847608687 100644 --- a/src/Android/MainApplication.cs +++ b/src/Android/MainApplication.cs @@ -5,6 +5,7 @@ using Android.App; using Android.Runtime; using Bit.App.Abstractions; using Bit.App.Services; +using Bit.Core; using Bit.Core.Abstractions; using Bit.Core.Services; using Bit.Core.Utilities; @@ -104,6 +105,10 @@ namespace Bit.Droid private async Task BootstrapAsync() { + var disableFavicon = await ServiceContainer.Resolve("storageService").GetAsync( + Constants.DisableFaviconKey); + await ServiceContainer.Resolve("stateService").SaveAsync(Constants.DisableFaviconKey, + disableFavicon); await ServiceContainer.Resolve("environmentService").SetUrlsFromStorageAsync(); } } diff --git a/src/Android/Services/DeviceActionService.cs b/src/Android/Services/DeviceActionService.cs index 5e860f3c4..85bf6c988 100644 --- a/src/Android/Services/DeviceActionService.cs +++ b/src/Android/Services/DeviceActionService.cs @@ -562,7 +562,7 @@ namespace Bit.Droid.Services { var autoCopyDisabled = await _storageService.GetAsync(Constants.DisableAutoTotpCopyKey); var canAccessPremium = await ServiceContainer.Resolve("userService").CanAccessPremiumAsync(); - if(canAccessPremium && !autoCopyDisabled.GetValueOrDefault() && + if((canAccessPremium || cipher.OrganizationUseTotp) && !autoCopyDisabled.GetValueOrDefault() && !string.IsNullOrWhiteSpace(cipher?.Login?.Totp)) { var totp = await ServiceContainer.Resolve("totpService").GetCodeAsync(cipher.Login.Totp); diff --git a/src/App/Controls/CipherViewCell/CipherViewCell.xaml.cs b/src/App/Controls/CipherViewCell/CipherViewCell.xaml.cs index e6432bc83..721a85a52 100644 --- a/src/App/Controls/CipherViewCell/CipherViewCell.xaml.cs +++ b/src/App/Controls/CipherViewCell/CipherViewCell.xaml.cs @@ -1,9 +1,11 @@ using Bit.App.Pages; using Bit.Core; +using Bit.Core.Abstractions; using Bit.Core.Enums; using Bit.Core.Models.View; using Bit.Core.Utilities; using System; +using System.Threading.Tasks; using Xamarin.Forms; namespace Bit.App.Controls @@ -16,12 +18,18 @@ namespace Bit.App.Controls public static readonly BindableProperty ButtonCommandProperty = BindableProperty.Create( nameof(ButtonCommand), typeof(Command), typeof(CipherViewCell)); + private readonly IStateService _stateService; + private readonly IEnvironmentService _environmentService; + private CipherViewCellViewModel _viewModel; public CipherViewCell() { InitializeComponent(); _viewModel = _grid.BindingContext as CipherViewCellViewModel; + + _stateService = ServiceContainer.Resolve("stateService"); + _environmentService = ServiceContainer.Resolve("environmentService"); } public CipherView Cipher @@ -45,7 +53,7 @@ namespace Bit.App.Controls } } - protected override void OnBindingContextChanged() + protected async override void OnBindingContextChanged() { string icon = null; string image = null; @@ -65,7 +73,7 @@ namespace Bit.App.Controls switch(cipher.Type) { case CipherType.Login: - var loginIconImage = GetLoginIconImage(cipher); + var loginIconImage = await GetLoginIconImage(cipher); icon = loginIconImage.Item1; image = loginIconImage.Item2; break; @@ -99,11 +107,11 @@ namespace Bit.App.Controls base.OnBindingContextChanged(); } - private Tuple GetLoginIconImage(CipherView cipher) + private async Task> GetLoginIconImage(CipherView cipher) { string icon = ""; string image = null; - var imageEnabled = true; + var imageEnabled = !(await _stateService.GetAsync(Constants.DisableFaviconKey)).GetValueOrDefault(); if(cipher.Login.Uri != null) { var hostnameUri = cipher.Login.Uri; @@ -130,7 +138,18 @@ namespace Bit.App.Controls if(imageEnabled && isWebsite) { var hostname = CoreHelpers.GetHostname(hostnameUri); - var iconsUrl = "https://icons.bitwarden.net"; + var iconsUrl = _environmentService.IconsUrl; + if(string.IsNullOrWhiteSpace(iconsUrl)) + { + if(!string.IsNullOrWhiteSpace(_environmentService.BaseUrl)) + { + iconsUrl = string.Format("{0}/icons", _environmentService.BaseUrl); + } + else + { + iconsUrl = "https://icons.bitwarden.net"; + } + } image = string.Format("{0}/{1}/icon.png", iconsUrl, hostname); } }