Exemple #1
0
        public GitHubAuthenticationService(IPreferences preferences,
                                           IAnalyticsService analyticsService,
                                           GitHubUserService gitHubUserService,
                                           RepositoryDatabase repositoryDatabase,
                                           GitHubGraphQLApiService gitHubGraphQLApiService,
                                           AzureFunctionsApiService azureFunctionsApiService)
        {
            _preferences              = preferences;
            _analyticsService         = analyticsService;
            _gitHubUserService        = gitHubUserService;
            _repositoryDatabase       = repositoryDatabase;
            _gitHubGraphQLApiService  = gitHubGraphQLApiService;
            _azureFunctionsApiService = azureFunctionsApiService;

            ThemeService.PreferenceChanged           += HandlePreferenceChanged;
            LanguageService.PreferredLanguageChanged += HandlePreferredLanguageChanged;
        }
 public UITestsBackdoorService(IMainThread mainThread,
                               ThemeService themeService,
                               LanguageService languageService,
                               GitHubUserService gitHubUserService,
                               NotificationService notificationService,
                               GitHubGraphQLApiService gitHubGraphQLApiService,
                               TrendsChartSettingsService trendsChartSettingsService,
                               GitHubAuthenticationService gitHubAuthenticationService)
 {
     _mainThread                  = mainThread;
     _themeService                = themeService;
     _languageService             = languageService;
     _gitHubUserService           = gitHubUserService;
     _notificationService         = notificationService;
     _gitHubGraphQLApiService     = gitHubGraphQLApiService;
     _trendsChartSettingsService  = trendsChartSettingsService;
     _gitHubAuthenticationService = gitHubAuthenticationService;
 }
Exemple #3
0
        public OnboardingViewModel(DeepLinkingService deepLinkingService,
                                   GitHubAuthenticationService gitHubAuthenticationService,
                                   NotificationService notificationService,
                                   IAnalyticsService analyticsService,
                                   IMainThread mainThread,
                                   FirstRunService firstRunService,
                                   GitHubUserService gitHubUserService)
            : base(gitHubAuthenticationService, deepLinkingService, analyticsService, mainThread, gitHubUserService)
        {
            const string defaultNotificationSvg = "bell.svg";

            _notificationService = notificationService;
            _analyticsService    = analyticsService;
            _firstRunService     = firstRunService;

            NotificationStatusSvgImageSource = defaultNotificationSvg;

            EnableNotificationsButtonTapped = new AsyncCommand(ExecuteEnableNotificationsButtonTapped);
        }
Exemple #4
0
        public SettingsViewModel(IMainThread mainThread,
                                 ThemeService themeService,
                                 LanguageService languageService,
                                 IVersionTracking versionTracking,
                                 IAnalyticsService analyticsService,
                                 GitHubUserService gitHubUserService,
                                 DeepLinkingService deepLinkingService,
                                 NotificationService notificationService,
                                 TrendsChartSettingsService trendsChartSettingsService,
                                 GitHubAuthenticationService gitHubAuthenticationService)
            : base(mainThread, analyticsService, gitHubUserService, deepLinkingService, gitHubAuthenticationService)
        {
            _themeService               = themeService;
            _versionTracking            = versionTracking;
            _languageService            = languageService;
            _deepLinkingService         = deepLinkingService;
            _notificationService        = notificationService;
            _trendsChartSettingsService = trendsChartSettingsService;

            CopyrightLabelTappedCommand = new AsyncCommand(ExecuteCopyrightLabelTappedCommand);
            GitHubUserViewTappedCommand = new AsyncCommand(ExecuteGitHubUserViewTappedCommand, _ => IsNotAuthenticating);

            App.Resumed += HandleResumed;

            GitHubUserService.NameChanged      += HandleNameChanged;
            GitHubUserService.AliasChanged     += HandleAliasChanged;
            GitHubUserService.AvatarUrlChanged += HandleAvatarUrlChanged;

            ThemeService.PreferenceChanged           += HandlePreferenceChanged;
            LanguageService.PreferredLanguageChanged += HandlePreferredLanguageChanged;
            GitHubAuthenticationService.AuthorizeSessionCompleted += HandleAuthorizeSessionCompleted;

            ThemePickerSelectedIndex     = (int)themeService.Preference;
            PreferredChartsSelectedIndex = (int)trendsChartSettingsService.CurrentTrendsChartOption;
            LanguagePickerSelectedIndex  = CultureConstants.CulturePickerOptions.Keys.ToList().IndexOf(languageService.PreferredLanguage ?? string.Empty);

            initializeIsRegisterForNotificationsSwitch().SafeFireAndForget();

            InitializeText();

            async Task initializeIsRegisterForNotificationsSwitch() => IsRegisterForNotificationsSwitchToggled = notificationService.ShouldSendNotifications && await notificationService.AreNotificationsEnabled().ConfigureAwait(false);
        }
