Java Code Examples for android.view.accessibility.AccessibilityNodeInfo#setPackageName()

The following examples show how to use android.view.accessibility.AccessibilityNodeInfo#setPackageName() . 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: DrawerLayout.java    From Dashchan with Apache License 2.0 7 votes vote down vote up
/**
 * This should really be in AccessibilityNodeInfoCompat, but there unfortunately
 * seem to be a few elements that are not easily cloneable using the underlying API.
 * Leave it private here as it's not general-purpose useful.
 */
private void copyNodeInfoNoChildren(AccessibilityNodeInfo dest, AccessibilityNodeInfo src) {
	final Rect rect = mTmpRect;

	src.getBoundsInParent(rect);
	dest.setBoundsInParent(rect);

	src.getBoundsInScreen(rect);
	dest.setBoundsInScreen(rect);

	dest.setVisibleToUser(src.isVisibleToUser());
	dest.setPackageName(src.getPackageName());
	dest.setClassName(src.getClassName());
	dest.setContentDescription(src.getContentDescription());

	dest.setEnabled(src.isEnabled());
	dest.setClickable(src.isClickable());
	dest.setFocusable(src.isFocusable());
	dest.setFocused(src.isFocused());
	dest.setAccessibilityFocused(src.isAccessibilityFocused());
	dest.setSelected(src.isSelected());
	dest.setLongClickable(src.isLongClickable());

	dest.addAction(src.getActions());
}
 
Example 2
Source File: CustomVirtualViewCompatMode.java    From input-samples with Apache License 2.0 6 votes vote down vote up
private AccessibilityNodeInfo onProvideAutofillCompatModeAccessibilityNodeInfo() {
    final AccessibilityNodeInfo node = AccessibilityNodeInfo.obtain();

    final String packageName = getContext().getPackageName();
    node.setPackageName(packageName);
    node.setClassName(getClass().getName());

    final int childrenSize = mVirtualViews.size();
    for (int i = 0; i < childrenSize; i++) {
        final Item item = mVirtualViews.valueAt(i);
        if (DEBUG) {
            Log.d(TAG, "Adding new A11Y child with id " + item.id + ": " + item);
        }
        node.addChild(this, item.id);
    }
    return node;
}
 
Example 3
Source File: BrowserAccessibilityManager.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @see AccessibilityNodeProvider#createAccessibilityNodeInfo(int)
 */
protected AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
    if (!mAccessibilityManager.isEnabled() || mNativeObj == 0 || !mFrameInfoInitialized) {
        return null;
    }

    int rootId = nativeGetRootId(mNativeObj);
    if (virtualViewId == View.NO_ID) {
        virtualViewId = rootId;
    }
    if (mAccessibilityFocusId == View.NO_ID) {
        mAccessibilityFocusId = rootId;
    }

    final AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(mView);
    info.setPackageName(mContentViewCore.getContext().getPackageName());
    info.setSource(mView, virtualViewId);

    if (nativePopulateAccessibilityNodeInfo(mNativeObj, info, virtualViewId)) {
        return info;
    } else {
        return null;
    }
}
 
Example 4
Source File: BrowserAccessibilityManager.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @see AccessibilityNodeProvider#createAccessibilityNodeInfo(int)
 */
protected AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
    if (!mAccessibilityManager.isEnabled() || mNativeObj == 0 || !mFrameInfoInitialized) {
        return null;
    }

    int rootId = nativeGetRootId(mNativeObj);
    if (virtualViewId == View.NO_ID) {
        virtualViewId = rootId;
    }
    if (mAccessibilityFocusId == View.NO_ID) {
        mAccessibilityFocusId = rootId;
    }

    final AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(mView);
    info.setPackageName(mContentViewCore.getContext().getPackageName());
    info.setSource(mView, virtualViewId);

    if (nativePopulateAccessibilityNodeInfo(mNativeObj, info, virtualViewId)) {
        return info;
    } else {
        return null;
    }
}
 
