コード例 #1
0
        public NotificationServiceIos(IPermissionsChecker permissionsChecker, ITimeService timeService)
            : base(permissionsChecker)
        {
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));

            this.timeService = timeService;

            var openAndCreateFromCalendarEventAction = UNNotificationAction.FromIdentifier(
                OpenAndCreateFromCalendarEvent,
                FoundationResources.OpenAppAndStartAction,
                UNNotificationActionOptions.AuthenticationRequired | UNNotificationActionOptions.Foreground
                );

            var openAndNavigateToCalendarAction = UNNotificationAction.FromIdentifier(
                OpenAndNavigateToCalendar,
                FoundationResources.OpenAppAction,
                UNNotificationActionOptions.AuthenticationRequired | UNNotificationActionOptions.Foreground
                );

            var startTimeEntryInBackgroundAction = UNNotificationAction.FromIdentifier(
                StartTimeEntryInBackground,
                FoundationResources.StartInBackgroundAction,
                UNNotificationActionOptions.AuthenticationRequired
                );

            var calendarEventCategory = UNNotificationCategory.FromIdentifier(
                CalendarEventCategory,
                new UNNotificationAction[] { openAndCreateFromCalendarEventAction, startTimeEntryInBackgroundAction, openAndNavigateToCalendarAction },
                new string[] { },
                UNNotificationCategoryOptions.None
                );

            UNUserNotificationCenter.Current.SetNotificationCategories(new NSSet <UNNotificationCategory>(calendarEventCategory));
        }
コード例 #2
0
        public NotificationSettingsViewModel(
            INavigationService navigationService,
            IBackgroundService backgroundService,
            IPermissionsChecker permissionsChecker,
            IUserPreferences userPreferences,
            ISchedulerProvider schedulerProvider,
            IRxActionFactory rxActionFactory)
            : base(navigationService)
        {
            Ensure.Argument.IsNotNull(backgroundService, nameof(backgroundService));
            Ensure.Argument.IsNotNull(permissionsChecker, nameof(permissionsChecker));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));

            PermissionGranted = backgroundService.AppResumedFromBackground
                                .SelectUnit()
                                .StartWith(Unit.Default)
                                .SelectMany(_ => permissionsChecker.NotificationPermissionGranted)
                                .DistinctUntilChanged()
                                .AsDriver(schedulerProvider);

            UpcomingEvents = userPreferences.CalendarNotificationsSettings()
                             .Select(s => s.Title())
                             .DistinctUntilChanged()
                             .AsDriver(schedulerProvider);

            RequestAccess      = rxActionFactory.FromAction(requestAccess);
            OpenUpcomingEvents = rxActionFactory.FromAsync(openUpcomingEvents);
        }
コード例 #3
0
 public static void InjectChecker(IPermissionsChecker checker)
 {
     // best put some code here to make sure this is only called once,
     // as well as doing thread synchronization
     if (_checker == null)
         _checker = checker;
 }
コード例 #4
0
        public CalendarPermissionDeniedViewModel(INavigationService navigationService, IPermissionsChecker permissionsChecker, IRxActionFactory rxActionFactory)
            : base(navigationService)
        {
            Ensure.Argument.IsNotNull(permissionsChecker, nameof(permissionsChecker));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));

            this.permissionsChecker = permissionsChecker;

            EnableAccess = rxActionFactory.FromAction(enableAccess);
        }
コード例 #5
0
        public CalendarSettingsViewModel(
            IUserPreferences userPreferences,
            IInteractorFactory interactorFactory,
            IOnboardingStorage onboardingStorage,
            IAnalyticsService analyticsService,
            INavigationService navigationService,
            IRxActionFactory rxActionFactory,
            IPermissionsChecker permissionsChecker)
            : base(userPreferences, interactorFactory, onboardingStorage, analyticsService, navigationService, rxActionFactory)
        {
            Ensure.Argument.IsNotNull(permissionsChecker, nameof(permissionsChecker));

            this.permissionsChecker = permissionsChecker;

            RequestAccess            = rxActionFactory.FromAction(requestAccess);
            TogglCalendarIntegration = rxActionFactory.FromAsync(togglCalendarIntegration);

            CalendarListVisible = calendarListVisibleSubject.AsObservable().DistinctUntilChanged();
        }
