Skip to content

Commit cf59def

Browse files
committed
Process authentication methods in one operation to improve performance
1 parent 4650882 commit cf59def

9 files changed

Lines changed: 127 additions & 63 deletions

File tree

src/Platforms/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageVersion Include="ContextMenuContainer" Version="1.2.3" />
1212
<PackageVersion Include="H.NotifyIcon.Uno.WinUI" Version="2.3.0" />
1313
<PackageVersion Include="IconPacks.Material" Version="1.0.8940.2-build" />
14-
<PackageVersion Include="LibVLCSharp.MAUI" Version="3.9.5" />
14+
<PackageVersion Include="LibVLCSharp.MAUI" Version="3.9.7.1" />
1515
<PackageVersion Include="LiveChartsCore.SkiaSharpView.Uno.WinUI" Version="2.0.0-rc6.1" />
1616
<PackageVersion Include="Microsoft.Maui.Controls" Version="10.0.31" />
1717
<PackageVersion Include="Microsoft.Maui.Controls.Compatibility" Version="10.0.31" />

src/Platforms/SecureFolderFS.Maui/Resources/Styles/VideoPlayerStyles.xaml

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,41 @@
55
xmlns:mi_cupertino="clr-namespace:MauiIcons.Cupertino;assembly=MauiIcons.Cupertino"
66
xmlns:mi_material="clr-namespace:MauiIcons.Material;assembly=MauiIcons.Material">
77

8-
<Style x:Key="VideoLabelStyle" TargetType="Label">
9-
<Setter Property="TextColor" Value="#ffffff" />
10-
</Style>
11-
128
<Style x:Key="VideoSeekBarStyle" TargetType="Slider">
139
<Setter Property="ThumbColor" Value="Transparent" />
1410
<Setter Property="HorizontalOptions" Value="FillAndExpand" />
1511
</Style>
1612

