bootstrap

This commit is contained in:
Kyle Spearrin 2019-04-18 12:31:35 -04:00
parent fff32e8086
commit e141991166
2 changed files with 17 additions and 1 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Threading.Tasks;
using Android.App;
using Android.Runtime;
using Bit.App.Abstractions;
@ -32,10 +33,11 @@ namespace Bit.Droid
public override void OnCreate()
{
base.OnCreate();
Bootstrap();
Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this);
}
public void RegisterLocalServices()
private void RegisterLocalServices()
{
var preferencesStorage = new PreferencesStorageService(null);
var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
@ -58,5 +60,18 @@ namespace Bit.Droid
ServiceContainer.Register<IDeviceActionService>("deviceActionService", deviceActionService);
ServiceContainer.Register<IPlatformUtilsService>("platformUtilsService", platformUtilsService);
}
private void Bootstrap()
{
(ServiceContainer.Resolve<II18nService>("i18nService") as MobileI18nService).Init();
ServiceContainer.Resolve<IAuthService>("authService").Init();
// Note: This is not awaited
var bootstrapTask = BootstrapAsync();
}
private async Task BootstrapAsync()
{
await ServiceContainer.Resolve<IEnvironmentService>("environmentService").SetUrlsFromStorageAsync();
}
}
}

View file

@ -19,5 +19,6 @@ namespace Bit.Core.Abstractions
Task<AuthResult> LogInCompleteAsync(string email, string masterPassword, TwoFactorProviderType twoFactorProvider, string twoFactorToken, bool? remember = null);
Task<AuthResult> LogInTwoFactorAsync(TwoFactorProviderType twoFactorProvider, string twoFactorToken, bool? remember = null);
void LogOut(Action callback);
void Init();
}
}