diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index 3ef96d99b..8a02b77a7 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -935,6 +935,21 @@ + + + + + + + + + + + + + + + diff --git a/src/Android/Resources/Resource.Designer.cs b/src/Android/Resources/Resource.Designer.cs index 76e05e615..67d14c36c 100644 --- a/src/Android/Resources/Resource.Designer.cs +++ b/src/Android/Resources/Resource.Designer.cs @@ -2756,8 +2756,8 @@ namespace Bit.Android // aapt resource value: 0x7f0200e6 public const int notification_sm = 2130837734; - // aapt resource value: 0x7f0200f7 - public const int notification_template_icon_bg = 2130837751; + // aapt resource value: 0x7f0200f8 + public const int notification_template_icon_bg = 2130837752; // aapt resource value: 0x7f0200e7 public const int paperclip = 2130837735; @@ -2799,13 +2799,16 @@ namespace Bit.Android public const int tools_selected = 2130837747; // aapt resource value: 0x7f0200f4 - public const int upload = 2130837748; + public const int trash = 2130837748; // aapt resource value: 0x7f0200f5 - public const int user = 2130837749; + public const int upload = 2130837749; // aapt resource value: 0x7f0200f6 - public const int yubikey = 2130837750; + public const int user = 2130837750; + + // aapt resource value: 0x7f0200f7 + public const int yubikey = 2130837751; static Drawable() { diff --git a/src/Android/Resources/drawable-hdpi/paperclip.png b/src/Android/Resources/drawable-hdpi/paperclip.png index 9d87e364a..c6db5eb1b 100644 Binary files a/src/Android/Resources/drawable-hdpi/paperclip.png and b/src/Android/Resources/drawable-hdpi/paperclip.png differ diff --git a/src/Android/Resources/drawable-hdpi/trash.png b/src/Android/Resources/drawable-hdpi/trash.png new file mode 100644 index 000000000..19be4b36c Binary files /dev/null and b/src/Android/Resources/drawable-hdpi/trash.png differ diff --git a/src/Android/Resources/drawable-xhdpi/paperclip.png b/src/Android/Resources/drawable-xhdpi/paperclip.png index 825dee100..852e27724 100644 Binary files a/src/Android/Resources/drawable-xhdpi/paperclip.png and b/src/Android/Resources/drawable-xhdpi/paperclip.png differ diff --git a/src/Android/Resources/drawable-xhdpi/trash.png b/src/Android/Resources/drawable-xhdpi/trash.png new file mode 100644 index 000000000..9136d27ff Binary files /dev/null and b/src/Android/Resources/drawable-xhdpi/trash.png differ diff --git a/src/Android/Resources/drawable-xxhdpi/paperclip.png b/src/Android/Resources/drawable-xxhdpi/paperclip.png index 0bb78b189..97eedb9ea 100644 Binary files a/src/Android/Resources/drawable-xxhdpi/paperclip.png and b/src/Android/Resources/drawable-xxhdpi/paperclip.png differ diff --git a/src/Android/Resources/drawable-xxhdpi/trash.png b/src/Android/Resources/drawable-xxhdpi/trash.png new file mode 100644 index 000000000..536fc9e46 Binary files /dev/null and b/src/Android/Resources/drawable-xxhdpi/trash.png differ diff --git a/src/Android/Resources/drawable-xxxhdpi/paperclip.png b/src/Android/Resources/drawable-xxxhdpi/paperclip.png index 545de466a..5fcf999ae 100644 Binary files a/src/Android/Resources/drawable-xxxhdpi/paperclip.png and b/src/Android/Resources/drawable-xxxhdpi/paperclip.png differ diff --git a/src/Android/Resources/drawable-xxxhdpi/trash.png b/src/Android/Resources/drawable-xxxhdpi/trash.png new file mode 100644 index 000000000..97491ec48 Binary files /dev/null and b/src/Android/Resources/drawable-xxxhdpi/trash.png differ diff --git a/src/Android/Resources/drawable/paperclip.png b/src/Android/Resources/drawable/paperclip.png index d46ad5ad9..61f4c4b4b 100644 Binary files a/src/Android/Resources/drawable/paperclip.png and b/src/Android/Resources/drawable/paperclip.png differ diff --git a/src/Android/Resources/drawable/trash.png b/src/Android/Resources/drawable/trash.png new file mode 100644 index 000000000..75b96dadd Binary files /dev/null and b/src/Android/Resources/drawable/trash.png differ diff --git a/src/App/Controls/VaultAttachmentsViewCell.cs b/src/App/Controls/VaultAttachmentsViewCell.cs index 5ed05d1bf..fc82f2b77 100644 --- a/src/App/Controls/VaultAttachmentsViewCell.cs +++ b/src/App/Controls/VaultAttachmentsViewCell.cs @@ -6,10 +6,11 @@ namespace Bit.App.Controls public class VaultAttachmentsViewCell : LabeledRightDetailCell { public VaultAttachmentsViewCell() - : base(false) { Label.SetBinding(Label.TextProperty, nameof(VaultAttachmentsPageModel.Attachment.Name)); Detail.SetBinding(Label.TextProperty, nameof(VaultAttachmentsPageModel.Attachment.SizeName)); + Icon.Source = "trash"; + Detail.MinimumWidthRequest = 100; BackgroundColor = Color.White; if(Device.RuntimePlatform == Device.iOS) diff --git a/src/App/Pages/Vault/VaultAttachmentsPage.cs b/src/App/Pages/Vault/VaultAttachmentsPage.cs index e4e0e5db9..7118baddd 100644 --- a/src/App/Pages/Vault/VaultAttachmentsPage.cs +++ b/src/App/Pages/Vault/VaultAttachmentsPage.cs @@ -22,10 +22,13 @@ namespace Bit.App.Pages private readonly IConnectivity _connectivity; private readonly IDeviceActionService _deviceActiveService; private readonly IGoogleAnalyticsService _googleAnalyticsService; + private readonly ITokenService _tokenService; + private readonly ICryptoService _cryptoService; private readonly string _loginId; private Login _login; private byte[] _fileBytes; private DateTime? _lastAction; + private bool _canUseAttachments = true; public VaultAttachmentsPage(string loginId) : base(true) @@ -36,6 +39,8 @@ namespace Bit.App.Pages _userDialogs = Resolver.Resolve(); _deviceActiveService = Resolver.Resolve(); _googleAnalyticsService = Resolver.Resolve(); + _tokenService = Resolver.Resolve(); + _cryptoService = Resolver.Resolve(); Init(); } @@ -51,6 +56,8 @@ namespace Bit.App.Pages private void Init() { + _canUseAttachments = _cryptoService.EncKey != null; + SubscribeFileResult(true); var selectButton = new ExtendedButton { @@ -103,10 +110,14 @@ namespace Bit.App.Pages ItemsSource = PresentationAttchments, HasUnevenRows = true, ItemTemplate = new DataTemplate(() => new VaultAttachmentsViewCell()), - Footer = NewTable, VerticalOptions = LayoutOptions.FillAndExpand }; + if(_tokenService.TokenPremium) + { + ListView.Footer = NewTable; + } + NoDataLabel = new Label { Text = AppResources.NoAttachments, @@ -130,6 +141,13 @@ namespace Bit.App.Pages } _lastAction = DateTime.UtcNow; + + if(!_canUseAttachments) + { + await ShowUpdateKeyAsync(); + return; + } + if(!_connectivity.IsConnected) { AlertNoConnection(); @@ -168,7 +186,11 @@ namespace Bit.App.Pages Title = AppResources.Attachments; Content = ListView; - ToolbarItems.Add(saveToolBarItem); + + if(_tokenService.TokenPremium) + { + ToolbarItems.Add(saveToolBarItem); + } if(Device.RuntimePlatform == Device.iOS) { @@ -186,6 +208,11 @@ namespace Bit.App.Pages base.OnAppearing(); ListView.ItemSelected += AttachmentSelected; await LoadAttachmentsAsync(); + + if(_tokenService.TokenPremium && !_canUseAttachments) + { + await ShowUpdateKeyAsync(); + } } protected override void OnDisappearing() @@ -235,30 +262,28 @@ namespace Bit.App.Pages ((ListView)sender).SelectedItem = null; - var buttons = new List { }; - var selection = await DisplayActionSheet(attachment.Name, AppResources.Cancel, AppResources.Delete, - buttons.ToArray()); - - if(selection == AppResources.Delete) + if(!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No)) { - _userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black); - var saveTask = await _loginService.DeleteAttachmentAsync(_login, attachment.Id); - _userDialogs.HideLoading(); + return; + } - if(saveTask.Succeeded) - { - _userDialogs.Toast(AppResources.AttachmentDeleted); - _googleAnalyticsService.TrackAppEvent("DeletedAttachment"); - await LoadAttachmentsAsync(); - } - else if(saveTask.Errors.Count() > 0) - { - await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred); - } - else - { - await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); - } + _userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black); + var saveTask = await _loginService.DeleteAttachmentAsync(_login, attachment.Id); + _userDialogs.HideLoading(); + + if(saveTask.Succeeded) + { + _userDialogs.Toast(AppResources.AttachmentDeleted); + _googleAnalyticsService.TrackAppEvent("DeletedAttachment"); + await LoadAttachmentsAsync(); + } + else if(saveTask.Errors.Count() > 0) + { + await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred); + } + else + { + await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); } } @@ -284,5 +309,15 @@ namespace Bit.App.Pages SubscribeFileResult(true); }); } + + private async Task ShowUpdateKeyAsync() + { + var confirmed = await _userDialogs.ConfirmAsync(AppResources.UpdateKey, AppResources.FeatureUnavailable, + AppResources.LearnMore, AppResources.Cancel); + if(confirmed) + { + Device.OpenUri(new Uri("https://help.bitwarden.com")); + } + } } } diff --git a/src/App/Pages/Vault/VaultViewLoginPage.cs b/src/App/Pages/Vault/VaultViewLoginPage.cs index 00e60781e..b203943f0 100644 --- a/src/App/Pages/Vault/VaultViewLoginPage.cs +++ b/src/App/Pages/Vault/VaultViewLoginPage.cs @@ -231,7 +231,7 @@ namespace Bit.App.Pages { Table.Root.Remove(AttachmentsSection); } - if(Model.ShowAttachments) + if(Model.ShowAttachments && _tokenService.TokenPremium) { AttachmentsSection = new TableSection(AppResources.Attachments); AttachmentCells = new List(); diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index 8953e90d3..32e061c41 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -1024,6 +1024,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Feature Unavailable. + /// + public static string FeatureUnavailable { + get { + return ResourceManager.GetString("FeatureUnavailable", resourceCulture); + } + } + /// /// Looks up a localized string similar to File. /// @@ -1267,6 +1276,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Learn More. + /// + public static string LearnMore { + get { + return ResourceManager.GetString("LearnMore", resourceCulture); + } + } + /// /// Looks up a localized string similar to Length. /// @@ -1537,6 +1555,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Maximum file size is 100 MB.. + /// + public static string MaxFileSize { + get { + return ResourceManager.GetString("MaxFileSize", resourceCulture); + } + } + /// /// Looks up a localized string similar to Minimum Numbers. /// @@ -2221,6 +2248,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to You cannot use this feature until you update your encryption key.. + /// + public static string UpdateKey { + get { + return ResourceManager.GetString("UpdateKey", resourceCulture); + } + } + /// /// Looks up a localized string similar to URI. /// diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index 7a64973c3..6ab7020d3 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -986,4 +986,16 @@ File Source + + Feature Unavailable + + + Maximum file size is 100 MB. + + + You cannot use this feature until you update your encryption key. + + + Learn More + \ No newline at end of file diff --git a/src/iOS/Resources/paperclip.png b/src/iOS/Resources/paperclip.png index d46ad5ad9..61f4c4b4b 100644 Binary files a/src/iOS/Resources/paperclip.png and b/src/iOS/Resources/paperclip.png differ diff --git a/src/iOS/Resources/paperclip@2x.png b/src/iOS/Resources/paperclip@2x.png index 825dee100..852e27724 100644 Binary files a/src/iOS/Resources/paperclip@2x.png and b/src/iOS/Resources/paperclip@2x.png differ diff --git a/src/iOS/Resources/paperclip@3x.png b/src/iOS/Resources/paperclip@3x.png index 0bb78b189..97eedb9ea 100644 Binary files a/src/iOS/Resources/paperclip@3x.png and b/src/iOS/Resources/paperclip@3x.png differ diff --git a/src/iOS/Resources/trash.png b/src/iOS/Resources/trash.png new file mode 100644 index 000000000..75b96dadd Binary files /dev/null and b/src/iOS/Resources/trash.png differ diff --git a/src/iOS/Resources/trash@2x.png b/src/iOS/Resources/trash@2x.png new file mode 100644 index 000000000..9136d27ff Binary files /dev/null and b/src/iOS/Resources/trash@2x.png differ diff --git a/src/iOS/Resources/trash@3x.png b/src/iOS/Resources/trash@3x.png new file mode 100644 index 000000000..536fc9e46 Binary files /dev/null and b/src/iOS/Resources/trash@3x.png differ diff --git a/src/iOS/iOS.csproj b/src/iOS/iOS.csproj index 694a9fe3c..2d7b7b087 100644 --- a/src/iOS/iOS.csproj +++ b/src/iOS/iOS.csproj @@ -776,6 +776,15 @@ + + + + + + + + +