Search in sources :

Example 21 with AttachInfo

use of android.view.View.AttachInfo in project android_frameworks_base by ResurrectionRemix.

the class AccessibilityInteractionController method applyAppScaleAndMagnificationSpecIfNeeded.

private void applyAppScaleAndMagnificationSpecIfNeeded(AccessibilityNodeInfo info, MagnificationSpec spec) {
    if (info == null) {
        return;
    }
    final float applicationScale = mViewRootImpl.mAttachInfo.mApplicationScale;
    if (!shouldApplyAppScaleAndMagnificationSpec(applicationScale, spec)) {
        return;
    }
    Rect boundsInParent = mTempRect;
    Rect boundsInScreen = mTempRect1;
    info.getBoundsInParent(boundsInParent);
    info.getBoundsInScreen(boundsInScreen);
    if (applicationScale != 1.0f) {
        boundsInParent.scale(applicationScale);
        boundsInScreen.scale(applicationScale);
    }
    if (spec != null) {
        boundsInParent.scale(spec.scale);
        // boundsInParent must not be offset.
        boundsInScreen.scale(spec.scale);
        boundsInScreen.offset((int) spec.offsetX, (int) spec.offsetY);
    }
    info.setBoundsInParent(boundsInParent);
    info.setBoundsInScreen(boundsInScreen);
    if (spec != null) {
        AttachInfo attachInfo = mViewRootImpl.mAttachInfo;
        if (attachInfo.mDisplay == null) {
            return;
        }
        final float scale = attachInfo.mApplicationScale * spec.scale;
        Rect visibleWinFrame = mTempRect1;
        visibleWinFrame.left = (int) (attachInfo.mWindowLeft * scale + spec.offsetX);
        visibleWinFrame.top = (int) (attachInfo.mWindowTop * scale + spec.offsetY);
        visibleWinFrame.right = (int) (visibleWinFrame.left + mViewRootImpl.mWidth * scale);
        visibleWinFrame.bottom = (int) (visibleWinFrame.top + mViewRootImpl.mHeight * scale);
        attachInfo.mDisplay.getRealSize(mTempPoint);
        final int displayWidth = mTempPoint.x;
        final int displayHeight = mTempPoint.y;
        Rect visibleDisplayFrame = mTempRect2;
        visibleDisplayFrame.set(0, 0, displayWidth, displayHeight);
        if (!visibleWinFrame.intersect(visibleDisplayFrame)) {
            // If there's no intersection with display, set visibleWinFrame empty.
            visibleDisplayFrame.setEmpty();
        }
        if (!visibleWinFrame.intersects(boundsInScreen.left, boundsInScreen.top, boundsInScreen.right, boundsInScreen.bottom)) {
            info.setVisibleToUser(false);
        }
    }
}
Also used : Rect(android.graphics.Rect) AttachInfo(android.view.View.AttachInfo) Point(android.graphics.Point)

Example 22 with AttachInfo

use of android.view.View.AttachInfo in project android_frameworks_base by crdroidandroid.

the class AccessibilityInteractionController method applyAppScaleAndMagnificationSpecIfNeeded.