Exemple #5
0
        public BackgroundFetchService(IAppInfo appInfo,
                                      GitHubUserService gitHubUserService,
                                      IAnalyticsService analyticsService,
                                      GitHubApiV3Service gitHubApiV3Service,
                                      RepositoryDatabase repositoryDatabase,
                                      NotificationService notificationService,
                                      ReferringSitesDatabase referringSitesDatabase,
                                      GitHubGraphQLApiService gitHubGraphQLApiService,
                                      GitHubApiRepositoriesService gitHubApiRepositoriesService)
        {
            _analyticsService             = analyticsService;
            _gitHubUserService            = gitHubUserService;
            _gitHubApiV3Service           = gitHubApiV3Service;
            _repositoryDatabase           = repositoryDatabase;
            _notificationService          = notificationService;
            _referringSitesDatabase       = referringSitesDatabase;
            _gitHubGraphQLApiService      = gitHubGraphQLApiService;
            _gitHubApiRepositoriesService = gitHubApiRepositoriesService;

            CleanUpDatabaseIdentifier            = $"{appInfo.PackageName}.{nameof(CleanUpDatabase)}";
            NotifyTrendingRepositoriesIdentifier = $"{appInfo.PackageName}.{nameof(NotifyTrendingRepositories)}";
        }
Exemple #6
0
        public RepositoryViewModel(IMainThread mainThread,
                                   ImageCachingService imageService,
                                   IAnalyticsService analyticsService,
                                   GitHubUserService gitHubUserService,
                                   MobileSortingService sortingService,
                                   RepositoryDatabase repositoryDatabase,
                                   GitHubApiV3Service gitHubApiV3Service,
                                   GitHubGraphQLApiService gitHubGraphQLApiService,
                                   GitHubApiExceptionService gitHubApiExceptionService,
                                   GitHubAuthenticationService gitHubAuthenticationService,
                                   GitHubApiRepositoriesService gitHubApiRepositoriesService) : base(analyticsService, mainThread)
        {
            LanguageService.PreferredLanguageChanged += HandlePreferredLanguageChanged;

            SetTitleText();

            _imageService                 = imageService;
            _gitHubUserService            = gitHubUserService;
            _mobileSortingService         = sortingService;
            _repositoryDatabase           = repositoryDatabase;
            _gitHubApiV3Service           = gitHubApiV3Service;
            _gitHubGraphQLApiService      = gitHubGraphQLApiService;
            _gitHubApiExceptionService    = gitHubApiExceptionService;
            _gitHubAuthenticationService  = gitHubAuthenticationService;
            _gitHubApiRepositoriesService = gitHubApiRepositoriesService;

            RefreshState = RefreshState.Uninitialized;

            PullToRefreshCommand      = new AsyncCommand(() => ExecutePullToRefreshCommand(gitHubUserService.Alias));
            FilterRepositoriesCommand = new Command <string>(SetSearchBarText);
            SortRepositoriesCommand   = new Command <SortingOption>(ExecuteSortRepositoriesCommand);

            NotificationService.SortingOptionRequested += HandleSortingOptionRequested;

            GitHubAuthenticationService.DemoUserActivated         += HandleDemoUserActivated;
            GitHubAuthenticationService.LoggedOut                 += HandleGitHubAuthenticationServiceLoggedOut;
            GitHubAuthenticationService.AuthorizeSessionCompleted += HandleAuthorizeSessionCompleted;
        }
 public GitHubApiV3Service(IAnalyticsService analyticsService, IMainThread mainThread, GitHubUserService gitHubUserService, IGitHubApiV3 gitHubApiV3) : base(analyticsService, mainThread)
 {
     _githubApiClient   = gitHubApiV3;
     _gitHubUserService = gitHubUserService;
 }
 public GitHubGraphQLApiService(IAnalyticsService analyticsService, IMainThread mainThread, GitHubUserService gitHubUserService, IGitHubGraphQLApi gitHubGraphQLApi) : base(analyticsService, mainThread)
 {
     _githubApiClient   = gitHubGraphQLApi;
     _gitHubUserService = gitHubUserService;
 }
        public RepositoryPage(RepositoryViewModel repositoryViewModel,
                              IAnalyticsService analyticsService,
                              MobileSortingService sortingService,
                              DeepLinkingService deepLinkingService,
                              IMainThread mainThread,
                              FirstRunService firstRunService,
                              GitHubUserService gitHubUserService) : base(repositoryViewModel, analyticsService, mainThread)
        {
            _firstRunService    = firstRunService;
            _gitHubUserService  = gitHubUserService;
            _deepLinkingService = deepLinkingService;

            ViewModel.PullToRefreshFailed += HandlePullToRefreshFailed;
            SearchBarTextChanged          += HandleSearchBarTextChanged;

            var collectionView = new CollectionView
            {
                ItemTemplate    = new RepositoryDataTemplateSelector(sortingService),
                BackgroundColor = Color.Transparent,
                SelectionMode   = SelectionMode.Single,
                AutomationId    = RepositoryPageAutomationIds.CollectionView,
                //Work around for https://github.com/xamarin/Xamarin.Forms/issues/9879
                Header = Device.RuntimePlatform is Device.Android ? new BoxView {
                    HeightRequest = BaseRepositoryDataTemplate.BottomPadding
                } : null,
                Footer = Device.RuntimePlatform is Device.Android ? new BoxView {
                    HeightRequest = BaseRepositoryDataTemplate.TopPadding
                } : null,
                EmptyView = new EmptyDataView("EmptyRepositoriesList", RepositoryPageAutomationIds.EmptyDataView)
                            .Bind <EmptyDataView, bool, bool>(IsVisibleProperty, nameof(RepositoryViewModel.IsRefreshing), convert: isRefreshing => !isRefreshing)
                            .Bind(EmptyDataView.TitleProperty, nameof(RepositoryViewModel.EmptyDataViewTitle))
                            .Bind(EmptyDataView.DescriptionProperty, nameof(RepositoryViewModel.EmptyDataViewDescription))
            };

            collectionView.SelectionChanged += HandleCollectionViewSelectionChanged;
            collectionView.SetBinding(CollectionView.ItemsSourceProperty, nameof(RepositoryViewModel.VisibleRepositoryList));

            _refreshView = new RefreshView
            {
                AutomationId = RepositoryPageAutomationIds.RefreshView,
                Content      = collectionView
            }.DynamicResource(RefreshView.RefreshColorProperty, nameof(BaseTheme.PullToRefreshColor))
            .Bind(RefreshView.IsRefreshingProperty, nameof(RepositoryViewModel.IsRefreshing))
            .Bind(RefreshView.CommandProperty, nameof(RepositoryViewModel.PullToRefreshCommand));

            var settingsToolbarItem = new ToolbarItem
            {
                Text            = PageTitles.SettingsPage,
                IconImageSource = Device.RuntimePlatform is Device.iOS ? "Settings" : null,
                Order           = Device.RuntimePlatform is Device.Android ? ToolbarItemOrder.Secondary : ToolbarItemOrder.Default,
                AutomationId    = RepositoryPageAutomationIds.SettingsButton,
                Command         = new AsyncCommand(ExecuteSetttingsToolbarItemCommand)
            };

            ToolbarItems.Add(settingsToolbarItem);

            var sortToolbarItem = new ToolbarItem
            {
                Text            = RepositoryPageConstants.SortToolbarItemText,
                Priority        = 1,
                IconImageSource = Device.RuntimePlatform is Device.iOS ? "Sort" : null,
                Order           = Device.RuntimePlatform is Device.Android ? ToolbarItemOrder.Secondary : ToolbarItemOrder.Default,
                AutomationId    = RepositoryPageAutomationIds.SortButton,
                Command         = new AsyncCommand(ExecuteSortToolbarItemCommand)
            };

            ToolbarItems.Add(sortToolbarItem);

            //Work-around to prevent LargeNavigationBar from collapsing when CollectionView is scrolled; prevents janky animation when LargeNavigationBar collapses
            if (Device.RuntimePlatform is Device.iOS)
            {
                Content = new Grid
                {
                    Children =
                    {
                        new BoxView {
                            HeightRequest = 0
                        },
                        _refreshView
                    }
                };
            }
            else
            {
                Content = _refreshView;
            }

            this.SetBinding(TitleProperty, nameof(RepositoryViewModel.TitleText));
        }
