mirror of
https://github.com/bitwarden/mobile
synced 2026-01-08 11:33:31 +00:00
download, decrypt and open attachment files
This commit is contained in:
@@ -16,7 +16,7 @@ namespace Bit.App.Pages
|
||||
private readonly IUserDialogs _userDialogs;
|
||||
private readonly IPasswordGenerationService _passwordGenerationService;
|
||||
private readonly ISettings _settings;
|
||||
private readonly IClipboardService _clipboardService;
|
||||
private readonly IDeviceActionService _clipboardService;
|
||||
private readonly IGoogleAnalyticsService _googleAnalyticsService;
|
||||
private readonly Action<string> _passwordValueAction;
|
||||
private readonly bool _fromAutofill;
|
||||
@@ -26,7 +26,7 @@ namespace Bit.App.Pages
|
||||
_userDialogs = Resolver.Resolve<IUserDialogs>();
|
||||
_passwordGenerationService = Resolver.Resolve<IPasswordGenerationService>();
|
||||
_settings = Resolver.Resolve<ISettings>();
|
||||
_clipboardService = Resolver.Resolve<IClipboardService>();
|
||||
_clipboardService = Resolver.Resolve<IDeviceActionService>();
|
||||
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
|
||||
_passwordValueAction = passwordValueAction;
|
||||
_fromAutofill = fromAutofill;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Bit.App.Pages
|
||||
{
|
||||
private readonly ILoginService _loginService;
|
||||
private readonly IDeviceInfoService _deviceInfoService;
|
||||
private readonly IClipboardService _clipboardService;
|
||||
private readonly IDeviceActionService _clipboardService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private CancellationTokenSource _filterResultsCancellationTokenSource;
|
||||
private readonly string _name;
|
||||
@@ -47,7 +47,7 @@ namespace Bit.App.Pages
|
||||
|
||||
_loginService = Resolver.Resolve<ILoginService>();
|
||||
_deviceInfoService = Resolver.Resolve<IDeviceInfoService>();
|
||||
_clipboardService = Resolver.Resolve<IClipboardService>();
|
||||
_clipboardService = Resolver.Resolve<IDeviceActionService>();
|
||||
_settingsService = Resolver.Resolve<ISettingsService>();
|
||||
UserDialogs = Resolver.Resolve<IUserDialogs>();
|
||||
GoogleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Bit.App.Pages
|
||||
private readonly ILoginService _loginService;
|
||||
private readonly IUserDialogs _userDialogs;
|
||||
private readonly IConnectivity _connectivity;
|
||||
private readonly IClipboardService _clipboardService;
|
||||
private readonly IDeviceActionService _clipboardService;
|
||||
private readonly ISyncService _syncService;
|
||||
private readonly IPushNotification _pushNotification;
|
||||
private readonly IDeviceInfoService _deviceInfoService;
|
||||
@@ -41,7 +41,7 @@ namespace Bit.App.Pages
|
||||
_loginService = Resolver.Resolve<ILoginService>();
|
||||
_connectivity = Resolver.Resolve<IConnectivity>();
|
||||
_userDialogs = Resolver.Resolve<IUserDialogs>();
|
||||
_clipboardService = Resolver.Resolve<IClipboardService>();
|
||||
_clipboardService = Resolver.Resolve<IDeviceActionService>();
|
||||
_syncService = Resolver.Resolve<ISyncService>();
|
||||
_pushNotification = Resolver.Resolve<IPushNotification>();
|
||||
_deviceInfoService = Resolver.Resolve<IDeviceInfoService>();
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace Bit.App.Pages
|
||||
private readonly string _loginId;
|
||||
private readonly ILoginService _loginService;
|
||||
private readonly IUserDialogs _userDialogs;
|
||||
private readonly IClipboardService _clipboardService;
|
||||
private readonly IDeviceActionService _deviceActionService;
|
||||
|
||||
public VaultViewLoginPage(string loginId)
|
||||
{
|
||||
_loginId = loginId;
|
||||
_loginService = Resolver.Resolve<ILoginService>();
|
||||
_userDialogs = Resolver.Resolve<IUserDialogs>();
|
||||
_clipboardService = Resolver.Resolve<IClipboardService>();
|
||||
_deviceActionService = Resolver.Resolve<IDeviceActionService>();
|
||||
|
||||
Init();
|
||||
}
|
||||
@@ -194,9 +194,9 @@ namespace Bit.App.Pages
|
||||
AttachmentsSection = new TableSection(AppResources.Attachments);
|
||||
foreach(var attachment in Model.Attachments)
|
||||
{
|
||||
AttachmentsSection.Add(new AttachmentViewCell(attachment, () =>
|
||||
AttachmentsSection.Add(new AttachmentViewCell(attachment, async () =>
|
||||
{
|
||||
|
||||
await SaveAttachmentAsync(attachment);
|
||||
}));
|
||||
}
|
||||
Table.Root.Add(AttachmentsSection);
|
||||
@@ -211,6 +211,23 @@ namespace Bit.App.Pages
|
||||
EditItem.Dispose();
|
||||
}
|
||||
|
||||
private async Task SaveAttachmentAsync(VaultViewLoginPageModel.Attachment attachment)
|
||||
{
|
||||
var data = await _loginService.DownloadAndDecryptAttachmentAsync(null, attachment.Url);
|
||||
if(data == null)
|
||||
{
|
||||
await _userDialogs.AlertAsync(AppResources.UnableToDownloadFile, null, AppResources.Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
var opened = _deviceActionService.OpenFile(data, attachment.Id, attachment.Name);
|
||||
if(!opened)
|
||||
{
|
||||
await _userDialogs.AlertAsync(AppResources.UnableToOpenFile, null, AppResources.Ok);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void NotesCell_Tapped(object sender, EventArgs e)
|
||||
{
|
||||
Copy(Model.Notes, AppResources.Notes);
|
||||
@@ -218,7 +235,7 @@ namespace Bit.App.Pages
|
||||
|
||||
private void Copy(string copyText, string alertLabel)
|
||||
{
|
||||
_clipboardService.CopyToClipboard(copyText);
|
||||
_deviceActionService.CopyToClipboard(copyText);
|
||||
_userDialogs.Toast(string.Format(AppResources.ValueHasBeenCopied, alertLabel));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user