Merge "Fixing issue where we were adding text to each scroll event. (Bug: 5328362)"
This commit is contained in:
@@ -39,6 +39,7 @@ import android.view.ViewConfiguration;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewParent;
|
import android.view.ViewParent;
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
|
import android.view.accessibility.AccessibilityManager;
|
||||||
import android.view.accessibility.AccessibilityNodeInfo;
|
import android.view.accessibility.AccessibilityNodeInfo;
|
||||||
import android.view.animation.Interpolator;
|
import android.view.animation.Interpolator;
|
||||||
import android.widget.Checkable;
|
import android.widget.Checkable;
|
||||||
@@ -402,6 +403,14 @@ public abstract class PagedView extends ViewGroup {
|
|||||||
if (mTouchState == TOUCH_STATE_REST) {
|
if (mTouchState == TOUCH_STATE_REST) {
|
||||||
pageEndMoving();
|
pageEndMoving();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notify the user when the page changes
|
||||||
|
if (AccessibilityManager.getInstance(getContext()).isEnabled()) {
|
||||||
|
AccessibilityEvent ev =
|
||||||
|
AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED);
|
||||||
|
ev.getText().add(getCurrentPageDescription());
|
||||||
|
sendAccessibilityEventUnchecked(ev);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -1860,27 +1869,6 @@ public abstract class PagedView extends ViewGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
|
|
||||||
// Do not append text content to scroll events they are fired frequently
|
|
||||||
// and the client has already received another event type with the text.
|
|
||||||
if (event.getEventType() != AccessibilityEvent.TYPE_VIEW_SCROLLED) {
|
|
||||||
super.dispatchPopulateAccessibilityEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
onPopulateAccessibilityEvent(event);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
|
|
||||||
super.onPopulateAccessibilityEvent(event);
|
|
||||||
|
|
||||||
if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
|
|
||||||
event.getText().add(getCurrentPageDescription());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getCurrentPageDescription() {
|
protected String getCurrentPageDescription() {
|
||||||
int page = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
|
int page = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
|
||||||
return String.format(mContext.getString(R.string.default_scroll_format),
|
return String.format(mContext.getString(R.string.default_scroll_format),
|
||||||
|
|||||||
Reference in New Issue
Block a user