Java Code Examples for android.view.accessibility.AccessibilityEvent#setMaxScrollY()

The following examples show how to use android.view.accessibility.AccessibilityEvent#setMaxScrollY() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentViewCore.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @see View#onInitializeAccessibilityEvent(AccessibilityEvent)
 */
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    // Note: this is only used by the script-injecting accessibility code.
    event.setClassName(this.getClass().getName());

    // Identify where the top-left of the screen currently points to.
    event.setScrollX(mRenderCoordinates.getScrollXPixInt());
    event.setScrollY(mRenderCoordinates.getScrollYPixInt());

    // The maximum scroll values are determined by taking the content dimensions and
    // subtracting off the actual dimensions of the ChromeView.
    int maxScrollXPix = Math.max(0, mRenderCoordinates.getMaxHorizontalScrollPixInt());
    int maxScrollYPix = Math.max(0, mRenderCoordinates.getMaxVerticalScrollPixInt());
    event.setScrollable(maxScrollXPix > 0 || maxScrollYPix > 0);

    // Setting the maximum scroll values requires API level 15 or higher.
    final int SDK_VERSION_REQUIRED_TO_SET_SCROLL = 15;
    if (Build.VERSION.SDK_INT >= SDK_VERSION_REQUIRED_TO_SET_SCROLL) {
        event.setMaxScrollX(maxScrollXPix);
        event.setMaxScrollY(maxScrollYPix);
    }
}
 
Example 2
Source File: AnScrollView.java    From Animer with Apache License 2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(AnScrollView.class.getName());
    final boolean scrollable = getScrollRange() > 0;
    event.setScrollable(scrollable);
    event.setScrollX(getScrollX());
    event.setScrollY(getScrollY());
    if(isVertScroll()){
        event.setMaxScrollX(getScrollX());
        event.setMaxScrollY(getScrollRange());
    }
    else {
        event.setMaxScrollX(getScrollRange());
        event.setMaxScrollY(getScrollY());
    }

}
 
Example 3
Source File: PagedView.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
private void sendScrollAccessibilityEvent() {
    AccessibilityManager am =
            (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (am.isEnabled()) {
        if (mCurrentPage != getNextPage()) {
            AccessibilityEvent ev =
                    AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED);
            ev.setScrollable(true);
            ev.setScrollX(getScrollX());
            ev.setScrollY(getScrollY());
            ev.setMaxScrollX(mMaxScrollX);
            ev.setMaxScrollY(0);

            sendAccessibilityEventUnchecked(ev);
        }
    }
}
 
Example 4
Source File: ContentViewCore.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @see View#onInitializeAccessibilityEvent(AccessibilityEvent)
 */
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    // Note: this is only used by the script-injecting accessibility code.
    event.setClassName(this.getClass().getName());

    // Identify where the top-left of the screen currently points to.
    event.setScrollX(mRenderCoordinates.getScrollXPixInt());
    event.setScrollY(mRenderCoordinates.getScrollYPixInt());

    // The maximum scroll values are determined by taking the content dimensions and
    // subtracting off the actual dimensions of the ChromeView.
    int maxScrollXPix = Math.max(0, mRenderCoordinates.getMaxHorizontalScrollPixInt());
    int maxScrollYPix = Math.max(0, mRenderCoordinates.getMaxVerticalScrollPixInt());
    event.setScrollable(maxScrollXPix > 0 || maxScrollYPix > 0);

    // Setting the maximum scroll values requires API level 15 or higher.
    final int SDK_VERSION_REQUIRED_TO_SET_SCROLL = 15;
    if (Build.VERSION.SDK_INT >= SDK_VERSION_REQUIRED_TO_SET_SCROLL) {
        event.setMaxScrollX(maxScrollXPix);
        event.setMaxScrollY(maxScrollYPix);
    }
}
 
Example 5
Source File: PagedView.java    From Trebuchet with GNU General Public License v3.0 6 votes vote down vote up
private void sendScrollAccessibilityEvent() {
    AccessibilityManager am =
            (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (am.isEnabled()) {
        if (mCurrentPage != getNextPage()) {
            AccessibilityEvent ev =
                    AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED);
            ev.setScrollable(true);
            ev.setScrollX(getScrollX());
            ev.setScrollY(getScrollY());
            ev.setMaxScrollX(mMaxScrollX);
            ev.setMaxScrollY(0);

            sendAccessibilityEventUnchecked(ev);
        }
    }
}
 