コード例 #6
0
        public SuggestionsViewModel(
            IInteractorFactory interactorFactory,
            IOnboardingStorage onboardingStorage,
            ISchedulerProvider schedulerProvider,
            IRxActionFactory rxActionFactory,
            IAnalyticsService analyticsService,
            ITimeService timeService,
            IPermissionsChecker permissionsChecker,
            INavigationService navigationService,
            IBackgroundService backgroundService,
            IUserPreferences userPreferences,
            ISyncManager syncManager,
            IWidgetsService widgetsService)
            : base(navigationService)
        {
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(permissionsChecker, nameof(permissionsChecker));
            Ensure.Argument.IsNotNull(backgroundService, nameof(backgroundService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(syncManager, nameof(syncManager));
            Ensure.Argument.IsNotNull(widgetsService, nameof(widgetsService));

            this.interactorFactory  = interactorFactory;
            this.onboardingStorage  = onboardingStorage;
            this.schedulerProvider  = schedulerProvider;
            this.rxActionFactory    = rxActionFactory;
            this.analyticsService   = analyticsService;
            this.timeService        = timeService;
            this.permissionsChecker = permissionsChecker;
            this.backgroundService  = backgroundService;
            this.userPreferences    = userPreferences;
            this.syncManager        = syncManager;
            this.widgetsService     = widgetsService;
        }
コード例 #7
0
 protected PermissionedOperation(IPermissionsChecker checker)
 {
     _checker = checker;
 }
コード例 #8
0
        public SettingsViewModel(
            ITogglDataSource dataSource,
            ISyncManager syncManager,
            IPlatformInfo platformInfo,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            IInteractorFactory interactorFactory,
            IOnboardingStorage onboardingStorage,
            INavigationService navigationService,
            IRxActionFactory rxActionFactory,
            IPermissionsChecker permissionsChecker,
            ISchedulerProvider schedulerProvider)
            : base(navigationService)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(syncManager, nameof(syncManager));
            Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo));
            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(rxActionFactory, nameof(rxActionFactory));
            Ensure.Argument.IsNotNull(permissionsChecker, nameof(permissionsChecker));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));

            this.dataSource         = dataSource;
            this.syncManager        = syncManager;
            this.platformInfo       = platformInfo;
            this.userPreferences    = userPreferences;
            this.analyticsService   = analyticsService;
            this.interactorFactory  = interactorFactory;
            this.onboardingStorage  = onboardingStorage;
            this.permissionsChecker = permissionsChecker;

            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.ToLocalizedString())
                .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();

            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);

            SwipeActionsEnabled = userPreferences.SwipeActionsEnabled
                                  .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);
            OpenSiriShortcuts         = rxActionFactory.FromAsync(openSiriShorcuts);
            OpenSiriWorkflows         = rxActionFactory.FromAsync(openSiriWorkflows);
            SubmitFeedback            = rxActionFactory.FromAsync(submitFeedback);
            SelectDateFormat          = rxActionFactory.FromAsync(selectDateFormat);
            PickDefaultWorkspace      = rxActionFactory.FromAsync(pickDefaultWorkspace);
            SelectDurationFormat      = rxActionFactory.FromAsync(selectDurationFormat);
            SelectBeginningOfWeek     = rxActionFactory.FromAsync(selectBeginningOfWeek);
            ToggleTimeEntriesGrouping = rxActionFactory.FromAsync(toggleTimeEntriesGrouping);
            ToggleManualMode          = rxActionFactory.FromAction(toggleManualMode);
            ToggleSwipeActions        = rxActionFactory.FromAction(toggleSwipeActions);
        }
コード例 #9
0
 public CalendarServiceAndroid(IPermissionsChecker permissionsChecker)
     : base(permissionsChecker)
 {
 }
コード例 #10
0
 public CalendarServiceIos(IPermissionsChecker permissionsChecker)
     : base(permissionsChecker)
 {
 }
コード例 #11
0
        public MainTabBarViewModel(
            ITimeService timeService,
            ITogglDataSource dataSource,
            ISyncManager syncManager,
            IRatingService ratingService,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            IBackgroundService backgroundService,
            IInteractorFactory interactorFactory,
            IOnboardingStorage onboardingStorage,
            ISchedulerProvider schedulerProvider,
            IPermissionsChecker permissionsChecker,
            INavigationService navigationService,
            IRemoteConfigService remoteConfigService,
            IAccessibilityService accessibilityService,
            IUpdateRemoteConfigCacheService updateRemoteConfigCacheService,
            IAccessRestrictionStorage accessRestrictionStorage,
            IRxActionFactory rxActionFactory,
            IUserAccessManager userAccessManager,
            IPrivateSharedStorageService privateSharedStorageService,
            IPlatformInfo platformInfo)
            : base(navigationService)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(syncManager, nameof(syncManager));
            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(backgroundService, nameof(backgroundService));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(permissionsChecker, nameof(permissionsChecker));
            Ensure.Argument.IsNotNull(remoteConfigService, nameof(remoteConfigService));
            Ensure.Argument.IsNotNull(accessibilityService, nameof(accessibilityService));
            Ensure.Argument.IsNotNull(updateRemoteConfigCacheService, nameof(updateRemoteConfigCacheService));
            Ensure.Argument.IsNotNull(accessRestrictionStorage, nameof(accessRestrictionStorage));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            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.platformInfo        = platformInfo;

            mainViewModel = new MainViewModel(
                dataSource,
                syncManager,
                timeService,
                ratingService,
                userPreferences,
                analyticsService,
                onboardingStorage,
                interactorFactory,
                navigationService,
                remoteConfigService,
                accessibilityService,
                updateRemoteConfigCacheService,
                accessRestrictionStorage,
                schedulerProvider,
                rxActionFactory,
                permissionsChecker,
                backgroundService,
                platformInfo);

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

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

            settingsViewModel = new SettingsViewModel(
                dataSource,
                syncManager,
                platformInfo,
                userPreferences,
                analyticsService,
                interactorFactory,
                onboardingStorage,
                navigationService,
                rxActionFactory,
                permissionsChecker,
                schedulerProvider);

            Tabs = getViewModels().ToList();
        }
