@@ -484,15 +484,22 @@ public void onToggleSoftKeyboardRequest() {
484
484
}
485
485
486
486
public void setSoftKeyboardState (boolean isStartup , boolean isReloadTermuxProperties ) {
487
- boolean noRequestFocus = false ;
487
+ boolean noShowKeyboard = false ;
488
+
489
+ // Requesting terminal view focus is necessary regardless of if soft keyboard is to be
490
+ // disabled or hidden at startup, otherwise if hardware keyboard is attached and user
491
+ // starts typing on hardware keyboard without tapping on the terminal first, then a colour
492
+ // tint will be added to the terminal as highlight for the focussed view. Test with a light
493
+ // theme.
488
494
489
495
// If soft keyboard is disabled by user for Termux (check function docs for Termux behaviour info)
490
496
if (KeyboardUtils .shouldSoftKeyboardBeDisabled (mActivity ,
491
497
mActivity .getPreferences ().isSoftKeyboardEnabled (),
492
498
mActivity .getPreferences ().isSoftKeyboardEnabledOnlyIfNoHardware ())) {
493
499
Logger .logVerbose (LOG_TAG , "Maintaining disabled soft keyboard" );
494
500
KeyboardUtils .disableSoftKeyboard (mActivity , mActivity .getTerminalView ());
495
- noRequestFocus = true ;
501
+ mActivity .getTerminalView ().requestFocus ();
502
+ noShowKeyboard = true ;
496
503
// Delay is only required if onCreate() is called like when Termux app is exited with
497
504
// double back press, not when Termux app is switched back from another app and keyboard
498
505
// toggle is pressed to enable keyboard
@@ -508,10 +515,12 @@ public void setSoftKeyboardState(boolean isStartup, boolean isReloadTermuxProper
508
515
// If soft keyboard is to be hidden on startup
509
516
if (isStartup && mActivity .getProperties ().shouldSoftKeyboardBeHiddenOnStartup ()) {
510
517
Logger .logVerbose (LOG_TAG , "Hiding soft keyboard on startup" );
511
- KeyboardUtils .hideSoftKeyboard (mActivity , mActivity .getTerminalView ());
512
518
// Required to keep keyboard hidden when Termux app is switched back from another app
513
519
KeyboardUtils .setSoftKeyboardAlwaysHiddenFlags (mActivity );
514
- noRequestFocus = true ;
520
+
521
+ KeyboardUtils .hideSoftKeyboard (mActivity , mActivity .getTerminalView ());
522
+ mActivity .getTerminalView ().requestFocus ();
523
+ noShowKeyboard = true ;
515
524
// Required to keep keyboard hidden on app startup
516
525
mShowSoftKeyboardIgnoreOnce = true ;
517
526
}
@@ -541,7 +550,7 @@ public void onFocusChange(View view, boolean hasFocus) {
541
550
542
551
// Do not force show soft keyboard if termux-reload-settings command was run with hardware keyboard
543
552
// or soft keyboard is to be hidden or is disabled
544
- if (!isReloadTermuxProperties && !noRequestFocus ) {
553
+ if (!isReloadTermuxProperties && !noShowKeyboard ) {
545
554
// Request focus for TerminalView
546
555
// Also show the keyboard, since onFocusChange will not be called if TerminalView already
547
556
// had focus on startup to show the keyboard, like when opening url with context menu
0 commit comments