1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-12-30 17:38:11 +01:00

attachment updates

This commit is contained in:
Kyle Spearrin 2017-07-24 10:34:22 -04:00
parent d14b23ca82
commit b920e7e95c
24 changed files with 142 additions and 31 deletions

View File

@ -935,6 +935,21 @@
<ItemGroup> <ItemGroup>
<AndroidResource Include="Resources\drawable-xxxhdpi\paperclip.png" /> <AndroidResource Include="Resources\drawable-xxxhdpi\paperclip.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\trash.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-hdpi\trash.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xhdpi\trash.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxhdpi\trash.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxxhdpi\trash.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Import Project="..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" /> <Import Project="..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

View File

@ -2756,8 +2756,8 @@ namespace Bit.Android
// aapt resource value: 0x7f0200e6 // aapt resource value: 0x7f0200e6
public const int notification_sm = 2130837734; public const int notification_sm = 2130837734;
// aapt resource value: 0x7f0200f7 // aapt resource value: 0x7f0200f8
public const int notification_template_icon_bg = 2130837751; public const int notification_template_icon_bg = 2130837752;
// aapt resource value: 0x7f0200e7 // aapt resource value: 0x7f0200e7
public const int paperclip = 2130837735; public const int paperclip = 2130837735;
@ -2799,13 +2799,16 @@ namespace Bit.Android
public const int tools_selected = 2130837747; public const int tools_selected = 2130837747;
// aapt resource value: 0x7f0200f4 // aapt resource value: 0x7f0200f4
public const int upload = 2130837748; public const int trash = 2130837748;
// aapt resource value: 0x7f0200f5 // aapt resource value: 0x7f0200f5
public const int user = 2130837749; public const int upload = 2130837749;
// aapt resource value: 0x7f0200f6 // 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() static Drawable()
{ {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 658 B

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 802 B

After

Width:  |  Height:  |  Size: 802 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 B

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

View File

@ -6,10 +6,11 @@ namespace Bit.App.Controls
public class VaultAttachmentsViewCell : LabeledRightDetailCell public class VaultAttachmentsViewCell : LabeledRightDetailCell
{ {
public VaultAttachmentsViewCell() public VaultAttachmentsViewCell()
: base(false)
{ {
Label.SetBinding(Label.TextProperty, nameof(VaultAttachmentsPageModel.Attachment.Name)); Label.SetBinding(Label.TextProperty, nameof(VaultAttachmentsPageModel.Attachment.Name));
Detail.SetBinding(Label.TextProperty, nameof(VaultAttachmentsPageModel.Attachment.SizeName)); Detail.SetBinding(Label.TextProperty, nameof(VaultAttachmentsPageModel.Attachment.SizeName));
Icon.Source = "trash";
Detail.MinimumWidthRequest = 100;
BackgroundColor = Color.White; BackgroundColor = Color.White;
if(Device.RuntimePlatform == Device.iOS) if(Device.RuntimePlatform == Device.iOS)

View File

@ -22,10 +22,13 @@ namespace Bit.App.Pages
private readonly IConnectivity _connectivity; private readonly IConnectivity _connectivity;
private readonly IDeviceActionService _deviceActiveService; private readonly IDeviceActionService _deviceActiveService;
private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly IGoogleAnalyticsService _googleAnalyticsService;
private readonly ITokenService _tokenService;
private readonly ICryptoService _cryptoService;
private readonly string _loginId; private readonly string _loginId;
private Login _login; private Login _login;
private byte[] _fileBytes; private byte[] _fileBytes;
private DateTime? _lastAction; private DateTime? _lastAction;
private bool _canUseAttachments = true;
public VaultAttachmentsPage(string loginId) public VaultAttachmentsPage(string loginId)
: base(true) : base(true)
@ -36,6 +39,8 @@ namespace Bit.App.Pages
_userDialogs = Resolver.Resolve<IUserDialogs>(); _userDialogs = Resolver.Resolve<IUserDialogs>();
_deviceActiveService = Resolver.Resolve<IDeviceActionService>(); _deviceActiveService = Resolver.Resolve<IDeviceActionService>();
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>(); _googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
_tokenService = Resolver.Resolve<ITokenService>();
_cryptoService = Resolver.Resolve<ICryptoService>();
Init(); Init();
} }
@ -51,6 +56,8 @@ namespace Bit.App.Pages
private void Init() private void Init()
{ {
_canUseAttachments = _cryptoService.EncKey != null;
SubscribeFileResult(true); SubscribeFileResult(true);
var selectButton = new ExtendedButton var selectButton = new ExtendedButton
{ {
@ -103,10 +110,14 @@ namespace Bit.App.Pages
ItemsSource = PresentationAttchments, ItemsSource = PresentationAttchments,
HasUnevenRows = true, HasUnevenRows = true,
ItemTemplate = new DataTemplate(() => new VaultAttachmentsViewCell()), ItemTemplate = new DataTemplate(() => new VaultAttachmentsViewCell()),
Footer = NewTable,
VerticalOptions = LayoutOptions.FillAndExpand VerticalOptions = LayoutOptions.FillAndExpand
}; };
if(_tokenService.TokenPremium)
{
ListView.Footer = NewTable;
}
NoDataLabel = new Label NoDataLabel = new Label
{ {
Text = AppResources.NoAttachments, Text = AppResources.NoAttachments,
@ -130,6 +141,13 @@ namespace Bit.App.Pages
} }
_lastAction = DateTime.UtcNow; _lastAction = DateTime.UtcNow;
if(!_canUseAttachments)
{
await ShowUpdateKeyAsync();
return;
}
if(!_connectivity.IsConnected) if(!_connectivity.IsConnected)
{ {
AlertNoConnection(); AlertNoConnection();
@ -168,7 +186,11 @@ namespace Bit.App.Pages
Title = AppResources.Attachments; Title = AppResources.Attachments;
Content = ListView; Content = ListView;
if(_tokenService.TokenPremium)
{
ToolbarItems.Add(saveToolBarItem); ToolbarItems.Add(saveToolBarItem);
}
if(Device.RuntimePlatform == Device.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
@ -186,6 +208,11 @@ namespace Bit.App.Pages
base.OnAppearing(); base.OnAppearing();
ListView.ItemSelected += AttachmentSelected; ListView.ItemSelected += AttachmentSelected;
await LoadAttachmentsAsync(); await LoadAttachmentsAsync();
if(_tokenService.TokenPremium && !_canUseAttachments)
{
await ShowUpdateKeyAsync();
}
} }
protected override void OnDisappearing() protected override void OnDisappearing()
@ -235,12 +262,11 @@ namespace Bit.App.Pages
((ListView)sender).SelectedItem = null; ((ListView)sender).SelectedItem = null;
var buttons = new List<string> { }; if(!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No))
var selection = await DisplayActionSheet(attachment.Name, AppResources.Cancel, AppResources.Delete,
buttons.ToArray());
if(selection == AppResources.Delete)
{ {
return;
}
_userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black); _userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black);
var saveTask = await _loginService.DeleteAttachmentAsync(_login, attachment.Id); var saveTask = await _loginService.DeleteAttachmentAsync(_login, attachment.Id);
_userDialogs.HideLoading(); _userDialogs.HideLoading();
@ -260,7 +286,6 @@ namespace Bit.App.Pages
await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred);
} }
} }
}
private void AlertNoConnection() private void AlertNoConnection()
{ {
@ -284,5 +309,15 @@ namespace Bit.App.Pages
SubscribeFileResult(true); 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"));
}
}
} }
} }

