autofill not enabled prompt if migrated

This commit is contained in:
Kyle Spearrin 2019-06-04 10:51:10 -04:00
parent f856e559a2
commit 0a664c47b7
5 changed files with 38 additions and 3 deletions

View file

@ -183,6 +183,7 @@ namespace Bit.App.Migration
// Remove "needs migration" flag
settingsShim.Remove(Constants.OldUserIdKey);
await storageService.SaveAsync(Constants.MigratedFromV1, true);
Migrating = false;
messagingService.Send("migrated");
if(Xamarin.Essentials.Connectivity.NetworkAccess != Xamarin.Essentials.NetworkAccess.None)

View file

@ -17,6 +17,7 @@ namespace Bit.App.Pages
private readonly IPushNotificationService _pushNotificationService;
private readonly IStorageService _storageService;
private readonly ILockService _lockService;
private readonly IDeviceActionService _deviceActionService;
private readonly GroupingsPageViewModel _vm;
private readonly string _pageName;
@ -31,6 +32,7 @@ namespace Bit.App.Pages
_pushNotificationService = ServiceContainer.Resolve<IPushNotificationService>("pushNotificationService");
_storageService = ServiceContainer.Resolve<IStorageService>("storageService");
_lockService = ServiceContainer.Resolve<ILockService>("lockService");
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
_vm = BindingContext as GroupingsPageViewModel;
_vm.Page = this;
_vm.MainPage = mainPage;
@ -104,11 +106,29 @@ namespace Bit.App.Pages
await _pushNotificationService.RegisterAsync();
}
}
else if(Device.RuntimePlatform == Device.Android &&
DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1))
else if(Device.RuntimePlatform == Device.Android)
{
if(DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1))
{
await _pushNotificationService.RegisterAsync();
}
if(!_deviceActionService.AutofillAccessibilityServiceRunning()
&& !_deviceActionService.AutofillServiceEnabled())
{
var migratedFromV1 = await _storageService.GetAsync<bool?>(Constants.MigratedFromV1);
if(migratedFromV1.GetValueOrDefault())
{
var migratedFromV1AutofillPromptShown = await _storageService.GetAsync<bool?>(
Constants.MigratedFromV1AutofillPromptShown);
if(!migratedFromV1AutofillPromptShown.GetValueOrDefault())
{
await DisplayAlert(AppResources.Autofill,
AppResources.AutofillServiceNotEnabled, AppResources.Ok);
}
}
}
await _storageService.SaveAsync(Constants.MigratedFromV1AutofillPromptShown, true);
}
}
protected override void OnDisappearing()

View file

@ -420,6 +420,15 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Auto-fill makes it easy to securely access your Bitwarden vault from other websites and apps. It looks like you have not enabled an auto-fill service for Bitwarden. Enable auto-fill for Bitwarden from the &quot;Settings&quot; screen..
/// </summary>
public static string AutofillServiceNotEnabled {
get {
return ResourceManager.GetString("AutofillServiceNotEnabled", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Your logins are now easily accessible right from your keyboard while logging into apps and websites..
/// </summary>

View file

@ -1553,4 +1553,7 @@
<data name="LockOptionOnRestart" xml:space="preserve">
<value>On App Restart</value>
</data>
<data name="AutofillServiceNotEnabled" xml:space="preserve">
<value>Auto-fill makes it easy to securely access your Bitwarden vault from other websites and apps. It looks like you have not enabled an auto-fill service for Bitwarden. Enable auto-fill for Bitwarden from the "Settings" screen.</value>
</data>
</root>

View file

@ -28,6 +28,8 @@
public static string LastBuildKey = "lastBuild";
public static string OldUserIdKey = "userId";
public static string AddSitePromptShownKey = "addSitePromptShown";
public static string MigratedFromV1 = "migratedFromV1";
public static string MigratedFromV1AutofillPromptShown = "migratedV1AutofillPromptShown";
public const int SelectFileRequestCode = 42;
public const int SelectFilePermissionRequestCode = 43;
}