Пример #1
0
        public ReportsCalendarViewModel(
            ITimeService timeService,
            IDialogService dialogService,
            ITogglDataSource dataSource,
            IIntentDonationService intentDonationService,
            IRxActionFactory rxActionFactory)
        {
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));

            this.timeService           = timeService;
            this.dialogService         = dialogService;
            this.dataSource            = dataSource;
            this.intentDonationService = intentDonationService;

            SelectDay      = rxActionFactory.FromAsync <ReportsCalendarDayViewModel>(calendarDayTapped);
            SelectShortcut = rxActionFactory.FromAction <ReportsCalendarBaseQuickSelectShortcut>(quickSelect);

            CurrentPageObservable = currentPageSubject.AsObservable();

            SelectedDateRangeObservable = selectedDateRangeSubject
                                          .ShareReplay(1);

            HighlightedDateRangeObservable = highlightedDateRangeSubject
                                             .ShareReplay(1);
        }
        public CreateTimeEntryInteractor(
            IIdProvider idProvider,
            ITimeService timeService,
            ITogglDataSource dataSource,
            IAnalyticsService analyticsService,
            IIntentDonationService intentDonationService,
            ITimeEntryPrototype prototype,
            DateTimeOffset startTime,
            TimeSpan?duration,
            TimeEntryStartOrigin origin)
        {
            Ensure.Argument.IsNotNull(origin, nameof(origin));
            Ensure.Argument.IsNotNull(prototype, nameof(prototype));
            Ensure.Argument.IsNotNull(idProvider, nameof(idProvider));
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));

            this.origin                = origin;
            this.duration              = duration;
            this.prototype             = prototype;
            this.startTime             = startTime;
            this.idProvider            = idProvider;
            this.dataSource            = dataSource;
            this.timeService           = timeService;
            this.analyticsService      = analyticsService;
            this.intentDonationService = intentDonationService;
        }
Пример #3
0
        public ReportsCalendarViewModel(
            ITimeService timeService,
            IDialogService dialogService,
            ITogglDataSource dataSource,
            IIntentDonationService intentDonationService,
            IRxActionFactory rxActionFactory)
        {
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));

            this.timeService           = timeService;
            this.dialogService         = dialogService;
            this.dataSource            = dataSource;
            this.intentDonationService = intentDonationService;

            SelectDay      = rxActionFactory.FromAsync <ReportsCalendarDayViewModel>(calendarDayTapped);
            SelectShortcut = rxActionFactory.FromAction <ReportsCalendarBaseQuickSelectShortcut>(quickSelect);

            CurrentPageObservable = currentPageSubject
                                    .StartWith(MonthsToShow - 1)
                                    .DistinctUntilChanged();
        }
