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

Commit fa781b11 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Refactor onImeFocusLost part from setCurrentRootViewLocked for better readability" into main

parents 4d6a407f b58f340a
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;