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

Commit b70c82dc authored by satok's avatar satok
Browse files

Hide IME Switch Button when a handset is locked.

Bug: 3247192

Change-Id: I61a327b480c5b3055a14219050cebb04cf0adf6e
parent d57896a6
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -61,14 +61,14 @@ public class InputMethodButton extends ImageView {
            new HashMap<String, InputMethodInfo>();
    private ImageView mIcon;
    private IBinder mToken;
    private boolean mKeyboardShown;
    private boolean mKeyboardVisible = false;
    private boolean mScreenLocked = false;
    private InputMethodInfo mShortcutInfo;
    private InputMethodSubtype mShortcutSubtype;

    public InputMethodButton(Context context, AttributeSet attrs) {
        super(context, attrs);

        mKeyboardShown = false;
        // Resource Id of the input method button. This id is defined in status_bar.xml
        mId = getId();
        // IME hookup
@@ -99,7 +99,7 @@ public class InputMethodButton extends ImageView {
    protected void onAttachedToWindow() {
        mIcon = (ImageView) findViewById(mId);

        refreshStatusIcon(mKeyboardShown);
        refreshStatusIcon();
    }

    private InputMethodInfo getCurrentInputMethodInfo() {
@@ -167,6 +167,7 @@ public class InputMethodButton extends ImageView {
    // * There are no explicitly enabled (by the user) subtypes of the IME, or the IME doesn't have
    // its subtypes at all
    private boolean needsToShowIMEButton() {
        if (!mKeyboardVisible || mScreenLocked) return false;
        List<InputMethodInfo> imis = mImm.getEnabledInputMethodList();
        final int size = imis.size();
        final int visibility = loadInputMethodSelectorVisibility();
@@ -182,8 +183,8 @@ public class InputMethodButton extends ImageView {
        return false;
    }

    private void refreshStatusIcon(boolean keyboardShown) {
        if (!keyboardShown) {
    private void refreshStatusIcon() {
        if (!needsToShowIMEButton()) {
            setVisibility(View.INVISIBLE);
            return;
        } else {
@@ -215,9 +216,14 @@ public class InputMethodButton extends ImageView {
                Settings.Secure.INPUT_METHOD_SELECTOR_VISIBILITY, ID_IME_BUTTON_VISIBILITY_AUTO);
    }

    public void setIMEButtonVisible(IBinder token, boolean visible) {
    public void setIMEButtonVisible(IBinder token, boolean keyboardVisible) {
        mToken = token;
        mKeyboardShown = visible ? needsToShowIMEButton() : false;
        refreshStatusIcon(mKeyboardShown);
        mKeyboardVisible = keyboardVisible;
        refreshStatusIcon();
    }

    public void setScreenLocked(boolean locked) {
        mScreenLocked = locked;
        refreshStatusIcon();
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -692,9 +692,11 @@ public class TabletStatusBar extends StatusBar {
            if ((state & StatusBarManager.DISABLE_NAVIGATION) != 0) {
                Slog.d(TAG, "DISABLE_NAVIGATION: yes");
                mNavigationArea.setVisibility(View.GONE);
                mInputMethodSwitchButton.setScreenLocked(true);
            } else {
                Slog.d(TAG, "DISABLE_NAVIGATION: no");
                mNavigationArea.setVisibility(View.VISIBLE);
                mInputMethodSwitchButton.setScreenLocked(false);
            }
        }
    }