mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +03:00
disable favicons and totp copy fix for org
This commit is contained in:
parent
6c6da368dd
commit
6be54fa7ee
3 changed files with 30 additions and 6 deletions
|
@ -5,6 +5,7 @@ using Android.App;
|
||||||
using Android.Runtime;
|
using Android.Runtime;
|
||||||
using Bit.App.Abstractions;
|
using Bit.App.Abstractions;
|
||||||
using Bit.App.Services;
|
using Bit.App.Services;
|
||||||
|
using Bit.Core;
|
||||||
using Bit.Core.Abstractions;
|
using Bit.Core.Abstractions;
|
||||||
using Bit.Core.Services;
|
using Bit.Core.Services;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
|
@ -104,6 +105,10 @@ namespace Bit.Droid
|
||||||
|
|
||||||
private async Task BootstrapAsync()
|
private async Task BootstrapAsync()
|
||||||
{
|
{
|
||||||
|
var disableFavicon = await ServiceContainer.Resolve<IStorageService>("storageService").GetAsync<bool?>(
|
||||||
|
Constants.DisableFaviconKey);
|
||||||
|
await ServiceContainer.Resolve<IStateService>("stateService").SaveAsync(Constants.DisableFaviconKey,
|
||||||
|
disableFavicon);
|
||||||
await ServiceContainer.Resolve<IEnvironmentService>("environmentService").SetUrlsFromStorageAsync();
|
await ServiceContainer.Resolve<IEnvironmentService>("environmentService").SetUrlsFromStorageAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -562,7 +562,7 @@ namespace Bit.Droid.Services
|
||||||
{
|
{
|
||||||
var autoCopyDisabled = await _storageService.GetAsync<bool?>(Constants.DisableAutoTotpCopyKey);
|
var autoCopyDisabled = await _storageService.GetAsync<bool?>(Constants.DisableAutoTotpCopyKey);
|
||||||
var canAccessPremium = await ServiceContainer.Resolve<IUserService>("userService").CanAccessPremiumAsync();
|
var canAccessPremium = await ServiceContainer.Resolve<IUserService>("userService").CanAccessPremiumAsync();
|
||||||
if(canAccessPremium && !autoCopyDisabled.GetValueOrDefault() &&
|
if((canAccessPremium || cipher.OrganizationUseTotp) && !autoCopyDisabled.GetValueOrDefault() &&
|
||||||
!string.IsNullOrWhiteSpace(cipher?.Login?.Totp))
|
!string.IsNullOrWhiteSpace(cipher?.Login?.Totp))
|
||||||
{
|
{
|
||||||
var totp = await ServiceContainer.Resolve<ITotpService>("totpService").GetCodeAsync(cipher.Login.Totp);
|
var totp = await ServiceContainer.Resolve<ITotpService>("totpService").GetCodeAsync(cipher.Login.Totp);
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
using Bit.App.Pages;
|
using Bit.App.Pages;
|
||||||
using Bit.Core;
|
using Bit.Core;
|
||||||
|
using Bit.Core.Abstractions;
|
||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
using Bit.Core.Models.View;
|
using Bit.Core.Models.View;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Bit.App.Controls
|
namespace Bit.App.Controls
|
||||||
|
@ -16,12 +18,18 @@ namespace Bit.App.Controls
|
||||||
public static readonly BindableProperty ButtonCommandProperty = BindableProperty.Create(
|
public static readonly BindableProperty ButtonCommandProperty = BindableProperty.Create(
|
||||||
nameof(ButtonCommand), typeof(Command<CipherView>), typeof(CipherViewCell));
|
nameof(ButtonCommand), typeof(Command<CipherView>), typeof(CipherViewCell));
|
||||||
|
|
||||||
|
private readonly IStateService _stateService;
|
||||||
|
private readonly IEnvironmentService _environmentService;
|
||||||
|
|
||||||
private CipherViewCellViewModel _viewModel;
|
private CipherViewCellViewModel _viewModel;
|
||||||
|
|
||||||
public CipherViewCell()
|
public CipherViewCell()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_viewModel = _grid.BindingContext as CipherViewCellViewModel;
|
_viewModel = _grid.BindingContext as CipherViewCellViewModel;
|
||||||
|
|
||||||
|
_stateService = ServiceContainer.Resolve<IStateService>("stateService");
|
||||||
|
_environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService");
|
||||||
}
|
}
|
||||||
|
|
||||||
public CipherView Cipher
|
public CipherView Cipher
|
||||||
|
@ -45,7 +53,7 @@ namespace Bit.App.Controls
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnBindingContextChanged()
|
protected async override void OnBindingContextChanged()
|
||||||
{
|
{
|
||||||
string icon = null;
|
string icon = null;
|
||||||
string image = null;
|
string image = null;
|
||||||
|
@ -65,7 +73,7 @@ namespace Bit.App.Controls
|
||||||
switch(cipher.Type)
|
switch(cipher.Type)
|
||||||
{
|
{
|
||||||
case CipherType.Login:
|
case CipherType.Login:
|
||||||
var loginIconImage = GetLoginIconImage(cipher);
|
var loginIconImage = await GetLoginIconImage(cipher);
|
||||||
icon = loginIconImage.Item1;
|
icon = loginIconImage.Item1;
|
||||||
image = loginIconImage.Item2;
|
image = loginIconImage.Item2;
|
||||||
break;
|
break;
|
||||||
|
@ -99,11 +107,11 @@ namespace Bit.App.Controls
|
||||||
base.OnBindingContextChanged();
|
base.OnBindingContextChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tuple<string, string> GetLoginIconImage(CipherView cipher)
|
private async Task<Tuple<string, string>> GetLoginIconImage(CipherView cipher)
|
||||||
{
|
{
|
||||||
string icon = "";
|
string icon = "";
|
||||||
string image = null;
|
string image = null;
|
||||||
var imageEnabled = true;
|
var imageEnabled = !(await _stateService.GetAsync<bool?>(Constants.DisableFaviconKey)).GetValueOrDefault();
|
||||||
if(cipher.Login.Uri != null)
|
if(cipher.Login.Uri != null)
|
||||||
{
|
{
|
||||||
var hostnameUri = cipher.Login.Uri;
|
var hostnameUri = cipher.Login.Uri;
|
||||||
|
@ -130,7 +138,18 @@ namespace Bit.App.Controls
|
||||||
if(imageEnabled && isWebsite)
|
if(imageEnabled && isWebsite)
|
||||||
{
|
{
|
||||||
var hostname = CoreHelpers.GetHostname(hostnameUri);
|
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);
|
image = string.Format("{0}/{1}/icon.png", iconsUrl, hostname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue