Example #1
0
        public AppServices(ITogglApi api, ITogglDatabase database)
        {
            Scheduler   = System.Reactive.Concurrency.Scheduler.Default;
            TimeService = new TimeService(Scheduler);

            var errorHandlingService = new ErrorHandlingService(NavigationServiceSubstitute, AccessRestrictionStorageSubsitute);

            syncErrorHandlingService = new SyncErrorHandlingService(errorHandlingService);

            var dataSource = new TogglDataSource(
                database,
                TimeService,
                AnalyticsServiceSubstitute);

            SyncManager = TogglSyncManager.CreateSyncManager(
                database,
                api,
                dataSource,
                TimeService,
                AnalyticsServiceSubstitute,
                LastTimeUsageStorageSubstitute,
                Scheduler,
                AutomaticSyncingService);

            syncErrorHandlingService.HandleErrorsOf(SyncManager);
        }
Example #2
0
        public AppServices(ITogglApi api, ITogglDatabase database)
        {
            Scheduler   = System.Reactive.Concurrency.Scheduler.Default;
            TimeService = new TimeService(Scheduler);

            var errorHandlingService = new ErrorHandlingService(NavigationServiceSubstitute, AccessRestrictionStorageSubsitute);

            syncErrorHandlingService = new SyncErrorHandlingService(errorHandlingService);

            ISyncManager createSyncManager(ITogglDataSource dataSource)
            {
                var syncManager = TogglSyncManager.CreateSyncManager(
                    database,
                    api,
                    dataSource,
                    TimeService,
                    AnalyticsServiceSubstitute,
                    LastTimeUsageStorageSubstitute,
                    Scheduler,
                    StopwatchProvider);

                syncErrorHandlingService.HandleErrorsOf(syncManager);

                return(syncManager);
            }

            var togglDataSource = new TogglDataSource(
                api,
                database,
                TimeService,
                createSyncManager,
                AnalyticsServiceSubstitute);

            SyncManager = togglDataSource.SyncManager;
        }
        public static void Initialize(this MvvmCrossFoundation foundation)
        {
            initializeInversionOfControl(foundation);

            Func <ITogglDataSource, ISyncManager> createSyncManager(ITogglApi api) => dataSource =>
            TogglSyncManager.CreateSyncManager(foundation.Database, api, dataSource, foundation.TimeService, foundation.AnalyticsService, foundation.LastTimeUsageStorage, retryDelayLimit, foundation.Scheduler);

            ITogglDataSource createDataSource(ITogglApi api)
            {
                var dataSource = new TogglDataSource(
                    api,
                    foundation.Database,
                    foundation.TimeService,
                    foundation.ErrorHandlingService,
                    foundation.BackgroundService,
                    createSyncManager(api),
                    TimeSpan.FromMinutes(5),
                    foundation.NotificationService,
                    foundation.ShortcutCreator,
                    foundation.AnalyticsService)
                                 .RegisterServices();

                Mvx.ConstructAndRegisterSingleton <IInteractorFactory, InteractorFactory>();
                Mvx.ConstructAndRegisterSingleton <IAutocompleteProvider, AutocompleteProvider>();

                return(dataSource);
            }

            var loginManager =
                new LoginManager(foundation.ApiFactory, foundation.Database, foundation.GoogleService, foundation.ShortcutCreator, foundation.AccessRestrictionStorage, foundation.AnalyticsService, foundation.PrivateSharedStorageService, createDataSource, foundation.Scheduler);

            Mvx.RegisterSingleton <ILoginManager>(loginManager);
        }
Example #4
0
 public TogglDataSourceTest()
 {
     SyncManager.ProgressObservable.Returns(ProgressSubject.AsObservable());
     DataSource = new TogglDataSource(
         Database,
         TimeService,
         AnalyticsService);
 }
Example #5
0
 public TogglDataSourceTest()
 {
     SyncManager.ProgressObservable.Returns(ProgressSubject.AsObservable());
     DataSource = new TogglDataSource(
         Api,
         Database,
         TimeService,
         _ => SyncManager,
         NotificationService,
         ApplicationShortcutCreator,
         AnalyticsService);
 }
Example #6
0
 public TogglDataSourceTest()
 {
     SyncManager.ProgressObservable.Returns(ProgressSubject.AsObservable());
     DataSource = new TogglDataSource(
         Api,
         Database,
         TimeService,
         ErrorHandlingService,
         BackgroundService,
         _ => SyncManager,
         MinimumTimeInBackgroundForFullSync,
         ApplicationShortcutCreator,
         AnalyticsService);
 }
