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

Commit 7095d92a authored by Chong Zhang's avatar Chong Zhang Committed by Android (Google) Code Review
Browse files

Merge "Apply IME adjust to newly added window" into nyc-dev

parents bd1708a1 5117e273
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -322,6 +322,32 @@ class Task implements DimLayer.DimLayerUser {
        mPreparedFrozenBounds.set(mBounds);
    }

    /**
     * Align the task to the adjusted bounds.
     *
     * @param adjustedBounds Adjusted bounds to which the task should be aligned.
     * @param tempInsetBounds Insets bounds for the task.
     * @param alignBottom True if the task's bottom should be aligned to the adjusted
     *                    bounds's bottom; false if the task's top should be aligned
     *                    the adjusted bounds's top.
     */
    void alignToAdjustedBounds(
            Rect adjustedBounds, Rect tempInsetBounds, boolean alignBottom) {
        if (!isResizeable() || mOverrideConfig == Configuration.EMPTY) {
            return;
        }

        getBounds(mTmpRect2);
        if (alignBottom) {
            int offsetY = adjustedBounds.bottom - mTmpRect2.bottom;
            mTmpRect2.offset(0, offsetY);
        } else {
            mTmpRect2.offsetTo(adjustedBounds.left, adjustedBounds.top);
        }
        setTempInsetBounds(tempInsetBounds);
        resizeLocked(mTmpRect2, mOverrideConfig, false /* forced */);
    }

    void resetScrollLocked() {
        if (mScrollValid) {
            mScrollValid = false;
+16 −13
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ public class TaskStack implements DimLayer.DimLayerUser,
        Rect insetBounds = null;
        if (adjusted && isAdjustedForMinimizedDock()) {
            insetBounds = mBounds;
        } else if (adjusted && isAdjustedForIme()) {
        } else if (adjusted && mAdjustedForIme) {
            if (mImeGoingAway) {
                insetBounds = mBounds;
            } else {
@@ -264,16 +264,9 @@ public class TaskStack implements DimLayer.DimLayerUser,
                task.resizeLocked(null, null, false /* forced */);
                task.getBounds(mTmpRect2);
                task.scrollLocked(mTmpRect2);
            } else if (task.isResizeable() && task.mOverrideConfig != Configuration.EMPTY) {
                task.getBounds(mTmpRect2);
                if (mAdjustedForIme && getDockSide() == DOCKED_TOP) {
                    int offsetY = adjustedBounds.bottom - mTmpRect2.bottom;
                    mTmpRect2.offset(0, offsetY);
            } else {
                    mTmpRect2.offsetTo(adjustedBounds.left, adjustedBounds.top);
                }
                task.setTempInsetBounds(tempInsetBounds);
                task.resizeLocked(mTmpRect2, task.mOverrideConfig, false /* forced */);
                final boolean alignBottom = mAdjustedForIme && getDockSide() == DOCKED_TOP;
                task.alignToAdjustedBounds(adjustedBounds, tempInsetBounds, alignBottom);
            }
        }
    }
@@ -868,7 +861,7 @@ public class TaskStack implements DimLayer.DimLayerUser,
    }

    boolean isAdjustedForIme() {
        return mAdjustedForIme || mImeGoingAway;
        return mAdjustedForIme;
    }

    boolean isAnimatingForIme() {
@@ -1083,7 +1076,7 @@ public class TaskStack implements DimLayer.DimLayerUser,
    /**
     * Updates the adjustment depending on it's current state.
     */
    void updateAdjustedBounds() {
    private void updateAdjustedBounds() {
        boolean adjust = false;
        if (mMinimizeAmount != 0f) {
            adjust = adjustForMinimizedDockedStack(mMinimizeAmount);
@@ -1103,6 +1096,16 @@ public class TaskStack implements DimLayer.DimLayerUser,
        }
    }

    void applyAdjustForImeIfNeeded(Task task) {
        if (mMinimizeAmount != 0f || !mAdjustedForIme || mAdjustedBounds.isEmpty()) {
            return;
        }

        final Rect insetBounds = mImeGoingAway ? mBounds : mFullyAdjustedImeBounds;
        task.alignToAdjustedBounds(mAdjustedBounds, insetBounds, getDockSide() == DOCKED_TOP);
        mDisplayContent.layoutNeeded = true;
    }

    boolean isAdjustedForMinimizedDockedStack() {
        return mMinimizeAmount != 0f;
    }
+4 −0
Original line number Diff line number Diff line
@@ -2077,6 +2077,10 @@ public class WindowManagerService extends IWindowManager.Stub
            // we need to update this new window's scroll position when it's added.
            win.applyScrollIfNeeded();

            // If the window is being added to a stack that's currently adjusted for IME,
            // make sure to apply the same adjust to this new window.
            win.applyAdjustForImeIfNeeded();

            if (type == TYPE_DOCK_DIVIDER) {
                getDefaultDisplayContentLocked().getDockedDividerController().setWindow(win);
            }
+7 −0
Original line number Diff line number Diff line
@@ -1620,6 +1620,13 @@ final class WindowState implements WindowManagerPolicy.WindowState {
        }
    }

    void applyAdjustForImeIfNeeded() {
        final Task task = getTask();
        if (task != null && task.mStack != null && task.mStack.isAdjustedForIme()) {
            task.mStack.applyAdjustForImeIfNeeded(task);
        }
    }

    int getTouchableRegion(Region region, int flags) {
        final boolean modal = (flags & (FLAG_NOT_TOUCH_MODAL | FLAG_NOT_FOCUSABLE)) == 0;
        if (modal && mAppToken != null) {