Example 5
Source File: CustomVirtualViewCompatMode.java    From android-AutofillFramework with Apache License 2.0 6 votes vote down vote up
private AccessibilityNodeInfo onProvideAutofillCompatModeAccessibilityNodeInfo() {
    final AccessibilityNodeInfo node = AccessibilityNodeInfo.obtain();

    final String packageName = getContext().getPackageName();
    node.setPackageName(packageName);
    node.setClassName(getClass().getName());

    final int childrenSize = mVirtualViews.size();
    for (int i = 0; i < childrenSize; i++) {
        final Item item = mVirtualViews.valueAt(i);
        if (DEBUG) {
            Log.d(TAG, "Adding new A11Y child with id " + item.id + ": " + item);
        }
        node.addChild(this, item.id);
    }
    return node;
}
 
Example 6
Source File: AbstractCustomVirtualView.java    From android-AutofillFramework with Apache License 2.0 6 votes vote down vote up
protected AccessibilityNodeInfo provideAccessibilityNodeInfo(View parent, Context context) {
    final AccessibilityNodeInfo node = AccessibilityNodeInfo.obtain();
    node.setSource(parent, id);
    node.setPackageName(context.getPackageName());
    node.setClassName(getClassName());
    node.setEditable(editable);
    node.setViewIdResourceName(idEntry);
    node.setVisibleToUser(true);
    final Rect absBounds = line.getAbsCoordinates();
    if (absBounds != null) {
        node.setBoundsInScreen(absBounds);
    }
    if (TextUtils.getTrimmedLength(text) > 0) {
        // TODO: Must checked trimmed length because input fields use 8 empty spaces to
        // set width
        node.setText(text);
    }
    return node;
}
 
Example 7
Source File: AbstractCustomVirtualView.java    From input-samples with Apache License 2.0 6 votes vote down vote up
protected AccessibilityNodeInfo provideAccessibilityNodeInfo(View parent, Context context) {
    final AccessibilityNodeInfo node = AccessibilityNodeInfo.obtain();
    node.setSource(parent, id);
    node.setPackageName(context.getPackageName());
    node.setClassName(getClassName());
    node.setEditable(editable);
    node.setViewIdResourceName(idEntry);
    node.setVisibleToUser(true);
    final Rect absBounds = line.getAbsCoordinates();
    if (absBounds != null) {
        node.setBoundsInScreen(absBounds);
    }
    if (TextUtils.getTrimmedLength(text) > 0) {
        // TODO: Must checked trimmed length because input fields use 8 empty spaces to
        // set width
        node.setText(text);
    }
    return node;
}
 
