mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 02:35:19 +08:00
Fix issue where wrong IME inputType would be set if termux was returned to from another app with text input view mode selected
This commit is contained in:
@@ -262,20 +262,29 @@ public final class TerminalView extends View {
|
||||
|
||||
@Override
|
||||
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
|
||||
if (mClient.shouldEnforceCharBasedInput()) {
|
||||
// Some keyboards seems do not reset the internal state on TYPE_NULL.
|
||||
// Affects mostly Samsung stock keyboards.
|
||||
// https://github.com/termux/termux-app/issues/686
|
||||
outAttrs.inputType = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
|
||||
// Ensure that inputType is only set if TerminalView is selected view with the keyboard and
|
||||
// an alternate view is not selected, like an EditText. This is necessary if an activity is
|
||||
// initially started with the alternate view or if activity is returned to from another app
|
||||
// and the alternate view was the one selected the last time.
|
||||
if (mClient.isTerminalViewSelected()) {
|
||||
if (mClient.shouldEnforceCharBasedInput()) {
|
||||
// Some keyboards seems do not reset the internal state on TYPE_NULL.
|
||||
// Affects mostly Samsung stock keyboards.
|
||||
// https://github.com/termux/termux-app/issues/686
|
||||
outAttrs.inputType = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
|
||||
} else {
|
||||
// Using InputType.NULL is the most correct input type and avoids issues with other hacks.
|
||||
//
|
||||
// Previous keyboard issues:
|
||||
// https://github.com/termux/termux-packages/issues/25
|
||||
// https://github.com/termux/termux-app/issues/87.
|
||||
// https://github.com/termux/termux-app/issues/126.
|
||||
// https://github.com/termux/termux-app/issues/137 (japanese chars and TYPE_NULL).
|
||||
outAttrs.inputType = InputType.TYPE_NULL;
|
||||
}
|
||||
} else {
|
||||
// Using InputType.NULL is the most correct input type and avoids issues with other hacks.
|
||||
//
|
||||
// Previous keyboard issues:
|
||||
// https://github.com/termux/termux-packages/issues/25
|
||||
// https://github.com/termux/termux-app/issues/87.
|
||||
// https://github.com/termux/termux-app/issues/126.
|
||||
// https://github.com/termux/termux-app/issues/137 (japanese chars and TYPE_NULL).
|
||||
outAttrs.inputType = InputType.TYPE_NULL;
|
||||
// Corresponds to android:inputType="text"
|
||||
outAttrs.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL;
|
||||
}
|
||||
|
||||
// Note that IME_ACTION_NONE cannot be used as that makes it impossible to input newlines using the on-screen
|
||||
|
@@ -34,6 +34,8 @@ public interface TerminalViewClient {
|
||||
|
||||
boolean shouldUseCtrlSpaceWorkaround();
|
||||
|
||||
boolean isTerminalViewSelected();
|
||||
|
||||
|
||||
|
||||
void copyModeChanged(boolean copyMode);
|
||||
|
Reference in New Issue
Block a user