Пример #4
0
        public LogoutInteractor(
            IAnalyticsService analyticsService,
            INotificationService notificationService,
            IApplicationShortcutCreator shortcutCreator,
            ISyncManager syncManager,
            ITogglDatabase database,
            IUserPreferences userPreferences,
            IPrivateSharedStorageService privateSharedStorageService,
            IIntentDonationService intentDonationService,
            IUserAccessManager userAccessManager,
            LogoutSource source)
        {
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(notificationService, nameof(notificationService));
            Ensure.Argument.IsNotNull(shortcutCreator, nameof(shortcutCreator));
            Ensure.Argument.IsNotNull(syncManager, nameof(syncManager));
            Ensure.Argument.IsNotNull(database, nameof(database));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(privateSharedStorageService, nameof(privateSharedStorageService));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager));
            Ensure.Argument.IsADefinedEnumValue(source, nameof(source));

            this.analyticsService            = analyticsService;
            this.shortcutCreator             = shortcutCreator;
            this.notificationService         = notificationService;
            this.syncManager                 = syncManager;
            this.database                    = database;
            this.userPreferences             = userPreferences;
            this.privateSharedStorageService = privateSharedStorageService;
            this.intentDonationService       = intentDonationService;
            this.userAccessManager           = userAccessManager;
            this.source = source;
        }
        public InteractorFactory(
            IIdProvider idProvider,
            ITimeService timeService,
            ITogglDataSource dataSource,
            ITogglApi api,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            INotificationService notificationService,
            IIntentDonationService intentDonationService,
            IApplicationShortcutCreator shortcutCreator,
            ILastTimeUsageStorage lastTimeUsageStorage,
            IPlatformInfo platformInfo,
            UserAgent userAgent,
            ICalendarService calendarService,
            ISyncManager syncManager,
            IStopwatchProvider stopwatchProvider,
            ITogglDatabase database,
            IPrivateSharedStorageService privateSharedStorageService,
            IUserAccessManager userAccessManager)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(api, nameof(api));
            Ensure.Argument.IsNotNull(idProvider, nameof(idProvider));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(shortcutCreator, nameof(shortcutCreator));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(notificationService, nameof(notificationService));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo));
            Ensure.Argument.IsNotNull(userAgent, nameof(userAgent));
            Ensure.Argument.IsNotNull(calendarService, nameof(calendarService));
            Ensure.Argument.IsNotNull(syncManager, nameof(syncManager));
            Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider));
            Ensure.Argument.IsNotNull(database, nameof(database));
            Ensure.Argument.IsNotNull(privateSharedStorageService, nameof(privateSharedStorageService));
            Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager));

            this.dataSource                  = dataSource;
            this.api                         = api;
            this.idProvider                  = idProvider;
            this.timeService                 = timeService;
            this.userPreferences             = userPreferences;
            this.shortcutCreator             = shortcutCreator;
            this.analyticsService            = analyticsService;
            this.notificationService         = notificationService;
            this.intentDonationService       = intentDonationService;
            this.lastTimeUsageStorage        = lastTimeUsageStorage;
            this.platformInfo                = platformInfo;
            this.userAgent                   = userAgent;
            this.calendarService             = calendarService;
            this.syncManager                 = syncManager;
            this.stopwatchProvider           = stopwatchProvider;
            this.database                    = database;
            this.privateSharedStorageService = privateSharedStorageService;
            this.userAccessManager           = userAccessManager;
        }
Пример #6
0
        public MainViewModel(
            ITogglDataSource dataSource,
            ITimeService timeService,
            IRatingService ratingService,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IInteractorFactory interactorFactory,
            IMvxNavigationService navigationService,
            IRemoteConfigService remoteConfigService,
            ISuggestionProviderContainer suggestionProviders,
            IIntentDonationService intentDonationService,
            IAccessRestrictionStorage accessRestrictionStorage,
            ISchedulerProvider schedulerProvider,
            IStopwatchProvider stopwatchProvider,
            IRxActionFactory rxActionFactory)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(ratingService, nameof(ratingService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider));
            Ensure.Argument.IsNotNull(remoteConfigService, nameof(remoteConfigService));
            Ensure.Argument.IsNotNull(suggestionProviders, nameof(suggestionProviders));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(accessRestrictionStorage, nameof(accessRestrictionStorage));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));

            this.dataSource               = dataSource;
            this.userPreferences          = userPreferences;
            this.analyticsService         = analyticsService;
            this.interactorFactory        = interactorFactory;
            this.navigationService        = navigationService;
            this.onboardingStorage        = onboardingStorage;
            this.SchedulerProvider        = schedulerProvider;
            this.intentDonationService    = intentDonationService;
            this.accessRestrictionStorage = accessRestrictionStorage;
            this.stopwatchProvider        = stopwatchProvider;
            this.rxActionFactory          = rxActionFactory;

            TimeService = timeService;

            SuggestionsViewModel = new SuggestionsViewModel(dataSource, interactorFactory, onboardingStorage, suggestionProviders, schedulerProvider, rxActionFactory);
            RatingViewModel      = new RatingViewModel(timeService, dataSource, ratingService, analyticsService, onboardingStorage, navigationService, SchedulerProvider, rxActionFactory);
            TimeEntriesViewModel = new TimeEntriesViewModel(dataSource, interactorFactory, analyticsService, SchedulerProvider, rxActionFactory);

            LogEmpty         = TimeEntriesViewModel.Empty.AsDriver(SchedulerProvider);
            TimeEntriesCount = TimeEntriesViewModel.Count.AsDriver(SchedulerProvider);

            ratingViewExperiment = new RatingViewExperiment(timeService, dataSource, onboardingStorage, remoteConfigService);
        }
 public CreateTimeEntryInteractor(
     IIdProvider idProvider,
     ITimeService timeService,
     ITogglDataSource dataSource,
     IAnalyticsService analyticsService,
     IIntentDonationService intentDonationService,
     ITimeEntryPrototype prototype,
     DateTimeOffset startTime,
     TimeSpan?duration)
     : this(idProvider, timeService, dataSource, analyticsService, intentDonationService, prototype, startTime, duration,
            prototype.Duration.HasValue ? TimeEntryStartOrigin.Manual : TimeEntryStartOrigin.Timer)
 {
 }
        public ReportsCalendarViewModel(
            ITimeService timeService,
            ITogglDataSource dataSource,
            IIntentDonationService intentDonationService)
        {
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));

            this.timeService           = timeService;
            this.dataSource            = dataSource;
            this.intentDonationService = intentDonationService;

            CalendarDayTappedCommand = new MvxCommand <ReportsCalendarDayViewModel>(calendarDayTapped);
            QuickSelectCommand       = new MvxCommand <ReportsCalendarBaseQuickSelectShortcut>(quickSelect);

            disposableBag = new CompositeDisposable();
        }
        public InteractorFactory(
            IIdProvider idProvider,
            ITimeService timeService,
            ITogglDataSource dataSource,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            INotificationService notificationService,
            IIntentDonationService intentDonationService,
            IApplicationShortcutCreator shortcutCreator,
            ILastTimeUsageStorage lastTimeUsageStorage,
            IPlatformConstants platformConstants,
            UserAgent userAgent,
            ICalendarService calendarService)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(idProvider, nameof(idProvider));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(shortcutCreator, nameof(shortcutCreator));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(notificationService, nameof(notificationService));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(lastTimeUsageStorage, nameof(lastTimeUsageStorage));
            Ensure.Argument.IsNotNull(platformConstants, nameof(platformConstants));
            Ensure.Argument.IsNotNull(userAgent, nameof(userAgent));
            Ensure.Argument.IsNotNull(calendarService, nameof(calendarService));

            this.dataSource            = dataSource;
            this.idProvider            = idProvider;
            this.timeService           = timeService;
            this.userPreferences       = userPreferences;
            this.shortcutCreator       = shortcutCreator;
            this.analyticsService      = analyticsService;
            this.notificationService   = notificationService;
            this.intentDonationService = intentDonationService;
            this.lastTimeUsageStorage  = lastTimeUsageStorage;
            this.platformConstants     = platformConstants;
            this.userAgent             = userAgent;
            this.calendarService       = calendarService;
        }