Example #7
0
        public static void Initialize(this MvvmCrossFoundation foundation)
        {
            initializeInversionOfControl(foundation);

            Func <ITogglDataSource, ISyncManager> createSyncManager(ITogglApi api) => dataSource =>
            TogglSyncManager.CreateSyncManager(
                foundation.Database,
                api,
                dataSource,
                foundation.TimeService,
                foundation.AnalyticsService,
                foundation.LastTimeUsageStorage,
                foundation.Scheduler,
                foundation.StopwatchProvider);

            ITogglDataSource createDataSource(ITogglApi api)
            {
                var dataSource = new TogglDataSource(
                    api,
                    foundation.Database,
                    foundation.TimeService,
                    createSyncManager(api),
                    foundation.AnalyticsService)
                                 .RegisterServices();

                Mvx.RegisterSingleton <ITogglApi>(api);
                Mvx.ConstructAndRegisterSingleton <IInteractorFactory, InteractorFactory>();
                Mvx.ConstructAndRegisterSingleton <IAutocompleteProvider, AutocompleteProvider>();

                foundation.SyncErrorHandlingService.HandleErrorsOf(dataSource.SyncManager);

                return(dataSource);
            }

            var userAccessManager =
                new UserAccessManager(foundation.ApiFactory, foundation.Database, foundation.GoogleService, foundation.ShortcutCreator, foundation.PrivateSharedStorageService, createDataSource);

            Mvx.RegisterSingleton <IUserAccessManager>(userAccessManager);

            foundation.BackgroundSyncService.SetupBackgroundSync(userAccessManager);
            foundation.AutomaticSyncingService.SetupAutomaticSync(userAccessManager);
        }
Example #8
0
        public static void Initialize(this FoundationMvvmCross self, App app, IScheduler scheduler)
        {
            Func <ITogglDataSource, ISyncManager> createSyncManager(ITogglApi api) => dataSource =>
            TogglSyncManager.CreateSyncManager(self.Database, api, dataSource, self.TimeService, self.AnalyticsService, retryDelayLimit, scheduler);

            ITogglDataSource createDataSource(ITogglApi api)
            {
                var dataSource = new TogglDataSource(api, self.Database, self.TimeService, self.ApiErrorHandlingService, self.BackgroundService, createSyncManager(api), TimeSpan.FromMinutes(5), self.ShortcutCreator)
                                 .RegisterServices();

                Mvx.ConstructAndRegisterSingleton <IInteractorFactory, InteractorFactory>();

                return(dataSource);
            }

            var loginManager =
                new LoginManager(self.ApiFactory, self.Database, self.GoogleService, self.ShortcutCreator, self.AccessRestrictionStorage, createDataSource);

            Mvx.RegisterSingleton <ILoginManager>(loginManager);

            app.Initialize(loginManager, self.NavigationService, self.AccessRestrictionStorage);
        }
Example #9
0
        public AppServices(ITogglApi api, ITogglDatabase database)
        {
            TogglApi    = api;
            Scheduler   = System.Reactive.Concurrency.Scheduler.Default;
            TimeService = new TimeService(Scheduler);

            var errorHandlingService = new ErrorHandlingService(NavigationServiceSubstitute, AccessRestrictionStorageSubsitute);

            syncErrorHandlingService = new SyncErrorHandlingService(errorHandlingService);

            var dataSource = new TogglDataSource(
                database,
                TimeService,
                AnalyticsServiceSubstitute);

            var dependencyContainer = new TestDependencyContainer();

            dependencyContainer.MockKeyValueStorage = KeyValueStorage;
            dependencyContainer.MockPushNotificationsTokenService = PushNotificationsTokenService;
            dependencyContainer.MockTimeService = TimeService;
            dependencyContainer.MockPushNotificationsTokenStorage = PushNotificationsTokenStorage;
            dependencyContainer.MockRemoteConfigService           = RemoteConfigService;

            SyncManager = TogglSyncManager.CreateSyncManager(
                database,
                api,
                dataSource,
                TimeService,
                AnalyticsServiceSubstitute,
                LastTimeUsageStorageSubstitute,
                Scheduler,
                AutomaticSyncingService,
                dependencyContainer);

            syncErrorHandlingService.HandleErrorsOf(SyncManager);
        }
