2016-05-02 09:52:09 +03:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using Android.App;
|
|
|
|
|
using Android.Content.PM;
|
|
|
|
|
using Android.Runtime;
|
|
|
|
|
using Android.Views;
|
|
|
|
|
using Android.Widget;
|
|
|
|
|
using Android.OS;
|
|
|
|
|
using Microsoft.Practices.Unity;
|
|
|
|
|
using Bit.App.Abstractions;
|
|
|
|
|
using Bit.App.Services;
|
|
|
|
|
using XLabs.Ioc.Unity;
|
|
|
|
|
using XLabs.Ioc;
|
|
|
|
|
using Bit.Android.Services;
|
2016-05-03 00:50:16 +03:00
|
|
|
|
using Plugin.Settings;
|
2016-05-03 09:08:50 +03:00
|
|
|
|
using Plugin.Connectivity;
|
|
|
|
|
using Acr.UserDialogs;
|
2016-05-06 07:17:38 +03:00
|
|
|
|
using Bit.App.Repositories;
|
2016-05-02 09:52:09 +03:00
|
|
|
|
|
|
|
|
|
namespace Bit.Android
|
|
|
|
|
{
|
|
|
|
|
[Activity(Label = "bitwarden", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
|
|
|
|
|
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
|
|
|
|
|
{
|
|
|
|
|
protected override void OnCreate(Bundle bundle)
|
|
|
|
|
{
|
|
|
|
|
base.OnCreate(bundle);
|
|
|
|
|
|
|
|
|
|
global::Xamarin.Forms.Forms.Init(this, bundle);
|
|
|
|
|
|
|
|
|
|
if(!Resolver.IsSet)
|
|
|
|
|
{
|
|
|
|
|
SetIoc();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LoadApplication(new App.App(Resolver.Resolve<IAuthService>(), Resolver.Resolve<IDatabaseService>()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetIoc()
|
|
|
|
|
{
|
|
|
|
|
var container = new UnityContainer();
|
|
|
|
|
|
|
|
|
|
container
|
2016-05-06 07:17:38 +03:00
|
|
|
|
// Services
|
2016-05-02 09:52:09 +03:00
|
|
|
|
.RegisterType<IDatabaseService, DatabaseService>(new ContainerControlledLifetimeManager())
|
2016-05-06 07:17:38 +03:00
|
|
|
|
.RegisterType<ISqlService, SqlService>(new ContainerControlledLifetimeManager())
|
2016-05-02 09:52:09 +03:00
|
|
|
|
.RegisterType<ISecureStorageService, KeyStoreStorageService>(new ContainerControlledLifetimeManager())
|
|
|
|
|
.RegisterType<ICryptoService, CryptoService>(new ContainerControlledLifetimeManager())
|
|
|
|
|
.RegisterType<IAuthService, AuthService>(new ContainerControlledLifetimeManager())
|
|
|
|
|
.RegisterType<IFolderService, FolderService>(new ContainerControlledLifetimeManager())
|
2016-05-03 09:08:50 +03:00
|
|
|
|
.RegisterType<ISiteService, SiteService>(new ContainerControlledLifetimeManager())
|
2016-05-06 07:17:38 +03:00
|
|
|
|
.RegisterType<ISyncService, SyncService>(new ContainerControlledLifetimeManager())
|
|
|
|
|
// Repositories
|
|
|
|
|
.RegisterType<IFolderRepository, FolderRepository>(new ContainerControlledLifetimeManager())
|
|
|
|
|
.RegisterType<IFolderApiRepository, FolderApiRepository>(new ContainerControlledLifetimeManager())
|
|
|
|
|
.RegisterType<ISiteRepository, SiteRepository>(new ContainerControlledLifetimeManager())
|
|
|
|
|
.RegisterType<ISiteApiRepository, SiteApiRepository>(new ContainerControlledLifetimeManager())
|
|
|
|
|
.RegisterType<IAuthApiRepository, AuthApiRepository>(new ContainerControlledLifetimeManager())
|
|
|
|
|
// Other
|
|
|
|
|
.RegisterInstance(CrossSettings.Current, new ContainerControlledLifetimeManager())
|
2016-05-03 09:08:50 +03:00
|
|
|
|
.RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager())
|
|
|
|
|
.RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager());
|
2016-05-02 09:52:09 +03:00
|
|
|
|
|
|
|
|
|
Resolver.SetResolver(new UnityResolver(container));
|
2016-05-03 09:08:50 +03:00
|
|
|
|
|
|
|
|
|
UserDialogs.Init(this);
|
2016-05-02 09:52:09 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|