mirror of
https://github.com/bitwarden/mobile
synced 2026-01-06 10:34:07 +00:00
Changed all C# control flow block statements to include space between keyword and open paren (#800)
This commit is contained in:
@@ -8,7 +8,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
public ExtendedUITableViewCell()
|
||||
{
|
||||
BackgroundColor = ThemeHelpers.BackgroundColor;
|
||||
if(!ThemeHelpers.LightTheme)
|
||||
if (!ThemeHelpers.LightTheme)
|
||||
{
|
||||
SelectionStyle = UITableViewCellSelectionStyle.None;
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
: base(style, reusedId)
|
||||
{
|
||||
BackgroundColor = ThemeHelpers.BackgroundColor;
|
||||
if(!ThemeHelpers.LightTheme)
|
||||
if (!ThemeHelpers.LightTheme)
|
||||
{
|
||||
SelectionStyle = UITableViewCellSelectionStyle.None;
|
||||
}
|
||||
|
||||
@@ -22,16 +22,16 @@ namespace Bit.iOS.Core.Controllers
|
||||
public override void ViewDidLoad()
|
||||
{
|
||||
base.ViewDidLoad();
|
||||
if(View != null)
|
||||
if (View != null)
|
||||
{
|
||||
View.BackgroundColor = ThemeHelpers.BackgroundColor;
|
||||
}
|
||||
if(TableView != null)
|
||||
if (TableView != null)
|
||||
{
|
||||
TableView.BackgroundColor = ThemeHelpers.BackgroundColor;
|
||||
TableView.SeparatorColor = ThemeHelpers.SeparatorColor;
|
||||
}
|
||||
if(NavigationController?.NavigationBar != null)
|
||||
if (NavigationController?.NavigationBar != null)
|
||||
{
|
||||
NavigationController.NavigationBar.BarTintColor = ThemeHelpers.NavBarBackgroundColor;
|
||||
NavigationController.NavigationBar.BackgroundColor = ThemeHelpers.NavBarBackgroundColor;
|
||||
|
||||
@@ -8,9 +8,9 @@ namespace Bit.iOS.Core.Views
|
||||
{
|
||||
public override void WillDisplayHeaderView(UITableView tableView, UIView headerView, nint section)
|
||||
{
|
||||
if(headerView != null && headerView is UITableViewHeaderFooterView hv)
|
||||
if (headerView != null && headerView is UITableViewHeaderFooterView hv)
|
||||
{
|
||||
if(hv.TextLabel != null)
|
||||
if (hv.TextLabel != null)
|
||||
{
|
||||
hv.TextLabel.TextColor = ThemeHelpers.MutedColor;
|
||||
}
|
||||
@@ -19,9 +19,9 @@ namespace Bit.iOS.Core.Views
|
||||
|
||||
public override void WillDisplayFooterView(UITableView tableView, UIView footerView, nint section)
|
||||
{
|
||||
if(footerView != null && footerView is UITableViewHeaderFooterView fv)
|
||||
if (footerView != null && footerView is UITableViewHeaderFooterView fv)
|
||||
{
|
||||
if(fv.TextLabel != null)
|
||||
if (fv.TextLabel != null)
|
||||
{
|
||||
fv.TextLabel.TextColor = ThemeHelpers.MutedColor;
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace Bit.iOS.Core.Controllers
|
||||
public override void ViewDidLoad()
|
||||
{
|
||||
base.ViewDidLoad();
|
||||
if(View != null)
|
||||
if (View != null)
|
||||
{
|
||||
View.BackgroundColor = ThemeHelpers.BackgroundColor;
|
||||
}
|
||||
if(NavigationController?.NavigationBar != null)
|
||||
if (NavigationController?.NavigationBar != null)
|
||||
{
|
||||
NavigationController.NavigationBar.BarTintColor = ThemeHelpers.NavBarBackgroundColor;
|
||||
NavigationController.NavigationBar.BackgroundColor = ThemeHelpers.NavBarBackgroundColor;
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
CheckPasswordAsync().GetAwaiter().GetResult();
|
||||
return true;
|
||||
};
|
||||
if(_pinLock)
|
||||
if (_pinLock)
|
||||
{
|
||||
MasterPasswordCell.TextField.KeyboardType = UIKeyboardType.NumberPad;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
base.ViewDidLoad();
|
||||
|
||||
if(_fingerprintLock)
|
||||
if (_fingerprintLock)
|
||||
{
|
||||
var tasks = Task.Run(async () =>
|
||||
{
|
||||
@@ -93,7 +93,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
public override void ViewDidAppear(bool animated)
|
||||
{
|
||||
base.ViewDidAppear(animated);
|
||||
if(!_fingerprintLock)
|
||||
if (!_fingerprintLock)
|
||||
{
|
||||
MasterPasswordCell.TextField.BecomeFirstResponder();
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
protected async Task CheckPasswordAsync()
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(MasterPasswordCell.TextField.Text))
|
||||
if (string.IsNullOrWhiteSpace(MasterPasswordCell.TextField.Text))
|
||||
{
|
||||
var alert = Dialogs.CreateAlert(AppResources.AnErrorHasOccurred,
|
||||
string.Format(AppResources.ValidationFieldRequired,
|
||||
@@ -116,12 +116,12 @@ namespace Bit.iOS.Core.Controllers
|
||||
var kdfIterations = await _userService.GetKdfIterationsAsync();
|
||||
var inputtedValue = MasterPasswordCell.TextField.Text;
|
||||
|
||||
if(_pinLock)
|
||||
if (_pinLock)
|
||||
{
|
||||
var failed = true;
|
||||
try
|
||||
{
|
||||
if(_pinSet.Item1)
|
||||
if (_pinSet.Item1)
|
||||
{
|
||||
var key = await _cryptoService.MakeKeyFromPinAsync(inputtedValue, email,
|
||||
kdf.GetValueOrDefault(KdfType.PBKDF2_SHA256), kdfIterations.GetValueOrDefault(5000),
|
||||
@@ -130,7 +130,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
var protectedPin = await _storageService.GetAsync<string>(Bit.Core.Constants.ProtectedPin);
|
||||
var decPin = await _cryptoService.DecryptToUtf8Async(new CipherString(protectedPin), encKey);
|
||||
failed = decPin != inputtedValue;
|
||||
if(!failed)
|
||||
if (!failed)
|
||||
{
|
||||
await SetKeyAndContinueAsync(key);
|
||||
}
|
||||
@@ -147,10 +147,10 @@ namespace Bit.iOS.Core.Controllers
|
||||
{
|
||||
failed = true;
|
||||
}
|
||||
if(failed)
|
||||
if (failed)
|
||||
{
|
||||
_invalidPinAttempts++;
|
||||
if(_invalidPinAttempts >= 5)
|
||||
if (_invalidPinAttempts >= 5)
|
||||
{
|
||||
Cancel?.Invoke();
|
||||
return;
|
||||
@@ -163,19 +163,19 @@ namespace Bit.iOS.Core.Controllers
|
||||
var key2 = await _cryptoService.MakeKeyAsync(inputtedValue, email, kdf, kdfIterations);
|
||||
var keyHash = await _cryptoService.HashPasswordAsync(inputtedValue, key2);
|
||||
var storedKeyHash = await _cryptoService.GetKeyHashAsync();
|
||||
if(storedKeyHash == null)
|
||||
if (storedKeyHash == null)
|
||||
{
|
||||
var oldKey = await _secureStorageService.GetAsync<string>("oldKey");
|
||||
if(key2.KeyB64 == oldKey)
|
||||
if (key2.KeyB64 == oldKey)
|
||||
{
|
||||
await _secureStorageService.RemoveAsync("oldKey");
|
||||
await _cryptoService.SetKeyHashAsync(keyHash);
|
||||
storedKeyHash = keyHash;
|
||||
}
|
||||
}
|
||||
if(storedKeyHash != null && keyHash != null && storedKeyHash == keyHash)
|
||||
if (storedKeyHash != null && keyHash != null && storedKeyHash == keyHash)
|
||||
{
|
||||
if(_pinSet.Item1)
|
||||
if (_pinSet.Item1)
|
||||
{
|
||||
var protectedPin = await _storageService.GetAsync<string>(Bit.Core.Constants.ProtectedPin);
|
||||
var encKey = await _cryptoService.GetEncKeyAsync(key2);
|
||||
@@ -196,7 +196,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
private async Task SetKeyAndContinueAsync(SymmetricCryptoKey key)
|
||||
{
|
||||
var hasKey = await _cryptoService.HasKeyAsync();
|
||||
if(!hasKey)
|
||||
if (!hasKey)
|
||||
{
|
||||
await _cryptoService.SetKeyAsync(key);
|
||||
}
|
||||
@@ -212,7 +212,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
public async Task PromptFingerprintAsync()
|
||||
{
|
||||
if(!_fingerprintLock)
|
||||
if (!_fingerprintLock)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -220,7 +220,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
_pinLock ? AppResources.PIN : AppResources.MasterPassword,
|
||||
() => MasterPasswordCell.TextField.BecomeFirstResponder());
|
||||
_lockService.FingerprintLocked = !success;
|
||||
if(success)
|
||||
if (success)
|
||||
{
|
||||
DoContinue();
|
||||
}
|
||||
@@ -250,16 +250,16 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
if(indexPath.Section == 0)
|
||||
if (indexPath.Section == 0)
|
||||
{
|
||||
if(indexPath.Row == 0)
|
||||
if (indexPath.Row == 0)
|
||||
{
|
||||
return _controller.MasterPasswordCell;
|
||||
}
|
||||
}
|
||||
else if(indexPath.Section == 1)
|
||||
else if (indexPath.Section == 1)
|
||||
{
|
||||
if(indexPath.Row == 0)
|
||||
if (indexPath.Row == 0)
|
||||
{
|
||||
var fingerprintButtonText = _controller._deviceActionService.SupportsFaceBiometric() ?
|
||||
AppResources.UseFaceIDToUnlock : AppResources.UseFingerprintToUnlock;
|
||||
@@ -284,7 +284,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
public override nint RowsInSection(UITableView tableview, nint section)
|
||||
{
|
||||
if(section <= 1)
|
||||
if (section <= 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -305,17 +305,17 @@ namespace Bit.iOS.Core.Controllers
|
||||
{
|
||||
tableView.DeselectRow(indexPath, true);
|
||||
tableView.EndEditing(true);
|
||||
if(indexPath.Section == 1 && indexPath.Row == 0)
|
||||
if (indexPath.Section == 1 && indexPath.Row == 0)
|
||||
{
|
||||
var task = _controller.PromptFingerprintAsync();
|
||||
return;
|
||||
}
|
||||
var cell = tableView.CellAt(indexPath);
|
||||
if(cell == null)
|
||||
if (cell == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(cell is ISelectable selectableCell)
|
||||
if (cell is ISelectable selectableCell)
|
||||
{
|
||||
selectableCell.Select();
|
||||
}
|
||||
|
||||
@@ -116,21 +116,21 @@ namespace Bit.iOS.Core.Controllers
|
||||
protected async Task SaveAsync()
|
||||
{
|
||||
/*
|
||||
if(!_connectivity.IsConnected)
|
||||
if (!_connectivity.IsConnected)
|
||||
{
|
||||
AlertNoConnection();
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
if(string.IsNullOrWhiteSpace(PasswordCell?.TextField?.Text))
|
||||
if (string.IsNullOrWhiteSpace(PasswordCell?.TextField?.Text))
|
||||
{
|
||||
DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired,
|
||||
AppResources.Password), AppResources.Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
if(string.IsNullOrWhiteSpace(NameCell?.TextField?.Text))
|
||||
if (string.IsNullOrWhiteSpace(NameCell?.TextField?.Text))
|
||||
{
|
||||
DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired,
|
||||
AppResources.Name), AppResources.Ok);
|
||||
@@ -155,7 +155,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
}
|
||||
};
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(UriCell?.TextField?.Text))
|
||||
if (!string.IsNullOrWhiteSpace(UriCell?.TextField?.Text))
|
||||
{
|
||||
cipher.Login.Uris = new List<LoginUriView>
|
||||
{
|
||||
@@ -174,10 +174,10 @@ namespace Bit.iOS.Core.Controllers
|
||||
await _cipherService.SaveWithServerAsync(cipherDomain);
|
||||
await loadingAlert.DismissViewControllerAsync(true);
|
||||
await _storageService.SaveAsync(Bit.Core.Constants.ClearCiphersCacheKey, true);
|
||||
if(await ASHelpers.IdentitiesCanIncremental())
|
||||
if (await ASHelpers.IdentitiesCanIncremental())
|
||||
{
|
||||
var identity = await ASHelpers.GetCipherIdentityAsync(cipherDomain.Id);
|
||||
if(identity != null)
|
||||
if (identity != null)
|
||||
{
|
||||
await ASCredentialIdentityStore.SharedStore.SaveCredentialIdentitiesAsync(
|
||||
new ASPasswordCredentialIdentity[] { identity });
|
||||
@@ -189,9 +189,9 @@ namespace Bit.iOS.Core.Controllers
|
||||
}
|
||||
Success(cipherDomain.Id);
|
||||
}
|
||||
catch(ApiException e)
|
||||
catch (ApiException e)
|
||||
{
|
||||
if(e?.Error != null)
|
||||
if (e?.Error != null)
|
||||
{
|
||||
DisplayAlert(AppResources.AnErrorHasOccurred, e.Error.GetSingleMessage(), AppResources.Ok);
|
||||
}
|
||||
@@ -221,41 +221,41 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
if(indexPath.Section == 0)
|
||||
if (indexPath.Section == 0)
|
||||
{
|
||||
if(indexPath.Row == 0)
|
||||
if (indexPath.Row == 0)
|
||||
{
|
||||
return _controller.NameCell;
|
||||
}
|
||||
else if(indexPath.Row == 1)
|
||||
else if (indexPath.Row == 1)
|
||||
{
|
||||
return _controller.UsernameCell;
|
||||
}
|
||||
else if(indexPath.Row == 2)
|
||||
else if (indexPath.Row == 2)
|
||||
{
|
||||
return _controller.PasswordCell;
|
||||
}
|
||||
else if(indexPath.Row == 3)
|
||||
else if (indexPath.Row == 3)
|
||||
{
|
||||
return _controller.GeneratePasswordCell;
|
||||
}
|
||||
}
|
||||
else if(indexPath.Section == 1)
|
||||
else if (indexPath.Section == 1)
|
||||
{
|
||||
return _controller.UriCell;
|
||||
}
|
||||
else if(indexPath.Section == 2)
|
||||
else if (indexPath.Section == 2)
|
||||
{
|
||||
if(indexPath.Row == 0)
|
||||
if (indexPath.Row == 0)
|
||||
{
|
||||
return _controller.FolderCell;
|
||||
}
|
||||
else if(indexPath.Row == 1)
|
||||
else if (indexPath.Row == 1)
|
||||
{
|
||||
return _controller.FavoriteCell;
|
||||
}
|
||||
}
|
||||
else if(indexPath.Section == 3)
|
||||
else if (indexPath.Section == 3)
|
||||
{
|
||||
return _controller.NotesCell;
|
||||
}
|
||||
@@ -275,15 +275,15 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
public override nint RowsInSection(UITableView tableview, nint section)
|
||||
{
|
||||
if(section == 0)
|
||||
if (section == 0)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
else if(section == 1)
|
||||
else if (section == 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if(section == 2)
|
||||
else if (section == 2)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
@@ -300,11 +300,11 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
public override string TitleForHeader(UITableView tableView, nint section)
|
||||
{
|
||||
if(section == 0)
|
||||
if (section == 0)
|
||||
{
|
||||
return AppResources.ItemInformation;
|
||||
}
|
||||
else if(section == 3)
|
||||
else if (section == 3)
|
||||
{
|
||||
return AppResources.Notes;
|
||||
}
|
||||
@@ -317,19 +317,19 @@ namespace Bit.iOS.Core.Controllers
|
||||
tableView.DeselectRow(indexPath, true);
|
||||
tableView.EndEditing(true);
|
||||
|
||||
if(indexPath.Section == 0 && indexPath.Row == 3)
|
||||
if (indexPath.Section == 0 && indexPath.Row == 3)
|
||||
{
|
||||
_controller.PerformSegue("passwordGeneratorSegue", this);
|
||||
}
|
||||
|
||||
var cell = tableView.CellAt(indexPath);
|
||||
if(cell == null)
|
||||
if (cell == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var selectableCell = cell as ISelectable;
|
||||
if(selectableCell != null)
|
||||
if (selectableCell != null)
|
||||
{
|
||||
selectableCell.Select();
|
||||
}
|
||||
|
||||
@@ -56,12 +56,12 @@ namespace Bit.iOS.Core.Controllers
|
||||
BasePasswordLabel.TextColor = ThemeHelpers.TextColor;
|
||||
|
||||
var controller = ChildViewControllers.LastOrDefault();
|
||||
if(controller != null)
|
||||
if (controller != null)
|
||||
{
|
||||
OptionsTableViewController = controller as UITableViewController;
|
||||
}
|
||||
|
||||
if(OptionsTableViewController != null)
|
||||
if (OptionsTableViewController != null)
|
||||
{
|
||||
OptionsTableViewController.TableView.RowHeight = UITableView.AutomaticDimension;
|
||||
OptionsTableViewController.TableView.EstimatedRowHeight = 70;
|
||||
@@ -89,14 +89,14 @@ namespace Bit.iOS.Core.Controllers
|
||||
LengthCell.ValueChanged += Options_ValueChanged;
|
||||
|
||||
// Adjust based on context password options
|
||||
if(PasswordOptions != null)
|
||||
if (PasswordOptions != null)
|
||||
{
|
||||
if(PasswordOptions.RequireDigits)
|
||||
if (PasswordOptions.RequireDigits)
|
||||
{
|
||||
NumbersCell.Switch.On = true;
|
||||
NumbersCell.Switch.Enabled = false;
|
||||
|
||||
if(MinNumbersCell.Value < 1)
|
||||
if (MinNumbersCell.Value < 1)
|
||||
{
|
||||
MinNumbersCell.Value = 1;
|
||||
}
|
||||
@@ -104,12 +104,12 @@ namespace Bit.iOS.Core.Controllers
|
||||
MinNumbersCell.Stepper.MinimumValue = 1;
|
||||
}
|
||||
|
||||
if(PasswordOptions.RequireSymbols)
|
||||
if (PasswordOptions.RequireSymbols)
|
||||
{
|
||||
SpecialCell.Switch.On = true;
|
||||
SpecialCell.Switch.Enabled = false;
|
||||
|
||||
if(MinSpecialCell.Value < 1)
|
||||
if (MinSpecialCell.Value < 1)
|
||||
{
|
||||
MinSpecialCell.Value = 1;
|
||||
}
|
||||
@@ -117,11 +117,11 @@ namespace Bit.iOS.Core.Controllers
|
||||
MinSpecialCell.Stepper.MinimumValue = 1;
|
||||
}
|
||||
|
||||
if(PasswordOptions.MinLength < PasswordOptions.MaxLength)
|
||||
if (PasswordOptions.MinLength < PasswordOptions.MaxLength)
|
||||
{
|
||||
if(PasswordOptions.MinLength > 0 && PasswordOptions.MinLength > LengthCell.Slider.MinValue)
|
||||
if (PasswordOptions.MinLength > 0 && PasswordOptions.MinLength > LengthCell.Slider.MinValue)
|
||||
{
|
||||
if(LengthCell.Value < PasswordOptions.MinLength)
|
||||
if (LengthCell.Value < PasswordOptions.MinLength)
|
||||
{
|
||||
LengthCell.Slider.Value = PasswordOptions.MinLength;
|
||||
}
|
||||
@@ -129,9 +129,9 @@ namespace Bit.iOS.Core.Controllers
|
||||
LengthCell.Slider.MinValue = PasswordOptions.MinLength;
|
||||
}
|
||||
|
||||
if(PasswordOptions.MaxLength > 5 && PasswordOptions.MaxLength < LengthCell.Slider.MaxValue)
|
||||
if (PasswordOptions.MaxLength > 5 && PasswordOptions.MaxLength < LengthCell.Slider.MaxValue)
|
||||
{
|
||||
if(LengthCell.Value > PasswordOptions.MaxLength)
|
||||
if (LengthCell.Value > PasswordOptions.MaxLength)
|
||||
{
|
||||
LengthCell.Slider.Value = PasswordOptions.MaxLength;
|
||||
}
|
||||
@@ -147,7 +147,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
private void Options_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(InvalidState())
|
||||
if (InvalidState())
|
||||
{
|
||||
LowercaseCell.Switch.On = true;
|
||||
}
|
||||
@@ -186,46 +186,46 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
if(indexPath.Section == 0)
|
||||
if (indexPath.Section == 0)
|
||||
{
|
||||
var cell = new ExtendedUITableViewCell();
|
||||
cell.TextLabel.TextColor = ThemeHelpers.PrimaryColor;
|
||||
if(indexPath.Row == 0)
|
||||
if (indexPath.Row == 0)
|
||||
{
|
||||
cell.TextLabel.Text = AppResources.RegeneratePassword;
|
||||
}
|
||||
else if(indexPath.Row == 1)
|
||||
else if (indexPath.Row == 1)
|
||||
{
|
||||
cell.TextLabel.Text = AppResources.CopyPassword;
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
if(indexPath.Row == 0)
|
||||
if (indexPath.Row == 0)
|
||||
{
|
||||
return _controller.LengthCell;
|
||||
}
|
||||
else if(indexPath.Row == 1)
|
||||
else if (indexPath.Row == 1)
|
||||
{
|
||||
return _controller.UppercaseCell;
|
||||
}
|
||||
else if(indexPath.Row == 2)
|
||||
else if (indexPath.Row == 2)
|
||||
{
|
||||
return _controller.LowercaseCell;
|
||||
}
|
||||
else if(indexPath.Row == 3)
|
||||
else if (indexPath.Row == 3)
|
||||
{
|
||||
return _controller.NumbersCell;
|
||||
}
|
||||
else if(indexPath.Row == 4)
|
||||
else if (indexPath.Row == 4)
|
||||
{
|
||||
return _controller.SpecialCell;
|
||||
}
|
||||
else if(indexPath.Row == 5)
|
||||
else if (indexPath.Row == 5)
|
||||
{
|
||||
return _controller.MinNumbersCell;
|
||||
}
|
||||
else if(indexPath.Row == 6)
|
||||
else if (indexPath.Row == 6)
|
||||
{
|
||||
return _controller.MinSpecialCell;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
public override nint RowsInSection(UITableView tableview, nint section)
|
||||
{
|
||||
if(section == 0)
|
||||
if (section == 0)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
@@ -255,7 +255,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
public override nfloat GetHeightForHeader(UITableView tableView, nint section)
|
||||
{
|
||||
if(section == 0)
|
||||
if (section == 0)
|
||||
{
|
||||
return 0.00001f;
|
||||
}
|
||||
@@ -265,7 +265,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
public override UIView GetViewForHeader(UITableView tableView, nint section)
|
||||
{
|
||||
if(section == 0)
|
||||
if (section == 0)
|
||||
{
|
||||
return new UIView(CGRect.Empty)
|
||||
{
|
||||
@@ -278,7 +278,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
public override string TitleForHeader(UITableView tableView, nint section)
|
||||
{
|
||||
if(section == 1)
|
||||
if (section == 1)
|
||||
{
|
||||
return AppResources.Options;
|
||||
}
|
||||
@@ -288,7 +288,7 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
public override string TitleForFooter(UITableView tableView, nint section)
|
||||
{
|
||||
if(section == 1)
|
||||
if (section == 1)
|
||||
{
|
||||
return AppResources.OptionDefaults;
|
||||
}
|
||||
@@ -298,13 +298,13 @@ namespace Bit.iOS.Core.Controllers
|
||||
|
||||
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
if(indexPath.Section == 0)
|
||||
if (indexPath.Section == 0)
|
||||
{
|
||||
if(indexPath.Row == 0)
|
||||
if (indexPath.Row == 0)
|
||||
{
|
||||
var task = _controller.GeneratePasswordAsync();
|
||||
}
|
||||
else if(indexPath.Row == 1)
|
||||
else if (indexPath.Row == 1)
|
||||
{
|
||||
UIPasteboard clipboard = UIPasteboard.General;
|
||||
clipboard.String = _controller.BasePasswordLabel.Text;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Bit.iOS.Core.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(UrlString) || !Uri.TryCreate(UrlString, UriKind.Absolute, out Uri uri))
|
||||
if (string.IsNullOrWhiteSpace(UrlString) || !Uri.TryCreate(UrlString, UriKind.Absolute, out Uri uri))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -27,18 +27,18 @@ namespace Bit.iOS.Core.Models
|
||||
set
|
||||
{
|
||||
_uriString = value;
|
||||
if(string.IsNullOrWhiteSpace(_uriString))
|
||||
if (string.IsNullOrWhiteSpace(_uriString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(!_uriString.StartsWith(Bit.Core.Constants.iOSAppProtocol) && _uriString.Contains("."))
|
||||
if (!_uriString.StartsWith(Bit.Core.Constants.iOSAppProtocol) && _uriString.Contains("."))
|
||||
{
|
||||
if(!_uriString.Contains("://") && !_uriString.Contains(" "))
|
||||
if (!_uriString.Contains("://") && !_uriString.Contains(" "))
|
||||
{
|
||||
_uriString = string.Concat("http://", _uriString);
|
||||
}
|
||||
}
|
||||
if(!_uriString.StartsWith("http") && !_uriString.StartsWith(Bit.Core.Constants.iOSAppProtocol))
|
||||
if (!_uriString.StartsWith("http") && !_uriString.StartsWith(Bit.Core.Constants.iOSAppProtocol))
|
||||
{
|
||||
_uriString = string.Concat(Bit.Core.Constants.iOSAppProtocol, _uriString);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Bit.iOS.Core.Models
|
||||
public FillScript(PageDetails pageDetails, string fillUsername, string fillPassword,
|
||||
List<Tuple<string, string>> fillFields)
|
||||
{
|
||||
if(pageDetails == null)
|
||||
if (pageDetails == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -23,18 +23,18 @@ namespace Bit.iOS.Core.Models
|
||||
|
||||
var filledFields = new Dictionary<string, PageDetails.Field>();
|
||||
|
||||
if(fillFields?.Any() ?? false)
|
||||
if (fillFields?.Any() ?? false)
|
||||
{
|
||||
var fieldNames = fillFields.Select(f => f.Item1?.ToLower()).ToArray();
|
||||
foreach(var field in pageDetails.Fields.Where(f => f.Viewable))
|
||||
foreach (var field in pageDetails.Fields.Where(f => f.Viewable))
|
||||
{
|
||||
if(filledFields.ContainsKey(field.OpId))
|
||||
if (filledFields.ContainsKey(field.OpId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var matchingIndex = FindMatchingFieldIndex(field, fieldNames);
|
||||
if(matchingIndex > -1)
|
||||
if (matchingIndex > -1)
|
||||
{
|
||||
filledFields.Add(field.OpId, field);
|
||||
Script.Add(new List<string> { "click_on_opid", field.OpId });
|
||||
@@ -43,7 +43,7 @@ namespace Bit.iOS.Core.Models
|
||||
}
|
||||
}
|
||||
|
||||
if(string.IsNullOrWhiteSpace(fillPassword))
|
||||
if (string.IsNullOrWhiteSpace(fillPassword))
|
||||
{
|
||||
// No password for this login. Maybe they just wanted to auto-fill some custom fields?
|
||||
SetFillScriptForFocus(filledFields);
|
||||
@@ -54,39 +54,39 @@ namespace Bit.iOS.Core.Models
|
||||
List<PageDetails.Field> passwords = new List<PageDetails.Field>();
|
||||
|
||||
var passwordFields = pageDetails.Fields.Where(f => f.Type == "password" && f.Viewable).ToArray();
|
||||
if(!passwordFields.Any())
|
||||
if (!passwordFields.Any())
|
||||
{
|
||||
// not able to find any viewable password fields. maybe there are some "hidden" ones?
|
||||
passwordFields = pageDetails.Fields.Where(f => f.Type == "password").ToArray();
|
||||
}
|
||||
|
||||
foreach(var form in pageDetails.Forms)
|
||||
foreach (var form in pageDetails.Forms)
|
||||
{
|
||||
var passwordFieldsForForm = passwordFields.Where(f => f.Form == form.Key).ToArray();
|
||||
passwords.AddRange(passwordFieldsForForm);
|
||||
|
||||
if(string.IsNullOrWhiteSpace(fillUsername))
|
||||
if (string.IsNullOrWhiteSpace(fillUsername))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach(var pf in passwordFieldsForForm)
|
||||
foreach (var pf in passwordFieldsForForm)
|
||||
{
|
||||
var username = FindUsernameField(pageDetails, pf, false, true);
|
||||
if(username == null)
|
||||
if (username == null)
|
||||
{
|
||||
// not able to find any viewable username fields. maybe there are some "hidden" ones?
|
||||
username = FindUsernameField(pageDetails, pf, true, true);
|
||||
}
|
||||
|
||||
if(username != null)
|
||||
if (username != null)
|
||||
{
|
||||
usernames.Add(username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(passwordFields.Any() && !passwords.Any())
|
||||
if (passwordFields.Any() && !passwords.Any())
|
||||
{
|
||||
// The page does not have any forms with password fields. Use the first password field on the page and the
|
||||
// input field just before it as the username.
|
||||
@@ -94,29 +94,29 @@ namespace Bit.iOS.Core.Models
|
||||
var pf = passwordFields.First();
|
||||
passwords.Add(pf);
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(fillUsername) && pf.ElementNumber > 0)
|
||||
if (!string.IsNullOrWhiteSpace(fillUsername) && pf.ElementNumber > 0)
|
||||
{
|
||||
var username = FindUsernameField(pageDetails, pf, false, false);
|
||||
if(username == null)
|
||||
if (username == null)
|
||||
{
|
||||
// not able to find any viewable username fields. maybe there are some "hidden" ones?
|
||||
username = FindUsernameField(pageDetails, pf, true, false);
|
||||
}
|
||||
|
||||
if(username != null)
|
||||
if (username != null)
|
||||
{
|
||||
usernames.Add(username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!passwordFields.Any())
|
||||
if (!passwordFields.Any())
|
||||
{
|
||||
// No password fields on this page. Let's try to just fuzzy fill the username.
|
||||
var usernameFieldNamesList = _usernameFieldNames.ToList();
|
||||
foreach(var f in pageDetails.Fields)
|
||||
foreach (var f in pageDetails.Fields)
|
||||
{
|
||||
if(f.Viewable && (f.Type == "text" || f.Type == "email" || f.Type == "tel") &&
|
||||
if (f.Viewable && (f.Type == "text" || f.Type == "email" || f.Type == "tel") &&
|
||||
FieldIsFuzzyMatch(f, usernameFieldNamesList))
|
||||
{
|
||||
usernames.Add(f);
|
||||
@@ -124,14 +124,14 @@ namespace Bit.iOS.Core.Models
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var username in usernames.Where(u => !filledFields.ContainsKey(u.OpId)))
|
||||
foreach (var username in usernames.Where(u => !filledFields.ContainsKey(u.OpId)))
|
||||
{
|
||||
filledFields.Add(username.OpId, username);
|
||||
Script.Add(new List<string> { "click_on_opid", username.OpId });
|
||||
Script.Add(new List<string> { "fill_by_opid", username.OpId, fillUsername });
|
||||
}
|
||||
|
||||
foreach(var password in passwords.Where(p => !filledFields.ContainsKey(p.OpId)))
|
||||
foreach (var password in passwords.Where(p => !filledFields.ContainsKey(p.OpId)))
|
||||
{
|
||||
filledFields.Add(password.OpId, password);
|
||||
Script.Add(new List<string> { "click_on_opid", password.OpId });
|
||||
@@ -157,21 +157,21 @@ namespace Bit.iOS.Core.Models
|
||||
{
|
||||
PageDetails.Field usernameField = null;
|
||||
|
||||
foreach(var f in pageDetails.Fields)
|
||||
foreach (var f in pageDetails.Fields)
|
||||
{
|
||||
if(f.ElementNumber >= passwordField.ElementNumber)
|
||||
if (f.ElementNumber >= passwordField.ElementNumber)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if((!checkForm || f.Form == passwordField.Form)
|
||||
if ((!checkForm || f.Form == passwordField.Form)
|
||||
&& (canBeHidden || f.Viewable)
|
||||
&& f.ElementNumber < passwordField.ElementNumber
|
||||
&& (f.Type == "text" || f.Type == "email" || f.Type == "tel"))
|
||||
{
|
||||
usernameField = f;
|
||||
|
||||
if(FindMatchingFieldIndex(f, _usernameFieldNames) > -1)
|
||||
if (FindMatchingFieldIndex(f, _usernameFieldNames) > -1)
|
||||
{
|
||||
// We found an exact match. No need to keep looking.
|
||||
break;
|
||||
@@ -185,19 +185,19 @@ namespace Bit.iOS.Core.Models
|
||||
private int FindMatchingFieldIndex(PageDetails.Field field, string[] names)
|
||||
{
|
||||
var matchingIndex = -1;
|
||||
if(!string.IsNullOrWhiteSpace(field.HtmlId))
|
||||
if (!string.IsNullOrWhiteSpace(field.HtmlId))
|
||||
{
|
||||
matchingIndex = Array.IndexOf(names, field.HtmlId.ToLower());
|
||||
}
|
||||
if(matchingIndex < 0 && !string.IsNullOrWhiteSpace(field.HtmlName))
|
||||
if (matchingIndex < 0 && !string.IsNullOrWhiteSpace(field.HtmlName))
|
||||
{
|
||||
matchingIndex = Array.IndexOf(names, field.HtmlName.ToLower());
|
||||
}
|
||||
if(matchingIndex < 0 && !string.IsNullOrWhiteSpace(field.LabelTag))
|
||||
if (matchingIndex < 0 && !string.IsNullOrWhiteSpace(field.LabelTag))
|
||||
{
|
||||
matchingIndex = Array.IndexOf(names, CleanLabel(field.LabelTag));
|
||||
}
|
||||
if(matchingIndex < 0 && !string.IsNullOrWhiteSpace(field.Placeholder))
|
||||
if (matchingIndex < 0 && !string.IsNullOrWhiteSpace(field.Placeholder))
|
||||
{
|
||||
matchingIndex = Array.IndexOf(names, field.Placeholder.ToLower());
|
||||
}
|
||||
@@ -207,19 +207,19 @@ namespace Bit.iOS.Core.Models
|
||||
|
||||
private bool FieldIsFuzzyMatch(PageDetails.Field field, List<string> names)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(field.HtmlId) && FuzzyMatch(names, field.HtmlId.ToLower()))
|
||||
if (!string.IsNullOrWhiteSpace(field.HtmlId) && FuzzyMatch(names, field.HtmlId.ToLower()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(!string.IsNullOrWhiteSpace(field.HtmlName) && FuzzyMatch(names, field.HtmlName.ToLower()))
|
||||
if (!string.IsNullOrWhiteSpace(field.HtmlName) && FuzzyMatch(names, field.HtmlName.ToLower()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(!string.IsNullOrWhiteSpace(field.LabelTag) && FuzzyMatch(names, CleanLabel(field.LabelTag)))
|
||||
if (!string.IsNullOrWhiteSpace(field.LabelTag) && FuzzyMatch(names, CleanLabel(field.LabelTag)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(!string.IsNullOrWhiteSpace(field.Placeholder) && FuzzyMatch(names, field.Placeholder.ToLower()))
|
||||
if (!string.IsNullOrWhiteSpace(field.Placeholder) && FuzzyMatch(names, field.Placeholder.ToLower()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ namespace Bit.iOS.Core.Models
|
||||
|
||||
private bool FuzzyMatch(List<string> options, string value)
|
||||
{
|
||||
if((!options?.Any() ?? true) || string.IsNullOrWhiteSpace(value))
|
||||
if ((!options?.Any() ?? true) || string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -239,18 +239,18 @@ namespace Bit.iOS.Core.Models
|
||||
|
||||
private void SetFillScriptForFocus(IDictionary<string, PageDetails.Field> filledFields)
|
||||
{
|
||||
if(!filledFields.Any())
|
||||
if (!filledFields.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PageDetails.Field lastField = null, lastPasswordField = null;
|
||||
foreach(var field in filledFields)
|
||||
foreach (var field in filledFields)
|
||||
{
|
||||
if(field.Value.Viewable)
|
||||
if (field.Value.Viewable)
|
||||
{
|
||||
lastField = field.Value;
|
||||
if(field.Value.Type == "password")
|
||||
if (field.Value.Type == "password")
|
||||
{
|
||||
lastPasswordField = field.Value;
|
||||
}
|
||||
@@ -258,11 +258,11 @@ namespace Bit.iOS.Core.Models
|
||||
}
|
||||
|
||||
// Prioritize password field over others.
|
||||
if(lastPasswordField != null)
|
||||
if (lastPasswordField != null)
|
||||
{
|
||||
Script.Add(new List<string> { "focus_by_opid", lastPasswordField.OpId });
|
||||
}
|
||||
else if(lastField != null)
|
||||
else if (lastField != null)
|
||||
{
|
||||
Script.Add(new List<string> { "focus_by_opid", lastField.OpId });
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ namespace Bit.iOS.Core.Services
|
||||
{
|
||||
uint keySize = 32;
|
||||
uint pseudoRandomAlgorithm = 3; // kCCPRFHmacAlgSHA256
|
||||
if(algorithm == CryptoHashAlgorithm.Sha512)
|
||||
if (algorithm == CryptoHashAlgorithm.Sha512)
|
||||
{
|
||||
keySize = 64;
|
||||
pseudoRandomAlgorithm = 5; // kCCPRFHmacAlgSHA512
|
||||
}
|
||||
else if(algorithm != CryptoHashAlgorithm.Sha256)
|
||||
else if (algorithm != CryptoHashAlgorithm.Sha256)
|
||||
{
|
||||
throw new ArgumentException("Unsupported PBKDF2 algorithm.");
|
||||
}
|
||||
|
||||
@@ -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('/');
|
||||
|
||||
@@ -33,10 +33,10 @@ namespace Bit.iOS.Core.Services
|
||||
var appId = await _getAppId.Invoke();
|
||||
var formattedKey = string.Format(_keyFormat, appId, key);
|
||||
byte[] dataBytes = null;
|
||||
using(var existingRecord = GetKeyRecord(formattedKey))
|
||||
using(var record = SecKeyChain.QueryAsRecord(existingRecord, out var resultCode))
|
||||
using (var existingRecord = GetKeyRecord(formattedKey))
|
||||
using (var record = SecKeyChain.QueryAsRecord(existingRecord, out var resultCode))
|
||||
{
|
||||
if(resultCode == SecStatusCode.ItemNotFound || resultCode == SecStatusCode.InteractionNotAllowed)
|
||||
if (resultCode == SecStatusCode.ItemNotFound || resultCode == SecStatusCode.InteractionNotAllowed)
|
||||
{
|
||||
return (T)(object)null;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ namespace Bit.iOS.Core.Services
|
||||
}
|
||||
|
||||
var dataString = Encoding.UTF8.GetString(dataBytes);
|
||||
if(typeof(T) == typeof(string))
|
||||
if (typeof(T) == typeof(string))
|
||||
{
|
||||
return (T)(object)dataString;
|
||||
}
|
||||
@@ -58,14 +58,14 @@ namespace Bit.iOS.Core.Services
|
||||
|
||||
public async Task SaveAsync<T>(string key, T obj)
|
||||
{
|
||||
if(obj == null)
|
||||
if (obj == null)
|
||||
{
|
||||
await RemoveAsync(key);
|
||||
return;
|
||||
}
|
||||
|
||||
string dataString = null;
|
||||
if(typeof(T) == typeof(string))
|
||||
if (typeof(T) == typeof(string))
|
||||
{
|
||||
dataString = obj as string;
|
||||
}
|
||||
@@ -77,8 +77,8 @@ namespace Bit.iOS.Core.Services
|
||||
var appId = await _getAppId.Invoke();
|
||||
var formattedKey = string.Format(_keyFormat, appId, key);
|
||||
var dataBytes = Encoding.UTF8.GetBytes(dataString);
|
||||
using(var data = NSData.FromArray(dataBytes))
|
||||
using(var newRecord = GetKeyRecord(formattedKey, data))
|
||||
using (var data = NSData.FromArray(dataBytes))
|
||||
using (var newRecord = GetKeyRecord(formattedKey, data))
|
||||
{
|
||||
await RemoveAsync(key);
|
||||
CheckError(SecKeyChain.Add(newRecord));
|
||||
@@ -89,9 +89,9 @@ namespace Bit.iOS.Core.Services
|
||||
{
|
||||
var appId = await _getAppId.Invoke();
|
||||
var formattedKey = string.Format(_keyFormat, appId, key);
|
||||
using(var record = GetExistingRecord(formattedKey))
|
||||
using (var record = GetExistingRecord(formattedKey))
|
||||
{
|
||||
if(record != null)
|
||||
if (record != null)
|
||||
{
|
||||
CheckError(SecKeyChain.Remove(record));
|
||||
}
|
||||
@@ -106,7 +106,7 @@ namespace Bit.iOS.Core.Services
|
||||
Account = key,
|
||||
AccessGroup = _group
|
||||
};
|
||||
if(data != null)
|
||||
if (data != null)
|
||||
{
|
||||
record.Generic = data;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ namespace Bit.iOS.Core.Services
|
||||
|
||||
private void CheckError(SecStatusCode resultCode, [CallerMemberName] string caller = null)
|
||||
{
|
||||
if(resultCode != SecStatusCode.Success)
|
||||
if (resultCode != SecStatusCode.Success)
|
||||
{
|
||||
throw new Exception(string.Format("Failed to execute {0}. Result code: {1}", caller, resultCode));
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Bit.iOS.Core.Services
|
||||
public CultureInfo GetCurrentCultureInfo()
|
||||
{
|
||||
var netLanguage = "en";
|
||||
if(NSLocale.PreferredLanguages.Length > 0)
|
||||
if (NSLocale.PreferredLanguages.Length > 0)
|
||||
{
|
||||
var pref = NSLocale.PreferredLanguages[0];
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Bit.iOS.Core.Services
|
||||
{
|
||||
ci = new CultureInfo(netLanguage);
|
||||
}
|
||||
catch(CultureNotFoundException e1)
|
||||
catch (CultureNotFoundException e1)
|
||||
{
|
||||
// iOS locale not valid .NET culture (eg. "en-ES" : English in Spain)
|
||||
// fallback to first characters, in this case "en"
|
||||
@@ -34,7 +34,7 @@ namespace Bit.iOS.Core.Services
|
||||
Console.WriteLine(netLanguage + " failed, trying " + fallback + " (" + e1.Message + ")");
|
||||
ci = new CultureInfo(fallback);
|
||||
}
|
||||
catch(CultureNotFoundException e2)
|
||||
catch (CultureNotFoundException e2)
|
||||
{
|
||||
// iOS language not valid .NET culture, falling back to English
|
||||
Console.WriteLine(netLanguage + " couldn't be set, using 'en' (" + e2.Message + ")");
|
||||
@@ -49,18 +49,18 @@ namespace Bit.iOS.Core.Services
|
||||
{
|
||||
Console.WriteLine("iOS Language:" + iOSLanguage);
|
||||
var netLanguage = iOSLanguage;
|
||||
if(iOSLanguage.StartsWith("zh-Hant") || iOSLanguage.StartsWith("zh-HK"))
|
||||
if (iOSLanguage.StartsWith("zh-Hant") || iOSLanguage.StartsWith("zh-HK"))
|
||||
{
|
||||
netLanguage = "zh-Hant";
|
||||
}
|
||||
else if(iOSLanguage.StartsWith("zh"))
|
||||
else if (iOSLanguage.StartsWith("zh"))
|
||||
{
|
||||
netLanguage = "zh-Hans";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Certain languages need to be converted to CultureInfo equivalent
|
||||
switch(iOSLanguage)
|
||||
switch (iOSLanguage)
|
||||
{
|
||||
case "ms-MY": // "Malaysian (Malaysia)" not supported .NET culture
|
||||
case "ms-SG": // "Malaysian (Singapore)" not supported .NET culture
|
||||
@@ -83,7 +83,7 @@ namespace Bit.iOS.Core.Services
|
||||
Console.WriteLine(".NET Fallback Language:" + platCulture.LanguageCode);
|
||||
// Use the first part of the identifier (two chars, usually);
|
||||
var netLanguage = platCulture.LanguageCode;
|
||||
switch(platCulture.LanguageCode)
|
||||
switch (platCulture.LanguageCode)
|
||||
{
|
||||
case "pt":
|
||||
netLanguage = "pt-PT"; // fallback to Portuguese (Portugal)
|
||||
|
||||
@@ -12,11 +12,11 @@ namespace Bit.iOS.Core.Utilities
|
||||
{
|
||||
public static async Task ReplaceAllIdentities()
|
||||
{
|
||||
if(await AutofillEnabled())
|
||||
if (await AutofillEnabled())
|
||||
{
|
||||
var storageService = ServiceContainer.Resolve<IStorageService>("storageService");
|
||||
var lockService = ServiceContainer.Resolve<ILockService>("lockService");
|
||||
if(await lockService.IsLockedAsync())
|
||||
if (await lockService.IsLockedAsync())
|
||||
{
|
||||
await storageService.SaveAsync(Constants.AutofillNeedsIdentityReplacementKey, true);
|
||||
return;
|
||||
@@ -24,15 +24,15 @@ namespace Bit.iOS.Core.Utilities
|
||||
var cipherService = ServiceContainer.Resolve<ICipherService>("cipherService");
|
||||
var identities = new List<ASPasswordCredentialIdentity>();
|
||||
var ciphers = await cipherService.GetAllDecryptedAsync();
|
||||
foreach(var cipher in ciphers)
|
||||
foreach (var cipher in ciphers)
|
||||
{
|
||||
var identity = ToCredentialIdentity(cipher);
|
||||
if(identity != null)
|
||||
if (identity != null)
|
||||
{
|
||||
identities.Add(identity);
|
||||
}
|
||||
}
|
||||
if(identities.Any())
|
||||
if (identities.Any())
|
||||
{
|
||||
await ASCredentialIdentityStore.SharedStore?.ReplaceCredentialIdentitiesAsync(identities.ToArray());
|
||||
await storageService.SaveAsync(Constants.AutofillNeedsIdentityReplacementKey, false);
|
||||
@@ -56,7 +56,7 @@ namespace Bit.iOS.Core.Utilities
|
||||
{
|
||||
var cipherService = ServiceContainer.Resolve<ICipherService>("cipherService");
|
||||
var cipher = await cipherService.GetAsync(cipherId);
|
||||
if(cipher == null)
|
||||
if (cipher == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -66,17 +66,17 @@ namespace Bit.iOS.Core.Utilities
|
||||
|
||||
public static ASPasswordCredentialIdentity ToCredentialIdentity(CipherView cipher)
|
||||
{
|
||||
if(!cipher?.Login?.Uris?.Any() ?? true)
|
||||
if (!cipher?.Login?.Uris?.Any() ?? true)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var uri = cipher.Login.Uris.FirstOrDefault(u => u.Match != Bit.Core.Enums.UriMatchType.Never)?.Uri;
|
||||
if(string.IsNullOrWhiteSpace(uri))
|
||||
if (string.IsNullOrWhiteSpace(uri))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var username = cipher.Login.Username;
|
||||
if(string.IsNullOrWhiteSpace(username))
|
||||
if (string.IsNullOrWhiteSpace(username))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Bit.iOS.Core.Utilities
|
||||
public static UIAlertController CreateActionSheet(string title, UIViewController controller)
|
||||
{
|
||||
var sheet = UIAlertController.Create(title, null, UIAlertControllerStyle.ActionSheet);
|
||||
if(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
|
||||
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
|
||||
{
|
||||
var x = controller.View.Bounds.Width / 2;
|
||||
var y = controller.View.Bounds.Bottom;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Bit.iOS.Core.Utilities
|
||||
UINavigationBar.Appearance.ShadowImage = new UIImage();
|
||||
UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
|
||||
UIStepper.Appearance.TintColor = MutedColor;
|
||||
if(!LightTheme)
|
||||
if (!LightTheme)
|
||||
{
|
||||
UISwitch.Appearance.TintColor = MutedColor;
|
||||
}
|
||||
@@ -59,12 +59,12 @@ namespace Bit.iOS.Core.Utilities
|
||||
private static void SetThemeVariables(string theme)
|
||||
{
|
||||
LightTheme = false;
|
||||
if(string.IsNullOrWhiteSpace(theme) && UsingOsDarkTheme)
|
||||
if (string.IsNullOrWhiteSpace(theme) && UsingOsDarkTheme)
|
||||
{
|
||||
theme = "dark";
|
||||
}
|
||||
|
||||
if(theme == "dark")
|
||||
if (theme == "dark")
|
||||
{
|
||||
var whiteColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor();
|
||||
MutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor();
|
||||
@@ -79,7 +79,7 @@ namespace Bit.iOS.Core.Utilities
|
||||
NavBarBackgroundColor = Xamarin.Forms.Color.FromHex("#212121").ToUIColor();
|
||||
NavBarTextColor = whiteColor;
|
||||
}
|
||||
else if(theme == "black")
|
||||
else if (theme == "black")
|
||||
{
|
||||
var blackColor = Xamarin.Forms.Color.FromHex("#000000").ToUIColor();
|
||||
var whiteColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor();
|
||||
@@ -95,7 +95,7 @@ namespace Bit.iOS.Core.Utilities
|
||||
NavBarBackgroundColor = blackColor;
|
||||
NavBarTextColor = whiteColor;
|
||||
}
|
||||
else if(theme == "nord")
|
||||
else if (theme == "nord")
|
||||
{
|
||||
MutedColor = Xamarin.Forms.Color.FromHex("#d8dee9").ToUIColor();
|
||||
SuccessColor = Xamarin.Forms.Color.FromHex("#a3be8c").ToUIColor();
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Bit.iOS.Core.Utilities
|
||||
|
||||
public static void RegisterLocalServices()
|
||||
{
|
||||
if(ServiceContainer.Resolve<ILogService>("logService", true) == null)
|
||||
if (ServiceContainer.Resolve<ILogService>("logService", true) == null)
|
||||
{
|
||||
ServiceContainer.Register<ILogService>("logService", new ConsoleLogService());
|
||||
}
|
||||
@@ -87,7 +87,7 @@ namespace Bit.iOS.Core.Utilities
|
||||
await ServiceContainer.Resolve<IStateService>("stateService").SaveAsync(
|
||||
Bit.Core.Constants.DisableFaviconKey, disableFavicon);
|
||||
await ServiceContainer.Resolve<IEnvironmentService>("environmentService").SetUrlsFromStorageAsync();
|
||||
if(postBootstrapFunc != null)
|
||||
if (postBootstrapFunc != null)
|
||||
{
|
||||
await postBootstrapFunc.Invoke();
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace Bit.iOS.Core.Views
|
||||
{
|
||||
NSRunLoop.Main.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(searchText))
|
||||
if (!string.IsNullOrWhiteSpace(searchText))
|
||||
{
|
||||
await Task.Delay(300);
|
||||
if(searchText != searchBar.Text)
|
||||
if (searchText != searchBar.Text)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ namespace Bit.iOS.Core.Views
|
||||
((ExtensionTableSource)_tableView.Source).FilterResults(searchText, cts.Token);
|
||||
_tableView.ReloadData();
|
||||
}
|
||||
catch(OperationCanceledException) { }
|
||||
catch (OperationCanceledException) { }
|
||||
_filterResultsCancellationTokenSource = cts;
|
||||
});
|
||||
}, cts.Token);
|
||||
|
||||
@@ -44,14 +44,14 @@ namespace Bit.iOS.Core.Views
|
||||
{
|
||||
var combinedLogins = new List<CipherView>();
|
||||
|
||||
if(urlFilter)
|
||||
if (urlFilter)
|
||||
{
|
||||
var logins = await _cipherService.GetAllDecryptedByUrlAsync(_context.UrlString);
|
||||
if(logins?.Item1 != null)
|
||||
if (logins?.Item1 != null)
|
||||
{
|
||||
combinedLogins.AddRange(logins.Item1);
|
||||
}
|
||||
if(logins?.Item2 != null)
|
||||
if (logins?.Item2 != null)
|
||||
{
|
||||
combinedLogins.AddRange(logins.Item2);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ namespace Bit.iOS.Core.Views
|
||||
{
|
||||
ct.ThrowIfCancellationRequested();
|
||||
|
||||
if(string.IsNullOrWhiteSpace(searchFilter))
|
||||
if (string.IsNullOrWhiteSpace(searchFilter))
|
||||
{
|
||||
Items = _allItems.ToList();
|
||||
}
|
||||
@@ -95,7 +95,7 @@ namespace Bit.iOS.Core.Views
|
||||
|
||||
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
if(Items == null || Items.Count() == 0)
|
||||
if (Items == null || Items.Count() == 0)
|
||||
{
|
||||
var noDataCell = new ExtendedUITableViewCell(UITableViewCellStyle.Default, "NoDataCell");
|
||||
noDataCell.TextLabel.Text = AppResources.NoItemsTap;
|
||||
@@ -109,7 +109,7 @@ namespace Bit.iOS.Core.Views
|
||||
var cell = tableView.DequeueReusableCell(CellIdentifier);
|
||||
|
||||
// if there are no cells to reuse, create a new one
|
||||
if(cell == null)
|
||||
if (cell == null)
|
||||
{
|
||||
Debug.WriteLine("BW Log, Make new cell for list.");
|
||||
cell = new ExtendedUITableViewCell(UITableViewCellStyle.Subtitle, CellIdentifier);
|
||||
@@ -121,7 +121,7 @@ namespace Bit.iOS.Core.Views
|
||||
|
||||
public override void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath)
|
||||
{
|
||||
if(Items == null || Items.Count() == 0 || cell == null)
|
||||
if (Items == null || Items.Count() == 0 || cell == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -135,9 +135,9 @@ namespace Bit.iOS.Core.Views
|
||||
{
|
||||
string totp = null;
|
||||
var accessPremium = await _userService.CanAccessPremiumAsync();
|
||||
if(accessPremium || (item?.CipherView.OrganizationUseTotp ?? false))
|
||||
if (accessPremium || (item?.CipherView.OrganizationUseTotp ?? false))
|
||||
{
|
||||
if(item != null && !string.IsNullOrWhiteSpace(item.Totp))
|
||||
if (item != null && !string.IsNullOrWhiteSpace(item.Totp))
|
||||
{
|
||||
totp = await _totpService.GetCodeAsync(item.Totp);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Bit.iOS.Core.Views
|
||||
var descriptor = UIFontDescriptor.PreferredBody;
|
||||
var pointSize = descriptor.PointSize;
|
||||
|
||||
if(labelName != null && !useLabelAsPlaceholder)
|
||||
if (labelName != null && !useLabelAsPlaceholder)
|
||||
{
|
||||
Label = new UILabel
|
||||
{
|
||||
@@ -30,7 +30,7 @@ namespace Bit.iOS.Core.Views
|
||||
ContentView.Add(Label);
|
||||
}
|
||||
|
||||
if(useTextView)
|
||||
if (useTextView)
|
||||
{
|
||||
TextView = new UITextView
|
||||
{
|
||||
@@ -41,7 +41,7 @@ namespace Bit.iOS.Core.Views
|
||||
BackgroundColor = ThemeHelpers.BackgroundColor
|
||||
};
|
||||
|
||||
if(!ThemeHelpers.LightTheme)
|
||||
if (!ThemeHelpers.LightTheme)
|
||||
{
|
||||
TextView.KeyboardAppearance = UIKeyboardAppearance.Dark;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ namespace Bit.iOS.Core.Views
|
||||
NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, TextView, NSLayoutAttribute.Bottom, 1f, 10f)
|
||||
});
|
||||
|
||||
if(labelName != null && !useLabelAsPlaceholder)
|
||||
if (labelName != null && !useLabelAsPlaceholder)
|
||||
{
|
||||
ContentView.AddConstraint(
|
||||
NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Bottom, 1f, 10f));
|
||||
@@ -64,7 +64,7 @@ namespace Bit.iOS.Core.Views
|
||||
NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1f, 10f));
|
||||
}
|
||||
|
||||
if(height.HasValue)
|
||||
if (height.HasValue)
|
||||
{
|
||||
ContentView.AddConstraint(
|
||||
NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, height.Value));
|
||||
@@ -83,12 +83,12 @@ namespace Bit.iOS.Core.Views
|
||||
BackgroundColor = ThemeHelpers.BackgroundColor
|
||||
};
|
||||
|
||||
if(!ThemeHelpers.LightTheme)
|
||||
if (!ThemeHelpers.LightTheme)
|
||||
{
|
||||
TextField.KeyboardAppearance = UIKeyboardAppearance.Dark;
|
||||
}
|
||||
|
||||
if(useLabelAsPlaceholder)
|
||||
if (useLabelAsPlaceholder)
|
||||
{
|
||||
TextField.Placeholder = labelName;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ namespace Bit.iOS.Core.Views
|
||||
NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, TextField, NSLayoutAttribute.Bottom, 1f, 10f)
|
||||
});
|
||||
|
||||
if(labelName != null && !useLabelAsPlaceholder)
|
||||
if (labelName != null && !useLabelAsPlaceholder)
|
||||
{
|
||||
ContentView.AddConstraint(
|
||||
NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Top, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Bottom, 1f, 10f));
|
||||
@@ -111,14 +111,14 @@ namespace Bit.iOS.Core.Views
|
||||
NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Top, 1f, 10f));
|
||||
}
|
||||
|
||||
if(height.HasValue)
|
||||
if (height.HasValue)
|
||||
{
|
||||
ContentView.AddConstraint(
|
||||
NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, height.Value));
|
||||
}
|
||||
}
|
||||
|
||||
if(labelName != null && !useLabelAsPlaceholder)
|
||||
if (labelName != null && !useLabelAsPlaceholder)
|
||||
{
|
||||
ContentView.AddConstraints(new NSLayoutConstraint[] {
|
||||
NSLayoutConstraint.Create(Label, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContentView, NSLayoutAttribute.Leading, 1f, 15f),
|
||||
@@ -134,11 +134,11 @@ namespace Bit.iOS.Core.Views
|
||||
|
||||
public void Select()
|
||||
{
|
||||
if(TextView != null)
|
||||
if (TextView != null)
|
||||
{
|
||||
TextView.BecomeFirstResponder();
|
||||
}
|
||||
else if(TextField != null)
|
||||
else if (TextField != null)
|
||||
{
|
||||
TextField.BecomeFirstResponder();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Bit.iOS.Core.Views
|
||||
BackgroundColor = ThemeHelpers.BackgroundColor
|
||||
};
|
||||
|
||||
if(!ThemeHelpers.LightTheme)
|
||||
if (!ThemeHelpers.LightTheme)
|
||||
{
|
||||
TextField.KeyboardAppearance = UIKeyboardAppearance.Dark;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ namespace Bit.iOS.Core.Views
|
||||
var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, (o, a) =>
|
||||
{
|
||||
var s = (PickerSource)Picker.Model;
|
||||
if(s.SelectedIndex == -1 && Items != null && Items.Count > 0)
|
||||
if (s.SelectedIndex == -1 && Items != null && Items.Count > 0)
|
||||
{
|
||||
UpdatePickerSelectedIndex(0);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace Bit.iOS.Core.Views
|
||||
NSLayoutConstraint.Create(ContentView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, Label, NSLayoutAttribute.Trailing, 1f, 15f)
|
||||
});
|
||||
|
||||
if(height.HasValue)
|
||||
if (height.HasValue)
|
||||
{
|
||||
ContentView.AddConstraint(
|
||||
NSLayoutConstraint.Create(TextField, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, height.Value));
|
||||
@@ -120,7 +120,7 @@ namespace Bit.iOS.Core.Views
|
||||
{
|
||||
TextField.Text = SelectedIndex == -1 || Items == null ? "" : Items[SelectedIndex];
|
||||
Picker.ReloadAllComponents();
|
||||
if(Items == null || Items.Count == 0)
|
||||
if (Items == null || Items.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -187,7 +187,7 @@ namespace Bit.iOS.Core.Views
|
||||
|
||||
public override void Selected(UIPickerView picker, nint row, nint component)
|
||||
{
|
||||
if(_cell.Items.Count == 0)
|
||||
if (_cell.Items.Count == 0)
|
||||
{
|
||||
SelectedItem = null;
|
||||
SelectedIndex = -1;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Bit.iOS.Core.Views
|
||||
|
||||
Value = newValue;
|
||||
|
||||
if(valueChanged)
|
||||
if (valueChanged)
|
||||
{
|
||||
ValueChanged?.Invoke(this, null);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Bit.iOS.Core.Views
|
||||
{
|
||||
TextLabel.Text = labelName;
|
||||
TextLabel.TextColor = ThemeHelpers.TextColor;
|
||||
if(!ThemeHelpers.LightTheme)
|
||||
if (!ThemeHelpers.LightTheme)
|
||||
{
|
||||
Switch.TintColor = ThemeHelpers.MutedColor;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Bit.iOS.Core.Views
|
||||
var bgColor = UIColor.DarkGray;
|
||||
var nordTheme = Application.Current?.Resources != null &&
|
||||
((Color)Application.Current.Resources["BackgroundColor"]) == Color.FromHex("#3b4252");
|
||||
if(nordTheme)
|
||||
if (nordTheme)
|
||||
{
|
||||
bgColor = Color.FromHex("#4c566a").ToUIColor();
|
||||
}
|
||||
@@ -70,7 +70,7 @@ namespace Bit.iOS.Core.Views
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if(Superview != null)
|
||||
if (Superview != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ namespace Bit.iOS.Core.Views
|
||||
LayoutIfNeeded();
|
||||
|
||||
var localSuperView = UIApplication.SharedApplication.KeyWindow;
|
||||
if(localSuperView != null)
|
||||
if (localSuperView != null)
|
||||
{
|
||||
localSuperView.AddSubview(this);
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Bit.iOS.Core.Views
|
||||
|
||||
public void Dismiss(bool animated = true)
|
||||
{
|
||||
if(Dismissed)
|
||||
if (Dismissed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ namespace Bit.iOS.Core.Views
|
||||
_dismissTimer?.Invalidate();
|
||||
_dismissTimer = null;
|
||||
|
||||
if(!animated)
|
||||
if (!animated)
|
||||
{
|
||||
RemoveFromSuperview();
|
||||
DismissCallback?.Invoke();
|
||||
|
||||
Reference in New Issue
Block a user