am 0e3057c6: Merge "Add accessibility scroll support to some widgets." into jb-dev
* commit '0e3057c667425e4b1326c598442e69a4e0e036e2': Add accessibility scroll support to some widgets.
This commit is contained in:
@@ -1480,6 +1480,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
|
||||
@Override
|
||||
public boolean performAccessibilityAction(int action, Bundle arguments) {
|
||||
if (super.performAccessibilityAction(action, arguments)) {
|
||||
return true;
|
||||
}
|
||||
switch (action) {
|
||||
case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: {
|
||||
if (getLastVisiblePosition() < getCount() - 1) {
|
||||
@@ -1496,7 +1499,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
}
|
||||
} return false;
|
||||
}
|
||||
return super.performAccessibilityAction(action, arguments);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.annotation.Widget;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
@@ -1367,6 +1368,35 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
|
||||
super.onInitializeAccessibilityNodeInfo(info);
|
||||
info.setClassName(Gallery.class.getName());
|
||||
info.setScrollable(mItemCount > 1);
|
||||
if (mItemCount > 0 && mSelectedPosition < mItemCount - 1) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
|
||||
}
|
||||
if (mItemCount > 0 && mSelectedPosition > 0) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performAccessibilityAction(int action, Bundle arguments) {
|
||||
if (super.performAccessibilityAction(action, arguments)) {
|
||||
return true;
|
||||
}
|
||||
switch (action) {
|
||||
case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: {
|
||||
if (mItemCount > 0 && mSelectedPosition < mItemCount - 1) {
|
||||
final int currentChildIndex = mSelectedPosition - mFirstPosition;
|
||||
return scrollToChild(currentChildIndex + 1);
|
||||
}
|
||||
} return false;
|
||||
case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: {
|
||||
if (mItemCount > 0 && mSelectedPosition > 0) {
|
||||
final int currentChildIndex = mSelectedPosition - mFirstPosition;
|
||||
return scrollToChild(currentChildIndex - 1);
|
||||
}
|
||||
} return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -739,6 +739,9 @@ public class HorizontalScrollView extends FrameLayout {
|
||||
|
||||
@Override
|
||||
public boolean performAccessibilityAction(int action, Bundle arguments) {
|
||||
if (super.performAccessibilityAction(action, arguments)) {
|
||||
return true;
|
||||
}
|
||||
switch (action) {
|
||||
case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: {
|
||||
final int viewportWidth = getWidth() - mPaddingLeft - mPaddingRight;
|
||||
@@ -757,7 +760,7 @@ public class HorizontalScrollView extends FrameLayout {
|
||||
}
|
||||
} return false;
|
||||
}
|
||||
return super.performAccessibilityAction(action, arguments);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2172,6 +2172,18 @@ public class NumberPicker extends LinearLayout {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: {
|
||||
if (getWrapSelectorWheel() || getValue() < getMaxValue()) {
|
||||
changeValueByOne(true);
|
||||
return true;
|
||||
}
|
||||
} return false;
|
||||
case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: {
|
||||
if (getWrapSelectorWheel() || getValue() > getMinValue()) {
|
||||
changeValueByOne(false);
|
||||
return true;
|
||||
}
|
||||
} return false;
|
||||
}
|
||||
} break;
|
||||
case VIRTUAL_VIEW_ID_INPUT: {
|
||||
@@ -2497,6 +2509,12 @@ public class NumberPicker extends LinearLayout {
|
||||
if (mAccessibilityFocusedView == View.NO_ID) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
|
||||
}
|
||||
if (getWrapSelectorWheel() || getValue() < getMaxValue()) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
|
||||
}
|
||||
if (getWrapSelectorWheel() || getValue() > getMinValue()) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -742,6 +742,9 @@ public class ScrollView extends FrameLayout {
|
||||
|
||||
@Override
|
||||
public boolean performAccessibilityAction(int action, Bundle arguments) {
|
||||
if (super.performAccessibilityAction(action, arguments)) {
|
||||
return true;
|
||||
}
|
||||
switch (action) {
|
||||
case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: {
|
||||
final int viewportHeight = getHeight() - mPaddingBottom - mPaddingTop;
|
||||
@@ -760,7 +763,7 @@ public class ScrollView extends FrameLayout {
|
||||
}
|
||||
} return false;
|
||||
}
|
||||
return super.performAccessibilityAction(action, arguments);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Region;
|
||||
import android.graphics.TableMaskFilter;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.InputDevice;
|
||||
@@ -1228,6 +1229,35 @@ public class StackView extends AdapterViewAnimator {
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
|
||||
super.onInitializeAccessibilityNodeInfo(info);
|
||||
info.setClassName(StackView.class.getName());
|
||||
info.setScrollable(getChildCount() > 1);
|
||||
if (getDisplayedChild() < getChildCount() - 1) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
|
||||
}
|
||||
if (getDisplayedChild() > 0) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performAccessibilityAction(int action, Bundle arguments) {
|
||||
if (super.performAccessibilityAction(action, arguments)) {
|
||||
return true;
|
||||
}
|
||||
switch (action) {
|
||||
case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: {
|
||||
if (getDisplayedChild() < getChildCount() - 1) {
|
||||
showNext();
|
||||
return true;
|
||||
}
|
||||
} return false;
|
||||
case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: {
|
||||
if (getDisplayedChild() > 0) {
|
||||
showPrevious();
|
||||
return true;
|
||||
}
|
||||
} return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
class LayoutParams extends ViewGroup.LayoutParams {
|
||||
|
||||
Reference in New Issue
Block a user