List of usage examples for android.view.accessibility AccessibilityNodeInfo getBoundsInScreen
public void getBoundsInScreen(Rect outBounds)
From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java
private void handleGoToWork(AccessibilityNodeInfo info) { if (isGo) {// ww w. j av a2 s.c o m isGo = false; // Toast.makeText(App.mContext, "???? ... ", Toast.LENGTH_SHORT).show(); Rect mRect = new Rect(); info.getBoundsInScreen(mRect); ShellUtils.CommandResult mCommandResult = doShellCmdInputTap(mRect.centerX(), mRect.centerY()); if (mCommandResult.result == 0) { STATE = STATE_CHECKED_IN; } } }
From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java
private void toSignIn() { AccessibilityNodeInfo mAccessibilityNodeInfo = this.getRootInActiveWindow(); if (mAccessibilityNodeInfo == null) return;/*from ww w. j a va 2 s .c om*/ List<AccessibilityNodeInfo> mEdPhoneNodes = mAccessibilityNodeInfo .findAccessibilityNodeInfosByViewId(PHONE_ID); if (mEdPhoneNodes == null || mEdPhoneNodes.isEmpty()) return; isChecking = true; AccessibilityNodeInfo mEdPhoneNode = mEdPhoneNodes.get(0); CharSequence mCharSequence = mEdPhoneNode.getText(); if (mCharSequence != null && !mCharSequence.toString().equals(targetCheckInAcount.getAccount())) { mEdPhoneNode.performAction(AccessibilityNodeInfo.ACTION_FOCUS);//? Rect mRect = new Rect(); mEdPhoneNode.getBoundsInScreen(mRect); doShellCmdInputTap(mRect.right - 10, mRect.centerY()); setTextToView(mEdPhoneNode, ""); setTextToView(mEdPhoneNode, targetCheckInAcount.getAccount()); } List<AccessibilityNodeInfo> mEdPasswordNodes = mAccessibilityNodeInfo .findAccessibilityNodeInfosByViewId(PASSWORD_ID); if (mEdPasswordNodes == null) return; AccessibilityNodeInfo mEdPasswordNode = mEdPasswordNodes.get(0); CharSequence mCharSequencePassword = mEdPasswordNode.getText(); setTextToView(mEdPasswordNode, ""); setTextToView(mEdPasswordNode, targetCheckInAcount.getPassword()); /*?*/ inputClick(BUTTON_ID); }
From source file:org.sufficientlysecure.keychain.gm.GmAccessibilityService.java
@SuppressLint("RtlHardcoded") private void drawOverlay(AccessibilityNodeInfo node, View.OnClickListener onClickListener) { mOverlay = new FrameLayout(this); // must be encapsulated into FrameLayout for animation FrameLayout mAnimatedChild = new FrameLayout(this); LayoutInflater systemInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final Context contextThemeWrapper = new ContextThemeWrapper(this, R.style.FixedBottomSheetTheme); LayoutInflater inflater = systemInflater.cloneInContext(contextThemeWrapper); View child = inflater.inflate(R.layout.fixed_bottom_sheet, null); mAnimatedChild.addView(child);/*ww w .ja v a 2 s. c o m*/ Button b = (Button) child.findViewById(R.id.fixed_bottom_sheet_button); b.setText(R.string.decrypt_with_openkeychain); b.setOnClickListener(onClickListener); ImageButton close = (ImageButton) child.findViewById(R.id.fixed_bottom_sheet_close); close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { closeOverlay(); } }); Rect webviewRect = new Rect(); node.getBoundsInScreen(webviewRect); Display display = mWindowManager.getDefaultDisplay(); Rect displayRect = new Rect(); display.getRectSize(displayRect); int xpos = webviewRect.left; int ypos = webviewRect.top - getStatusBarHeight() < getToolbarHeight() ? getToolbarHeight() : webviewRect.top - getStatusBarHeight(); int width = webviewRect.width(); int height = webviewRect.bottom < displayRect.height() ? webviewRect.bottom - getToolbarHeight() - getStatusBarHeight() : displayRect.height() - ypos - getStatusBarHeight(); WindowManager.LayoutParams params = new WindowManager.LayoutParams(width, height, xpos, ypos, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT); params.gravity = Gravity.TOP | Gravity.LEFT; params.windowAnimations = R.style.OverlayAnimation; mWindowManager.addView(mOverlay, params); mOverlay.addView(mAnimatedChild); }
From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.ViewHierarchyElement.java
ViewHierarchyElement(int id, @Nullable ViewHierarchyElement 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; // Base properties this.className = fromInfo.getClassName(); this.packageName = fromInfo.getPackageName(); this.accessibilityClassName = fromInfo.getClassName(); this.contentDescription = SpannableString.valueOf(fromInfo.getContentDescription()); this.text = SpannableString.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.hasTouchDelegate = false; /* Touch delegates are not considered by AccessibilityServices */ android.graphics.Rect tempRect = new android.graphics.Rect(); fromInfo.getBoundsInScreen(tempRect); this.boundsInScreen = new Rect(tempRect); this.nonclippedHeight = null; /* AccessibilityServices cannot discover nonclipped dimensions */ this.nonclippedWidth = null; /* AccessibilityServices cannot discover nonclipped dimensions */ this.textSize = null; this.textColor = null; this.backgroundDrawableColor = null; this.typefaceStyle = null; this.enabled = fromInfo.isEnabled(); }