Example 8
Source File: MaterialTapTargetPrompt.java    From MaterialTapTargetPrompt with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info)
{
    super.onInitializeAccessibilityNodeInfo(host, info);

    @Nullable final Package viewPackage = PromptView.this.getClass().getPackage();
    if (viewPackage != null)
    {
        info.setPackageName(viewPackage.getName());
    }
    info.setSource(host);
    info.setClickable(true);
    info.setEnabled(true);
    info.setChecked(false);
    info.setFocusable(true);
    info.setFocused(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
    {
        info.setLabelFor(mPromptOptions.getTargetView());
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
    {
        info.setDismissable(true);
    }

    info.setContentDescription(mPromptOptions.getContentDescription());
    info.setText(mPromptOptions.getContentDescription());
}
 
Example 9
Source File: NumberPicker.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
private AccessibilityNodeInfo createAccessibilityNodeInfoForVirtualButton(int virtualViewId,
        String text, int left, int top, int right, int bottom) {
    AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
    info.setClassName(Button.class.getName());
    info.setPackageName(getContext().getPackageName());
    info.setSource(NumberPicker.this, virtualViewId);
    info.setParent(NumberPicker.this);
    info.setText(text);
    info.setClickable(true);
    info.setLongClickable(true);
    info.setEnabled(NumberPicker.this.isEnabled());
    Rect boundsInParent = mTempRect;
    boundsInParent.set(left, top, right, bottom);
    // info.setVisibleToUser(isVisibleToUser(boundsInParent));
    info.setBoundsInParent(boundsInParent);
    Rect boundsInScreen = boundsInParent;
    int[] locationOnScreen = mTempArray;
    getLocationOnScreen(locationOnScreen);
    boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
    info.setBoundsInScreen(boundsInScreen);

    if (mAccessibilityFocusedView != virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
    }
    if (mAccessibilityFocusedView == virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    }
    if (NumberPicker.this.isEnabled()) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
    }

    return info;
}
 
Example 10
Source File: NumberPicker.java    From NewXmPluginSDK with Apache License 2.0 5 votes vote down vote up
private AccessibilityNodeInfo createAccessibilityNodeInfoForVirtualButton(int virtualViewId,
        String text, int left, int top, int right, int bottom) {
    AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
    info.setClassName(Button.class.getName());
    info.setPackageName(getContext().getPackageName());
    info.setSource(NumberPicker.this, virtualViewId);
    info.setParent(NumberPicker.this);
    info.setText(text);
    info.setClickable(true);
    info.setLongClickable(true);
    info.setEnabled(NumberPicker.this.isEnabled());
    Rect boundsInParent = mTempRect;
    boundsInParent.set(left, top, right, bottom);
    info.setVisibleToUser(getVisibility() == View.VISIBLE);
    info.setBoundsInParent(boundsInParent);
    Rect boundsInScreen = boundsInParent;
    int[] locationOnScreen = mTempArray;
    getLocationOnScreen(locationOnScreen);
    boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
    info.setBoundsInScreen(boundsInScreen);

    if (mAccessibilityFocusedView != virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
    }
    if (mAccessibilityFocusedView == virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    }
    if (NumberPicker.this.isEnabled()) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
    }

    return info;
}
 
Example 11
Source File: UiAutomationElement.java    From appium-uiautomator2-server with Apache License 2.0 5 votes vote down vote up
private void addToastMsgToRoot(CharSequence tokenMSG) {
    AccessibilityNodeInfo node = AccessibilityNodeInfo.obtain();
    node.setText(tokenMSG);
    node.setClassName(Toast.class.getName());
    node.setPackageName("com.android.settings");
    setField("mSealed", true, node);

    this.children.add(new UiAutomationElement(node, this.children.size()));
}
 
Example 12
Source File: TextPicker.java    From GifAssistant with Apache License 2.0 5 votes vote down vote up
private AccessibilityNodeInfo createAccessibilityNodeInfoForVirtualButton(int virtualViewId,
                                                                          String text, int left, int top, int right, int bottom) {
    AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
    info.setClassName(Button.class.getName());
    info.setPackageName(getContext().getPackageName());
    info.setSource(TextPicker.this, virtualViewId);
    info.setParent(TextPicker.this);
    info.setText(text);
    info.setClickable(true);
    info.setLongClickable(true);
    info.setEnabled(TextPicker.this.isEnabled());
    Rect boundsInParent = mTempRect;
    boundsInParent.set(left, top, right, bottom);
    // TODO info.setVisibleToUser(isVisibleToUser(boundsInParent));
    info.setBoundsInParent(boundsInParent);
    Rect boundsInScreen = boundsInParent;
    int[] locationOnScreen = mTempArray;
    getLocationOnScreen(locationOnScreen);
    boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
    info.setBoundsInScreen(boundsInScreen);

    if (mAccessibilityFocusedView != virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
    }
    if (mAccessibilityFocusedView == virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    }
    if (TextPicker.this.isEnabled()) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
    }

    return info;
}
 
Example 13
Source File: BrowserAccessibilityManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @see AccessibilityNodeProvider#createAccessibilityNodeInfo(int)
 */
