Loading core/java/android/view/View.java +7 −17 Original line number Diff line number Diff line Loading @@ -4003,10 +4003,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal event.setEnabled(isEnabled()); event.setContentDescription(mContentDescription); final int eventType = event.getEventType(); switch (eventType) { case AccessibilityEvent.TYPE_VIEW_FOCUSED: { if (mAttachInfo != null) { if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED && mAttachInfo != null) { ArrayList<View> focusablesTempList = mAttachInfo.mFocusablesTempList; getRootView().addFocusables(focusablesTempList, View.FOCUS_FORWARD, FOCUSABLES_ALL); Loading @@ -4014,13 +4011,6 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal event.setCurrentItemIndex(focusablesTempList.indexOf(this)); focusablesTempList.clear(); } } break; case AccessibilityEvent.TYPE_VIEW_SCROLLED: { event.setScrollX(mScrollX); event.setScrollY(mScrollY); event.setItemCount(getHeight()); } break; } } /** Loading core/java/android/view/accessibility/AccessibilityEvent.java +74 −11 Original line number Diff line number Diff line Loading @@ -79,6 +79,16 @@ import java.util.List; * <li>{@link #isPassword()} - Whether the source is password.</li> * <li>{@link #isChecked()} - Whether the source is checked.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * </p> * <p> Loading @@ -97,6 +107,16 @@ import java.util.List; * <li>{@link #isPassword()} - Whether the source is password.</li> * <li>{@link #isChecked()} - Whether the source is checked.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * </p> * <p> Loading @@ -117,6 +137,16 @@ import java.util.List; * <li>{@link #getItemCount()} - The number of selectable items of the source.</li> * <li>{@link #getCurrentItemIndex()} - The currently selected item index.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * </p> * <p> Loading @@ -137,6 +167,16 @@ import java.util.List; * <li>{@link #getItemCount()} - The number of focusable items on the screen.</li> * <li>{@link #getCurrentItemIndex()} - The currently focused item index.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * </p> * <p> Loading Loading @@ -218,18 +258,17 @@ import java.util.List; * <li>{@link #getEventTime()} - The event time.</li> * <li>{@link #getText()} - The text of the source's sub-tree.</li> * <li>{@link #isEnabled()} - Whether the source is enabled.</li> * <li>{@link #getScrollX()} - The horizontal offset of the source * (without descendants of AdapterView)).</li> * <li>{@link #getScrollY()} - The vertical offset of the source * (without descendants of AdapterView)).</li> * <li>{@link #getFromIndex()} - The index of the first visible item of the source * (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The index of the last visible item of the source * (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source (for descendants of AdapterView) * or the height of the source in pixels (all other cases).</li> * <li>{@link #getText()} - Text for providing more context.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * <em>Note:</em> This event type is not dispatched to descendants though * {@link android.view.View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) Loading Loading @@ -334,6 +373,16 @@ import java.util.List; * <li>{@link #getText()} - The text of the source's sub-tree.</li> * <li>{@link #isEnabled()} - Whether the source is enabled.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * </p> * <b>View hover exit</b> - represents the event of stopping to hover Loading @@ -350,6 +399,16 @@ import java.util.List; * <li>{@link #getText()} - The text of the source's sub-tree.</li> * <li>{@link #isEnabled()} - Whether the source is enabled.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * </p> * <p> Loading Loading @@ -816,6 +875,8 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par record.mToIndex = parcel.readInt(); record.mScrollX = parcel.readInt(); record.mScrollY = parcel.readInt(); record.mMaxScrollX = parcel.readInt(); record.mMaxScrollY = parcel.readInt(); record.mAddedCount = parcel.readInt(); record.mRemovedCount = parcel.readInt(); record.mClassName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel); Loading Loading @@ -868,6 +929,8 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par parcel.writeInt(record.mToIndex); parcel.writeInt(record.mScrollX); parcel.writeInt(record.mScrollY); parcel.writeInt(record.mMaxScrollX); parcel.writeInt(record.mMaxScrollY); parcel.writeInt(record.mAddedCount); parcel.writeInt(record.mRemovedCount); TextUtils.writeToParcel(record.mClassName, parcel, flags); Loading core/java/android/view/accessibility/AccessibilityRecord.java +61 −8 Original line number Diff line number Diff line Loading @@ -73,6 +73,8 @@ public class AccessibilityRecord { int mToIndex = UNDEFINED; int mScrollX = UNDEFINED; int mScrollY = UNDEFINED; int mMaxScrollX = UNDEFINED; int mMaxScrollY = UNDEFINED; int mAddedCount= UNDEFINED; int mRemovedCount = UNDEFINED; Loading Loading @@ -348,18 +350,18 @@ public class AccessibilityRecord { } /** * Gets the scroll position of the source along the X axis. * Gets the scroll offset of the source left edge in pixels. * * @return The scroll along the X axis. * @return The scroll. */ public int getScrollX() { return mScrollX; } /** * Sets the scroll position of the source along the X axis. * Sets the scroll offset of the source left edge in pixels. * * @param scrollX The scroll along the X axis. * @param scrollX The scroll. */ public void setScrollX(int scrollX) { enforceNotSealed(); Loading @@ -367,24 +369,69 @@ public class AccessibilityRecord { } /** * Gets the scroll position of the source along the Y axis. * Gets the scroll offset of the source top edge in pixels. * * @return The scroll along the Y axis. * @return The scroll. */ public int getScrollY() { return mScrollY; } /** * Sets the scroll position of the source along the Y axis. * Sets the scroll offset of the source top edge in pixels. * * @param scrollY The scroll along the Y axis. * @param scrollY The scroll. */ public void setScrollY(int scrollY) { enforceNotSealed(); mScrollY = scrollY; } /** * Gets the max scroll offset of the source left edge in pixels. * * @return The max scroll. * * @hide */ public int getMaxScrollX() { return mMaxScrollX; } /** * Sets the max scroll offset of the source left edge in pixels. * * @param maxScrollX The max scroll. * * @hide */ public void setMaxScrollX(int maxScrollX) { enforceNotSealed(); mMaxScrollX = maxScrollX; } /** * Gets the max scroll offset of the source top edge in pixels. * * @return The max scroll. * * @hide */ public int getMaxScrollY() { return mMaxScrollY; } /** * Sets the max scroll offset of the source top edge in pixels. * * @param maxScrollY The max scroll. * * @hide */ public void setMaxScrollY(int maxScrollY) { enforceNotSealed(); mMaxScrollY = maxScrollY; } /** * Gets the number of added characters. * Loading Loading @@ -658,6 +705,8 @@ public class AccessibilityRecord { mToIndex = record.mToIndex; mScrollX = record.mScrollX; mScrollY = record.mScrollY; mMaxScrollX = record.mMaxScrollX; mMaxScrollY = record.mMaxScrollY; mAddedCount = record.mAddedCount; mRemovedCount = record.mRemovedCount; mClassName = record.mClassName; Loading @@ -682,6 +731,8 @@ public class AccessibilityRecord { mToIndex = UNDEFINED; mScrollX = UNDEFINED; mScrollY = UNDEFINED; mMaxScrollX = UNDEFINED; mMaxScrollY = UNDEFINED; mAddedCount = UNDEFINED; mRemovedCount = UNDEFINED; mClassName = null; Loading Loading @@ -711,6 +762,8 @@ public class AccessibilityRecord { builder.append("; ToIndex: " + mToIndex); builder.append("; ScrollX: " + mScrollX); builder.append("; ScrollY: " + mScrollY); builder.append("; MaxScrollX: " + mMaxScrollX); builder.append("; MaxScrollY: " + mMaxScrollY); builder.append("; AddedCount: " + mAddedCount); builder.append("; RemovedCount: " + mRemovedCount); builder.append("; ParcelableData: " + mParcelableData); Loading core/java/android/webkit/WebView.java +27 −0 Original line number Diff line number Diff line Loading @@ -77,7 +77,9 @@ import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.ViewParent; import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityNodeInfo; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; Loading Loading @@ -1302,6 +1304,31 @@ public class WebView extends AbsoluteLayout } } @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); info.setScrollable(isScrollableForAccessibility()); } @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setScrollable(isScrollableForAccessibility()); event.setScrollX(mScrollX); event.setScrollY(mScrollY); final int convertedContentWidth = contentToViewX(getContentWidth()); final int adjustedViewWidth = getWidth() - mPaddingLeft - mPaddingRight; event.setMaxScrollX(Math.max(convertedContentWidth - adjustedViewWidth, 0)); final int convertedContentHeight = contentToViewY(getContentHeight()); final int adjustedViewHeight = getHeight() - mPaddingTop - mPaddingBottom; event.setMaxScrollY(Math.max(convertedContentHeight - adjustedViewHeight, 0)); } private boolean isScrollableForAccessibility() { return (contentToViewX(getContentWidth()) > getWidth() - mPaddingLeft - mPaddingRight || contentToViewY(getContentHeight()) > getHeight() - mPaddingTop - mPaddingBottom); } @Override public void setOverScrollMode(int mode) { super.setOverScrollMode(mode); Loading core/java/android/widget/AbsListView.java +6 −22 Original line number Diff line number Diff line Loading @@ -1269,41 +1269,25 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te onScrollChanged(0, 0, 0, 0); // dummy values, View's implementation does not use these. } @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); info.setScrollable(true); } @Override public void sendAccessibilityEvent(int eventType) { // Since this class calls onScrollChanged even if the mFirstPosition and the // child count have not changed we will avoid sending duplicate accessibility // events. if (eventType == AccessibilityEvent.TYPE_VIEW_SCROLLED) { final int lastPosition = mFirstPosition + getChildCount(); if (mLastAccessibilityScrollEventFromIndex == mFirstPosition && mLastAccessibilityScrollEventToIndex == lastPosition) { final int firstVisiblePosition = getFirstVisiblePosition(); final int lastVisiblePosition = getLastVisiblePosition(); if (mLastAccessibilityScrollEventFromIndex == firstVisiblePosition && mLastAccessibilityScrollEventToIndex == lastVisiblePosition) { return; } else { mLastAccessibilityScrollEventFromIndex = mFirstPosition; mLastAccessibilityScrollEventToIndex = lastPosition; mLastAccessibilityScrollEventFromIndex = firstVisiblePosition; mLastAccessibilityScrollEventToIndex = lastVisiblePosition; } } super.sendAccessibilityEvent(eventType); } @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setScrollable(true); if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) { event.setFromIndex(mFirstPosition); event.setToIndex(mFirstPosition + getChildCount()); event.setItemCount(mItemCount); } } /** * Indicates whether the children's drawing cache is used during a scroll. * By default, the drawing cache is enabled but this will consume more memory. Loading Loading
core/java/android/view/View.java +7 −17 Original line number Diff line number Diff line Loading @@ -4003,10 +4003,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal event.setEnabled(isEnabled()); event.setContentDescription(mContentDescription); final int eventType = event.getEventType(); switch (eventType) { case AccessibilityEvent.TYPE_VIEW_FOCUSED: { if (mAttachInfo != null) { if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED && mAttachInfo != null) { ArrayList<View> focusablesTempList = mAttachInfo.mFocusablesTempList; getRootView().addFocusables(focusablesTempList, View.FOCUS_FORWARD, FOCUSABLES_ALL); Loading @@ -4014,13 +4011,6 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal event.setCurrentItemIndex(focusablesTempList.indexOf(this)); focusablesTempList.clear(); } } break; case AccessibilityEvent.TYPE_VIEW_SCROLLED: { event.setScrollX(mScrollX); event.setScrollY(mScrollY); event.setItemCount(getHeight()); } break; } } /** Loading
core/java/android/view/accessibility/AccessibilityEvent.java +74 −11 Original line number Diff line number Diff line Loading @@ -79,6 +79,16 @@ import java.util.List; * <li>{@link #isPassword()} - Whether the source is password.</li> * <li>{@link #isChecked()} - Whether the source is checked.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * </p> * <p> Loading @@ -97,6 +107,16 @@ import java.util.List; * <li>{@link #isPassword()} - Whether the source is password.</li> * <li>{@link #isChecked()} - Whether the source is checked.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * </p> * <p> Loading @@ -117,6 +137,16 @@ import java.util.List; * <li>{@link #getItemCount()} - The number of selectable items of the source.</li> * <li>{@link #getCurrentItemIndex()} - The currently selected item index.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * </p> * <p> Loading @@ -137,6 +167,16 @@ import java.util.List; * <li>{@link #getItemCount()} - The number of focusable items on the screen.</li> * <li>{@link #getCurrentItemIndex()} - The currently focused item index.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * </p> * <p> Loading Loading @@ -218,18 +258,17 @@ import java.util.List; * <li>{@link #getEventTime()} - The event time.</li> * <li>{@link #getText()} - The text of the source's sub-tree.</li> * <li>{@link #isEnabled()} - Whether the source is enabled.</li> * <li>{@link #getScrollX()} - The horizontal offset of the source * (without descendants of AdapterView)).</li> * <li>{@link #getScrollY()} - The vertical offset of the source * (without descendants of AdapterView)).</li> * <li>{@link #getFromIndex()} - The index of the first visible item of the source * (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The index of the last visible item of the source * (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source (for descendants of AdapterView) * or the height of the source in pixels (all other cases).</li> * <li>{@link #getText()} - Text for providing more context.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * <em>Note:</em> This event type is not dispatched to descendants though * {@link android.view.View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) Loading Loading @@ -334,6 +373,16 @@ import java.util.List; * <li>{@link #getText()} - The text of the source's sub-tree.</li> * <li>{@link #isEnabled()} - Whether the source is enabled.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * </p> * <b>View hover exit</b> - represents the event of stopping to hover Loading @@ -350,6 +399,16 @@ import java.util.List; * <li>{@link #getText()} - The text of the source's sub-tree.</li> * <li>{@link #isEnabled()} - Whether the source is enabled.</li> * <li>{@link #getContentDescription()} - The content description of the source.</li> * <li>{@link #getScrollX()} - The offset of the source left edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getScrollY()} - The offset of the source top edge in pixels * (without descendants of AdapterView).</li> * <li>{@link #getFromIndex()} - The zero based index of the first visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getToIndex()} - The zero based index of the last visible item of the source, * inclusive (for descendants of AdapterView).</li> * <li>{@link #getItemCount()} - The total items of the source * (for descendants of AdapterView).</li> * </ul> * </p> * <p> Loading Loading @@ -816,6 +875,8 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par record.mToIndex = parcel.readInt(); record.mScrollX = parcel.readInt(); record.mScrollY = parcel.readInt(); record.mMaxScrollX = parcel.readInt(); record.mMaxScrollY = parcel.readInt(); record.mAddedCount = parcel.readInt(); record.mRemovedCount = parcel.readInt(); record.mClassName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel); Loading Loading @@ -868,6 +929,8 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par parcel.writeInt(record.mToIndex); parcel.writeInt(record.mScrollX); parcel.writeInt(record.mScrollY); parcel.writeInt(record.mMaxScrollX); parcel.writeInt(record.mMaxScrollY); parcel.writeInt(record.mAddedCount); parcel.writeInt(record.mRemovedCount); TextUtils.writeToParcel(record.mClassName, parcel, flags); Loading
core/java/android/view/accessibility/AccessibilityRecord.java +61 −8 Original line number Diff line number Diff line Loading @@ -73,6 +73,8 @@ public class AccessibilityRecord { int mToIndex = UNDEFINED; int mScrollX = UNDEFINED; int mScrollY = UNDEFINED; int mMaxScrollX = UNDEFINED; int mMaxScrollY = UNDEFINED; int mAddedCount= UNDEFINED; int mRemovedCount = UNDEFINED; Loading Loading @@ -348,18 +350,18 @@ public class AccessibilityRecord { } /** * Gets the scroll position of the source along the X axis. * Gets the scroll offset of the source left edge in pixels. * * @return The scroll along the X axis. * @return The scroll. */ public int getScrollX() { return mScrollX; } /** * Sets the scroll position of the source along the X axis. * Sets the scroll offset of the source left edge in pixels. * * @param scrollX The scroll along the X axis. * @param scrollX The scroll. */ public void setScrollX(int scrollX) { enforceNotSealed(); Loading @@ -367,24 +369,69 @@ public class AccessibilityRecord { } /** * Gets the scroll position of the source along the Y axis. * Gets the scroll offset of the source top edge in pixels. * * @return The scroll along the Y axis. * @return The scroll. */ public int getScrollY() { return mScrollY; } /** * Sets the scroll position of the source along the Y axis. * Sets the scroll offset of the source top edge in pixels. * * @param scrollY The scroll along the Y axis. * @param scrollY The scroll. */ public void setScrollY(int scrollY) { enforceNotSealed(); mScrollY = scrollY; } /** * Gets the max scroll offset of the source left edge in pixels. * * @return The max scroll. * * @hide */ public int getMaxScrollX() { return mMaxScrollX; } /** * Sets the max scroll offset of the source left edge in pixels. * * @param maxScrollX The max scroll. * * @hide */ public void setMaxScrollX(int maxScrollX) { enforceNotSealed(); mMaxScrollX = maxScrollX; } /** * Gets the max scroll offset of the source top edge in pixels. * * @return The max scroll. * * @hide */ public int getMaxScrollY() { return mMaxScrollY; } /** * Sets the max scroll offset of the source top edge in pixels. * * @param maxScrollY The max scroll. * * @hide */ public void setMaxScrollY(int maxScrollY) { enforceNotSealed(); mMaxScrollY = maxScrollY; } /** * Gets the number of added characters. * Loading Loading @@ -658,6 +705,8 @@ public class AccessibilityRecord { mToIndex = record.mToIndex; mScrollX = record.mScrollX; mScrollY = record.mScrollY; mMaxScrollX = record.mMaxScrollX; mMaxScrollY = record.mMaxScrollY; mAddedCount = record.mAddedCount; mRemovedCount = record.mRemovedCount; mClassName = record.mClassName; Loading @@ -682,6 +731,8 @@ public class AccessibilityRecord { mToIndex = UNDEFINED; mScrollX = UNDEFINED; mScrollY = UNDEFINED; mMaxScrollX = UNDEFINED; mMaxScrollY = UNDEFINED; mAddedCount = UNDEFINED; mRemovedCount = UNDEFINED; mClassName = null; Loading Loading @@ -711,6 +762,8 @@ public class AccessibilityRecord { builder.append("; ToIndex: " + mToIndex); builder.append("; ScrollX: " + mScrollX); builder.append("; ScrollY: " + mScrollY); builder.append("; MaxScrollX: " + mMaxScrollX); builder.append("; MaxScrollY: " + mMaxScrollY); builder.append("; AddedCount: " + mAddedCount); builder.append("; RemovedCount: " + mRemovedCount); builder.append("; ParcelableData: " + mParcelableData); Loading
core/java/android/webkit/WebView.java +27 −0 Original line number Diff line number Diff line Loading @@ -77,7 +77,9 @@ import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.ViewParent; import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityNodeInfo; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; Loading Loading @@ -1302,6 +1304,31 @@ public class WebView extends AbsoluteLayout } } @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); info.setScrollable(isScrollableForAccessibility()); } @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setScrollable(isScrollableForAccessibility()); event.setScrollX(mScrollX); event.setScrollY(mScrollY); final int convertedContentWidth = contentToViewX(getContentWidth()); final int adjustedViewWidth = getWidth() - mPaddingLeft - mPaddingRight; event.setMaxScrollX(Math.max(convertedContentWidth - adjustedViewWidth, 0)); final int convertedContentHeight = contentToViewY(getContentHeight()); final int adjustedViewHeight = getHeight() - mPaddingTop - mPaddingBottom; event.setMaxScrollY(Math.max(convertedContentHeight - adjustedViewHeight, 0)); } private boolean isScrollableForAccessibility() { return (contentToViewX(getContentWidth()) > getWidth() - mPaddingLeft - mPaddingRight || contentToViewY(getContentHeight()) > getHeight() - mPaddingTop - mPaddingBottom); } @Override public void setOverScrollMode(int mode) { super.setOverScrollMode(mode); Loading
core/java/android/widget/AbsListView.java +6 −22 Original line number Diff line number Diff line Loading @@ -1269,41 +1269,25 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te onScrollChanged(0, 0, 0, 0); // dummy values, View's implementation does not use these. } @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); info.setScrollable(true); } @Override public void sendAccessibilityEvent(int eventType) { // Since this class calls onScrollChanged even if the mFirstPosition and the // child count have not changed we will avoid sending duplicate accessibility // events. if (eventType == AccessibilityEvent.TYPE_VIEW_SCROLLED) { final int lastPosition = mFirstPosition + getChildCount(); if (mLastAccessibilityScrollEventFromIndex == mFirstPosition && mLastAccessibilityScrollEventToIndex == lastPosition) { final int firstVisiblePosition = getFirstVisiblePosition(); final int lastVisiblePosition = getLastVisiblePosition(); if (mLastAccessibilityScrollEventFromIndex == firstVisiblePosition && mLastAccessibilityScrollEventToIndex == lastVisiblePosition) { return; } else { mLastAccessibilityScrollEventFromIndex = mFirstPosition; mLastAccessibilityScrollEventToIndex = lastPosition; mLastAccessibilityScrollEventFromIndex = firstVisiblePosition; mLastAccessibilityScrollEventToIndex = lastVisiblePosition; } } super.sendAccessibilityEvent(eventType); } @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setScrollable(true); if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) { event.setFromIndex(mFirstPosition); event.setToIndex(mFirstPosition + getChildCount()); event.setItemCount(mItemCount); } } /** * Indicates whether the children's drawing cache is used during a scroll. * By default, the drawing cache is enabled but this will consume more memory. Loading