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

Commit b58f340a authored by Felix Stern's avatar Felix Stern
Browse files

Refactor onImeFocusLost part from setCurrentRootViewLocked for better readability

Bug: 378098975
Test: None, only refactor
Flag: EXEMPT refactor
Change-Id: I2641b5f5ac7bd37da8548bba45735a918d17bd9f
parent ee1835d1
Loading
Loading
Loading
Loading
+21 −17
Original line number Diff line number Diff line
@@ -992,7 +992,19 @@ public final class InputMethodManager {
        private void setCurrentRootViewLocked(ViewRootImpl rootView) {
            final boolean wasEmpty = mCurRootView == null;
            if (Flags.refactorInsetsController() && !wasEmpty && mCurRootView != rootView) {
                final int softInputMode = mCurRootView.mWindowAttributes.softInputMode;
                onImeFocusLost(mCurRootView);
            }

            mImeDispatcher.switchRootView(mCurRootView, rootView);
            mCurRootView = rootView;
            if (wasEmpty && mCurRootView != null) {
                mImeDispatcher.updateReceivingDispatcher(mCurRootView.getOnBackInvokedDispatcher());
            }
        }
    }

    private void onImeFocusLost(@NonNull ViewRootImpl previousRootView) {
        final int softInputMode = previousRootView.mWindowAttributes.softInputMode;
        final int state =
                softInputMode & WindowManager.LayoutParams.SOFT_INPUT_MASK_STATE;
        if (state == WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) {
@@ -1003,22 +1015,14 @@ public final class InputMethodManager {
                    SoftInputShowHideReason.HIDE_WINDOW_LOST_FOCUS,
                    false /* fromUser */);
            if (DEBUG) {
                        Log.d(TAG, "setCurrentRootViewLocked, hiding IME because "
                Log.d(TAG, "onImeFocusLost, hiding IME because "
                        + "of STATE_ALWAYS_HIDDEN");
            }
                    mCurRootView.getInsetsController().hide(WindowInsets.Type.ime(),
            previousRootView.getInsetsController().hide(WindowInsets.Type.ime(),
                    false /* fromIme */, statsToken);
        }
    }

            mImeDispatcher.switchRootView(mCurRootView, rootView);
            mCurRootView = rootView;
            if (wasEmpty && mCurRootView != null) {
                mImeDispatcher.updateReceivingDispatcher(mCurRootView.getOnBackInvokedDispatcher());
            }
        }
    }

    /** @hide */
    public DelegateImpl getDelegate() {
        return mDelegate;