Accessibility fixes and updates

> Adding custom actions on the page indicator to go to overview mode
> Disabling custom actions on the first page
> Disabling 'move page left' on the second page

Change-Id: Ib8154f70cb3f93e663a881357c6c46c33253887f
This commit is contained in:
Sunny Goyal
2016-06-16 12:29:03 -07:00
parent 8e6a800480
commit d0a6ae7f64
8 changed files with 114 additions and 83 deletions

View File

@@ -154,7 +154,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// Page Indicator
@Thunk int mPageIndicatorViewId;
@Thunk PageIndicator mPageIndicator;
protected PageIndicator mPageIndicator;
// The viewport whether the pages are to be contained (the actual view may be larger than the
// viewport)
@ViewDebug.ExportedProperty(category = "launcher")
@@ -247,39 +247,14 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
mScroller.setInterpolator(mDefaultInterpolator);
}
protected void onAttachedToWindow() {
super.onAttachedToWindow();
// Hook up the page indicator
ViewGroup parent = (ViewGroup) getParent();
ViewGroup grandParent = (ViewGroup) parent.getParent();
if (mPageIndicator == null && mPageIndicatorViewId > -1) {
mPageIndicator = (PageIndicator) grandParent.findViewById(mPageIndicatorViewId);
public void initParentViews(View parent) {
if (mPageIndicatorViewId > -1) {
mPageIndicator = (PageIndicator) parent.findViewById(mPageIndicatorViewId);
mPageIndicator.setMarkersCount(getChildCount());
OnClickListener listener = getPageIndicatorClickListener();
if (listener != null) {
mPageIndicator.setOnClickListener(listener);
}
mPageIndicator.setContentDescription(getPageIndicatorDescription());
mPageIndicator.setContentDescription(getCurrentPageDescription());
}
}
protected String getPageIndicatorDescription() {
return getCurrentPageDescription();
}
protected OnClickListener getPageIndicatorClickListener() {
return null;
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// Unhook the page indicator
mPageIndicator = null;
}
// Convenience methods to map points from self to parent and vice versa
private float[] mapPointFromViewToParent(View v, float x, float y) {
sTmpPoint[0] = x;
@@ -467,7 +442,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
private void updatePageIndicator() {
// Update the page indicator (when we aren't reordering)
if (mPageIndicator != null) {
mPageIndicator.setContentDescription(getPageIndicatorDescription());
mPageIndicator.setContentDescription(getCurrentPageDescription());
if (!isReordering(false)) {
mPageIndicator.setActiveMarker(getNextPage());
}