13+
<Style x:Key="VideoControlsPanelStyle" TargetType="Layout">
14+
<Setter Property="Padding" Value="2,0,2,2" />
15+
<Setter Property="BackgroundColor" Value="{x:Null}" />
16+
<Setter Property="Background">
17+
<Setter.Value>
18+
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
19+
<GradientStop Offset="0" Color="#00000000" />
20+
<GradientStop Offset="0.4" Color="#80000000" />
21+
<GradientStop Offset="1" Color="#BB000000" />
22+
</LinearGradientBrush>
23+
</Setter.Value>
24+
</Setter>
25+
</Style>
26+
27+
<Style x:Key="VideoElapsedTimeLabelStyle" TargetType="Label">
28+
<Setter Property="HorizontalOptions" Value="StartAndExpand" />
29+
<Setter Property="Margin" Value="15,4,15,0" />
30+
<Setter Property="FontSize" Value="Small" />
31+
<Setter Property="TextColor" Value="#FFFFFF" />
32+
<Setter Property="VerticalOptions" Value="Center" />
33+
</Style>
34+
35+
<Style x:Key="VideoRemainingTimeLabelStyle" TargetType="Label">
36+
<Setter Property="HorizontalOptions" Value="StartAndExpand" />
37+
<Setter Property="Margin" Value="15,4,15,0" />
38+
<Setter Property="FontSize" Value="Small" />
39+
<Setter Property="TextColor" Value="#FFFFFF" />
40+
<Setter Property="VerticalOptions" Value="Center" />
41+
</Style>
42+
1743
<Style x:Key="VideoBaseButtonStyle" TargetType="Button">
1844
<Setter Property="CornerRadius" Value="0" />
1945
<Setter Property="Background" Value="Transparent" />
@@ -26,10 +52,10 @@
2652
TargetType="Button">
2753
<OnPlatform x:TypeArguments="Setter">
2854
<On Platform="Android">
29-
<Setter Property="mi:MauiIcon.Value" Value="{mi_material:Material AspectRatio}" />
55+
<Setter Property="mi:MauiIcon.Value" Value="{mi_material:Material AspectRatio, IconSize=24}" />
3056
</On>
3157
<On Platform="iOS">
32-
<Setter Property="mi:MauiIcon.Value" Value="{mi_cupertino:Cupertino RectangleCompressVertical}" />
58+
<Setter Property="mi:MauiIcon.Value" Value="{mi_cupertino:Cupertino RectangleCompressVertical, IconSize=24}" />
3359
</On>
3460
</OnPlatform>
3561
</Style>
@@ -38,6 +64,7 @@
3864
x:Key="VideoLockButtonStyle"
3965
BasedOn="{StaticResource VideoBaseButtonStyle}"
4066
TargetType="Button">
67+
<Setter Property="Text" Value="{x:Null}" />
4168
<OnPlatform x:TypeArguments="Setter">
4269
<On Platform="Android">
4370
<Setter Property="mi:MauiIcon.Value" Value="{mi_material:Material Lock}" />
@@ -52,6 +79,8 @@
5279
x:Key="VideoUnlockButtonStyle"
5380
BasedOn="{StaticResource VideoBaseButtonStyle}"
5481
TargetType="Button">
82+
<Setter Property="Text" Value="{x:Null}" />
83+
5584
<OnPlatform x:TypeArguments="Setter">
5685
<On Platform="Android">
5786
<Setter Property="mi:MauiIcon.Value" Value="{mi_material:Material LockOpen}" />
@@ -68,10 +97,10 @@
6897
TargetType="Button">
6998
<OnPlatform x:TypeArguments="Setter">
7099
<On Platform="Android">
71-
<Setter Property="mi:MauiIcon.Value" Value="{mi_material:Material Replay5}" />
100+
<Setter Property="mi:MauiIcon.Value" Value="{mi_material:Material Replay5, IconSize=24}" />
72101
</On>
73102
<On Platform="iOS">
74-
<Setter Property="mi:MauiIcon.Value" Value="{mi_cupertino:Cupertino Gobackward}" />
103+
<Setter Property="mi:MauiIcon.Value" Value="{mi_cupertino:Cupertino Gobackward, IconSize=24}" />
75104
</On>
76105
</OnPlatform>
77106
</Style>
@@ -82,10 +111,10 @@
82111
TargetType="Button">
83112
<OnPlatform x:TypeArguments="Setter">
84113
<On Platform="Android">
85-
<Setter Property="mi:MauiIcon.Value" Value="{mi_material:Material Forward5}" />
114+
<Setter Property="mi:MauiIcon.Value" Value="{mi_material:Material Forward5, IconSize=24}" />
86115
</On>
87116
<On Platform="iOS">
88-
<Setter Property="mi:MauiIcon.Value" Value="{mi_cupertino:Cupertino Goforward}" />
117+
<Setter Property="mi:MauiIcon.Value" Value="{mi_cupertino:Cupertino Goforward, IconSize=24}" />
89118
</On>
90119
</OnPlatform>
91120
</Style>

src/Platforms/SecureFolderFS.Maui/UserControls/CommandBarControl.xaml.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,21 @@ public bool IsImmersed
5656

5757
if (bValue)
5858
{
59-
commandBar.TopBorder.IsVisible = true;
6059
#if ANDROID
61-
await commandBar.TopBorder.TranslateToAsync(0, 0, 350U, Easing.CubicInOut);
60+
await commandBar.TopBorder.TranslateToAsync(0, -150, 350U, Easing.CubicInOut);
6261
#elif IOS
63-
await commandBar.TopBorder.FadeToAsync(1d, 350U, Easing.CubicInOut);
62+
await commandBar.TopBorder.FadeToAsync(0d, 350U, Easing.CubicInOut);
6463
#endif
64+
commandBar.TopBorder.IsVisible = false;
6565
}
6666
else
6767
{
68+
commandBar.TopBorder.IsVisible = true;
6869
#if ANDROID
69-
await commandBar.TopBorder.TranslateToAsync(0, -150, 350U, Easing.CubicInOut);
70+
await commandBar.TopBorder.TranslateToAsync(0, 0, 350U, Easing.CubicInOut);
7071
#elif IOS
71-
await commandBar.TopBorder.FadeToAsync(0d, 350U, Easing.CubicInOut);
72+
await commandBar.TopBorder.FadeToAsync(1d, 350U, Easing.CubicInOut);
7273
#endif
73-
commandBar.TopBorder.IsVisible = false;
7474
}
7575
});
7676

