Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d4200d0 authored by Jack Veenstra's avatar Jack Veenstra
Browse files

Fix bug with ScrollView so that text entry fields are not hidden by virtual keyboard.

parent a13ccc90
Loading
Loading
Loading
Loading
+8 −7
Original line number Original line Diff line number Diff line
@@ -743,7 +743,7 @@ public class ScrollView extends FrameLayout {


        final int maxJump = getMaxScrollAmount();
        final int maxJump = getMaxScrollAmount();


        if (nextFocused != null && isWithinDeltaOfScreen(nextFocused, maxJump)) {
        if (nextFocused != null && isWithinDeltaOfScreen(nextFocused, maxJump, getHeight())) {
            nextFocused.getDrawingRect(mTempRect);
            nextFocused.getDrawingRect(mTempRect);
            offsetDescendantRectToMyCoords(nextFocused, mTempRect);
            offsetDescendantRectToMyCoords(nextFocused, mTempRect);
            int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
            int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
@@ -792,19 +792,19 @@ public class ScrollView extends FrameLayout {
     *  screen.
     *  screen.
     */
     */
    private boolean isOffScreen(View descendant) {
    private boolean isOffScreen(View descendant) {
        return !isWithinDeltaOfScreen(descendant, 0);
        return !isWithinDeltaOfScreen(descendant, 0, getHeight());
    }
    }


    /**
    /**
     * @return whether the descendant of this scroll view is within delta
     * @return whether the descendant of this scroll view is within delta
     *  pixels of being on the screen.
     *  pixels of being on the screen.
     */
     */
    private boolean isWithinDeltaOfScreen(View descendant, int delta) {
    private boolean isWithinDeltaOfScreen(View descendant, int delta, int height) {
        descendant.getDrawingRect(mTempRect);
        descendant.getDrawingRect(mTempRect);
        offsetDescendantRectToMyCoords(descendant, mTempRect);
        offsetDescendantRectToMyCoords(descendant, mTempRect);


        return (mTempRect.bottom + delta) >= getScrollY()
        return (mTempRect.bottom + delta) >= getScrollY()
                && (mTempRect.top - delta) <= (getScrollY() + getHeight());
                && (mTempRect.top - delta) <= (getScrollY() + height);
    }
    }


    /**
    /**
@@ -1124,9 +1124,10 @@ public class ScrollView extends FrameLayout {
        if (null == currentFocused || this == currentFocused)
        if (null == currentFocused || this == currentFocused)
            return;
            return;


        final int maxJump = mBottom - mTop;
        // If the currently-focused view was visible on the screen when the

        // screen was at the old height, then scroll the screen to make that
        if (isWithinDeltaOfScreen(currentFocused, maxJump)) {
        // view visible with the new screen height.
        if (isWithinDeltaOfScreen(currentFocused, 0, oldh)) {
            currentFocused.getDrawingRect(mTempRect);
            currentFocused.getDrawingRect(mTempRect);
            offsetDescendantRectToMyCoords(currentFocused, mTempRect);
            offsetDescendantRectToMyCoords(currentFocused, mTempRect);
            int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
            int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);