Example #10
0
        protected override void InitializeApp(IMvxPluginManager pluginManager, IMvxApplication app)
        {
#if !USE_PRODUCTION_API
            System.Net.ServicePointManager.ServerCertificateValidationCallback
                += (sender, certificate, chain, sslPolicyErrors) => true;
#endif

            const string clientName = "Daneel";
            const string remoteConfigDefaultsFileName = "RemoteConfigDefaults";
            var          version     = NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"].ToString();
            var          database    = new Database();
            var          scheduler   = Scheduler.Default;
            var          timeService = new TimeService(scheduler);
            var          topViewControllerProvider = (ITopViewControllerProvider)Presenter;
            var          dialogService             = new DialogServiceIos(topViewControllerProvider);
            var          platformInfo = new PlatformInfoIos();
            var          suggestionProviderContainer = new SuggestionProviderContainer(
                new MostUsedTimeEntrySuggestionProvider(database, timeService, maxNumberOfSuggestions)
                );
            var intentDonationService       = new IntentDonationServiceIos(analyticsService);
            var privateSharedStorageService = new PrivateSharedStorageServiceIos();

            var appVersion          = Version.Parse(version);
            var keyValueStorage     = new UserDefaultsStorageIos();
            var permissionsService  = new PermissionsServiceIos();
            var userAgent           = new UserAgent(clientName, version);
            var settingsStorage     = new SettingsStorage(Version.Parse(version), keyValueStorage);
            var remoteConfigService = new RemoteConfigServiceIos();
            remoteConfigService.SetupDefaults(remoteConfigDefaultsFileName);
            var schedulerProvider       = new IOSSchedulerProvider();
            var calendarService         = new CalendarServiceIos(permissionsService);
            var notificationService     = new NotificationServiceIos(permissionsService, timeService);
            var backgroundSyncService   = new BackgroundSyncServiceIos();
            var backgroundService       = new BackgroundService(timeService, analyticsService);
            var automaticSyncingService = new AutomaticSyncingService(backgroundService, timeService);
            var errorHandlingService    = new ErrorHandlingService(navigationService, settingsStorage);

            var dataSource =
                new TogglDataSource(
                    database,
                    timeService,
                    analyticsService);

            var foundation =
                TogglFoundation
                .ForClient(userAgent, appVersion)
                .WithDataSource(dataSource)
                .WithDatabase(database)
                .WithScheduler(scheduler)
                .WithTimeService(timeService)
                .WithApiEnvironment(environment)
                .WithGoogleService <GoogleServiceIos>()
                .WithRatingService <RatingServiceIos>()
                .WithLicenseProvider <LicenseProviderIos>()
                .WithAnalyticsService(analyticsService)
                .WithSchedulerProvider(schedulerProvider)
                .WithRemoteConfigService(remoteConfigService)
                .WithNotificationService(notificationService)
                .WithApiFactory(new ApiFactory(environment, userAgent))
                .WithBackgroundService(backgroundService)
                .WithAutomaticSyncingService(automaticSyncingService)
                .WithApplicationShortcutCreator(new ApplicationShortcutCreator())
                .WithSuggestionProviderContainer(suggestionProviderContainer)
                .WithIntentDonationService(intentDonationService)
                .WithStopwatchProvider <FirebaseStopwatchProviderIos>()
                .WithPrivateSharedStorageService(privateSharedStorageService)
                .WithPlatformInfo(platformInfo)
                .WithBackgroundSyncService(backgroundSyncService)

                .StartRegisteringPlatformServices()
                .WithDialogService(dialogService)
                .WithLastTimeUsageStorage(settingsStorage)
                .WithBrowserService <BrowserServiceIos>()
                .WithKeyValueStorage(keyValueStorage)
                .WithUserPreferences(settingsStorage)
                .WithCalendarService(calendarService)
                .WithOnboardingStorage(settingsStorage)
                .WithNavigationService(navigationService)
                .WithPermissionsService(permissionsService)
                .WithAccessRestrictionStorage(settingsStorage)
                .WithPasswordManagerService <OnePasswordServiceIos>()
                .WithErrorHandlingService(errorHandlingService)
                .WithSyncErrorHandlingService(new SyncErrorHandlingService(errorHandlingService))
                .WithRxActionFactory(new RxActionFactory(schedulerProvider))
                .Build();

            foundation.RevokeNewUserIfNeeded().Initialize();

            base.InitializeApp(pluginManager, app);
        }
 public TogglDataSourceTest()
 {
     DataSource = new TogglDataSource(Database, Api, TimeService, Scheduler);
 }
