Skip to content

Commit e08e3b5

Browse files
Do not close soft keyboard when toolbar text input view is focused on
The TerminalToolbarViewPager EditText was requesting focus when it was selected. This called the TerminalView.onFocusChange() event with hasFocus=false, which closed the soft keyboard. Now soft keyboard will only be closed if both of them don't have focus. Fixes #2077
1 parent b711a46 commit e08e3b5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/src/main/java/com/termux/app/terminal/TermuxTerminalViewClient.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import android.view.KeyEvent;
1616
import android.view.MotionEvent;
1717
import android.view.View;
18+
import android.widget.EditText;
1819
import android.widget.ListView;
1920
import android.widget.Toast;
2021

@@ -464,8 +465,12 @@ public void setSoftKeyboardState(boolean isStartup, boolean isReloadTermuxProper
464465
mActivity.getTerminalView().setOnFocusChangeListener(new View.OnFocusChangeListener() {
465466
@Override
466467
public void onFocusChange(View view, boolean hasFocus) {
467-
// Force show soft keyboard if TerminalView has focus and close it if it doesn't
468-
KeyboardUtils.setSoftKeyboardVisibility(mShowSoftKeyboardRunnable, mActivity, mActivity.getTerminalView(), hasFocus);
468+
// Force show soft keyboard if TerminalView or toolbar text input view has
469+
// focus and close it if they don't
470+
boolean textInputViewHasFocus = false;
471+
final EditText textInputView = mActivity.findViewById(R.id.terminal_toolbar_text_input);
472+
if (textInputView != null) textInputViewHasFocus = textInputView.hasFocus();
473+
KeyboardUtils.setSoftKeyboardVisibility(mShowSoftKeyboardRunnable, mActivity, mActivity.getTerminalView(), hasFocus || textInputViewHasFocus);
469474
}
470475
});
471476

0 commit comments

Comments
 (0)