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

Commit c6c7cd27 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Show IME switcher also when hardware keyboard is connected.

As per discussion with UX team, we start showing IME switcher UI
not only when there are multiple IMEs are enabled but also when
a hardware keyboard is connected.

This CL also simplifies needsToShowImeSwitchOngoingNotification()
by renaming it with shouldShowImeSwitcherLocked() and unifying
related condition checking into that method.

Bug: 19496012
Change-Id: Id44724a2a46190382c283a52ece8edffb740807d
parent f038295e
Loading
Loading
Loading
Loading
+49 −44
Original line number Diff line number Diff line
@@ -1624,11 +1624,20 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        }
    }

    private boolean needsToShowImeSwitchOngoingNotification() {
    private boolean shouldShowImeSwitcherLocked() {
        if (!mShowOngoingImeSwitcherForPhones) return false;
        if (mSwitchingDialog != null) return false;
        if (isScreenLocked()) return false;
        synchronized (mMethodMap) {
        if ((mImeWindowVis & InputMethodService.IME_ACTIVE) == 0) return false;
        if (mWindowManagerService.isHardKeyboardAvailable()) {
            // When physical keyboard is attached, we show the ime switcher (or notification if
            // NavBar is not available) because SHOW_IME_WITH_HARD_KEYBOARD settings currently
            // exists in the IME switcher dialog.  Might be OK to remove this condition once
            // SHOW_IME_WITH_HARD_KEYBOARD settings finds a good place to live.
            return true;
        }
        if ((mImeWindowVis & InputMethodService.IME_VISIBLE) == 0) return false;

        List<InputMethodInfo> imis = mSettings.getEnabledInputMethodListLocked();
        final int N = imis.size();
        if (N > 2) return true;
@@ -1671,7 +1680,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        }
        return false;
    }
    }

    private boolean isKeyguardLocked() {
        return mKeyguardManager != null && mKeyguardManager.isKeyguardLocked();
@@ -1697,11 +1705,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                mImeWindowVis = vis;
                mInputShown = ((mImeWindowVis & InputMethodService.IME_VISIBLE) != 0);
                mBackDisposition = backDisposition;
                final boolean iconVisibility = ((vis & (InputMethodService.IME_ACTIVE)) != 0)
                        && (mWindowManagerService.isHardKeyboardAvailable()
                                || (vis & (InputMethodService.IME_VISIBLE)) != 0);
                final boolean needsToShowImeSwitcher = iconVisibility
                        && needsToShowImeSwitchOngoingNotification();
                // mImeWindowVis should be updated before calling shouldShowImeSwitcherLocked().
                final boolean needsToShowImeSwitcher = shouldShowImeSwitcherLocked();
                if (mStatusBar != null) {
                    mStatusBar.setImeWindowStatus(token, vis, backDisposition,
                            needsToShowImeSwitcher);