Example 6
Source File: NumberPicker.java    From NewXmPluginSDK with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(NumberPicker.class.getName());
    event.setScrollable(true);
    event.setScrollY((mMinValue + mValue) * mSelectorElementHeight);
    event.setMaxScrollY((mMaxValue - mMinValue) * mSelectorElementHeight);
}
 
Example 7
Source File: BrowserAccessibilityManager.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@CalledByNative
private void setAccessibilityEventScrollAttributes(AccessibilityEvent event,
        int scrollX, int scrollY, int maxScrollX, int maxScrollY) {
    event.setScrollX(scrollX);
    event.setScrollY(scrollY);
    event.setMaxScrollX(maxScrollX);
    event.setMaxScrollY(maxScrollY);
}
 
Example 8
Source File: BrowserAccessibilityManager.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@CalledByNative
private void setAccessibilityEventScrollAttributes(AccessibilityEvent event,
        int scrollX, int scrollY, int maxScrollX, int maxScrollY) {
    event.setScrollX(scrollX);
    event.setScrollY(scrollY);
    event.setMaxScrollX(maxScrollX);
    event.setMaxScrollY(maxScrollY);
}
 
Example 9
Source File: NumberPicker.java    From zen4android with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(NumberPicker.class.getName());
    event.setScrollable(true);
    event.setScrollY((mMinValue + mValue) * mSelectorElementHeight);
    event.setMaxScrollY((mMaxValue - mMinValue) * mSelectorElementHeight);
}
 
Example 10
Source File: BrowserAccessibilityManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@CalledByNative
private void setAccessibilityEventScrollAttributes(AccessibilityEvent event,
        int scrollX, int scrollY, int maxScrollX, int maxScrollY) {
    event.setScrollX(scrollX);
    event.setScrollY(scrollY);
    event.setMaxScrollX(maxScrollX);
    event.setMaxScrollY(maxScrollY);
}
 
Example 11
Source File: TextPicker.java    From GifAssistant with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(TextPicker.class.getName());
    event.setScrollable(true);
    event.setScrollY((mMinValue + mValue) * mSelectorElementHeight);
    event.setMaxScrollY((mMaxValue - mMinValue) * mSelectorElementHeight);
}
 
Example 12
Source File: NumberPicker.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) {
    super.onInitializeAccessibilityEventInternal(event);
    event.setClassName(NumberPicker.class.getName());
    event.setScrollable(true);
    event.setScrollY((mMinValue + mValue) * mSelectorElementHeight);
    event.setMaxScrollY((mMaxValue - mMinValue) * mSelectorElementHeight);
}
 
Example 13
Source File: NumberPicker.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(NumberPicker.class.getName());
    event.setScrollable(true);
    event.setScrollY((mMinValue + mValue) * mSelectorElementHeight);
    event.setMaxScrollY((mMaxValue - mMinValue) * mSelectorElementHeight);
}
 
Example 14
Source File: NumberPicker.java    From NumberPicker with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(NumberPicker.class.getName());
    event.setScrollable(isScrollerEnabled());
    final int scroll = (mMinValue + mValue) * mSelectorElementSize;
    final int maxScroll = (mMaxValue - mMinValue) * mSelectorElementSize;
    if (isHorizontalMode()) {
        event.setScrollX(scroll);
        event.setMaxScrollX(maxScroll);
    } else {
        event.setScrollY(scroll);
        event.setMaxScrollY(maxScroll);
    }
}
 
Example 15
Source File: NumberPicker.java    From DateTimePicker with Apache License 2.0 5 votes vote down vote up
public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) {
    event.setClassName(NumberPicker.class.getName());
    event.setScrollable(true);
    event.setScrollY((mMinValue + mValue) * mSelectorElementHeight);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { // FIXME what about API 14?
        event.setMaxScrollY((mMaxValue - mMinValue) * mSelectorElementHeight);
    }
}
 
Example 16
Source File: ScrollView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) {
    super.onInitializeAccessibilityEventInternal(event);
    final boolean scrollable = getScrollRange() > 0;
    event.setScrollable(scrollable);
    event.setScrollX(mScrollX);
    event.setScrollY(mScrollY);
    event.setMaxScrollX(mScrollX);
    event.setMaxScrollY(getScrollRange());
}
 
Example 17
Source File: HorizontalScrollView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) {
    super.onInitializeAccessibilityEventInternal(event);
    event.setScrollable(getScrollRange() > 0);
    event.setScrollX(mScrollX);
    event.setScrollY(mScrollY);
    event.setMaxScrollX(getScrollRange());
    event.setMaxScrollY(mScrollY);
}