View File

@ -231,7 +231,7 @@ namespace Bit.App.Pages
{ {
Table.Root.Remove(AttachmentsSection); Table.Root.Remove(AttachmentsSection);
} }
if(Model.ShowAttachments) if(Model.ShowAttachments && _tokenService.TokenPremium)
{ {
AttachmentsSection = new TableSection(AppResources.Attachments); AttachmentsSection = new TableSection(AppResources.Attachments);
AttachmentCells = new List<AttachmentViewCell>(); AttachmentCells = new List<AttachmentViewCell>();

View File

@ -1024,6 +1024,15 @@ namespace Bit.App.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Feature Unavailable.
/// </summary>
public static string FeatureUnavailable {
get {
return ResourceManager.GetString("FeatureUnavailable", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to File. /// Looks up a localized string similar to File.
/// </summary> /// </summary>
@ -1267,6 +1276,15 @@ namespace Bit.App.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Learn More.
/// </summary>
public static string LearnMore {
get {
return ResourceManager.GetString("LearnMore", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Length. /// Looks up a localized string similar to Length.
/// </summary> /// </summary>
@ -1537,6 +1555,15 @@ namespace Bit.App.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Maximum file size is 100 MB..
/// </summary>
public static string MaxFileSize {
get {
return ResourceManager.GetString("MaxFileSize", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Minimum Numbers. /// Looks up a localized string similar to Minimum Numbers.
/// </summary> /// </summary>
@ -2221,6 +2248,15 @@ namespace Bit.App.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to You cannot use this feature until you update your encryption key..
/// </summary>
public static string UpdateKey {
get {
return ResourceManager.GetString("UpdateKey", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to URI. /// Looks up a localized string similar to URI.
/// </summary> /// </summary>

View File

@ -986,4 +986,16 @@
<data name="FileSource" xml:space="preserve"> <data name="FileSource" xml:space="preserve">
<value>File Source</value> <value>File Source</value>
</data> </data>
<data name="FeatureUnavailable" xml:space="preserve">
<value>Feature Unavailable</value>
</data>
<data name="MaxFileSize" xml:space="preserve">
<value>Maximum file size is 100 MB.</value>
</data>
<data name="UpdateKey" xml:space="preserve">
<value>You cannot use this feature until you update your encryption key.</value>
</data>
<data name="LearnMore" xml:space="preserve">
<value>Learn More</value>
</data>
</root> </root>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 B

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 802 B

After

Width:  |  Height:  |  Size: 802 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
src/iOS/Resources/trash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

View File

@ -776,6 +776,15 @@
<ItemGroup> <ItemGroup>
<BundleResource Include="Resources\paperclip%403x.png" /> <BundleResource Include="Resources\paperclip%403x.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\trash.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\trash%402x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\trash%403x.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>