Bug 924480 - Part 2: Disable TalkBack access to Gecko with HomePager displayed. r=eeejay,lucasr

This commit is contained in:
Michael Comella 2013-10-18 09:42:53 -07:00
parent c7b9959e99
commit 4572d7ffb6

View File

@ -166,6 +166,12 @@ abstract public class BrowserApp extends GeckoApp
private BrowserHealthReporter mBrowserHealthReporter;
// The animator used to toggle HomePager visibility has a race where if the HomePager is shown
// (starting the animation), the HomePager is hidden, and the HomePager animation completes,
// both the web content and the HomePager will be hidden. This flag is used to prevent the
// race by determining if the web content should be hidden at the animation's end.
private boolean mHideWebContentOnAnimationEnd = false;
private SiteIdentityPopup mSiteIdentityPopup;
public SiteIdentityPopup getSiteIdentityPopup() {
@ -1573,7 +1579,38 @@ abstract public class BrowserApp extends GeckoApp
final ViewStub homePagerStub = (ViewStub) findViewById(R.id.home_pager_stub);
mHomePager = (HomePager) homePagerStub.inflate();
}
mHomePager.show(getSupportFragmentManager(), page, animator);
// Hide the web content so it cannot be focused by screen readers.
hideWebContentOnPropertyAnimationEnd(animator);
}
private void hideWebContentOnPropertyAnimationEnd(final PropertyAnimator animator) {
if (animator == null) {
hideWebContent();
return;
}
animator.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
@Override
public void onPropertyAnimationStart() {
mHideWebContentOnAnimationEnd = true;
}
@Override
public void onPropertyAnimationEnd() {
if (mHideWebContentOnAnimationEnd) {
hideWebContent();
}
}
});
}
private void hideWebContent() {
// The view is set to INVISIBLE, rather than GONE, to avoid
// the additional requestLayout() call.
mLayerView.setVisibility(View.INVISIBLE);
}
private void hideHomePager() {
@ -1586,6 +1623,12 @@ abstract public class BrowserApp extends GeckoApp
return;
}
// Prevent race in hiding web content - see declaration for more info.
mHideWebContentOnAnimationEnd = false;
// Display the previously hidden web content (which prevented screen reader access).
mLayerView.setVisibility(View.VISIBLE);
if (mHomePager != null) {
mHomePager.hide();
}