private void applyAppScaleAndMagnificationSpecIfNeeded(AccessibilityNodeInfo info, MagnificationSpec spec) {
    if (info == null) {
        return;
    }
    final float applicationScale = mViewRootImpl.mAttachInfo.mApplicationScale;
    if (!shouldApplyAppScaleAndMagnificationSpec(applicationScale, spec)) {
        return;
    }
    Rect boundsInParent = mTempRect;
    Rect boundsInScreen = mTempRect1;
    info.getBoundsInParent(boundsInParent);
    info.getBoundsInScreen(boundsInScreen);
    if (applicationScale != 1.0f) {
        boundsInParent.scale(applicationScale);
        boundsInScreen.scale(applicationScale);
    }
    if (spec != null) {
        boundsInParent.scale(spec.scale);
        // boundsInParent must not be offset.
        boundsInScreen.scale(spec.scale);
        boundsInScreen.offset((int) spec.offsetX, (int) spec.offsetY);
    }
    info.setBoundsInParent(boundsInParent);
    info.setBoundsInScreen(boundsInScreen);
    if (spec != null) {
        AttachInfo attachInfo = mViewRootImpl.mAttachInfo;
        if (attachInfo.mDisplay == null) {
            return;
        }
        final float scale = attachInfo.mApplicationScale * spec.scale;
        Rect visibleWinFrame = mTempRect1;
        visibleWinFrame.left = (int) (attachInfo.mWindowLeft * scale + spec.offsetX);
        visibleWinFrame.top = (int) (attachInfo.mWindowTop * scale + spec.offsetY);
        visibleWinFrame.right = (int) (visibleWinFrame.left + mViewRootImpl.mWidth * scale);
        visibleWinFrame.bottom = (int) (visibleWinFrame.top + mViewRootImpl.mHeight * scale);
        attachInfo.mDisplay.getRealSize(mTempPoint);
        final int displayWidth = mTempPoint.x;
        final int displayHeight = mTempPoint.y;
        Rect visibleDisplayFrame = mTempRect2;
        visibleDisplayFrame.set(0, 0, displayWidth, displayHeight);
        if (!visibleWinFrame.intersect(visibleDisplayFrame)) {
            // If there's no intersection with display, set visibleWinFrame empty.
            visibleDisplayFrame.setEmpty();
        }
        if (!visibleWinFrame.intersects(boundsInScreen.left, boundsInScreen.top, boundsInScreen.right, boundsInScreen.bottom)) {
            info.setVisibleToUser(false);
        }
    }
}
Also used : Rect(android.graphics.Rect) AttachInfo(android.view.View.AttachInfo) Point(android.graphics.Point)

Example 23 with AttachInfo

use of android.view.View.AttachInfo in project android_frameworks_base by DirtyUnicorns.

the class ViewRootImpl method getAccessibilityFocusedRect.

