Move the content description for Display size and text preview to xml
Bug: 395882764 Test: atest TextReadingPreviewControllerTest Test: atest TextReadingPreviewPreferenceTest Flag: EXEMPT BUGFIX Change-Id: I070ec2b9b39a205fd3a97636f0c45fb50b670049
This commit is contained in:
@@ -46,7 +46,6 @@
|
|||||||
android:id="@+id/preview_pager"
|
android:id="@+id/preview_pager"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="217dp"
|
android:layout_height="217dp"
|
||||||
android:contentDescription="@string/preview_pager_content_description"
|
|
||||||
android:nestedScrollingEnabled="true" />
|
android:nestedScrollingEnabled="true" />
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@@ -14,7 +14,11 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:contentDescription="@string/preview_pager_home_content_description" >
|
||||||
<com.android.settings.display.AppGridView
|
<com.android.settings.display.AppGridView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
@@ -25,3 +29,4 @@
|
|||||||
android:nestedScrollingEnabled="true"
|
android:nestedScrollingEnabled="true"
|
||||||
android:importantForAccessibility="noHideDescendants"
|
android:importantForAccessibility="noHideDescendants"
|
||||||
app:appCount="6"/>
|
app:appCount="6"/>
|
||||||
|
</FrameLayout>
|
||||||
|
@@ -14,18 +14,18 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fillViewport="true"
|
android:fillViewport="true"
|
||||||
android:importantForAccessibility="noHideDescendants">
|
android:contentDescription="@string/preview_pager_email_content_description">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:importantForAccessibility="noHideDescendants">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/subject"
|
android:id="@+id/subject"
|
||||||
|
@@ -19,12 +19,13 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fillViewport="true"
|
android:fillViewport="true"
|
||||||
android:importantForAccessibility="noHideDescendants">
|
android:contentDescription="@string/preview_pager_message_content_description">
|
||||||
|
|
||||||
<view class="com.android.settings.TouchBlockingFrameLayout"
|
<view class="com.android.settings.TouchBlockingFrameLayout"
|
||||||
android:id="@+id/frame"
|
android:id="@+id/frame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:importantForAccessibility="noHideDescendants">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@@ -810,23 +810,13 @@
|
|||||||
<!-- Allowed packages to show the confirmation dialog for a system locale suggestion -->
|
<!-- Allowed packages to show the confirmation dialog for a system locale suggestion -->
|
||||||
<string-array name="allowed_packages_for_locale_confirmation_diallog" translatable="false"/>
|
<string-array name="allowed_packages_for_locale_confirmation_diallog" translatable="false"/>
|
||||||
|
|
||||||
<!-- Array of text reading preview layouts. Must contain at least 1 layout.
|
<!-- Array of text reading preview layouts. Must contain at least 1 layout -->
|
||||||
Add content descriptions in the config_text_reading_preview_content_descriptions together
|
|
||||||
if adding more sample layouts here -->
|
|
||||||
<array name="config_text_reading_preview_samples">
|
<array name="config_text_reading_preview_samples">
|
||||||
<item>@layout/accessibility_text_reading_preview_app_grid</item>
|
<item>@layout/accessibility_text_reading_preview_app_grid</item>
|
||||||
<item>@layout/screen_zoom_preview_1</item>
|
<item>@layout/screen_zoom_preview_1</item>
|
||||||
<item>@layout/accessibility_text_reading_preview_mail_content</item>
|
<item>@layout/accessibility_text_reading_preview_mail_content</item>
|
||||||
</array>
|
</array>
|
||||||
|
|
||||||
<!-- Array of text reading preview layouts' content descriptions.
|
|
||||||
The order should be the same as the layouts in config_text_reading_preview_samples -->
|
|
||||||
<array name="config_text_reading_preview_content_descriptions">
|
|
||||||
<item>@string/preview_pager_home_content_description</item>
|
|
||||||
<item>@string/preview_pager_message_content_description</item>
|
|
||||||
<item>@string/preview_pager_email_content_description</item>
|
|
||||||
</array>
|
|
||||||
|
|
||||||
<!-- Package responsible for updating Mainline Modules -->
|
<!-- Package responsible for updating Mainline Modules -->
|
||||||
<string name="config_mainline_module_update_package" translatable="false">com.android.vending</string>
|
<string name="config_mainline_module_update_package" translatable="false">com.android.vending</string>
|
||||||
|
|
||||||
|
@@ -104,13 +104,11 @@ class TextReadingPreviewController extends BasePreferenceController implements
|
|||||||
final boolean isLayoutRtl =
|
final boolean isLayoutRtl =
|
||||||
origConfig.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
|
origConfig.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
|
||||||
final int[] previewSamples = getPreviewSampleLayouts(mContext);
|
final int[] previewSamples = getPreviewSampleLayouts(mContext);
|
||||||
final int[] previewContentDescriptions = getPreviewSampleContentDescriptions(mContext);
|
|
||||||
final PreviewPagerAdapter pagerAdapter = new PreviewPagerAdapter(mContext, isLayoutRtl,
|
final PreviewPagerAdapter pagerAdapter = new PreviewPagerAdapter(mContext, isLayoutRtl,
|
||||||
previewSamples, createConfig(origConfig));
|
previewSamples, createConfig(origConfig));
|
||||||
mPreviewPreference.setPreviewAdapter(pagerAdapter);
|
mPreviewPreference.setPreviewAdapter(pagerAdapter);
|
||||||
mPreviewPreference.setCurrentItem(
|
mPreviewPreference.setCurrentItem(
|
||||||
isLayoutRtl ? previewSamples.length - 1 : FRAME_INITIAL_INDEX);
|
isLayoutRtl ? previewSamples.length - 1 : FRAME_INITIAL_INDEX);
|
||||||
mPreviewPreference.setContentDescription(previewContentDescriptions);
|
|
||||||
|
|
||||||
final int initialPagerIndex =
|
final int initialPagerIndex =
|
||||||
mLastFontProgress * mDisplaySizeData.getValues().size() + mLastDisplayProgress;
|
mLastFontProgress * mDisplaySizeData.getValues().size() + mLastDisplayProgress;
|
||||||
@@ -190,20 +188,6 @@ class TextReadingPreviewController extends BasePreferenceController implements
|
|||||||
return previewSamples;
|
return previewSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
|
||||||
static int[] getPreviewSampleContentDescriptions(Context context) {
|
|
||||||
TypedArray typedArray = context.getResources().obtainTypedArray(
|
|
||||||
R.array.config_text_reading_preview_content_descriptions);
|
|
||||||
int previewCount = typedArray.length();
|
|
||||||
int[] previewContentDescriptions = new int[previewCount];
|
|
||||||
for (int i = 0; i < previewCount; i++) {
|
|
||||||
previewContentDescriptions[i] =
|
|
||||||
typedArray.getResourceId(i, R.string.preview_pager_content_description);
|
|
||||||
}
|
|
||||||
typedArray.recycle();
|
|
||||||
return previewContentDescriptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getPagerIndex() {
|
private int getPagerIndex() {
|
||||||
final int displayDataSize = mDisplaySizeData.getValues().size();
|
final int displayDataSize = mDisplaySizeData.getValues().size();
|
||||||
final int fontSizeProgress = mFontSizePreference.getProgress();
|
final int fontSizeProgress = mFontSizePreference.getProgress();
|
||||||
|
@@ -43,10 +43,26 @@ public class TextReadingPreviewPreference extends Preference {
|
|||||||
private int mCurrentItem;
|
private int mCurrentItem;
|
||||||
private int mLastLayerIndex;
|
private int mLastLayerIndex;
|
||||||
private PreviewPagerAdapter mPreviewAdapter;
|
private PreviewPagerAdapter mPreviewAdapter;
|
||||||
private int[] mContentDescriptions;
|
|
||||||
|
|
||||||
private int mLayoutMinHorizontalPadding = 0;
|
private int mLayoutMinHorizontalPadding = 0;
|
||||||
private int mBackgroundMinHorizontalPadding = 0;
|
private int mBackgroundMinHorizontalPadding = 0;
|
||||||
|
private final ViewPager.OnPageChangeListener mPageChangeListener =
|
||||||
|
new ViewPager.OnPageChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int i, float v, int i1) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int i) {
|
||||||
|
mCurrentItem = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int i) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
TextReadingPreviewPreference(Context context) {
|
TextReadingPreviewPreference(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -78,23 +94,7 @@ public class TextReadingPreviewPreference extends Preference {
|
|||||||
adjustPaddings(previewLayout, backgroundView);
|
adjustPaddings(previewLayout, backgroundView);
|
||||||
|
|
||||||
final ViewPager viewPager = (ViewPager) holder.findViewById(R.id.preview_pager);
|
final ViewPager viewPager = (ViewPager) holder.findViewById(R.id.preview_pager);
|
||||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
viewPager.addOnPageChangeListener(mPageChangeListener);
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int i, float v, int i1) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int i) {
|
|
||||||
mCurrentItem = i;
|
|
||||||
viewPager.setContentDescription(getContext().getString(mContentDescriptions[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int i) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
});
|
|
||||||
final DotsPageIndicator pageIndicator =
|
final DotsPageIndicator pageIndicator =
|
||||||
(DotsPageIndicator) holder.findViewById(R.id.page_indicator);
|
(DotsPageIndicator) holder.findViewById(R.id.page_indicator);
|
||||||
updateAdapterIfNeeded(viewPager, pageIndicator, mPreviewAdapter);
|
updateAdapterIfNeeded(viewPager, pageIndicator, mPreviewAdapter);
|
||||||
@@ -121,10 +121,6 @@ public class TextReadingPreviewPreference extends Preference {
|
|||||||
viewPager.setCurrentItem(getCurrentItem() + 1));
|
viewPager.setCurrentItem(getCurrentItem() + 1));
|
||||||
nextButton.setContentDescription(getContext().getString(
|
nextButton.setContentDescription(getContext().getString(
|
||||||
R.string.preview_pager_next_button));
|
R.string.preview_pager_next_button));
|
||||||
|
|
||||||
// Initialize the content description since the OnPageChangeListener#onPageSelected won't
|
|
||||||
// be called during setup.
|
|
||||||
viewPager.setContentDescription(getContext().getString(mContentDescriptions[0]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -173,10 +169,6 @@ public class TextReadingPreviewPreference extends Preference {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setContentDescription(int[] stringIds) {
|
|
||||||
mContentDescriptions = stringIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPreviewAdapter(PreviewPagerAdapter previewAdapter) {
|
void setPreviewAdapter(PreviewPagerAdapter previewAdapter) {
|
||||||
if (previewAdapter != mPreviewAdapter) {
|
if (previewAdapter != mPreviewAdapter) {
|
||||||
mPreviewAdapter = previewAdapter;
|
mPreviewAdapter = previewAdapter;
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -78,15 +76,6 @@ public class TextReadingPreviewControllerTest {
|
|||||||
mDisplaySizePreference = new AccessibilitySeekBarPreference(mContext, /* attr= */ null);
|
mDisplaySizePreference = new AccessibilitySeekBarPreference(mContext, /* attr= */ null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void numberOfPreviewSamples_numberOfPreviewContentDescription_isEqual() {
|
|
||||||
int[] previewSamples = TextReadingPreviewController.getPreviewSampleLayouts(mContext);
|
|
||||||
int[] previewContentDescriptions =
|
|
||||||
TextReadingPreviewController.getPreviewSampleContentDescriptions(mContext);
|
|
||||||
|
|
||||||
assertThat(previewSamples.length).isEqualTo(previewContentDescriptions.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void initPreviewerAdapter_verifyAction() {
|
public void initPreviewerAdapter_verifyAction() {
|
||||||
when(mPreferenceScreen.findPreference(PREVIEW_KEY)).thenReturn(mPreviewPreference);
|
when(mPreferenceScreen.findPreference(PREVIEW_KEY)).thenReturn(mPreviewPreference);
|
||||||
|
@@ -49,48 +49,28 @@ import org.robolectric.RobolectricTestRunner;
|
|||||||
*/
|
*/
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class TextReadingPreviewPreferenceTest {
|
public class TextReadingPreviewPreferenceTest {
|
||||||
private Context mContext;
|
|
||||||
private TextReadingPreviewPreference mTextReadingPreviewPreference;
|
private TextReadingPreviewPreference mTextReadingPreviewPreference;
|
||||||
private PreferenceViewHolder mHolder;
|
private PreferenceViewHolder mHolder;
|
||||||
private ViewPager mViewPager;
|
private ViewPager mViewPager;
|
||||||
private PreviewPagerAdapter mPreviewPagerAdapter;
|
private PreviewPagerAdapter mPreviewPagerAdapter;
|
||||||
private int mPreviewSampleCount;
|
private int mPreviewSampleCount;
|
||||||
private int[] mPreviewContentDescriptions;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mContext = ApplicationProvider.getApplicationContext();
|
final Context context = ApplicationProvider.getApplicationContext();
|
||||||
mPreviewContentDescriptions =
|
final int[] previewSamples = TextReadingPreviewController.getPreviewSampleLayouts(context);
|
||||||
TextReadingPreviewController.getPreviewSampleContentDescriptions(mContext);
|
|
||||||
final int[] previewSamples = TextReadingPreviewController.getPreviewSampleLayouts(mContext);
|
|
||||||
mPreviewSampleCount = previewSamples.length;
|
mPreviewSampleCount = previewSamples.length;
|
||||||
final Configuration[] configurations = createConfigurations(mPreviewSampleCount);
|
final Configuration[] configurations = createConfigurations(mPreviewSampleCount);
|
||||||
mTextReadingPreviewPreference = new TextReadingPreviewPreference(mContext);
|
mTextReadingPreviewPreference = new TextReadingPreviewPreference(context);
|
||||||
mPreviewPagerAdapter =
|
mPreviewPagerAdapter =
|
||||||
spy(new PreviewPagerAdapter(mContext, /* isLayoutRtl= */ false,
|
spy(new PreviewPagerAdapter(context, /* isLayoutRtl= */ false,
|
||||||
previewSamples, configurations));
|
previewSamples, configurations));
|
||||||
final LayoutInflater inflater = LayoutInflater.from(mContext);
|
final LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
final View view =
|
final View view =
|
||||||
inflater.inflate(mTextReadingPreviewPreference.getLayoutResource(),
|
inflater.inflate(mTextReadingPreviewPreference.getLayoutResource(),
|
||||||
new LinearLayout(mContext), false);
|
new LinearLayout(context), false);
|
||||||
mHolder = PreferenceViewHolder.createInstanceForTests(view);
|
mHolder = PreferenceViewHolder.createInstanceForTests(view);
|
||||||
mViewPager = view.findViewById(R.id.preview_pager);
|
mViewPager = view.findViewById(R.id.preview_pager);
|
||||||
mTextReadingPreviewPreference.setContentDescription(mPreviewContentDescriptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void changePreviewPage_getExpectedContentDescription() {
|
|
||||||
mTextReadingPreviewPreference.setPreviewAdapter(mPreviewPagerAdapter);
|
|
||||||
mTextReadingPreviewPreference.onBindViewHolder(mHolder);
|
|
||||||
|
|
||||||
// Verify the initial content description
|
|
||||||
assertThat(mViewPager.getContentDescription().toString())
|
|
||||||
.isEqualTo(mContext.getString(mPreviewContentDescriptions[0]));
|
|
||||||
|
|
||||||
// Change the preview page
|
|
||||||
mViewPager.setCurrentItem(1);
|
|
||||||
assertThat(mViewPager.getContentDescription().toString())
|
|
||||||
.isEqualTo(mContext.getString(mPreviewContentDescriptions[1]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user