src/Platforms/SecureFolderFS.Maui/Views/Modals/Vault/FilePreviewModalPage.xaml

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
x:Name="ThisPage"
1818
x:DataType="local:FilePreviewModalPage"
1919
IsImmersive="True"
20-
NavigationPage.HasNavigationBar="False">
20+
NavigationPage.HasNavigationBar="False"
21+
SafeAreaEdges="None">
2122

2223
<md:BaseModalPage.Resources>
2324
<vc:BoolToScrollOrientationConverter x:Key="BoolToScrollOrientationConverter" />
@@ -36,30 +37,27 @@
3637
<DataTemplate x:Key="VideoTemplate" x:DataType="vm:VideoPreviewerViewModel">
3738
<uc:PanRouter PanUpdatedCommand="{Binding GalleryView.PanUpdatedCommand, Mode=OneWay, Source={x:Reference ThisPage}}" TappedCommand="{Binding ViewModel.ToggleImmersionCommand, Mode=OneWay, Source={x:Reference ThisPage}}">
3839
<uc:PanRouter.RouterContent>
39-
<Label
40-
HorizontalTextAlignment="Center"
41-
Text="Video Previewer is disabled. It contains usage of ClickGestureRecognizer which was removed in .NET 10 causing a TypeLoadException in the LibVLC library."
42-
VerticalOptions="Center" />
43-
44-
<!-- <vlc:MediaPlayerElement Loaded="MediaPlayerElement_Loaded"> -->
45-
<!-- <vlc:MediaPlayerElement.PlaybackControls> -->
46-
<!-- <vlc:PlaybackControls -->
47-
<!-- AspectRatioButtonStyle="{StaticResource VideoAspectRatioButtonStyle}" -->
48-
<!-- BackgroundColor="Transparent" -->
49-
<!-- ElapsedTimeLabelStyle="{StaticResource VideoLabelStyle}" -->
50-
<!-- Foreground="#ffffff" -->
51-
<!-- IsTracksButtonVisible="False" -->
52-
<!-- LockButtonStyle="{StaticResource VideoLockButtonStyle}" -->
53-
<!-- MainColor="{AppThemeBinding Light={StaticResource PrimaryLightColor}, -->
54-
<!-- Dark={StaticResource PrimaryDarkColor}}" -->
55-
<!-- PlayPauseButtonStyle="{StaticResource VideoPlayPauseButtonStyle}" -->
56-
<!-- RemainingTimeLabelStyle="{StaticResource VideoLabelStyle}" -->
57-
<!-- RewindButtonStyle="{StaticResource VideoRewindButtonStyle}" -->
58-
<!-- SeekBarStyle="{StaticResource VideoSeekBarStyle}" -->
59-
<!-- SeekButtonStyle="{StaticResource VideoSeekButtonStyle}" -->
60-
<!-- UnLockButtonStyle="{StaticResource VideoUnlockButtonStyle}" /> -->
61-
<!-- </vlc:MediaPlayerElement.PlaybackControls> -->
62-
<!-- </vlc:MediaPlayerElement> -->
40+
<vlc:MediaPlayerElement Loaded="MediaPlayerElement_Loaded">
41+
<vlc:MediaPlayerElement.PlaybackControls>
42+
<vlc:PlaybackControls
43+
BackgroundColor="Transparent"
44+
ControlsPanelStyle="{StaticResource VideoControlsPanelStyle}"
45+
ElapsedTimeLabelStyle="{StaticResource VideoElapsedTimeLabelStyle}"
46+
Foreground="#FFFFFF"
47+
IsAspectRatioButtonVisible="False"
48+
IsLockButtonVisible="False"
49+
IsTracksButtonVisible="False"
50+
LockButtonStyle="{StaticResource VideoLockButtonStyle}"
51+
MainColor="{AppThemeBinding Light={StaticResource PrimaryLightColor},
52+
Dark={StaticResource PrimaryDarkColor}}"
53+
PlayPauseButtonStyle="{StaticResource VideoPlayPauseButtonStyle}"
54+
RemainingTimeLabelStyle="{StaticResource VideoRemainingTimeLabelStyle}"
55+
RewindButtonStyle="{StaticResource VideoRewindButtonStyle}"
56+
SeekBarStyle="{StaticResource VideoSeekBarStyle}"
57+
SeekButtonStyle="{StaticResource VideoSeekButtonStyle}"
58+
UnLockButtonStyle="{StaticResource VideoUnlockButtonStyle}" />
59+
</vlc:MediaPlayerElement.PlaybackControls>
60+
</vlc:MediaPlayerElement>
6361
</uc:PanRouter.RouterContent>
6462
</uc:PanRouter>
6563
</DataTemplate>