コード例 #12
0
ファイル: MainViewModel.cs プロジェクト: xleon/mobileapp
        public MainViewModel(
            ITogglDataSource dataSource,
            ISyncManager syncManager,
            ITimeService timeService,
            IRatingService ratingService,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IInteractorFactory interactorFactory,
            INavigationService navigationService,
            IRemoteConfigService remoteConfigService,
            IAccessibilityService accessibilityService,
            IUpdateRemoteConfigCacheService updateRemoteConfigCacheService,
            IAccessRestrictionStorage accessRestrictionStorage,
            ISchedulerProvider schedulerProvider,
            IRxActionFactory rxActionFactory,
            IPermissionsChecker permissionsChecker,
            IBackgroundService backgroundService,
            IPlatformInfo platformInfo,
            IWidgetsService widgetsService)
            : base(navigationService)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(syncManager, nameof(syncManager));
            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(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(remoteConfigService, nameof(remoteConfigService));
            Ensure.Argument.IsNotNull(accessibilityService, nameof(accessibilityService));
            Ensure.Argument.IsNotNull(updateRemoteConfigCacheService, nameof(updateRemoteConfigCacheService));
            Ensure.Argument.IsNotNull(accessRestrictionStorage, nameof(accessRestrictionStorage));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));
            Ensure.Argument.IsNotNull(permissionsChecker, nameof(permissionsChecker));
            Ensure.Argument.IsNotNull(backgroundService, nameof(backgroundService));
            Ensure.Argument.IsNotNull(platformInfo, nameof(platformInfo));
            Ensure.Argument.IsNotNull(widgetsService, nameof(widgetsService));

            this.dataSource               = dataSource;
            this.syncManager              = syncManager;
            this.platformInfo             = platformInfo;
            this.userPreferences          = userPreferences;
            this.rxActionFactory          = rxActionFactory;
            this.analyticsService         = analyticsService;
            this.interactorFactory        = interactorFactory;
            this.schedulerProvider        = schedulerProvider;
            this.accessibilityService     = accessibilityService;
            this.accessRestrictionStorage = accessRestrictionStorage;
            this.widgetsService           = widgetsService;

            TimeService       = timeService;
            OnboardingStorage = onboardingStorage;

            SuggestionsViewModel = new SuggestionsViewModel(interactorFactory, OnboardingStorage, schedulerProvider, rxActionFactory, analyticsService, timeService, permissionsChecker, navigationService, backgroundService, userPreferences, syncManager, widgetsService);
            RatingViewModel      = new RatingViewModel(timeService, ratingService, analyticsService, OnboardingStorage, navigationService, schedulerProvider, rxActionFactory);
            TimeEntriesViewModel = new TimeEntriesViewModel(dataSource, interactorFactory, analyticsService, schedulerProvider, rxActionFactory, timeService);

            TimeEntries = TimeEntriesViewModel.TimeEntries
                          .Throttle(TimeSpan.FromSeconds(throttlePeriodInSeconds))
                          .AsDriver(ImmutableList <MainLogSection> .Empty, schedulerProvider);

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

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

            SwipeActionsEnabled = userPreferences.SwipeActionsEnabled.AsDriver(schedulerProvider);
        }
コード例 #13
0
 public WithPermissionDecorator(IMp3Renamer renamer, IPermissionsChecker checker, UserRole userRole)
 {
     _renamer  = renamer;
     _checker  = checker;
     _userRole = userRole;
 }
コード例 #14
0
        protected PermissionAwareCalendarService(IPermissionsChecker permissionsChecker)
        {
            Ensure.Argument.IsNotNull(permissionsChecker, nameof(permissionsChecker));

            this.permissionsChecker = permissionsChecker;
        }
コード例 #15
0
 protected PermissionAwareNotificationService(IPermissionsChecker permissionsChecker)
 {
     this.permissionsChecker = permissionsChecker;
 }