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

Commit 3c5d0f10 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Close IME when attaching dock stack

So we don't end up with animation weirdness.

Bug: 28905720
Change-Id: I04124995dd99fa26d2e9be467c5976d7b20810a7
parent 08c46581
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -32,4 +32,9 @@ public interface InputMethodManagerInternal {
     * Called by the window manager to let the input method manager rotate the input method.
     */
    void switchInputMethod(boolean forwardDirection);

    /**
     * Hides the current input method, if visible.
     */
    void hideCurrentInputMethod();
}
+12 −0
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    static final int MSG_BIND_INPUT = 1010;
    static final int MSG_SHOW_SOFT_INPUT = 1020;
    static final int MSG_HIDE_SOFT_INPUT = 1030;
    static final int MSG_HIDE_CURRENT_INPUT_METHOD = 1035;
    static final int MSG_ATTACH_TOKEN = 1040;
    static final int MSG_CREATE_SESSION = 1050;

@@ -2846,6 +2847,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                }
                args.recycle();
                return true;
            case MSG_HIDE_CURRENT_INPUT_METHOD:
                synchronized (mMethodMap) {
                    hideCurrentInputLocked(0, null);
                }
                return true;
            case MSG_ATTACH_TOKEN:
                args = (SomeArgs)msg.obj;
                try {
@@ -3880,6 +3886,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            mHandler.sendMessage(mHandler.obtainMessage(MSG_SWITCH_IME,
                    forwardDirection ? 1 : 0, 0));
        }

        @Override
        public void hideCurrentInputMethod() {
            mHandler.removeMessages(MSG_HIDE_CURRENT_INPUT_METHOD);
            mHandler.sendEmptyMessage(MSG_HIDE_CURRENT_INPUT_METHOD);
        }
    }

    private static String imeWindowStatusToString(final int imeWindowVis) {
+32 −1
Original line number Diff line number Diff line
@@ -45,9 +45,11 @@ import android.view.SurfaceControl;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
import android.view.inputmethod.InputMethodManagerInternal;

import com.android.internal.policy.DividerSnapAlgorithm;
import com.android.internal.policy.DockedDividerUtils;
import com.android.server.LocalServices;
import com.android.server.wm.DimLayer.DimLayerUser;
import com.android.server.wm.WindowManagerService.H;

@@ -131,6 +133,7 @@ public class DockedStackDividerController implements DimLayerUser {
    private float mLastAnimationProgress;
    private float mLastDividerProgress;
    private final DividerSnapAlgorithm[] mSnapAlgorithmForRotation = new DividerSnapAlgorithm[4];
    private boolean mImeHideRequested;

    DockedStackDividerController(WindowManagerService service, DisplayContent displayContent) {
        mService = service;
@@ -375,11 +378,39 @@ public class DockedStackDividerController implements DimLayerUser {
            }
        }
        mDockedStackListeners.finishBroadcast();
        if (!exists) {
        if (exists) {
            InputMethodManagerInternal inputMethodManagerInternal =
                    LocalServices.getService(InputMethodManagerInternal.class);
            if (inputMethodManagerInternal != null) {

                // Hide the current IME to avoid problems with animations from IME adjustment when
                // attaching the docked stack.
                inputMethodManagerInternal.hideCurrentInputMethod();
                mImeHideRequested = true;
            }
        } else {
            setMinimizedDockedStack(false);
        }
    }

    /**
     * Resets the state that IME hide has been requested. See {@link #isImeHideRequested}.
     */
    void resetImeHideRequested() {
        mImeHideRequested = false;
    }

    /**
     * The docked stack divider controller makes sure the IME gets hidden when attaching the docked
     * stack, to avoid animation problems. This flag indicates whether the request to hide the IME
     * has been sent in an asynchronous manner, and the IME should be treated as hidden already.
     *
     * @return whether IME hide request has been sent
     */
    boolean isImeHideRequested() {
        return mImeHideRequested;
    }

    void notifyDockedStackMinimizedChanged(boolean minimizedDock, long animDuration) {
        mService.mH.removeMessages(NOTIFY_DOCKED_STACK_MINIMIZED_CHANGED);
        mService.mH.obtainMessage(NOTIFY_DOCKED_STACK_MINIMIZED_CHANGED,
+2 −1
Original line number Diff line number Diff line
@@ -7596,7 +7596,8 @@ public class WindowManagerService extends IWindowManager.Stub

    void adjustForImeIfNeeded(final DisplayContent displayContent) {
        final WindowState imeWin = mInputMethodWindow;
        final boolean imeVisible = imeWin != null && imeWin.isVisibleLw() && imeWin.isDisplayedLw();
        final boolean imeVisible = imeWin != null && imeWin.isVisibleLw() && imeWin.isDisplayedLw()
                && !displayContent.mDividerControllerLocked.isImeHideRequested();
        final boolean dockVisible = isStackVisibleLocked(DOCKED_STACK_ID);
        final TaskStack imeTargetStack = getImeFocusStackLocked();
        final int imeDockSide = (dockVisible && imeTargetStack != null) ?
+4 −0
Original line number Diff line number Diff line
@@ -1773,6 +1773,10 @@ class WindowStateAnimator {
                mWin.mAppToken.onFirstWindowDrawn(mWin, this);
            }

            if (mWin.mAttrs.type == TYPE_INPUT_METHOD) {
                mWin.mDisplayContent.mDividerControllerLocked.resetImeHideRequested();
            }

            return true;
        }
        return false;