Example #12
0
        protected override void InitializeApp(IMvxPluginManager pluginManager, IMvxApplication app)
        {
            const string clientName                  = "Giskard";
            var          packageInfo                 = ApplicationContext.PackageManager.GetPackageInfo(ApplicationContext.PackageName, 0);
            var          version                     = packageInfo.VersionName;
            var          sharedPreferences           = ApplicationContext.GetSharedPreferences(clientName, FileCreationMode.Private);
            var          database                    = new Database();
            var          scheduler                   = Scheduler.Default;
            var          timeService                 = new TimeService(scheduler);
            var          backgroundService           = new BackgroundService(timeService, analyticsService);
            var          suggestionProviderContainer = new SuggestionProviderContainer(
                new MostUsedTimeEntrySuggestionProvider(database, timeService, maxNumberOfSuggestions)
                );

            var appVersion              = Version.Parse(version);
            var userAgent               = new UserAgent(clientName, version);
            var dialogService           = new DialogServiceAndroid();
            var platformInfo            = new PlatformInfoAndroid();
            var keyValueStorage         = new SharedPreferencesStorageAndroid(sharedPreferences);
            var settingsStorage         = new SettingsStorage(appVersion, keyValueStorage);
            var schedulerProvider       = new AndroidSchedulerProvider();
            var permissionsService      = new PermissionsServiceAndroid();
            var calendarService         = new CalendarServiceAndroid(permissionsService);
            var automaticSyncingService = new AutomaticSyncingService(backgroundService, timeService);
            var errorHandlingService    = new ErrorHandlingService(navigationService, settingsStorage);

            ApplicationContext.RegisterReceiver(new TimezoneChangedBroadcastReceiver(timeService),
                                                new IntentFilter(Intent.ActionTimezoneChanged));

            var dataSource =
                new TogglDataSource(
                    database,
                    timeService,
                    analyticsService);

            var foundation =
                TogglFoundation
                .ForClient(userAgent, appVersion)
                .WithDatabase(database)
                .WithDataSource(dataSource)
                .WithScheduler(scheduler)
                .WithTimeService(timeService)
                .WithApiEnvironment(environment)
                .WithGoogleService <GoogleServiceAndroid>()
                .WithRatingService(new RatingServiceAndroid(ApplicationContext))
                .WithLicenseProvider <LicenseProviderAndroid>()
                .WithAnalyticsService(analyticsService)
                .WithSchedulerProvider(schedulerProvider)
                .WithPlatformInfo(platformInfo)
                .WithNotificationService <NotificationServiceAndroid>()
                .WithRemoteConfigService <RemoteConfigServiceAndroid>()
                .WithApiFactory(new ApiFactory(environment, userAgent))
                .WithBackgroundService(backgroundService)
                .WithAutomaticSyncingService(automaticSyncingService)
                .WithSuggestionProviderContainer(suggestionProviderContainer)
                .WithApplicationShortcutCreator(new ApplicationShortcutCreator(ApplicationContext))
                .WithStopwatchProvider <FirebaseStopwatchProviderAndroid>()
                .WithIntentDonationService(new NoopIntentDonationServiceAndroid())
                .WithPrivateSharedStorageService(new NoopPrivateSharedStorageServiceAndroid())
                .WithBackgroundSyncService <BackgroundSyncServiceAndroid>()
                .StartRegisteringPlatformServices()
                .WithDialogService(dialogService)
                .WithLastTimeUsageStorage(settingsStorage)
                .WithBrowserService <BrowserServiceAndroid>()
                .WithCalendarService(calendarService)
                .WithKeyValueStorage(keyValueStorage)
                .WithUserPreferences(settingsStorage)
                .WithOnboardingStorage(settingsStorage)
                .WithNavigationService(navigationService)
                .WithPermissionsService(permissionsService)
                .WithAccessRestrictionStorage(settingsStorage)
                .WithErrorHandlingService(errorHandlingService)
                .WithSyncErrorHandlingService(new SyncErrorHandlingService(errorHandlingService))
                .WithRxActionFactory(new RxActionFactory(schedulerProvider))
                .Build();

            foundation.RevokeNewUserIfNeeded().Initialize();

            ensureDataSourceInitializationIfLoggedIn();
            createApplicationLifecycleObserver(backgroundService);

            base.InitializeApp(pluginManager, app);
        }
Example #13
0
 public TogglDataSourceTest()
 {
     DataSource = new TogglDataSource(Database, Api);
 }