Пример #10
0
        public SettingsViewModel(
            ITogglDataSource dataSource,
            ISyncManager syncManager,
            IPlatformInfo platformInfo,
            IDialogService dialogService,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            IUserAccessManager userAccessManager,
            IInteractorFactory interactorFactory,
            IOnboardingStorage onboardingStorage,
            IMvxNavigationService navigationService,
            IPrivateSharedStorageService privateSharedStorageService,
            IIntentDonationService intentDonationService,
            IStopwatchProvider stopwatchProvider,
            IRxActionFactory rxActionFactory,
            IPermissionsService permissionsService,
            ISchedulerProvider schedulerProvider)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(syncManager, nameof(syncManager));
            Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager));
            Ensure.Argument.IsNotNull(privateSharedStorageService, nameof(privateSharedStorageService));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));
            Ensure.Argument.IsNotNull(permissionsService, nameof(permissionsService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));

            this.dataSource                  = dataSource;
            this.syncManager                 = syncManager;
            this.platformInfo                = platformInfo;
            this.dialogService               = dialogService;
            this.userPreferences             = userPreferences;
            this.rxActionFactory             = rxActionFactory;
            this.analyticsService            = analyticsService;
            this.interactorFactory           = interactorFactory;
            this.navigationService           = navigationService;
            this.userAccessManager           = userAccessManager;
            this.onboardingStorage           = onboardingStorage;
            this.stopwatchProvider           = stopwatchProvider;
            this.intentDonationService       = intentDonationService;
            this.privateSharedStorageService = privateSharedStorageService;
            this.rxActionFactory             = rxActionFactory;
            this.schedulerProvider           = schedulerProvider;
            this.permissionsService          = permissionsService;

            IsSynced =
                syncManager.ProgressObservable
                .SelectMany(checkSynced)
                .AsDriver(schedulerProvider);

            IsRunningSync =
                syncManager.ProgressObservable
                .Select(isRunningSync)
                .AsDriver(schedulerProvider);

            Name =
                dataSource.User.Current
                .Select(user => user.Fullname)
                .DistinctUntilChanged()
                .AsDriver(schedulerProvider);

            Email =
                dataSource.User.Current
                .Select(user => user.Email.ToString())
                .DistinctUntilChanged()
                .AsDriver(schedulerProvider);

            IsManualModeEnabled = userPreferences.IsManualModeEnabledObservable
                                  .AsDriver(schedulerProvider);

            AreRunningTimerNotificationsEnabled = userPreferences.AreRunningTimerNotificationsEnabledObservable
                                                  .AsDriver(schedulerProvider);

            AreStoppedTimerNotificationsEnabled = userPreferences.AreStoppedTimerNotificationsEnabledObservable
                                                  .AsDriver(schedulerProvider);

            WorkspaceName =
                dataSource.User.Current
                .DistinctUntilChanged(user => user.DefaultWorkspaceId)
                .SelectMany(_ => interactorFactory.GetDefaultWorkspace()
                            .TrackException <InvalidOperationException, IThreadSafeWorkspace>("SettingsViewModel.constructor")
                            .Execute()
                            )
                .Select(workspace => workspace.Name)
                .AsDriver(schedulerProvider);

            BeginningOfWeek =
                dataSource.User.Current
                .Select(user => user.BeginningOfWeek)
                .DistinctUntilChanged()
                .Select(beginningOfWeek => beginningOfWeek.ToString())
                .AsDriver(schedulerProvider);

            DateFormat =
                dataSource.Preferences.Current
                .Select(preferences => preferences.DateFormat.Localized)
                .DistinctUntilChanged()
                .AsDriver(schedulerProvider);

            DurationFormat =
                dataSource.Preferences.Current
                .Select(preferences => preferences.DurationFormat)
                .Select(DurationFormatToString.Convert)
                .DistinctUntilChanged()
                .AsDriver(schedulerProvider);

            UseTwentyFourHourFormat =
                dataSource.Preferences.Current
                .Select(preferences => preferences.TimeOfDayFormat.IsTwentyFourHoursFormat)
                .DistinctUntilChanged()
                .AsDriver(schedulerProvider);

            IsGroupingTimeEntries =
                dataSource.Preferences.Current
                .Select(preferences => preferences.CollapseTimeEntries)
                .DistinctUntilChanged()
                .AsDriver(false, schedulerProvider);

            IsCalendarSmartRemindersVisible = calendarPermissionGranted.AsObservable()
                                              .CombineLatest(userPreferences.EnabledCalendars.Select(ids => ids.Any()), CommonFunctions.And);

            CalendarSmartReminders = userPreferences.CalendarNotificationsSettings()
                                     .Select(s => s.Title())
                                     .DistinctUntilChanged();

            UserAvatar =
                dataSource.User.Current
                .Select(user => user.ImageUrl)
                .DistinctUntilChanged()
                .SelectMany(url => interactorFactory.GetUserAvatar(url).Execute())
                .AsDriver(schedulerProvider)
                .Where(avatar => avatar != null);

            Workspaces =
                dataSource.User.Current
                .DistinctUntilChanged(user => user.DefaultWorkspaceId)
                .SelectMany(user => interactorFactory
                            .GetAllWorkspaces()
                            .Execute()
                            .Select(selectableWorkspacesFromWorkspaces(user))
                            )
                .AsDriver(schedulerProvider);

            LoggingOut = loggingOutSubject.AsObservable()
                         .AsDriver(schedulerProvider);

            dataSource.User.Current
            .Subscribe(user => currentUser = user)
            .DisposedBy(disposeBag);

            dataSource.Preferences.Current
            .Subscribe(preferences => currentPreferences = preferences)
            .DisposedBy(disposeBag);

            IsRunningSync
            .Subscribe(isSyncing => this.isSyncing = isSyncing)
            .DisposedBy(disposeBag);

            IsFeedbackSuccessViewShowing = isFeedbackSuccessViewShowing.AsObservable()
                                           .AsDriver(schedulerProvider);

            OpenCalendarSettings         = rxActionFactory.FromAsync(openCalendarSettings);
            OpenCalendarSmartReminders   = rxActionFactory.FromAsync(openCalendarSmartReminders);
            OpenNotificationSettings     = rxActionFactory.FromAsync(openNotificationSettings);
            ToggleTwentyFourHourSettings = rxActionFactory.FromAsync(toggleUseTwentyFourHourClock);
            OpenHelpView              = rxActionFactory.FromAsync(openHelpView);
            TryLogout                 = rxActionFactory.FromAsync(tryLogout);
            OpenAboutView             = rxActionFactory.FromAsync(openAboutView);
            SubmitFeedback            = rxActionFactory.FromAsync(submitFeedback);
            SelectDateFormat          = rxActionFactory.FromAsync(selectDateFormat);
            PickDefaultWorkspace      = rxActionFactory.FromAsync(pickDefaultWorkspace);
            SelectDurationFormat      = rxActionFactory.FromAsync(selectDurationFormat);
            SelectBeginningOfWeek     = rxActionFactory.FromAsync(selectBeginningOfWeek);
            ToggleTimeEntriesGrouping = rxActionFactory.FromAsync(toggleTimeEntriesGrouping);
            SelectDefaultWorkspace    = rxActionFactory.FromAsync <SelectableWorkspaceViewModel>(selectDefaultWorkspace);
            Close = rxActionFactory.FromAsync(close);
        }
