diff options
author | Ivan Chiang <chiangi@google.com> | 2022-03-30 15:21:09 +0800 |
---|---|---|
committer | Ivan Chiang <chiangi@google.com> | 2022-04-08 11:31:17 +0800 |
commit | c0c42ad152051d378ed29db0f52d193fc657f849 (patch) | |
tree | a4453b433c8810d2430863967c8f436242ad9720 | |
parent | edaf075401a8a056e6c9e6e06dbd67ba5ac8329d (diff) | |
download | MediaProvider-c0c42ad152051d378ed29db0f52d193fc657f849.tar.gz |
Show full screen photoPicker when A11y is enabled
Test: atest com.android.providers.media.photopicker.espresso
Bug: 207073198
Change-Id: I779046483657d81f0a1a94d4caef769777ff4001
4 files changed, 39 insertions, 21 deletions
diff --git a/src/com/android/providers/media/photopicker/PhotoPickerActivity.java b/src/com/android/providers/media/photopicker/PhotoPickerActivity.java index a68e546be..4ec540fc0 100644 --- a/src/com/android/providers/media/photopicker/PhotoPickerActivity.java +++ b/src/com/android/providers/media/photopicker/PhotoPickerActivity.java @@ -39,6 +39,7 @@ import android.view.View; import android.view.ViewOutlineProvider; import android.view.WindowInsetsController; import android.view.WindowManager; +import android.view.accessibility.AccessibilityManager; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; @@ -95,6 +96,7 @@ public class PhotoPickerActivity extends AppCompatActivity { private int mToolBarIconColor; private int mToolbarHeight = 0; + private boolean mIsAccessibilityEnabled; @Override public void onCreate(Bundle savedInstanceState) { @@ -135,6 +137,12 @@ public class PhotoPickerActivity extends AppCompatActivity { mProfileButton = findViewById(R.id.profile_button); mTabLayout = findViewById(R.id.tab_layout); + + AccessibilityManager accessibilityManager = getSystemService(AccessibilityManager.class); + mIsAccessibilityEnabled = accessibilityManager.isEnabled(); + accessibilityManager.addAccessibilityStateChangeListener( + enabled -> mIsAccessibilityEnabled = enabled); + initBottomSheetBehavior(); restoreState(savedInstanceState); @@ -284,7 +292,8 @@ public class PhotoPickerActivity extends AppCompatActivity { } private void initStateForBottomSheet() { - if (!mSelection.canSelectMultiple() && !isOrientationLandscape()) { + if (!mIsAccessibilityEnabled && !mSelection.canSelectMultiple() + && !isOrientationLandscape()) { final int peekHeight = getBottomSheetPeekHeight(this); mBottomSheetBehavior.setPeekHeight(peekHeight); mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); diff --git a/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerActivityTest.java b/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerActivityTest.java index 4e9b48177..130504c58 100644 --- a/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerActivityTest.java +++ b/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerActivityTest.java @@ -242,16 +242,19 @@ public class PhotoPickerActivityTest extends PhotoPickerBaseTest { BottomSheetIdlingResource.register(mRule); try { - // Single select PhotoPicker is launched in partial screen mode - bottomSheetIdlingResource.setExpectedState(STATE_COLLAPSED); - mRule.getScenario().onActivity(activity -> { - assertBottomSheetState(activity, STATE_COLLAPSED); - }); + + // When accessibility is enabled, we always launch the photo picker in full screen mode. + // Accessibility is enabled in Espresso test, so we can't check the COLLAPSED state. +// // Single select PhotoPicker is launched in partial screen mode +// bottomSheetIdlingResource.setExpectedState(STATE_COLLAPSED); +// mRule.getScenario().onActivity(activity -> { +// assertBottomSheetState(activity, STATE_COLLAPSED); +// }); // Swipe up and check that the PhotoPicker is in full screen mode. +// onView(withId(PRIVACY_TEXT_ID)).check(matches(isDisplayed())); +// onView(withId(PRIVACY_TEXT_ID)).perform(ViewActions.swipeUp()); bottomSheetIdlingResource.setExpectedState(STATE_EXPANDED); - onView(withId(PRIVACY_TEXT_ID)).check(matches(isDisplayed())); - onView(withId(PRIVACY_TEXT_ID)).perform(ViewActions.swipeUp()); mRule.getScenario().onActivity(activity -> { assertBottomSheetState(activity, STATE_EXPANDED); }); diff --git a/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerTestActivity.java b/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerTestActivity.java index 55dcd99db..5b5a35639 100644 --- a/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerTestActivity.java +++ b/tests/src/com/android/providers/media/photopicker/espresso/PhotoPickerTestActivity.java @@ -29,4 +29,4 @@ public class PhotoPickerTestActivity extends PhotoPickerActivity { pickerViewModel.setUserIdManager(PhotoPickerBaseTest.getMockUserIdManager()); return pickerViewModel; } -}
\ No newline at end of file +} diff --git a/tests/src/com/android/providers/media/photopicker/espresso/PreviewSingleSelectTest.java b/tests/src/com/android/providers/media/photopicker/espresso/PreviewSingleSelectTest.java index 6606a2029..edeccd85e 100644 --- a/tests/src/com/android/providers/media/photopicker/espresso/PreviewSingleSelectTest.java +++ b/tests/src/com/android/providers/media/photopicker/espresso/PreviewSingleSelectTest.java @@ -74,12 +74,15 @@ public class PreviewSingleSelectTest extends PhotoPickerBaseTest { BottomSheetIdlingResource.register(mRule); try { - bottomSheetIdlingResource.setExpectedState(STATE_COLLAPSED); - onView(withId(DRAG_BAR_ID)).check(matches(isDisplayed())); - onView(withId(PRIVACY_TEXT_ID)).check(matches(isDisplayed())); - mRule.getScenario().onActivity(activity -> { - assertBottomSheetState(activity, STATE_COLLAPSED); - }); + // TODO(b/226318844): When accessibility is enabled, we always launch the photo picker + // in full screen mode. Accessibility is enabled in Espresso test, we can't check the + // COLLAPSED state. +// bottomSheetIdlingResource.setExpectedState(STATE_COLLAPSED); +// onView(withId(DRAG_BAR_ID)).check(matches(isDisplayed())); +// onView(withId(PRIVACY_TEXT_ID)).check(matches(isDisplayed())); +// mRule.getScenario().onActivity(activity -> { +// assertBottomSheetState(activity, STATE_COLLAPSED); +// }); // Navigate to preview longClickItem(PICKER_TAB_RECYCLERVIEW_ID, IMAGE_1_POSITION, ICON_THUMBNAIL_ID); @@ -106,14 +109,17 @@ public class PreviewSingleSelectTest extends PhotoPickerBaseTest { onView(withContentDescription("Navigate up")).perform(click()); onView(withId(PICKER_TAB_RECYCLERVIEW_ID)).check(matches(isDisplayed())); - - bottomSheetIdlingResource.setExpectedState(STATE_COLLAPSED); - // Shows dragBar and privacy text after we are back to Photos tab onView(withId(DRAG_BAR_ID)).check(matches(isDisplayed())); onView(withId(PRIVACY_TEXT_ID)).check(matches(isDisplayed())); - mRule.getScenario().onActivity(activity -> { - assertBottomSheetState(activity, STATE_COLLAPSED); - }); + + // TODO(b/226318844): When accessibility is enabled, we always launch the photo picker + // in full screen mode. Accessibility is enabled in Espresso test, we can't check the + // COLLAPSED state. +// bottomSheetIdlingResource.setExpectedState(STATE_COLLAPSED); +// // Shows dragBar and privacy text after we are back to Photos tab +// mRule.getScenario().onActivity(activity -> { +// assertBottomSheetState(activity, STATE_COLLAPSED); +// }); } finally { IdlingRegistry.getInstance().unregister(bottomSheetIdlingResource); } |