public static Point GetOverlayAnchorPosition(AccessibilityNodeInfo root, AccessibilityNodeInfo anchorView,
                                                     int rootRectHeight = 0)
        {
            if (rootRectHeight == 0)
            {
                rootRectHeight = GetNodeHeight(root);
            }

            var anchorViewRect = new Rect();

            anchorView.GetBoundsInScreen(anchorViewRect);
            var anchorViewRectLeft = anchorViewRect.Left;
            var anchorViewRectTop  = anchorViewRect.Top;

            anchorViewRect.Dispose();

            var calculatedTop = rootRectHeight - anchorViewRectTop;

            if ((int)Build.VERSION.SdkInt >= 24)
            {
                calculatedTop -= GetNavigationBarHeight();
            }

            return(new Point(anchorViewRectLeft, calculatedTop));
        }
        public static int GetNodeHeight(AccessibilityNodeInfo node)
        {
            var nodeRect = new Rect();

            node.GetBoundsInScreen(nodeRect);
            var nodeRectHeight = nodeRect.Height();

            nodeRect.Dispose();
            return(nodeRectHeight);
        }
Пример #3
0
        public static Point GetOverlayAnchorPosition(AccessibilityNodeInfo root, AccessibilityEvent e)
        {
            var rootRect = new Rect();

            root.GetBoundsInScreen(rootRect);
            var rootRectHeight = rootRect.Height();

            var eSrcRect = new Rect();

            e.Source.GetBoundsInScreen(eSrcRect);
            var eSrcRectLeft = eSrcRect.Left;
            var eSrcRectTop  = eSrcRect.Top;

            var navBarHeight  = GetNavigationBarHeight();
            var calculatedTop = rootRectHeight - eSrcRectTop - navBarHeight;

            return(new Point(eSrcRectLeft, calculatedTop));
        }
Пример #4
0
        public static Point GetOverlayAnchorPosition(AccessibilityNodeInfo root, AccessibilityNodeInfo anchorView)
        {
            var rootRect = new Rect();

            root.GetBoundsInScreen(rootRect);
            var rootRectHeight = rootRect.Height();

            var anchorViewRect = new Rect();

            anchorView.GetBoundsInScreen(anchorViewRect);
            var anchorViewRectLeft = anchorViewRect.Left;
            var anchorViewRectTop  = anchorViewRect.Top;

            var navBarHeight  = GetNavigationBarHeight();
            var calculatedTop = rootRectHeight - anchorViewRectTop - navBarHeight;

            return(new Point(anchorViewRectLeft, calculatedTop));
        }
Пример #5
0
        public static Point GetOverlayAnchorPosition(AccessibilityService service, AccessibilityNodeInfo anchorView,
                                                     int overlayViewHeight, bool isOverlayAboveAnchor)
        {
            var anchorViewRect = new Rect();

            anchorView.GetBoundsInScreen(anchorViewRect);
            var anchorViewX = anchorViewRect.Left;
            var anchorViewY = isOverlayAboveAnchor ? anchorViewRect.Top : anchorViewRect.Bottom;

            anchorViewRect.Dispose();

            if (isOverlayAboveAnchor)
            {
                anchorViewY -= overlayViewHeight;
            }
            anchorViewY -= GetStatusBarHeight(service);

            return(new Point(anchorViewX, anchorViewY));
        }