Пример #11
0
        public MainViewModel(
            ITogglDataSource dataSource,
            ITimeService timeService,
            IRatingService ratingService,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IInteractorFactory interactorFactory,
            IMvxNavigationService navigationService,
            IRemoteConfigService remoteConfigService,
            ISuggestionProviderContainer suggestionProviders,
            IIntentDonationService intentDonationService,
            IAccessRestrictionStorage accessRestrictionStorage,
            ISchedulerProvider schedulerProvider)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(ratingService, nameof(ratingService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(remoteConfigService, nameof(remoteConfigService));
            Ensure.Argument.IsNotNull(suggestionProviders, nameof(suggestionProviders));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(accessRestrictionStorage, nameof(accessRestrictionStorage));

            this.dataSource               = dataSource;
            this.timeService              = timeService;
            this.userPreferences          = userPreferences;
            this.analyticsService         = analyticsService;
            this.interactorFactory        = interactorFactory;
            this.navigationService        = navigationService;
            this.onboardingStorage        = onboardingStorage;
            this.schedulerProvider        = schedulerProvider;
            this.intentDonationService    = intentDonationService;
            this.accessRestrictionStorage = accessRestrictionStorage;

            SuggestionsViewModel = new SuggestionsViewModel(dataSource, interactorFactory, onboardingStorage, suggestionProviders);
            RatingViewModel      = new RatingViewModel(timeService, dataSource, ratingService, analyticsService, onboardingStorage, navigationService, schedulerProvider);
            TimeEntriesViewModel = new TimeEntriesViewModel(dataSource, interactorFactory, analyticsService, schedulerProvider);

            LogEmpty         = TimeEntriesViewModel.Empty.AsDriver(this.schedulerProvider);
            TimeEntriesCount = TimeEntriesViewModel.Count.AsDriver(this.schedulerProvider);

            ratingViewExperiment = new RatingViewExperiment(timeService, dataSource, onboardingStorage, remoteConfigService);

            OpenSettingsCommand              = new MvxAsyncCommand(openSettings);
            OpenReportsCommand               = new MvxAsyncCommand(openReports);
            OpenSyncFailuresCommand          = new MvxAsyncCommand(openSyncFailures);
            EditTimeEntryCommand             = new MvxAsyncCommand(editTimeEntry, canExecuteEditTimeEntryCommand);
            StopTimeEntryCommand             = new MvxAsyncCommand(stopTimeEntry, () => isStopButtonEnabled);
            StartTimeEntryCommand            = new MvxAsyncCommand(startTimeEntry, () => CurrentTimeEntryId.HasValue == false);
            AlternativeStartTimeEntryCommand = new MvxAsyncCommand(alternativeStartTimeEntry, () => CurrentTimeEntryId.HasValue == false);

            RefreshAction     = new UIAction(refresh);
            DeleteTimeEntry   = new InputAction <TimeEntryViewModel>(deleteTimeEntry);
            SelectTimeEntry   = new InputAction <TimeEntryViewModel>(timeEntrySelected);
            ContinueTimeEntry = new InputAction <TimeEntryViewModel>(continueTimeEntry);
        }
Пример #12
0
        public MainTabBarViewModel(
            ITimeService timeService,
            ITogglDataSource dataSource,
            ISyncManager syncManager,
            IDialogService dialogService,
            IRatingService ratingService,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            IBackgroundService backgroundService,
            IInteractorFactory interactorFactory,
            IOnboardingStorage onboardingStorage,
            ISchedulerProvider schedulerProvider,
            IPermissionsService permissionsService,
            IMvxNavigationService navigationService,
            IRemoteConfigService remoteConfigService,
            ISuggestionProviderContainer suggestionProviders,
            IIntentDonationService intentDonationService,
            IAccessRestrictionStorage accessRestrictionStorage,
            IStopwatchProvider stopwatchProvider,
            IRxActionFactory rxActionFactory,
            IUserAccessManager userAccessManager,
            IPrivateSharedStorageService privateSharedStorageService,
            IPlatformInfo platformInfo)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(syncManager, nameof(syncManager));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(ratingService, nameof(ratingService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(backgroundService, nameof(backgroundService));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(permissionsService, nameof(permissionsService));
            Ensure.Argument.IsNotNull(remoteConfigService, nameof(remoteConfigService));
            Ensure.Argument.IsNotNull(suggestionProviders, nameof(suggestionProviders));
            Ensure.Argument.IsNotNull(accessRestrictionStorage, nameof(accessRestrictionStorage));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));
            Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager));
            Ensure.Argument.IsNotNull(privateSharedStorageService, nameof(privateSharedStorageService));
            Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo));

            this.remoteConfigService = remoteConfigService;
            this.stopwatchProvider   = stopwatchProvider;
            this.platformInfo        = platformInfo;

            mainViewModel = new MainViewModel(
                dataSource,
                syncManager,
                timeService,
                ratingService,
                userPreferences,
                analyticsService,
                onboardingStorage,
                interactorFactory,
                navigationService,
                remoteConfigService,
                suggestionProviders,
                intentDonationService,
                accessRestrictionStorage,
                schedulerProvider,
                stopwatchProvider,
                rxActionFactory);

            reportsViewModel = new ReportsViewModel(
                dataSource,
                timeService,
                navigationService,
                interactorFactory,
                analyticsService,
                dialogService,
                intentDonationService,
                schedulerProvider,
                stopwatchProvider,
                rxActionFactory);

            calendarViewModel = new CalendarViewModel(
                dataSource,
                timeService,
                dialogService,
                userPreferences,
                analyticsService,
                backgroundService,
                interactorFactory,
                onboardingStorage,
                schedulerProvider,
                permissionsService,
                navigationService,
                stopwatchProvider,
                rxActionFactory);

            settingsViewModel = new SettingsViewModel(
                dataSource,
                syncManager,
                platformInfo,
                dialogService,
                userPreferences,
                analyticsService,
                userAccessManager,
                interactorFactory,
                onboardingStorage,
                navigationService,
                privateSharedStorageService,
                intentDonationService,
                stopwatchProvider,
                rxActionFactory,
                permissionsService,
                schedulerProvider);
        }
