termux / termux-app

Termux - a terminal emulator application for Android OS extendible by variety of packages.
https://f-droid.org/en/packages/com.termux
Other
36.94k stars 3.88k forks source link

[Bug]: Cannot change language with external keyboard. #4133

Open uncher opened 2 months ago

uncher commented 2 months ago

Problem description

Samsung Tab S9 FE with original external keyboard Book Cover Keyboard. This keyboard has separate key "Lang" for changing language. Termux version 0.118.1. Then i working in Termux - i cant change language with key Lang, Ctrl+Space hotkey also not working.

Steps to reproduce the behavior.

Samsung Tab S9 FE with Book Cover Keyboard, installed Termux app.

What is the expected behavior?

No response

System information

uncher commented 2 months ago

"change language" I mean keyboard layout

uncher commented 1 month ago

For mysefl I found next solution. In file termux-app-master\terminal-view\src\main\java\com\termux\view\TerminalView.java i add another else-if condition with KeyEvent.KEYCODE_LANGUAGE_SWITCH, change

        if (mClient.onKeyDown(keyCode, event, mTermSession)) {
            invalidate();
            return true;
        } else if (event.isSystem() && (!mClient.shouldBackButtonBeMappedToEscape() || keyCode != KeyEvent.KEYCODE_BACK)) {
            return super.onKeyDown(keyCode, event);
        } else if (event.getAction() == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
            mTermSession.write(event.getCharacters());
            return true;
        }

to

        if (mClient.onKeyDown(keyCode, event, mTermSession)) {
            invalidate();
            return true;
        } else if (event.isSystem() && (!mClient.shouldBackButtonBeMappedToEscape() || keyCode != KeyEvent.KEYCODE_BACK)) {
            return super.onKeyDown(keyCode, event);
        } else if (event.getAction() == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
            mTermSession.write(event.getCharacters());
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH) {
            return super.onKeyDown(keyCode, event);
        }

Work perfect for me. For building application i use last Android Studio Ladybug | 2024.2.1, Gradle JDK - Amazon Corretto 17.0.12