private boolean getAccessibilityFocusedRect(Rect bounds) {
    final AccessibilityManager manager = AccessibilityManager.getInstance(mView.mContext);
    if (!manager.isEnabled() || !manager.isTouchExplorationEnabled()) {
        return false;
    }
    final View host = mAccessibilityFocusedHost;
    if (host == null || host.mAttachInfo == null) {
        return false;
    }
    final AccessibilityNodeProvider provider = host.getAccessibilityNodeProvider();
    if (provider == null) {
        host.getBoundsOnScreen(bounds, true);
    } else if (mAccessibilityFocusedVirtualView != null) {
        mAccessibilityFocusedVirtualView.getBoundsInScreen(bounds);
    } else {
        return false;
    }
    // Transform the rect into window-relative coordinates.
    final AttachInfo attachInfo = mAttachInfo;
    bounds.offset(0, attachInfo.mViewRootImpl.mScrollY);
    bounds.offset(-attachInfo.mWindowLeft, -attachInfo.mWindowTop);
    if (!bounds.intersect(0, 0, attachInfo.mViewRootImpl.mWidth, attachInfo.mViewRootImpl.mHeight)) {
        // If no intersection, set bounds to empty.
        bounds.setEmpty();
    }
    return !bounds.isEmpty();
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AttachInfo(android.view.View.AttachInfo) AccessibilityNodeProvider(android.view.accessibility.AccessibilityNodeProvider)

Example 24 with AttachInfo

use of android.view.View.AttachInfo in project cornerstone by Onskreen.

the class ViewRootImpl method collectViewAttributes.

private boolean collectViewAttributes() {
    final View.AttachInfo attachInfo = mAttachInfo;
    if (attachInfo.mRecomputeGlobalAttributes) {
        // Log.i(TAG, "Computing view hierarchy attributes!");
        attachInfo.mRecomputeGlobalAttributes = false;
        boolean oldScreenOn = attachInfo.mKeepScreenOn;
        int oldVis = attachInfo.mSystemUiVisibility;
        boolean oldHasSystemUiListeners = attachInfo.mHasSystemUiListeners;
        attachInfo.mKeepScreenOn = false;
        attachInfo.mSystemUiVisibility = 0;
        attachInfo.mHasSystemUiListeners = false;
        mView.dispatchCollectViewAttributes(attachInfo, 0);
        attachInfo.mSystemUiVisibility &= ~attachInfo.mDisabledSystemUiVisibility;
        if (attachInfo.mKeepScreenOn != oldScreenOn || attachInfo.mSystemUiVisibility != oldVis || attachInfo.mHasSystemUiListeners != oldHasSystemUiListeners) {
            WindowManager.LayoutParams params = mWindowAttributes;
            applyKeepScreenOnFlag(params);
            params.subtreeSystemUiVisibility = attachInfo.mSystemUiVisibility;
            params.hasSystemUiListeners = attachInfo.mHasSystemUiListeners;
            mView.dispatchWindowSystemUiVisiblityChanged(attachInfo.mSystemUiVisibility);
            return true;
        }
    }
    return false;
}
Also used : Paint(android.graphics.Paint) Point(android.graphics.Point) AttachInfo(android.view.View.AttachInfo)

Example 25 with AttachInfo

use of android.view.View.AttachInfo in project cornerstone by Onskreen.

the class ViewRootImpl method scrollToRectOrFocus.

boolean scrollToRectOrFocus(Rect rectangle, boolean immediate) {
    final View.AttachInfo attachInfo = mAttachInfo;
    final Rect ci = attachInfo.mContentInsets;
    final Rect vi = attachInfo.mVisibleInsets;
    int scrollY = 0;
    boolean handled = false;
    if (vi.left > ci.left || vi.top > ci.top || vi.right > ci.right || vi.bottom > ci.bottom) {
        // We'll assume that we aren't going to change the scroll
        // offset, since we want to avoid that unless it is actually
        // going to make the focus visible...  otherwise we scroll
        // all over the place.
        scrollY = mScrollY;
        // We can be called for two different situations: during a draw,
        // to update the scroll position if the focus has changed (in which
        // case 'rectangle' is null), or in response to a
        // requestChildRectangleOnScreen() call (in which case 'rectangle'
        // is non-null and we just want to scroll to whatever that
        // rectangle is).
        View focus = mRealFocusedView;
        // line checks whether the view is still in our hierarchy.
        if (focus == null || focus.mAttachInfo != mAttachInfo) {
            mRealFocusedView = null;
            return false;
        }
        if (focus != mLastScrolledFocus) {
            // If the focus has changed, then ignore any requests to scroll
            // to a rectangle; first we want to make sure the entire focus
            // view is visible.
            rectangle = null;
        }
        if (DEBUG_INPUT_RESIZE)
            Log.v(TAG, "Eval scroll: focus=" + focus + " rectangle=" + rectangle + " ci=" + ci + " vi=" + vi);
        if (focus == mLastScrolledFocus && !mScrollMayChange && rectangle == null) {
            // as they are.
            if (DEBUG_INPUT_RESIZE)
                Log.v(TAG, "Keeping scroll y=" + mScrollY + " vi=" + vi.toShortString());
        } else if (focus != null) {
            // We need to determine if the currently focused view is
            // within the visible part of the window and, if not, apply
            // a pan so it can be seen.
            mLastScrolledFocus = focus;
            mScrollMayChange = false;
            if (DEBUG_INPUT_RESIZE)
                Log.v(TAG, "Need to scroll?");
            // Try to find the rectangle from the focus view.
            if (focus.getGlobalVisibleRect(mVisRect, null)) {
                if (DEBUG_INPUT_RESIZE)
                    Log.v(TAG, "Root w=" + mView.getWidth() + " h=" + mView.getHeight() + " ci=" + ci.toShortString() + " vi=" + vi.toShortString());
                if (rectangle == null) {
                    focus.getFocusedRect(mTempRect);
                    if (DEBUG_INPUT_RESIZE)
                        Log.v(TAG, "Focus " + focus + ": focusRect=" + mTempRect.toShortString());
                    if (mView instanceof ViewGroup) {
                        ((ViewGroup) mView).offsetDescendantRectToMyCoords(focus, mTempRect);
                    }
                    if (DEBUG_INPUT_RESIZE)
                        Log.v(TAG, "Focus in window: focusRect=" + mTempRect.toShortString() + " visRect=" + mVisRect.toShortString());
                } else {
                    mTempRect.set(rectangle);
                    if (DEBUG_INPUT_RESIZE)
                        Log.v(TAG, "Request scroll to rect: " + mTempRect.toShortString() + " visRect=" + mVisRect.toShortString());
                }
                if (mTempRect.intersect(mVisRect)) {
                    if (DEBUG_INPUT_RESIZE)
                        Log.v(TAG, "Focus window visible rect: " + mTempRect.toShortString());
                    if (mTempRect.height() > (mView.getHeight() - vi.top - vi.bottom)) {
                        // best is probably just to leave things as-is.
                        if (DEBUG_INPUT_RESIZE)
                            Log.v(TAG, "Too tall; leaving scrollY=" + scrollY);
                    } else if ((mTempRect.top - scrollY) < vi.top) {
                        scrollY -= vi.top - (mTempRect.top - scrollY);
                        if (DEBUG_INPUT_RESIZE)
                            Log.v(TAG, "Top covered; scrollY=" + scrollY);
                    } else if ((mTempRect.bottom - scrollY) > (mView.getHeight() - vi.bottom)) {
                        scrollY += (mTempRect.bottom - scrollY) - (mView.getHeight() - vi.bottom);
                        if (DEBUG_INPUT_RESIZE)
                            Log.v(TAG, "Bottom covered; scrollY=" + scrollY);
                    }
                    handled = true;
                }
            }
        }
    }
    if (scrollY != mScrollY) {
        if (DEBUG_INPUT_RESIZE)
            Log.v(TAG, "Pan scroll changed: old=" + mScrollY + " , new=" + scrollY);
        if (!immediate && mResizeBuffer == null) {
            if (mScroller == null) {
                mScroller = new Scroller(mView.getContext());
            }
            mScroller.startScroll(0, mScrollY, 0, scrollY - mScrollY);
        } else if (mScroller != null) {
            mScroller.abortAnimation();
        }
        mScrollY = scrollY;
    }
    return handled;
}
Also used : Rect(android.graphics.Rect) Scroller(android.widget.Scroller) Paint(android.graphics.Paint) Point(android.graphics.Point) AttachInfo(android.view.View.AttachInfo)

Aggregations

AttachInfo (android.view.View.AttachInfo)27 Point (android.graphics.Point)13 Rect (android.graphics.Rect)12 Paint (android.graphics.Paint)7 Context (android.content.Context)6 Handler (android.os.Handler)6 BridgeWindow (com.android.layoutlib.bridge.android.BridgeWindow)6 BridgeWindowSession (com.android.layoutlib.bridge.android.BridgeWindowSession)6 AccessibilityManager (android.view.accessibility.AccessibilityManager)5 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)5 CompatibilityInfo (android.content.res.CompatibilityInfo)2 Resources (android.content.res.Resources)2 Region (android.graphics.Region)2 RemoteException (android.os.RemoteException)2 DisplayMetrics (android.util.DisplayMetrics)2 IAccessibilityInteractionConnectionCallback (android.view.accessibility.IAccessibilityInteractionConnectionCallback)2 InputMethodManager (android.view.inputmethod.InputMethodManager)2 Scroller (android.widget.Scroller)2 BaseSurfaceHolder (com.android.internal.view.BaseSurfaceHolder)2 IInputMethodCallback (com.android.internal.view.IInputMethodCallback)1