Пример #13
0
        public MainTabBarViewModel(
            ITimeService timeService,
            ITogglDataSource dataSource,
            IDialogService dialogService,
            IRatingService ratingService,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            IBackgroundService backgroundService,
            IInteractorFactory interactorFactory,
            IOnboardingStorage onboardingStorage,
            ISchedulerProvider schedulerProvider,
            IPermissionsService permissionsService,
            IMvxNavigationService navigationService,
            IRemoteConfigService remoteConfigService,
            ISuggestionProviderContainer suggestionProviders,
            IIntentDonationService intentDonationService,
            IAccessRestrictionStorage accessRestrictionStorage)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(ratingService, nameof(ratingService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(backgroundService, nameof(backgroundService));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(permissionsService, nameof(permissionsService));
            Ensure.Argument.IsNotNull(remoteConfigService, nameof(remoteConfigService));
            Ensure.Argument.IsNotNull(suggestionProviders, nameof(suggestionProviders));
            Ensure.Argument.IsNotNull(accessRestrictionStorage, nameof(accessRestrictionStorage));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));

            this.remoteConfigService = remoteConfigService;

            mainViewModel = new MainViewModel(
                dataSource,
                timeService,
                ratingService,
                userPreferences,
                analyticsService,
                onboardingStorage,
                interactorFactory,
                navigationService,
                remoteConfigService,
                suggestionProviders,
                intentDonationService,
                accessRestrictionStorage,
                schedulerProvider);

            reportsViewModel = new ReportsViewModel(
                dataSource,
                timeService,
                navigationService,
                interactorFactory,
                analyticsService,
                dialogService,
                intentDonationService,
                schedulerProvider);

            calendarViewModel = new CalendarViewModel(
                dataSource,
                timeService,
                dialogService,
                userPreferences,
                analyticsService,
                backgroundService,
                interactorFactory,
                onboardingStorage,
                schedulerProvider,
                permissionsService,
                navigationService);
        }
        public StartTimeEntryViewModel(
            ITimeService timeService,
            ITogglDataSource dataSource,
            IDialogService dialogService,
            IUserPreferences userPreferences,
            IOnboardingStorage onboardingStorage,
            IInteractorFactory interactorFactory,
            INavigationService navigationService,
            IAnalyticsService analyticsService,
            ISchedulerProvider schedulerProvider,
            IIntentDonationService intentDonationService,
            IStopwatchProvider stopwatchProvider,
            IRxActionFactory rxActionFactory
            )
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));

            this.timeService           = timeService;
            this.dialogService         = dialogService;
            this.userPreferences       = userPreferences;
            this.navigationService     = navigationService;
            this.interactorFactory     = interactorFactory;
            this.analyticsService      = analyticsService;
            this.schedulerProvider     = schedulerProvider;
            this.intentDonationService = intentDonationService;
            this.stopwatchProvider     = stopwatchProvider;

            DataSource        = dataSource;
            OnboardingStorage = onboardingStorage;

            TextFieldInfo        = textFieldInfo.AsDriver(schedulerProvider);
            IsBillable           = isBillable.AsDriver(schedulerProvider);
            IsSuggestingTags     = isSuggestingTags.AsDriver(schedulerProvider);
            IsSuggestingProjects = isSuggestingProjects.AsDriver(schedulerProvider);
            IsBillableAvailable  = isBillableAvailable.AsDriver(schedulerProvider);
            DisplayedTime        = displayedTime
                                   .Select(time => time.ToFormattedString(DurationFormat.Improved))
                                   .AsDriver(schedulerProvider);

            Close                    = rxActionFactory.FromAsync(close);
            Done                     = rxActionFactory.FromObservable(done);
            DurationTapped           = rxActionFactory.FromAction(durationTapped);
            ToggleBillable           = rxActionFactory.FromAction(toggleBillable);
            SetStartDate             = rxActionFactory.FromAsync(setStartDate);
            ChangeTime               = rxActionFactory.FromAsync(changeTime);
            ToggleTagSuggestions     = rxActionFactory.FromAction(toggleTagSuggestions);
            ToggleProjectSuggestions = rxActionFactory.FromAction(toggleProjectSuggestions);
            SelectSuggestion         = rxActionFactory.FromAsync <AutocompleteSuggestion>(selectSuggestion);
            SetRunningTime           = rxActionFactory.FromAction <TimeSpan>(setRunningTime);
            ToggleTasks              = rxActionFactory.FromAction <ProjectSuggestion>(toggleTasks);
            SetTextSpans             = rxActionFactory.FromAction <IEnumerable <ISpan> >(setTextSpans);

            var queryByType = queryByTypeSubject
                              .AsObservable()
                              .SelectMany(type => interactorFactory.GetAutocompleteSuggestions(new QueryInfo("", type)).Execute());

            var queryByText = textFieldInfo
                              .SelectMany(setBillableValues)
                              .Select(QueryInfo.ParseFieldInfo)
                              .Do(onParsedQuery)
                              .ObserveOn(schedulerProvider.BackgroundScheduler)
                              .SelectMany(query => interactorFactory.GetAutocompleteSuggestions(query).Execute());

            Suggestions = Observable.Merge(queryByText, queryByType)
                          .Select(items => items.ToList()) // This is line is needed for now to read objects from realm
                          .Select(filter)
                          .Select(group)
                          .CombineLatest(expandedProjects, (groups, _) => groups)
                          .Select(toCollections)
                          .Select(addStaticElements)
                          .AsDriver(schedulerProvider);
        }
