Settings plusin doesn't support string null values for default on android. ref https://github.com/jamesmontemagno/SettingsPlugin/issues/8

This commit is contained in:
Kyle Spearrin 2016-08-29 23:06:29 -04:00
parent c7e81ed69f
commit ee883571da
7 changed files with 33 additions and 18 deletions

View file

@ -61,7 +61,7 @@ namespace Bit.App.Pages
entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope",
containerPadding: padding);
var lastLoginEmail = _settings.GetValueOrDefault<string>(Constants.LastLoginEmail);
var lastLoginEmail = _settings.GetValueOrDefault(Constants.LastLoginEmail, string.Empty);
if(!string.IsNullOrWhiteSpace(_email))
{
EmailCell.Entry.Text = _email;

View file

@ -44,7 +44,7 @@ namespace Bit.App.Pages
PinCell = new ExtendedSwitchCell
{
Text = "Unlock with PIN Code",
On = _settings.GetValueOrDefault<bool>(Constants.SettingPinUnlockOn)
On = _settings.GetValueOrDefault(Constants.SettingPinUnlockOn, false)
};
PinCell.OnChanged += PinCell_Changed;
@ -76,7 +76,7 @@ namespace Bit.App.Pages
FingerprintCell = new ExtendedSwitchCell
{
Text = "Unlock with " + fingerprintName,
On = _settings.GetValueOrDefault<bool>(Constants.SettingFingerprintUnlockOn),
On = _settings.GetValueOrDefault(Constants.SettingFingerprintUnlockOn, false),
IsEnabled = _fingerprint.IsAvailable
};
FingerprintCell.OnChanged += FingerprintCell_Changed;

View file

@ -72,7 +72,7 @@ namespace Bit.App.Pages
private void SetLastSync()
{
var lastSyncDate = _settings.GetValueOrDefault<DateTime?>(Constants.LastSync);
var lastSyncDate = _settings.GetValueOrDefault<DateTime?>(Constants.LastSync, null);
try
{
LastSyncLabel.Text = "Last Sync: " + lastSyncDate?.ToLocalTime().ToString() ?? "Never";

View file

@ -224,10 +224,10 @@ namespace Bit.App.Pages
if(_connectivity.IsConnected && Device.OS == TargetPlatform.iOS && !_favorites)
{
var pushPromptShow = _settings.GetValueOrDefault<bool>(Constants.PushInitialPromptShown);
var pushPromptShow = _settings.GetValueOrDefault(Constants.PushInitialPromptShown, false);
Action registerAction = () =>
{
var lastPushRegistration = _settings.GetValueOrDefault<DateTime?>(Constants.PushLastRegistrationDate);
var lastPushRegistration = _settings.GetValueOrDefault<DateTime?>(Constants.PushLastRegistrationDate, null);
if(!pushPromptShow || !lastPushRegistration.HasValue
|| (DateTime.UtcNow - lastPushRegistration) > TimeSpan.FromDays(1))
{

View file

@ -76,12 +76,17 @@ namespace Bit.App.Services
{
get
{
if(_userId != null)
if(!string.IsNullOrWhiteSpace(_userId))
{
return _userId;
}
_userId = _settings.GetValueOrDefault<string>(UserIdKey);
var userId = _settings.GetValueOrDefault(UserIdKey, string.Empty);
if(!string.IsNullOrWhiteSpace(userId))
{
_userId = userId;
}
return _userId;
}
set
@ -104,12 +109,17 @@ namespace Bit.App.Services
{
get
{
if(_previousUserId != null)
if(!string.IsNullOrWhiteSpace(_previousUserId))
{
return _previousUserId;
}
_previousUserId = _settings.GetValueOrDefault<string>(PreviousUserIdKey);
var previousUserId = _settings.GetValueOrDefault(PreviousUserIdKey, string.Empty);
if(!string.IsNullOrWhiteSpace(previousUserId))
{
_previousUserId = previousUserId;
}
return _previousUserId;
}
private set
@ -128,12 +138,17 @@ namespace Bit.App.Services
{
get
{
if(_email != null)
if(!string.IsNullOrWhiteSpace(_email))
{
return _email;
}
_email = _settings.GetValueOrDefault<string>(EmailKey);
var email = _settings.GetValueOrDefault(EmailKey, string.Empty);
if(!string.IsNullOrWhiteSpace(email))
{
_email = email;
}
return _email;
}
set
@ -155,14 +170,14 @@ namespace Bit.App.Services
{
get
{
return _cryptoService.Key != null && Token != null && UserId != null;
return _cryptoService.Key != null && !string.IsNullOrWhiteSpace(Token) && !string.IsNullOrWhiteSpace(UserId);
}
}
public bool IsAuthenticatedTwoFactor
{
get
{
return _cryptoService.Key != null && Token != null && UserId == null;
return _cryptoService.Key != null && !string.IsNullOrWhiteSpace(Token) && string.IsNullOrWhiteSpace(UserId);
}
}

View file

@ -50,8 +50,8 @@ namespace Bit.App.Services
}
// What method are we using to unlock?
var fingerprintUnlock = _settings.GetValueOrDefault<bool>(Constants.SettingFingerprintUnlockOn);
var pinUnlock = _settings.GetValueOrDefault<bool>(Constants.SettingPinUnlockOn);
var fingerprintUnlock = _settings.GetValueOrDefault(Constants.SettingFingerprintUnlockOn, false);
var pinUnlock = _settings.GetValueOrDefault(Constants.SettingPinUnlockOn, false);
if(fingerprintUnlock && _fingerprint.IsAvailable)
{
return LockType.Fingerprint;

View file

@ -170,7 +170,7 @@ namespace Bit.App.Services
public async Task<bool> IncrementalSyncAsync(TimeSpan syncThreshold)
{
DateTime? lastSync = _settings.GetValueOrDefault<DateTime?>(Constants.LastSync);
DateTime? lastSync = _settings.GetValueOrDefault<DateTime?>(Constants.LastSync, null);
if(lastSync != null && DateTime.UtcNow - lastSync.Value < syncThreshold)
{
return false;
@ -187,7 +187,7 @@ namespace Bit.App.Services
}
var now = DateTime.UtcNow;
DateTime? lastSync = _settings.GetValueOrDefault<DateTime?>(Constants.LastSync);
DateTime? lastSync = _settings.GetValueOrDefault<DateTime?>(Constants.LastSync, null);
if(lastSync == null)
{
return await FullSyncAsync().ConfigureAwait(false);