src/Platforms/SecureFolderFS.Maui/Views/Modals/Vault/FilePreviewModalPage.xaml.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,25 @@ protected override void OnDisappearing()
105105
void Presentation_Loaded(object? sender, EventArgs e)
106106
{
107107
presentation.Loaded -= Presentation_Loaded;
108-
var panPinchContainer = presentation.GetVisualTreeDescendants()
109-
.OfType<PanPinchContainer>()
110-
.FirstOrDefault();
108+
var descendants = presentation.GetVisualTreeDescendants();
109+
var found = descendants.FirstOrDefault(x => x is PanPinchContainer or PanRouter);
111110

112-
panPinchContainer?.TappedCommand ??= ViewModel?.ToggleImmersionCommand;
113-
panPinchContainer?.PanUpdatedCommand ??= GalleryView?.PanUpdatedCommand;
111+
switch (found)
112+
{
113+
case PanPinchContainer panPinchContainer:
114+
{
115+
panPinchContainer.TappedCommand ??= ViewModel?.ToggleImmersionCommand;
116+
panPinchContainer.PanUpdatedCommand ??= GalleryView?.PanUpdatedCommand;
117+
break;
118+
}
119+
120+
case PanRouter panRouter:
121+
{
122+
panRouter.TappedCommand ??= ViewModel?.ToggleImmersionCommand;
123+
panRouter.PanUpdatedCommand ??= GalleryView?.PanUpdatedCommand;
124+
break;
125+
}
126+
}
114127
}
115128
}
116129

src/Platforms/SecureFolderFS.UI/ServiceImplementation/BaseVaultCredentialsService.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using System.Threading;
5+
using System.Threading.Tasks;
46
using OwlCore.Storage;
7+
using SecureFolderFS.Sdk.Extensions;
58
using SecureFolderFS.Sdk.Services;
69
using SecureFolderFS.Sdk.ViewModels.Controls.Authentication;
10+
using SecureFolderFS.Shared.Extensions;
11+
using SecureFolderFS.Shared.Models;
12+
using SecureFolderFS.Storage.MemoryStorageEx;
713

814
namespace SecureFolderFS.UI.ServiceImplementation
915
{
@@ -34,6 +40,26 @@ public virtual IEnumerable<string> GetFileNameCiphers()
3440
yield return Core.Cryptography.Constants.CipherId.NONE;
3541
}
3642

43+
/// <inheritdoc/>
44+
public virtual async Task<string> FromUnlockProcedureAsync(AuthenticationMethod unlockProcedure, CancellationToken cancellationToken = default)
45+
{
46+
try
47+
{
48+
var emptyFolder = new MemoryFolderEx(string.Empty, string.Empty, null);
49+
var procedures = await GetCreationAsync(emptyFolder, string.Empty, cancellationToken).ToArrayAsyncImpl(cancellationToken);
50+
var result = unlockProcedure.Methods
51+
.Select(method => procedures.FirstOrDefault(p => p.Id == method)?.Title)
52+
.Where(title => title is not null);
53+
54+
procedures.DisposeAll();
55+
return string.Join(" + ", result);
56+
}
57+
catch (Exception)
58+
{
59+
return "AuthenticationUnavailable".ToLocalized();
60+
}
61+
}
62+
3763
/// <inheritdoc/>
3864
public abstract IAsyncEnumerable<AuthenticationViewModel> GetLoginAsync(IFolder vaultFolder, CancellationToken cancellationToken = default);
3965