protected AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
    if (!mAccessibilityManager.isEnabled() || mNativeObj == 0) {
        return null;
    }
    int rootId = nativeGetRootId(mNativeObj);

    if (virtualViewId == View.NO_ID) {
        return createNodeForHost(rootId);
    }

    if (!isFrameInfoInitialized()) {
        return null;
    }

    final AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(mView);
    info.setPackageName(mContentViewCore.getContext().getPackageName());
    info.setSource(mView, virtualViewId);

    if (virtualViewId == rootId) {
        info.setParent(mView);
    }

    if (nativePopulateAccessibilityNodeInfo(mNativeObj, info, virtualViewId)) {
        return info;
    } else {
        info.recycle();
        return null;
    }
}
 
Example 14
Source File: NumberPicker.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private AccessibilityNodeInfo createAccessibilityNodeInfoForVirtualButton(int virtualViewId,
        String text, int left, int top, int right, int bottom) {
    AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
    info.setClassName(Button.class.getName());
    info.setPackageName(mContext.getPackageName());
    info.setSource(NumberPicker.this, virtualViewId);
    info.setParent(NumberPicker.this);
    info.setText(text);
    info.setClickable(true);
    info.setLongClickable(true);
    info.setEnabled(NumberPicker.this.isEnabled());
    Rect boundsInParent = mTempRect;
    boundsInParent.set(left, top, right, bottom);
    info.setVisibleToUser(isVisibleToUser(boundsInParent));
    info.setBoundsInParent(boundsInParent);
    Rect boundsInScreen = boundsInParent;
    int[] locationOnScreen = mTempArray;
    getLocationOnScreen(locationOnScreen);
    boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
    info.setBoundsInScreen(boundsInScreen);

    if (mAccessibilityFocusedView != virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
    }
    if (mAccessibilityFocusedView == virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    }
    if (NumberPicker.this.isEnabled()) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
    }

    return info;
}
 
Example 15
Source File: NumberPicker.java    From zen4android with MIT License 5 votes vote down vote up
private AccessibilityNodeInfo createAccessibilityNodeInfoForVirtualButton(int virtualViewId,
        String text, int left, int top, int right, int bottom) {
    AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
    info.setClassName(Button.class.getName());
    info.setPackageName(getContext().getPackageName());
    info.setSource(NumberPicker.this, virtualViewId);
    info.setParent(NumberPicker.this);
    info.setText(text);
    info.setClickable(true);
    info.setLongClickable(true);
    info.setEnabled(NumberPicker.this.isEnabled());
    Rect boundsInParent = mTempRect;
    boundsInParent.set(left, top, right, bottom);
    // TODO info.setVisibleToUser(isVisibleToUser(boundsInParent));
    info.setBoundsInParent(boundsInParent);
    Rect boundsInScreen = boundsInParent;
    int[] locationOnScreen = mTempArray;
    getLocationOnScreen(locationOnScreen);
    boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
    info.setBoundsInScreen(boundsInScreen);

    if (mAccessibilityFocusedView != virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
    }
    if (mAccessibilityFocusedView == virtualViewId) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    }
    if (NumberPicker.this.isEnabled()) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
    }

    return info;
}
 
Example 16
Source File: NumberPicker.java    From ticdesign with Apache License 2.0 4 votes vote down vote up
private AccessibilityNodeInfo createAccessibilityNodeInfoForNumberPicker(int left, int top,
                int right, int bottom) {
            AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
            info.setClassName(NumberPicker.class.getName());
            info.setPackageName(getContext().getPackageName());
            info.setSource(NumberPicker.this);

            if (hasVirtualDecrementButton()) {
                info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_DECREMENT);
            }
            info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_INPUT);
            if (hasVirtualIncrementButton()) {
                info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_INCREMENT);
            }

            info.setParent((View) getParentForAccessibility());
            info.setEnabled(NumberPicker.this.isEnabled());
            info.setScrollable(true);