Exemple #10
0
 public GitHubApiV3Service(IAnalyticsService analyticsService, IMainThread mainThread, GitHubUserService gitHubUserService) : base(analyticsService, mainThread)
 {
     _gitHubUserService = gitHubUserService;
 }
Exemple #11
0
        public RepositoryPage(IMainThread mainThread,
                              FirstRunService firstRunService,
                              IAnalyticsService analyticsService,
                              GitHubUserService gitHubUserService,
                              DeepLinkingService deepLinkingService,
                              RepositoryViewModel repositoryViewModel,
                              MobileSortingService mobileSortingService) : base(repositoryViewModel, analyticsService, mainThread)
        {
            _firstRunService    = firstRunService;
            _gitHubUserService  = gitHubUserService;
            _deepLinkingService = deepLinkingService;

            SearchBarTextChanged += HandleSearchBarTextChanged;
            RepositoryViewModel.PullToRefreshFailed  += HandlePullToRefreshFailed;
            LanguageService.PreferredLanguageChanged += HandlePreferredLanguageChanged;

            this.SetBinding(TitleProperty, nameof(RepositoryViewModel.TitleText));

            ToolbarItems.Add(new ToolbarItem
            {
                Text            = PageTitles.SettingsPage,
                IconImageSource = Device.RuntimePlatform is Device.iOS ? "Settings" : null,
                Order           = Device.RuntimePlatform is Device.Android ? ToolbarItemOrder.Secondary : ToolbarItemOrder.Default,
                AutomationId    = RepositoryPageAutomationIds.SettingsButton,
                Command         = new AsyncCommand(ExecuteSetttingsToolbarItemCommand)
            });

            ToolbarItems.Add(new ToolbarItem
            {
                Text            = RepositoryPageConstants.SortToolbarItemText,
                Priority        = 1,
                IconImageSource = Device.RuntimePlatform is Device.iOS ? "Sort" : null,
                Order           = Device.RuntimePlatform is Device.Android ? ToolbarItemOrder.Secondary : ToolbarItemOrder.Default,
                AutomationId    = RepositoryPageAutomationIds.SortButton,
                Command         = new AsyncCommand(ExecuteSortToolbarItemCommand)
            });

            Content = new Grid
            {
                RowDefinitions = Rows.Define(
                    (Row.Totals, AbsoluteGridLength(125)),
                    (Row.CollectionView, Star),
                    (Row.Information, AbsoluteGridLength(100))),

                ColumnDefinitions = Columns.Define(
                    (Column.CollectionView, Star),
                    (Column.Information, AbsoluteGridLength(100))),

                Children =
                {
                    new TotalsLabel().Row(Row.Totals).ColumnSpan(All <Column>())
                    .Bind <Label,                                                bool,                                  bool>(IsVisibleProperty,    nameof(RepositoryViewModel.IsRefreshing),          convert: isRefreshing => !isRefreshing)
                    .Bind <Label,                                                IReadOnlyList <Repository>,            string>(Label.TextProperty, nameof(RepositoryViewModel.VisibleRepositoryList), convert: repositories => totalsLabelConverter(repositories, mobileSortingService)),

                    new RefreshView
                    {
                        AutomationId = RepositoryPageAutomationIds.RefreshView,
                        Content      = new CollectionView
                        {
                            ItemTemplate    = new RepositoryDataTemplateSelector(mobileSortingService),
                            BackgroundColor = Color.Transparent,
                            SelectionMode   = SelectionMode.Single,
                            AutomationId    = RepositoryPageAutomationIds.CollectionView,
                            //Work around for https://github.com/xamarin/Xamarin.Forms/issues/9879
                            Header = Device.RuntimePlatform is Device.Android ? new BoxView {
                                HeightRequest = BaseRepositoryDataTemplate.BottomPadding
                            } : null,
                            Footer = Device.RuntimePlatform is Device.Android ? new BoxView {
                                HeightRequest = BaseRepositoryDataTemplate.TopPadding
                            } : null,
                            EmptyView = new EmptyDataView("EmptyRepositoriesList",RepositoryPageAutomationIds.EmptyDataView)
                                        .Bind <EmptyDataView,                    bool,                                  bool>(IsVisibleProperty,    nameof(RepositoryViewModel.IsRefreshing),          convert: isRefreshing => !isRefreshing)
                                        .Bind(EmptyDataView.TitleProperty,       nameof(RepositoryViewModel.EmptyDataViewTitle))
                                        .Bind(EmptyDataView.DescriptionProperty, nameof(RepositoryViewModel.EmptyDataViewDescription))
                        }.Bind(CollectionView.ItemsSourceProperty,               nameof(RepositoryViewModel.VisibleRepositoryList))
                        .Invoke(collectionView => collectionView.SelectionChanged += HandleCollectionViewSelectionChanged)
                    }.RowSpan(All <Row>()).ColumnSpan(All <Column>()).Assign(out _refreshView)
                    .Bind(RefreshView.IsRefreshingProperty,                      nameof(RepositoryViewModel.IsRefreshing))
                    .Bind(RefreshView.CommandProperty,                           nameof(RepositoryViewModel.PullToRefreshCommand))
                    .DynamicResource(RefreshView.RefreshColorProperty,           nameof(BaseTheme.PullToRefreshColor)),
                }
            }.Assign(out Grid grid);