mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 18:55:31 +08:00
Fix issue where a colour tint/highlight would be added to the terminal
This would happen when soft keyboard was to be disabled or hidden at startup and a hardware keyboard was attached and user started typing on hardware keyboard without tapping on the terminal first.
This commit is contained in:
@@ -484,7 +484,13 @@ public class TermuxTerminalViewClient extends TermuxTerminalViewClientBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSoftKeyboardState(boolean isStartup, boolean isReloadTermuxProperties) {
|
public void setSoftKeyboardState(boolean isStartup, boolean isReloadTermuxProperties) {
|
||||||
boolean noRequestFocus = false;
|
boolean noShowKeyboard = false;
|
||||||
|
|
||||||
|
// Requesting terminal view focus is necessary regardless of if soft keyboard is to be
|
||||||
|
// disabled or hidden at startup, otherwise if hardware keyboard is attached and user
|
||||||
|
// starts typing on hardware keyboard without tapping on the terminal first, then a colour
|
||||||
|
// tint will be added to the terminal as highlight for the focussed view. Test with a light
|
||||||
|
// theme.
|
||||||
|
|
||||||
// If soft keyboard is disabled by user for Termux (check function docs for Termux behaviour info)
|
// If soft keyboard is disabled by user for Termux (check function docs for Termux behaviour info)
|
||||||
if (KeyboardUtils.shouldSoftKeyboardBeDisabled(mActivity,
|
if (KeyboardUtils.shouldSoftKeyboardBeDisabled(mActivity,
|
||||||
@@ -492,7 +498,8 @@ public class TermuxTerminalViewClient extends TermuxTerminalViewClientBase {
|
|||||||
mActivity.getPreferences().isSoftKeyboardEnabledOnlyIfNoHardware())) {
|
mActivity.getPreferences().isSoftKeyboardEnabledOnlyIfNoHardware())) {
|
||||||
Logger.logVerbose(LOG_TAG, "Maintaining disabled soft keyboard");
|
Logger.logVerbose(LOG_TAG, "Maintaining disabled soft keyboard");
|
||||||
KeyboardUtils.disableSoftKeyboard(mActivity, mActivity.getTerminalView());
|
KeyboardUtils.disableSoftKeyboard(mActivity, mActivity.getTerminalView());
|
||||||
noRequestFocus = true;
|
mActivity.getTerminalView().requestFocus();
|
||||||
|
noShowKeyboard = true;
|
||||||
// Delay is only required if onCreate() is called like when Termux app is exited with
|
// Delay is only required if onCreate() is called like when Termux app is exited with
|
||||||
// double back press, not when Termux app is switched back from another app and keyboard
|
// double back press, not when Termux app is switched back from another app and keyboard
|
||||||
// toggle is pressed to enable keyboard
|
// toggle is pressed to enable keyboard
|
||||||
@@ -508,10 +515,12 @@ public class TermuxTerminalViewClient extends TermuxTerminalViewClientBase {
|
|||||||
// If soft keyboard is to be hidden on startup
|
// If soft keyboard is to be hidden on startup
|
||||||
if (isStartup && mActivity.getProperties().shouldSoftKeyboardBeHiddenOnStartup()) {
|
if (isStartup && mActivity.getProperties().shouldSoftKeyboardBeHiddenOnStartup()) {
|
||||||
Logger.logVerbose(LOG_TAG, "Hiding soft keyboard on startup");
|
Logger.logVerbose(LOG_TAG, "Hiding soft keyboard on startup");
|
||||||
KeyboardUtils.hideSoftKeyboard(mActivity, mActivity.getTerminalView());
|
|
||||||
// Required to keep keyboard hidden when Termux app is switched back from another app
|
// Required to keep keyboard hidden when Termux app is switched back from another app
|
||||||
KeyboardUtils.setSoftKeyboardAlwaysHiddenFlags(mActivity);
|
KeyboardUtils.setSoftKeyboardAlwaysHiddenFlags(mActivity);
|
||||||
noRequestFocus = true;
|
|
||||||
|
KeyboardUtils.hideSoftKeyboard(mActivity, mActivity.getTerminalView());
|
||||||
|
mActivity.getTerminalView().requestFocus();
|
||||||
|
noShowKeyboard = true;
|
||||||
// Required to keep keyboard hidden on app startup
|
// Required to keep keyboard hidden on app startup
|
||||||
mShowSoftKeyboardIgnoreOnce = true;
|
mShowSoftKeyboardIgnoreOnce = true;
|
||||||
}
|
}
|
||||||
@@ -541,7 +550,7 @@ public class TermuxTerminalViewClient extends TermuxTerminalViewClientBase {
|
|||||||
|
|
||||||
// Do not force show soft keyboard if termux-reload-settings command was run with hardware keyboard
|
// Do not force show soft keyboard if termux-reload-settings command was run with hardware keyboard
|
||||||
// or soft keyboard is to be hidden or is disabled
|
// or soft keyboard is to be hidden or is disabled
|
||||||
if (!isReloadTermuxProperties && !noRequestFocus) {
|
if (!isReloadTermuxProperties && !noShowKeyboard) {
|
||||||
// Request focus for TerminalView
|
// Request focus for TerminalView
|
||||||
// Also show the keyboard, since onFocusChange will not be called if TerminalView already
|
// Also show the keyboard, since onFocusChange will not be called if TerminalView already
|
||||||
// had focus on startup to show the keyboard, like when opening url with context menu
|
// had focus on startup to show the keyboard, like when opening url with context menu
|
||||||
|
Reference in New Issue
Block a user