mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 10:45:23 +08:00
Add hide-soft-keyboard-on-startup property
If its set to `true` in termux.properties file, then soft keyboard will automatically be hidden on Termux App start to solve issues for when users use hardware keyboard and soft keyboard is automatically opened and wastes terminal screen space. The `TermuxPropertyConstants` classes has been updated to `v0.5.0`. Check its Changelog sections for info on changes. Fixes #1978
This commit is contained in:
@@ -405,8 +405,8 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
|
||||
private void setToggleKeyboardView() {
|
||||
findViewById(R.id.toggle_keyboard_button).setOnClickListener(v -> {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
|
||||
getDrawer().closeDrawers();
|
||||
});
|
||||
|
||||
@@ -414,6 +414,11 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
toggleTerminalToolbar();
|
||||
return true;
|
||||
});
|
||||
|
||||
// If soft keyboard is to be hidden on startup
|
||||
if(mProperties.shouldSoftKeyboardBeHiddenOnStartup()) {
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -10,7 +10,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/*
|
||||
* Version: v0.4.0
|
||||
* Version: v0.5.0
|
||||
*
|
||||
* Changelog
|
||||
*
|
||||
@@ -18,15 +18,18 @@ import java.util.Set;
|
||||
* - Initial Release.
|
||||
*
|
||||
* - 0.2.0 (2021-03-11)
|
||||
* - Renamed `HOME_PATH` to `TERMUX_HOME_DIR_PATH`
|
||||
* - Renamed `TERMUX_PROPERTIES_PRIMARY_PATH` to `TERMUX_PROPERTIES_PRIMARY_FILE_PATH`
|
||||
* - Renamed `TERMUX_PROPERTIES_SECONDARY_FILE_PATH` to `TERMUX_PROPERTIES_SECONDARY_FILE_PATH`
|
||||
* - Renamed `HOME_PATH` to `TERMUX_HOME_DIR_PATH`.
|
||||
* - Renamed `TERMUX_PROPERTIES_PRIMARY_PATH` to `TERMUX_PROPERTIES_PRIMARY_FILE_PATH`.
|
||||
* - Renamed `TERMUX_PROPERTIES_SECONDARY_FILE_PATH` to `TERMUX_PROPERTIES_SECONDARY_FILE_PATH`.
|
||||
*
|
||||
* - 0.3.0 (2021-03-16)
|
||||
* - Add `*TERMINAL_TOOLBAR_HEIGHT_SCALE_FACTOR*`
|
||||
* - Add `*TERMINAL_TOOLBAR_HEIGHT_SCALE_FACTOR*`.
|
||||
*
|
||||
* - 0.4.0 (2021-03-16)
|
||||
* - Removed `MAP_GENERIC_BOOLEAN` and `MAP_GENERIC_INVERTED_BOOLEAN`.
|
||||
*
|
||||
* - 0.5.0 (2021-03-25)
|
||||
* - Add `KEY_HIDE_SOFT_KEYBOARD_ON_STARTUP`.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -55,6 +58,11 @@ public final class TermuxPropertyConstants {
|
||||
|
||||
|
||||
|
||||
/** Defines the key for whether to hide soft keyboard when termux app is started */
|
||||
public static final String KEY_HIDE_SOFT_KEYBOARD_ON_STARTUP = "hide-soft-keyboard-on-startup"; // Default: "hide-soft-keyboard-on-startup"
|
||||
|
||||
|
||||
|
||||
/** Defines the key for whether to use black UI */
|
||||
public static final String KEY_USE_BLACK_UI = "use-black-ui"; // Default: "use-black-ui"
|
||||
|
||||
@@ -163,6 +171,7 @@ public final class TermuxPropertyConstants {
|
||||
public static final Set<String> TERMUX_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
|
||||
// boolean
|
||||
KEY_ENFORCE_CHAR_BASED_INPUT,
|
||||
KEY_HIDE_SOFT_KEYBOARD_ON_STARTUP,
|
||||
KEY_USE_BACK_KEY_AS_ESCAPE_KEY,
|
||||
KEY_USE_BLACK_UI,
|
||||
KEY_USE_CTRL_SPACE_WORKAROUND,
|
||||
@@ -196,6 +205,7 @@ public final class TermuxPropertyConstants {
|
||||
* */
|
||||
public static final Set<String> TERMUX_DEFAULT_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
|
||||
KEY_ENFORCE_CHAR_BASED_INPUT,
|
||||
KEY_HIDE_SOFT_KEYBOARD_ON_STARTUP,
|
||||
KEY_USE_CTRL_SPACE_WORKAROUND,
|
||||
KEY_USE_FULLSCREEN,
|
||||
KEY_USE_FULLSCREEN_WORKAROUND,
|
||||
|
@@ -437,6 +437,10 @@ public class TermuxSharedProperties implements SharedPropertiesParser {
|
||||
return (boolean) getInternalPropertyValue(TermuxPropertyConstants.KEY_ENFORCE_CHAR_BASED_INPUT, true);
|
||||
}
|
||||
|
||||
public boolean shouldSoftKeyboardBeHiddenOnStartup() {
|
||||
return (boolean) getInternalPropertyValue(TermuxPropertyConstants.KEY_HIDE_SOFT_KEYBOARD_ON_STARTUP, true);
|
||||
}
|
||||
|
||||
public boolean isBackKeyTheEscapeKey() {
|
||||
return (boolean) getInternalPropertyValue(TermuxPropertyConstants.KEY_USE_BACK_KEY_AS_ESCAPE_KEY, true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user