Skip to content

Commit 575d54e

Browse files
committed
Apply code review
1 parent 7df657e commit 575d54e

7 files changed

Lines changed: 33 additions & 45 deletions

File tree

src/Core/SecureFolderFS.Core.Cryptography/NameCrypt/AesSivNameCrypt.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public AesSivNameCrypt(KeyPair keyPair, string fileNameEncodingId)
1515
{
1616
_aesSiv256 = keyPair.UseKeys((dekKey, macKey) =>
1717
{
18-
return AesSiv256.CreateInstance(dekKey.ToArray(), macKey.ToArray()); // Note: AesSiv128 requires a byte[] key.
18+
// Note: AesSiv256 requires a byte[] key.
19+
return AesSiv256.CreateInstance(dekKey.ToArray(), macKey.ToArray());
1920
});
2021
}
2122

src/Core/SecureFolderFS.Core.MobileFS/Platforms/Android/FileSystem/FileSystemProvider.Helpers.cs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,9 @@ void AddFlags()
9090
}
9191
void AddMimeType() => row.Add(Document.ColumnMimeType, GetMimeForStorable(storable));
9292
void AddDocumentId() => row.Add(Document.ColumnDocumentId, documentId);
93-
void AddDisplayName()
94-
{
95-
if (string.IsNullOrEmpty(storable.Name))
96-
{
97-
var safRoot = _rootCollection?.GetSafRootForRootId(documentId?.Split(':')[0] ?? string.Empty);
98-
row.Add(Document.ColumnDisplayName, safRoot?.StorageRoot.Options.VolumeName ?? storable.Name);
99-
}
100-
else
101-
row.Add(Document.ColumnDisplayName, storable.Name);
102-
}
93+
void AddDisplayName() => row.Add(Document.ColumnDisplayName, string.IsNullOrEmpty(storable.Name)
94+
? safRoot.StorageRoot.Options.VolumeName
95+
: storable.Name);
10396
}
10497

10598
private string? GetDocumentIdForStorable(IStorable storable, string? rootId)
@@ -111,10 +104,9 @@ void AddDisplayName()
111104
if (safRoot is null)
112105
return null;
113106

114-
if (storable.Id == safRoot.StorageRoot.PlaintextRoot.Id)
115-
return $"{safRoot.RootId}:";
116-
117-
return $"{safRoot.RootId}:{storable.Id}";
107+
return storable.Id == safRoot.StorageRoot.PlaintextRoot.Id
108+
? $"{safRoot.RootId}:"
109+
: $"{safRoot.RootId}:{storable.Id}";
118110
}
119111

120112
private IStorable? GetStorableForDocumentId(string documentId)
@@ -142,7 +134,7 @@ void AddDisplayName()
142134
if (string.IsNullOrEmpty(path))
143135
return safRoot.StorageRoot.PlaintextRoot;
144136

145-
return safRoot.StorageRoot.PlaintextRoot.GetItemByRelativePathAsync(path).ConfigureAwait(false).GetAwaiter().GetResult();
137+
return SafetyHelpers.NoFailureResult(() => safRoot.StorageRoot.PlaintextRoot.GetItemByRelativePathAsync(path).ConfigureAwait(false).GetAwaiter().GetResult());
146138
}
147139

148140
private static string GetMimeForStorable(IStorable storable)

src/Core/SecureFolderFS.Core.MobileFS/Platforms/Android/FileSystem/FileSystemProvider.Main.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ public override bool OnCreate()
5353
rid = Constants.Android.Saf.IC_LOCK_LOCK;
5454

5555
foreach (var item in _rootCollection?.Roots ?? Enumerable.Empty<SafRoot>())
56-
{
5756
AddRoot(matrix, item, rid);
58-
}
5957

6058
return matrix;
6159
}

src/Platforms/SecureFolderFS.Maui/AppShell.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public AppShell()
2929
/// <inheritdoc/>
3030
public void Receive(VaultLockedMessage message)
3131
{
32-
Vibration.Vibrate(200d);
32+
Vibration.Vibrate(80d);
3333
}
3434

