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

The following examples show how to use android.view.accessibility.AccessibilityNodeInfo#isEditable() . 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: AutofillManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private boolean notifyViewEntered(int windowId, long nodeId, Rect focusedBounds) {
    final int virtualId = AccessibilityNodeInfo.getVirtualDescendantId(nodeId);
    if (!isVirtualNode(virtualId)) {
        return false;
    }
    final View view = findViewByAccessibilityId(windowId, nodeId);
    if (view == null) {
        return false;
    }
    final AccessibilityNodeInfo node = findVirtualNodeByAccessibilityId(view, virtualId);
    if (node == null) {
        return false;
    }
    if (!node.isEditable()) {
        return false;
    }
    final Rect newBounds = mTempBounds;
    node.getBoundsInScreen(newBounds);
    if (newBounds.equals(focusedBounds)) {
        return false;
    }
    focusedBounds.set(newBounds);
    AutofillManager.this.notifyViewEntered(view, virtualId, newBounds);
    return true;
}
 
Example 2
Source File: Tree.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
public void refresh(AccessibilityNodeInfo node) {
    if (sealed) {
        throw new IllegalArgumentException("sealed! " + super.toString());
    }

    mFocused = node.isFocused();
    node.getBoundsInScreen(mBoundsInScreen);
    node.getBoundsInParent(mBoundsInParent);

    mBoundsInScreen.offset(0, -OverlayDecryptView.SCREEN_OFFSET_Y);


    mText = AccessibilityNodeInfoUtils.getNodeText(node);
    mTextString = mText == null ? null : mText.toString();

    mIsEncoded = mText == null ? false : CryptoHandlerFacade.Companion.isEncoded(mCtx, mTextString);
    if (mIsEncoded) {
        mIsTextView = true;
    }
    mIsEditableTextNode = (node.isEditable()
            && node.isEnabled()
            && mIsEditText
            && !node.isPassword());
}
 
Example 3
Source File: OversecAccessibilityService.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
public boolean isEditableEditTextFocussed() {
    boolean res = false;
    AccessibilityNodeInfo anode = null;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        anode = findFocus(AccessibilityNodeInfo.FOCUS_INPUT);
    } else {
        anode = findFocus_PreLollipop();
    }
    if (anode != null) {
        if (anode.isEditable() && anode.isEnabled()) {
            if (mTree.isAEditText(anode)) {
                res = true;
            }
        }
        anode.recycle();
    }
    return res;
}
 
Example 4
Source File: ExperienceEnhanceService.java    From Clip-Stack with MIT License 6 votes vote down vote up
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {

    //Check package name
    AccessibilityNodeInfo nodeInfo = event.getSource();
    if (nodeInfo != null) {
        String packageName = String.valueOf(nodeInfo.getPackageName());
        if (packageName.contains("catchingnow.tinyclipboardmanager")) {
            stopFloatingWindow();
            return;
        }
    }

    //FW
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        AccessibilityNodeInfo findFocus = findFocus(AccessibilityNodeInfo.FOCUS_INPUT);
        if (findFocus != null &&
                findFocus.isEditable()) {
            //Log.i("AccessibilityNodeInfo", "true");
            startFloatingWindow();
        } else {
            //Log.i("AccessibilityNodeInfo", "false");
            stopFloatingWindow();
        }
    }
}
 
Example 5
Source File: AccessibilityNodeTree.java    From SoloPi with Apache License 2.0 5 votes vote down vote up
private void initAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    this.className = StringUtil.nonNullString(info.getClassName());
    this.packageName = StringUtil.nonNullString(info.getPackageName());
    this.resourceId = info.getViewIdResourceName();
    this.text = StringUtil.nonNullString(info.getText());
    this.description = StringUtil.nonNullString(info.getContentDescription());
    Rect rect = new Rect();
    info.getBoundsInScreen(rect);
    this.nodeBound = rect;
    this.isScrollable = info.isScrollable();
    this.visible = info.isVisibleToUser();
    this.isClickable = info.isClickable();
    this.isFocusable = info.isFocusable();
    this.isEditable = info.isEditable();
}
 
Example 6
Source File: SmsCodeAutoInputService.java    From SmsCode with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 手动对焦下的尝试自动输入
 * @param smsCode SMS code
 * @return 成功输入则返回true,否则返回false
 */
private boolean tryToAutoInputByManualFocus(String smsCode, boolean isRootAutoInputMode) {
    if (isRootAutoInputMode){
        return ShellUtils.inputText(smsCode);
    } else {
        AccessibilityNodeInfo focusedNodeInfo = findFocusNodeInfo();
        if (focusedNodeInfo != null && focusedNodeInfo.isEditable()) {
            inputText(focusedNodeInfo, smsCode);
            return true;
        }
        return false;
    }
}
 
Example 7
Source File: ViewHierarchyElementAndroid.java    From Accessibility-Test-Framework-for-Android with Apache License 2.0 4 votes vote down vote up
Builder(int id, @Nullable ViewHierarchyElementAndroid parent, AccessibilityNodeInfo fromInfo) {
  // Bookkeeping
  this.id = id;
  this.parentId = (parent != null) ? parent.getId() : null;

  // API 18+ properties
  this.resourceName = AT_18 ? fromInfo.getViewIdResourceName() : null;
  this.editable = AT_18 ? fromInfo.isEditable() : null;

  // API 16+ properties
  this.visibleToUser = AT_16 ? fromInfo.isVisibleToUser() : null;

  // API 21+ properties
  if (AT_21) {
    ImmutableList.Builder<ViewHierarchyActionAndroid> actionBuilder =
        new ImmutableList.Builder<>();
    actionBuilder.addAll(
        Lists.transform(
            fromInfo.getActionList(),
            action -> ViewHierarchyActionAndroid.newBuilder(action).build()));
    this.actionList = actionBuilder.build();
  }

  // API 24+ properties
  this.drawingOrder = AT_24 ? fromInfo.getDrawingOrder() : null;

  // API 29+ properties
  this.hasTouchDelegate = AT_29 ? (fromInfo.getTouchDelegateInfo() != null) : null;

  // Base properties
  this.className = fromInfo.getClassName();
  this.packageName = fromInfo.getPackageName();
  this.accessibilityClassName = fromInfo.getClassName();
  this.contentDescription = SpannableStringAndroid.valueOf(fromInfo.getContentDescription());
  this.text = SpannableStringAndroid.valueOf(fromInfo.getText());

  this.importantForAccessibility = true;
  this.clickable = fromInfo.isClickable();
  this.longClickable = fromInfo.isLongClickable();
  this.focusable = fromInfo.isFocusable();
  this.scrollable = fromInfo.isScrollable();
  this.canScrollForward =
      ((fromInfo.getActions() & AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) != 0);
  this.canScrollBackward =
      ((fromInfo.getActions() & AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) != 0);
  this.checkable = fromInfo.isCheckable();
  this.checked = fromInfo.isChecked();
  this.touchDelegateBounds = new ArrayList<>(); // Populated after construction
  android.graphics.Rect tempRect = new android.graphics.Rect();
  fromInfo.getBoundsInScreen(tempRect);
  this.boundsInScreen = new Rect(tempRect.left, tempRect.top, tempRect.right, tempRect.bottom);
  this.nonclippedHeight = null;
  this.nonclippedWidth = null;
  this.textSize = null;
  this.textColor = null;
  this.backgroundDrawableColor = null;
  this.typefaceStyle = null;
  this.enabled = fromInfo.isEnabled();
}