Add the content description for accessibility tutorial pages.
Bug: 155833961
Test: manual test & robo test
Change-Id: Iec86a6478706dcf6ce224046e8439a3d3b68144a
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 366254f..7a57070 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4942,6 +4942,8 @@
</string>
<!-- Summary for the accessibility preference screen to enable screen magnification via the nav bar. [CHAR LIMIT=none] -->
<string name="accessibility_screen_magnification_navbar_summary">When magnification is turned on, you can zoom in on your screen.\n\n<b>To zoom</b>, start magnification, then tap anywhere on the screen.\n<ul><li>Drag 2 or more fingers to scroll</li>\n<li>Pinch 2 or more fingers to adjust zoom</li></ul>\n\n<b>To zoom temporarily</b>, start magnification, then touch & hold anywhere on the screen.\n<ul><li>Drag to move around the screen</li>\n<li>Lift finger to zoom out</li></ul>\n\nYou can’t zoom in on the keyboard or navigation bar.</string>
+ <!-- Accessibility label for paging indicator in accessibility tutorial page. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_tutorial_pager">Page <xliff:g id="current_page" example="2">%1$d</xliff:g> of <xliff:g id="num_pages" example="3">%2$d</xliff:g></string>
<!-- Title for the accessibility tutorial dialog in accessibility service with button. [CHAR LIMIT=50] -->
<string name="accessibility_tutorial_dialog_title_button">Use accessibility button to open</string>
<!-- Title for the accessibility tutorial dialog in accessibility service with volume keys. [CHAR LIMIT=100] -->
diff --git a/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java b/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
index c36ad03..482822e 100644
--- a/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
+++ b/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
@@ -297,8 +297,14 @@
final ViewPager viewPager = contentView.findViewById(R.id.view_pager);
viewPager.setAdapter(new TutorialPagerAdapter(tutorialPages));
+ viewPager.setContentDescription(context.getString(R.string.accessibility_tutorial_pager,
+ /* firstPage */ 1, tutorialPages.size()));
+ viewPager.setImportantForAccessibility(tutorialPages.size() > 1
+ ? View.IMPORTANT_FOR_ACCESSIBILITY_YES
+ : View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
viewPager.addOnPageChangeListener(
- new TutorialPageChangeListener(context, title, instruction, tutorialPages));
+ new TutorialPageChangeListener(context, viewPager, title, instruction,
+ tutorialPages));
return contentView;
}
@@ -479,10 +485,12 @@
private final TextSwitcher mTitle;
private final TextSwitcher mInstruction;
private final List<TutorialPage> mTutorialPages;
+ private final ViewPager mViewPager;
- TutorialPageChangeListener(Context context, ViewGroup title, ViewGroup instruction,
- List<TutorialPage> tutorialPages) {
+ TutorialPageChangeListener(Context context, ViewPager viewPager, ViewGroup title,
+ ViewGroup instruction, List<TutorialPage> tutorialPages) {
this.mContext = context;
+ this.mViewPager = viewPager;
this.mTitle = (TextSwitcher) title;
this.mInstruction = (TextSwitcher) instruction;
this.mTutorialPages = tutorialPages;
@@ -521,6 +529,11 @@
}
mTutorialPages.get(position).getIndicatorIcon().setEnabled(true);
mLastTutorialPagePosition = position;
+
+ final int currentPageNumber = position + 1;
+ mViewPager.setContentDescription(
+ mContext.getString(R.string.accessibility_tutorial_pager,
+ currentPageNumber, mTutorialPages.size()));
}
@Override