//            TODO: Figure out compat implementation for this final float
//            final float applicationScale =
//                getContext().getResources().getCompatibilityInfo().applicationScale;
//
//            Rect boundsInParent = mTempRect;
//            boundsInParent.set(left, top, right, bottom);
//            boundsInParent.scale(applicationScale);
//            info.setBoundsInParent(boundsInParent);
//
//            info.setVisibleToUser(isVisibleToUser());
//
//            Rect boundsInScreen = boundsInParent;
//            int[] locationOnScreen = mTempArray;
//            getLocationOnScreen(locationOnScreen);
//            boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
//            boundsInScreen.scale(applicationScale);
//            info.setBoundsInScreen(boundsInScreen);

            if (mAccessibilityFocusedView != View.NO_ID) {
                info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
            }
            if (mAccessibilityFocusedView == View.NO_ID) {
                info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
            }
            if (NumberPicker.this.isEnabled()) {
                if (getWrapSelectorWheel() || getValue() < getMaxValue()) {
                    info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
                }
                if (getWrapSelectorWheel() || getValue() > getMinValue()) {
                    info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
                }
            }

            return info;
        }
 
Example 17
Source File: NumberPicker.java    From NewXmPluginSDK with Apache License 2.0 4 votes vote down vote up
private AccessibilityNodeInfo createAccessibilityNodeInfoForNumberPicker(int left, int top,
        int right, int bottom) {
    AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
    info.setClassName(NumberPicker.class.getName());
    info.setPackageName(getContext().getPackageName());
    info.setSource(NumberPicker.this);

    if (hasVirtualDecrementButton()) {
        info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_DECREMENT);
    }
    info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_INPUT);
    if (hasVirtualIncrementButton()) {
        info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_INCREMENT);
    }

    info.setParent((View) getParentForAccessibility());
    info.setEnabled(NumberPicker.this.isEnabled());
    info.setScrollable(true);

    Rect boundsInParent = mTempRect;

    boundsInParent.set(left, top, right, bottom);
    info.setBoundsInParent(boundsInParent);

    info.setVisibleToUser(getVisibility() == View.VISIBLE);

    Rect boundsInScreen = boundsInParent;
    int[] locationOnScreen = mTempArray;
    getLocationOnScreen(locationOnScreen);
    boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
    info.setBoundsInScreen(boundsInScreen);

    if (mAccessibilityFocusedView != View.NO_ID) {
        info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
    }
    if (mAccessibilityFocusedView == View.NO_ID) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    }
    if (NumberPicker.this.isEnabled()) {
        if (getWrapSelectorWheel() || getValue() < getMaxValue()) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
        }
        if (getWrapSelectorWheel() || getValue() > getMinValue()) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
        }
    }

    return info;
}
 
Example 18
Source File: TextPicker.java    From GifAssistant with Apache License 2.0 4 votes vote down vote up
private AccessibilityNodeInfo createAccessibilityNodeInfoForNumberPicker(int left, int top,
                                                                         int right, int bottom) {
    AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
    info.setClassName(TextPicker.class.getName());
    info.setPackageName(getContext().getPackageName());
    info.setSource(TextPicker.this);

    if (hasVirtualDecrementButton()) {
        info.addChild(TextPicker.this, VIRTUAL_VIEW_ID_DECREMENT);
    }
    info.addChild(TextPicker.this, VIRTUAL_VIEW_ID_INPUT);
    if (hasVirtualIncrementButton()) {
        info.addChild(TextPicker.this, VIRTUAL_VIEW_ID_INCREMENT);
    }

    info.setParent((View) getParentForAccessibility());
    info.setEnabled(TextPicker.this.isEnabled());
    info.setScrollable(true);

    /** TODO: Figure out compat implementation for this
     final float applicationScale =
     getContext().getResources().getCompatibilityInfo().applicationScale;

     Rect boundsInParent = mTempRect;
     boundsInParent.set(left, top, right, bottom);
     boundsInParent.scale(applicationScale);
     info.setBoundsInParent(boundsInParent);

     info.setVisibleToUser(isVisibleToUser());

     Rect boundsInScreen = boundsInParent;
     int[] locationOnScreen = mTempArray;
     getLocationOnScreen(locationOnScreen);
     boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
     boundsInScreen.scale(applicationScale);
     info.setBoundsInScreen(boundsInScreen);
     */

    if (mAccessibilityFocusedView != View.NO_ID) {
        info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
    }
    if (mAccessibilityFocusedView == View.NO_ID) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    }
    if (TextPicker.this.isEnabled()) {
        if (getWrapSelectorWheel() || getValue() < getMaxValue()) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
        }
        if (getWrapSelectorWheel() || getValue() > getMinValue()) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
        }
    }

    return info;
}
 
