Skip to content

Commit

Permalink
Add hide-soft-keyboard-on-startup property
Browse files Browse the repository at this point in the history
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 termux#1978
  • Loading branch information
agnostic-apollo committed Mar 25, 2021
1 parent 5e0637f commit 6cac463
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
9 changes: 7 additions & 2 deletions app/src/main/java/com/termux/app/TermuxActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,20 @@ private void setNewSessionButtonView() {

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();
});

findViewById(R.id.toggle_keyboard_button).setOnLongClickListener(v -> {
toggleTerminalToolbar();
return true;
});

// If soft keyboard is to be hidden on startup
if(mProperties.shouldSoftKeyboardBeHiddenOnStartup()) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@
import java.util.Set;

/*
* Version: v0.4.0
* Version: v0.5.0
*
* Changelog
*
* - 0.1.0 (2021-03-11)
* - 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`.
*/

/**
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ public boolean isEnforcingCharBasedInput() {
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);
}
Expand Down

0 comments on commit 6cac463

Please sign in to comment.