mirror of
https://github.com/bitwarden/mobile
synced 2025-12-15 07:43:37 +00:00
Changed all C# control flow block statements to include space between keyword and open paren (#800)
This commit is contained in:
@@ -41,7 +41,7 @@ namespace Bit.iOS.Core.Services
|
||||
{
|
||||
get
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(_userAgent))
|
||||
if (string.IsNullOrWhiteSpace(_userAgent))
|
||||
{
|
||||
_userAgent = $"Bitwarden_Mobile/{Xamarin.Essentials.AppInfo.VersionString} " +
|
||||
$"(iOS {UIDevice.CurrentDevice.SystemVersion}; Model {UIDevice.CurrentDevice.Model})";
|
||||
@@ -59,7 +59,7 @@ namespace Bit.iOS.Core.Services
|
||||
|
||||
public void Toast(string text, bool longDuration = false)
|
||||
{
|
||||
if(!_toast?.Dismissed ?? false)
|
||||
if (!_toast?.Dismissed ?? false)
|
||||
{
|
||||
_toast.Dismiss(false);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ namespace Bit.iOS.Core.Services
|
||||
{
|
||||
Duration = TimeSpan.FromSeconds(longDuration ? 5 : 3)
|
||||
};
|
||||
if(TabBarVisible())
|
||||
if (TabBarVisible())
|
||||
{
|
||||
_toast.BottomMargin = 55;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace Bit.iOS.Core.Services
|
||||
|
||||
public Task ShowLoadingAsync(string text)
|
||||
{
|
||||
if(_progressAlert != null)
|
||||
if (_progressAlert != null)
|
||||
{
|
||||
HideLoadingAsync().GetAwaiter().GetResult();
|
||||
}
|
||||
@@ -105,7 +105,7 @@ namespace Bit.iOS.Core.Services
|
||||
public Task HideLoadingAsync()
|
||||
{
|
||||
var result = new TaskCompletionSource<int>();
|
||||
if(_progressAlert == null)
|
||||
if (_progressAlert == null)
|
||||
{
|
||||
result.TrySetResult(0);
|
||||
}
|
||||
@@ -144,9 +144,9 @@ namespace Bit.iOS.Core.Services
|
||||
var url = new NSUrl(GetTempPath());
|
||||
var tmpFiles = NSFileManager.DefaultManager.GetDirectoryContent(url, null,
|
||||
NSDirectoryEnumerationOptions.SkipsHiddenFiles, out NSError error);
|
||||
if(error == null && tmpFiles.Length > 0)
|
||||
if (error == null && tmpFiles.Length > 0)
|
||||
{
|
||||
foreach(var item in tmpFiles)
|
||||
foreach (var item in tmpFiles)
|
||||
{
|
||||
NSFileManager.DefaultManager.Remove(item, out NSError itemError);
|
||||
}
|
||||
@@ -180,7 +180,7 @@ namespace Bit.iOS.Core.Services
|
||||
});
|
||||
picker.DidPickDocumentPicker += (sender, e) =>
|
||||
{
|
||||
if(SystemMajorVersion() < 11)
|
||||
if (SystemMajorVersion() < 11)
|
||||
{
|
||||
e.DocumentPicker.DidPickDocument += DocumentPicker_DidPickDocument;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ namespace Bit.iOS.Core.Services
|
||||
controller.PresentViewController(e.DocumentPicker, true, null);
|
||||
};
|
||||
var root = UIApplication.SharedApplication.KeyWindow.RootViewController;
|
||||
if(picker.PopoverPresentationController != null && root != null)
|
||||
if (picker.PopoverPresentationController != null && root != null)
|
||||
{
|
||||
picker.PopoverPresentationController.SourceView = root.View;
|
||||
picker.PopoverPresentationController.SourceRect = root.View.Bounds;
|
||||
@@ -221,11 +221,11 @@ namespace Bit.iOS.Core.Services
|
||||
{
|
||||
input = x;
|
||||
input.Text = text ?? string.Empty;
|
||||
if(numericKeyboard)
|
||||
if (numericKeyboard)
|
||||
{
|
||||
input.KeyboardType = UIKeyboardType.NumberPad;
|
||||
}
|
||||
if(!ThemeHelpers.LightTheme)
|
||||
if (!ThemeHelpers.LightTheme)
|
||||
{
|
||||
input.KeyboardAppearance = UIKeyboardAppearance.Dark;
|
||||
}
|
||||
@@ -238,7 +238,7 @@ namespace Bit.iOS.Core.Services
|
||||
public void RateApp()
|
||||
{
|
||||
string uri = null;
|
||||
if(SystemMajorVersion() < 11)
|
||||
if (SystemMajorVersion() < 11)
|
||||
{
|
||||
uri = "itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews" +
|
||||
"?id=1137397744&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software";
|
||||
@@ -252,13 +252,13 @@ namespace Bit.iOS.Core.Services
|
||||
|
||||
public bool SupportsFaceBiometric()
|
||||
{
|
||||
if(SystemMajorVersion() < 11)
|
||||
if (SystemMajorVersion() < 11)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
using(var context = new LAContext())
|
||||
using (var context = new LAContext())
|
||||
{
|
||||
if(!context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out var e))
|
||||
if (!context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out var e))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -311,7 +311,7 @@ namespace Bit.iOS.Core.Services
|
||||
public int SystemMajorVersion()
|
||||
{
|
||||
var versionParts = UIDevice.CurrentDevice.SystemVersion.Split('.');
|
||||
if(versionParts.Length > 0 && int.TryParse(versionParts[0], out var version))
|
||||
if (versionParts.Length > 0 && int.TryParse(versionParts[0], out var version))
|
||||
{
|
||||
return version;
|
||||
}
|
||||
@@ -328,14 +328,14 @@ namespace Bit.iOS.Core.Services
|
||||
{
|
||||
var result = new TaskCompletionSource<string>();
|
||||
var alert = UIAlertController.Create(title ?? string.Empty, message, UIAlertControllerStyle.Alert);
|
||||
if(!string.IsNullOrWhiteSpace(cancel))
|
||||
if (!string.IsNullOrWhiteSpace(cancel))
|
||||
{
|
||||
alert.AddAction(UIAlertAction.Create(cancel, UIAlertActionStyle.Cancel, x =>
|
||||
{
|
||||
result.TrySetResult(cancel);
|
||||
}));
|
||||
}
|
||||
foreach(var button in buttons)
|
||||
foreach (var button in buttons)
|
||||
{
|
||||
alert.AddAction(UIAlertAction.Create(button, UIAlertActionStyle.Default, x =>
|
||||
{
|
||||
@@ -391,7 +391,7 @@ namespace Bit.iOS.Core.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
if(SystemMajorVersion() > 12)
|
||||
if (SystemMajorVersion() > 12)
|
||||
{
|
||||
return UIScreen.MainScreen.TraitCollection.UserInterfaceStyle == UIUserInterfaceStyle.Dark;
|
||||
}
|
||||
@@ -402,10 +402,10 @@ namespace Bit.iOS.Core.Services
|
||||
|
||||
private void ImagePicker_FinishedPickingMedia(object sender, UIImagePickerMediaPickedEventArgs e)
|
||||
{
|
||||
if(sender is UIImagePickerController picker)
|
||||
if (sender is UIImagePickerController picker)
|
||||
{
|
||||
string fileName = null;
|
||||
if(e.Info.TryGetValue(UIImagePickerController.ReferenceUrl, out NSObject urlObj))
|
||||
if (e.Info.TryGetValue(UIImagePickerController.ReferenceUrl, out NSObject urlObj))
|
||||
{
|
||||
var result = PHAsset.FetchAssets(new NSUrl[] { (urlObj as NSUrl) }, null);
|
||||
fileName = result?.firstObject?.ValueForKey(new NSString("filename"))?.ToString();
|
||||
@@ -413,9 +413,9 @@ namespace Bit.iOS.Core.Services
|
||||
fileName = fileName ?? $"photo_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.jpg";
|
||||
var lowerFilename = fileName?.ToLowerInvariant();
|
||||
byte[] data;
|
||||
if(lowerFilename != null && (lowerFilename.EndsWith(".jpg") || lowerFilename.EndsWith(".jpeg")))
|
||||
if (lowerFilename != null && (lowerFilename.EndsWith(".jpg") || lowerFilename.EndsWith(".jpeg")))
|
||||
{
|
||||
using(var imageData = e.OriginalImage.AsJPEG())
|
||||
using (var imageData = e.OriginalImage.AsJPEG())
|
||||
{
|
||||
data = new byte[imageData.Length];
|
||||
System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, data, 0,
|
||||
@@ -424,7 +424,7 @@ namespace Bit.iOS.Core.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
using(var imageData = e.OriginalImage.AsPNG())
|
||||
using (var imageData = e.OriginalImage.AsPNG())
|
||||
{
|
||||
data = new byte[imageData.Length];
|
||||
System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, data, 0,
|
||||
@@ -438,7 +438,7 @@ namespace Bit.iOS.Core.Services
|
||||
|
||||
private void ImagePicker_Canceled(object sender, EventArgs e)
|
||||
{
|
||||
if(sender is UIImagePickerController picker)
|
||||
if (sender is UIImagePickerController picker)
|
||||
{
|
||||
picker.DismissViewController(true, null);
|
||||
}
|
||||
@@ -457,15 +457,15 @@ namespace Bit.iOS.Core.Services
|
||||
private UIViewController GetVisibleViewController(UIViewController controller = null)
|
||||
{
|
||||
controller = controller ?? UIApplication.SharedApplication.KeyWindow.RootViewController;
|
||||
if(controller.PresentedViewController == null)
|
||||
if (controller.PresentedViewController == null)
|
||||
{
|
||||
return controller;
|
||||
}
|
||||
if(controller.PresentedViewController is UINavigationController)
|
||||
if (controller.PresentedViewController is UINavigationController)
|
||||
{
|
||||
return ((UINavigationController)controller.PresentedViewController).VisibleViewController;
|
||||
}
|
||||
if(controller.PresentedViewController is UITabBarController)
|
||||
if (controller.PresentedViewController is UITabBarController)
|
||||
{
|
||||
return ((UITabBarController)controller.PresentedViewController).SelectedViewController;
|
||||
}
|
||||
@@ -476,7 +476,7 @@ namespace Bit.iOS.Core.Services
|
||||
{
|
||||
var window = UIApplication.SharedApplication.KeyWindow;
|
||||
var vc = window.RootViewController;
|
||||
while(vc.PresentedViewController != null)
|
||||
while (vc.PresentedViewController != null)
|
||||
{
|
||||
vc = vc.PresentedViewController;
|
||||
}
|
||||
@@ -502,10 +502,10 @@ namespace Bit.iOS.Core.Services
|
||||
url.StartAccessingSecurityScopedResource();
|
||||
var doc = new UIDocument(url);
|
||||
var fileName = doc.LocalizedName;
|
||||
if(string.IsNullOrWhiteSpace(fileName))
|
||||
if (string.IsNullOrWhiteSpace(fileName))
|
||||
{
|
||||
var path = doc.FileUrl?.ToString();
|
||||
if(path != null)
|
||||
if (path != null)
|
||||
{
|
||||
path = WebUtility.UrlDecode(path);
|
||||
var split = path.LastIndexOf('/');
|
||||
|
||||
Reference in New Issue
Block a user