3535
private async void AppShell_Loaded(object? sender, EventArgs e)

src/Platforms/SecureFolderFS.Maui/UserControls/HealthScanControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<ContentView
6868
Grid.Column="2"
6969
Content="{Binding IconSlot, Mode=OneWay, Source={x:Reference ThisControl}}"
70-
IsVisible="{Binding IconSlot, Mode=OneWay, Source={x:Reference ThisControl}}" />
70+
IsVisible="{Binding IconSlot, Mode=OneWay, Source={x:Reference ThisControl}, Converter={StaticResource NullToBoolConverter}}" />
7171
</Grid>
7272
</Grid>
7373

src/Platforms/SecureFolderFS.Maui/UserControls/Widgets/HealthWidget.xaml

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,24 @@
88
xmlns:uc="clr-namespace:SecureFolderFS.Maui.UserControls"
99
x:Name="RootControl">
1010

11-
<Grid>
12-
<uc:HealthScanControl
13-
x:Name="ScanControl"
14-
Title="{Binding StatusTitle, Mode=OneWay, Source={x:Reference RootControl}}"
15-
Clicked="HealthScanControl_Clicked"
16-
IsProgressing="{Binding IsProgressing, Mode=OneWay, Source={x:Reference RootControl}}"
17-
Severity="{Binding Severity, Mode=OneWay, Source={x:Reference RootControl}}"
18-
Subtitle="{Binding LastCheckedText, Mode=OneWay, Source={x:Reference RootControl}}">
19-
<uc:HealthScanControl.IconSlot>
20-
<Grid>
21-
<mi:MauiIcon
22-
Icon="{mi_material:Material ChevronRight}"
23-
IconColor="White"
24-
OnPlatforms="Android" />
25-
<mi:MauiIcon
26-
Icon="{mi_cupertino:Cupertino ChevronRight}"
27-
IconColor="White"
28-
OnPlatforms="iOS" />
29-
</Grid>
30-
</uc:HealthScanControl.IconSlot>
31-
</uc:HealthScanControl>
32-
</Grid>
11+
<uc:HealthScanControl
12+
x:Name="ScanControl"
13+
Title="{Binding StatusTitle, Mode=OneWay, Source={x:Reference RootControl}}"
14+
Clicked="HealthScanControl_Clicked"
15+
IsProgressing="{Binding IsProgressing, Mode=OneWay, Source={x:Reference RootControl}}"
16+
Severity="{Binding Severity, Mode=OneWay, Source={x:Reference RootControl}}"
17+
Subtitle="{Binding LastCheckedText, Mode=OneWay, Source={x:Reference RootControl}}">
18+
<uc:HealthScanControl.IconSlot>
19+
<Grid>
20+
<mi:MauiIcon
21+
Icon="{mi_material:Material ChevronRight}"
22+
IconColor="White"
23+
OnPlatforms="Android" />
24+
<mi:MauiIcon
25+
Icon="{mi_cupertino:Cupertino ChevronRight}"
26+
IconColor="White"
27+
OnPlatforms="iOS" />
28+
</Grid>
29+
</uc:HealthScanControl.IconSlot>
30+
</uc:HealthScanControl>
3331
</ContentView>

src/Shared/SecureFolderFS.Shared/Logging/FileOutputLoggerProvider.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Concurrent;
33
using System.IO;
44
using Microsoft.Extensions.Logging;
5+
using SecureFolderFS.Shared.Helpers;
56

67
namespace SecureFolderFS.Shared.Logging
78
{
@@ -34,9 +35,7 @@ public ILogger CreateLogger(string categoryName)
3435
internal void WriteMessage(string message)
3536
{
3637
lock (_writeLock)
37-
{
38-
File.AppendAllText(_filePath, message + Environment.NewLine);
39-
}
38+
SafetyHelpers.NoFailure(() => File.AppendAllText(_filePath, message + Environment.NewLine));
4039
}
4140

4241
/// <inheritdoc/>

0 commit comments

Comments
 (0)