Пример #15
0
 public Builder WithIntentDonationService(IIntentDonationService intentDonationService)
 {
     IntentDonationService = intentDonationService;
     return(this);
 }
Пример #16
0
        public SettingsViewModel(
            UserAgent userAgent,
            IMailService mailService,
            ITogglDataSource dataSource,
            IDialogService dialogService,
            IUserPreferences userPreferences,
            IFeedbackService feedbackService,
            IAnalyticsService analyticsService,
            IInteractorFactory interactorFactory,
            IPlatformConstants platformConstants,
            IOnboardingStorage onboardingStorage,
            IMvxNavigationService navigationService,
            IPrivateSharedStorageService privateSharedStorageService,
            IIntentDonationService intentDonationService)
        {
            Ensure.Argument.IsNotNull(userAgent, nameof(userAgent));
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(mailService, nameof(mailService));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(feedbackService, nameof(feedbackService));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(platformConstants, nameof(platformConstants));
            Ensure.Argument.IsNotNull(privateSharedStorageService, nameof(privateSharedStorageService));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));

            this.userAgent                   = userAgent;
            this.dataSource                  = dataSource;
            this.mailService                 = mailService;
            this.dialogService               = dialogService;
            this.userPreferences             = userPreferences;
            this.feedbackService             = feedbackService;
            this.analyticsService            = analyticsService;
            this.interactorFactory           = interactorFactory;
            this.navigationService           = navigationService;
            this.platformConstants           = platformConstants;
            this.onboardingStorage           = onboardingStorage;
            this.privateSharedStorageService = privateSharedStorageService;
            this.intentDonationService       = intentDonationService;

            IsSynced = dataSource.SyncManager.ProgressObservable.SelectMany(checkSynced);

            IsRunningSync =
                dataSource.SyncManager
                .ProgressObservable
                .Select(isRunningSync);

            Name =
                dataSource.User.Current
                .Select(user => user.Fullname)
                .DistinctUntilChanged();

            Email =
                dataSource.User.Current
                .Select(user => user.Email.ToString())
                .DistinctUntilChanged();

            IsManualModeEnabled = userPreferences.IsManualModeEnabledObservable;
            AreRunningTimerNotificationsEnabled = userPreferences.AreRunningTimerNotificationsEnabledObservable;
            AreStoppedTimerNotificationsEnabled = userPreferences.AreStoppedTimerNotificationsEnabledObservable;

            WorkspaceName =
                dataSource.User.Current
                .DistinctUntilChanged(user => user.DefaultWorkspaceId)
                .SelectMany(_ => interactorFactory.GetDefaultWorkspace().Execute())
                .Select(workspace => workspace.Name);

            BeginningOfWeek =
                dataSource.User.Current
                .Select(user => user.BeginningOfWeek)
                .DistinctUntilChanged()
                .Select(beginningOfWeek => beginningOfWeek.ToString());

            DateFormat =
                dataSource.Preferences.Current
                .Select(preferences => preferences.DateFormat.Localized)
                .DistinctUntilChanged();

            DurationFormat =
                dataSource.Preferences.Current
                .Select(preferences => preferences.DurationFormat)
                .Select(DurationFormatToString.Convert)
                .DistinctUntilChanged();

            UseTwentyFourHourFormat =
                dataSource.Preferences.Current
                .Select(preferences => preferences.TimeOfDayFormat.IsTwentyFourHoursFormat)
                .DistinctUntilChanged();

            UserAvatar =
                dataSource.User.Current
                .Select(user => user.ImageUrl)
                .DistinctUntilChanged()
                .SelectMany(url => interactorFactory.GetUserAvatar(url).Execute());

            Workspaces =
                dataSource.User.Current
                .DistinctUntilChanged(user => user.DefaultWorkspaceId)
                .SelectMany(user => interactorFactory
                            .GetAllWorkspaces()
                            .Execute()
                            .Select(selectableWorkspacesFromWorkspaces(user))
                            );

            LoggingOut = loggingOutSubject.AsObservable();

            dataSource.User.Current
            .Subscribe(user => currentUser = user)
            .DisposedBy(disposeBag);

            dataSource.Preferences.Current
            .Subscribe(preferences => currentPreferences = preferences)
            .DisposedBy(disposeBag);

            IsRunningSync
            .Subscribe(isSyncing => this.isSyncing = isSyncing)
            .DisposedBy(disposeBag);

            IsFeedbackSuccessViewShowing = isFeedbackSuccessViewShowing.AsObservable();

            OpenCalendarSettingsAction = new UIAction(openCalendarSettings);

            OpenNotificationSettingsAction = new UIAction(openNotificationSettings);
        }