Example 19
Source File: NumberPicker.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private AccessibilityNodeInfo createAccessibilityNodeInfoForNumberPicker(int left, int top,
        int right, int bottom) {
    AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
    info.setClassName(NumberPicker.class.getName());
    info.setPackageName(mContext.getPackageName());
    info.setSource(NumberPicker.this);

    if (hasVirtualDecrementButton()) {
        info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_DECREMENT);
    }
    info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_INPUT);
    if (hasVirtualIncrementButton()) {
        info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_INCREMENT);
    }

    info.setParent((View) getParentForAccessibility());
    info.setEnabled(NumberPicker.this.isEnabled());
    info.setScrollable(true);

    final float applicationScale =
        getContext().getResources().getCompatibilityInfo().applicationScale;

    Rect boundsInParent = mTempRect;
    boundsInParent.set(left, top, right, bottom);
    boundsInParent.scale(applicationScale);
    info.setBoundsInParent(boundsInParent);

    info.setVisibleToUser(isVisibleToUser());

    Rect boundsInScreen = boundsInParent;
    int[] locationOnScreen = mTempArray;
    getLocationOnScreen(locationOnScreen);
    boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
    boundsInScreen.scale(applicationScale);
    info.setBoundsInScreen(boundsInScreen);

    if (mAccessibilityFocusedView != View.NO_ID) {
        info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
    }
    if (mAccessibilityFocusedView == View.NO_ID) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    }
    if (NumberPicker.this.isEnabled()) {
        if (getWrapSelectorWheel() || getValue() < getMaxValue()) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
        }
        if (getWrapSelectorWheel() || getValue() > getMinValue()) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
        }
    }

    return info;
}
 
Example 20
Source File: NumberPicker.java    From zen4android with MIT License 4 votes vote down vote up
private AccessibilityNodeInfo createAccessibilityNodeInfoForNumberPicker(int left, int top,
        int right, int bottom) {
    AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
    info.setClassName(NumberPicker.class.getName());
    info.setPackageName(getContext().getPackageName());
    info.setSource(NumberPicker.this);

    if (hasVirtualDecrementButton()) {
        info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_DECREMENT);
    }
    info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_INPUT);
    if (hasVirtualIncrementButton()) {
        info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_INCREMENT);
    }

    info.setParent((View) getParentForAccessibility());
    info.setEnabled(NumberPicker.this.isEnabled());
    info.setScrollable(true);

    /** TODO: Figure out compat implementation for this
    final float applicationScale =
            getContext().getResources().getCompatibilityInfo().applicationScale;

    Rect boundsInParent = mTempRect;
    boundsInParent.set(left, top, right, bottom);
    boundsInParent.scale(applicationScale);
    info.setBoundsInParent(boundsInParent);

    info.setVisibleToUser(isVisibleToUser());

    Rect boundsInScreen = boundsInParent;
    int[] locationOnScreen = mTempArray;
    getLocationOnScreen(locationOnScreen);
    boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
    boundsInScreen.scale(applicationScale);
    info.setBoundsInScreen(boundsInScreen);
     */

    if (mAccessibilityFocusedView != View.NO_ID) {
        info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
    }
    if (mAccessibilityFocusedView == View.NO_ID) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    }
    if (NumberPicker.this.isEnabled()) {
        if (getWrapSelectorWheel() || getValue() < getMaxValue()) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
        }
        if (getWrapSelectorWheel() || getValue() > getMinValue()) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
        }
    }

    return info;
}