src/Sdk/SecureFolderFS.Sdk/Services/IVaultCredentialsService.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System.Collections.Generic;
22
using System.Threading;
3+
using System.Threading.Tasks;
34
using OwlCore.Storage;
45
using SecureFolderFS.Sdk.ViewModels.Controls.Authentication;
6+
using SecureFolderFS.Shared.Models;
57

68
namespace SecureFolderFS.Sdk.Services
79
{
@@ -25,6 +27,14 @@ public interface IVaultCredentialsService
2527
/// <returns>Returns <see cref="IEnumerable{T}"/> of type <see cref="string"/> that represents IDs of filename ciphers.</returns>
2628
IEnumerable<string> GetFileNameCiphers();
2729

30+
/// <summary>
31+
/// Converts the specified unlocking procedure into its corresponding format.
32+
/// </summary>
33+
/// <param name="unlockProcedure">The authentication method that represents the unlocking procedure.</param>
34+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that cancels this action.</param>
35+
/// <returns>A <see cref="Task"/> that represents the asynchronous operation. Value is a <see cref="string"/> that represents the formatted unlocked procedure.</returns>
36+
Task<string> FromUnlockProcedureAsync(AuthenticationMethod unlockProcedure, CancellationToken cancellationToken = default);
37+
2838
/// <summary>
2939
/// Asynchronously retrieves a collection of login authentication methods for a specified vault folder.
3040
/// </summary>

src/Sdk/SecureFolderFS.Sdk/ViewModels/Views/Vault/VaultPropertiesViewModel.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using SecureFolderFS.Shared;
1111
using SecureFolderFS.Shared.ComponentModel;
1212
using System.ComponentModel;
13-
using System.Linq;
1413
using System.Threading;
1514
using System.Threading.Tasks;
1615
using SecureFolderFS.Shared.Extensions;
@@ -54,8 +53,7 @@ public async Task InitAsync(CancellationToken cancellationToken = default)
5453
FileNameCipherText = string.IsNullOrEmpty(vaultOptions.FileNameCipherId) ? "NoEncryption".ToLocalized() : (vaultOptions.FileNameCipherId ?? "Unknown") + $" + {vaultOptions.NameEncodingId}";
5554
ActiveFileSystemText = UnlockedVaultViewModel.StorageRoot.FileSystemName;
5655
FileSystemDescriptionText = UnlockedVaultViewModel.StorageRoot.Options.GetDescription();
57-
58-
_ = UpdateSecurityTextAsync(cancellationToken);
56+
SecurityText = await VaultCredentialsService.FromUnlockProcedureAsync(vaultOptions.UnlockProcedure, cancellationToken);
5957

6058
if (!RecycleBinOverlayViewModel.IsInitialized && await IapService.IsOwnedAsync(IapProductType.Any, cancellationToken))
6159
await RecycleBinOverlayViewModel.InitAsync(cancellationToken);
@@ -130,17 +128,8 @@ private void ToggleFileSystemText()
130128

131129
private async Task UpdateSecurityTextAsync(CancellationToken cancellationToken)
132130
{
133-
try
134-
{
135-
var loginItems = await VaultCredentialsService
136-
.GetLoginAsync(UnlockedVaultViewModel.VaultFolder, cancellationToken)
137-
.ToArrayAsyncImpl(cancellationToken);
138-
SecurityText = string.Join(" + ", loginItems.Select(x => x.Title));
139-
}
140-
catch (Exception)
141-
{
142-
SecurityText = "AuthenticationUnavailable".ToLocalized();
143-
}
131+
var vaultOptions = await VaultService.GetVaultOptionsAsync(UnlockedVaultViewModel.VaultFolder, cancellationToken);
132+
SecurityText = await VaultCredentialsService.FromUnlockProcedureAsync(vaultOptions.UnlockProcedure, cancellationToken);
144133
}
145134

146135
/// <inheritdoc/>

src/Shared/SecureFolderFS.Shared/ComponentModel/IPassword.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32

43
namespace SecureFolderFS.Shared.ComponentModel
54
{

0 commit comments

Comments
 (0)