protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); if (State(savedInstanceState) == AppState.IsDestroyed) { return; } IsOnBoarding = Intent.GetBooleanExtra(DroidRequestCodes.isOnBoardinIntentExtra, false); if (IsOnBoarding && ConsentsHelper.IsNotFullyOnboarded) { GoToConsents(); return; } if (IsOnBoarding) { SetIsBackgroundActivityDialogShowEnableNewUser(true); } _pages = new List <AndroidX.Fragment.App.Fragment>(new AndroidX.Fragment.App.Fragment[] { _welcomePageOne, _welcomePageTwo, _welcomePageThree, _welcomePageFour }); _numPages = _pages.Count; SetContentView(Resource.Layout.welcome); _button = FindViewById <Button>(Resource.Id.buttonGetStarted); _previousButton = FindViewById <Button>(Resource.Id.buttonPrev); _previousButton.Text = WelcomeViewModel.PREVIOUS_PAGE_BUTTON_TEXT; _button.Text = WelcomeViewModel.NEXT_PAGE_BUTTON_TEXT; _button.Click += new SingleClick(GetNextButton_Click, 500).Run; _previousButton.Click += new SingleClick(GetPreviousButton_Click, 500).Run; _previousButton.Visibility = ViewStates.Gone; WelcomePagerAdapter adapter = new WelcomePagerAdapter(SupportFragmentManager, _pages); _pager = FindViewById <NonSwipeableViewPager>(Resource.Id.fragment); _pager.Adapter = adapter; _pager.SetPagingEnabled(false); _pager.AddOnPageChangeListener(this); _pager.AnnounceForAccessibility(IsOnBoarding ? WelcomeViewModel.ANNOUNCEMENT_PAGE_CHANGED_TO_ONE : WelcomeViewModel.ANNOUNCEMENT_PAGE_CHANGED_TO_ONE); _dotLayout = FindViewById <TabLayout>(Resource.Id.tabDots); _dotLayout.SetupWithViewPager(_pager, true); View rootView = Window.DecorView.RootView; rootView.LayoutDirection = LayoutUtils.GetLayoutDirection(); }
private void AnnouncePageChangesForScreenReaders() { // Change focus to fragment _pager.PerformAccessibilityAction(Android.Views.Accessibility.Action.AccessibilityFocus, null); AndroidX.Fragment.App.Fragment activeFragment = _pages[_pager.CurrentItem]; if (activeFragment == _welcomePageOne) { _pager.AnnounceForAccessibility(WelcomeViewModel.ANNOUNCEMENT_PAGE_CHANGED_TO_ONE); } else if (activeFragment == _welcomePageTwo) { _pager.AnnounceForAccessibility(WelcomeViewModel.ANNOUNCEMENT_PAGE_CHANGED_TO_TWO); } else if (activeFragment == _welcomePageThree) { _pager.AnnounceForAccessibility(WelcomeViewModel.ANNOUNCEMENT_PAGE_CHANGED_TO_THREE); } else if (activeFragment == _welcomePageFour) { _pager.AnnounceForAccessibility(WelcomeViewModel.ANNOUNCEMENT_PAGE_CHANGED_TO_FOUR); } }