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

Commit c3d175c0 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Fix wrong keyboard width when orientation has changed while IME is not shown

Bug: 5084021
Change-Id: Ie42da40b8249eaf9cf29707058906949278eff6a
parent 0a5345c7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ public class KeyboardId {
        return other instanceof KeyboardId && equals((KeyboardId) other);
    }

    boolean equals(KeyboardId other) {
    private boolean equals(KeyboardId other) {
        return other.mLocale.equals(this.mLocale)
            && other.mOrientation == this.mOrientation
            && other.mWidth == this.mWidth
+8 −7
Original line number Diff line number Diff line
@@ -161,24 +161,25 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
        }
    }

    public void onHideWindow() {
        mWindowWidth = 0;
        mIsAutoCorrectionActive = false;
    }

    @SuppressWarnings("unused")
    public void onSizeChanged(int w, int h, int oldw, int oldh) {
        // TODO: This hack should be removed when display metric returns a proper width.
        // Until then, the behavior of KeyboardSwitcher is suboptimal on a device that has a
        // vertical system navigation bar in landscape screen orientation, for instance.
        final int width = mInputMethodService.getWindow().getWindow().getDecorView().getWidth();
        // If the window width hasn't fixed yet or keyboard doesn't exist, nothing to do with.
        if (width == 0 || mCurrentId == null)
            return;
        // The window width is fixed.
        mWindowWidth = width;
        // If this is the first time the {@link KeyboardView} has been shown, no need to reload
        // keyboard.
        if (oldw == 0 && oldh == 0)
            return;
        // Reload keyboard with new width.
        final int orientation = mInputMethodService.getResources().getConfiguration().orientation;
        final KeyboardId newId = mCurrentId.cloneWithNewGeometry(orientation, width);
        // If the new keyboard is the same as the current one, no need to reload it.
        if (newId.equals(mCurrentId))
            return;
        setKeyboard(getKeyboard(newId));
    }

+1 −1
Original line number Diff line number Diff line
@@ -872,7 +872,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
    @Override
    public void hideWindow() {
        LatinImeLogger.commit();
        mKeyboardSwitcher.onAutoCorrectionStateChanged(false);
        mKeyboardSwitcher.onHideWindow();

        if (TRACE) Debug.stopMethodTracing();
        if (mOptionsDialog != null && mOptionsDialog.isShowing()) {