mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-10 04:24:05 +08:00
Allow users to disable soft keyboard automatically if hardware keyboard is connected
Users can enable this behaviour by enabling the `Termux Settings` -> `Keyboard I/O` -> `Soft Keyboard Only If No Hardware` toggle. Currently, for this case, soft keyboard will be disabled on Termux app startup and when switching back from another app. Soft keyboard can be temporarily enabled in show/hide soft keyboard toggle behaviour with keyboard toggle buttons and will continue to work when tapping on terminal view for opening and back button for closing, until Termux app is switched to another app. After returning back, keyboard will be disabled until toggle is pressed again. This also may help for the Lineage OS bug where blank space is shown where soft keyboard should be if "Show soft keyboard" toggle in "Language and Input" is disabled. Check KeyboardUtils.shouldSoftKeyboardBeDisabled() and https://github.com/termux/termux-app/issues/1995#issuecomment-837080079 for details. The `TermuxPreferenceConstants` class has been updated to `v0.10.0`. Check its Changelog sections for info on changes.
This commit is contained in:
@@ -62,6 +62,14 @@ public class TermuxAppSharedPreferences {
|
||||
SharedPreferenceUtils.setBoolean(mSharedPreferences, TERMUX_APP.KEY_SOFT_KEYBOARD_ENABLED, value, false);
|
||||
}
|
||||
|
||||
public boolean getSoftKeyboardEnabledOnlyIfNoHardware() {
|
||||
return SharedPreferenceUtils.getBoolean(mSharedPreferences, TERMUX_APP.KEY_SOFT_KEYBOARD_ENABLED_ONLY_IF_NO_HARDWARE, TERMUX_APP.DEFAULT_VALUE_KEY_SOFT_KEYBOARD_ENABLED_ONLY_IF_NO_HARDWARE);
|
||||
}
|
||||
|
||||
public void setSoftKeyboardEnabledOnlyIfNoHardware(boolean value) {
|
||||
SharedPreferenceUtils.setBoolean(mSharedPreferences, TERMUX_APP.KEY_SOFT_KEYBOARD_ENABLED_ONLY_IF_NO_HARDWARE, value, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean getKeepScreenOn() {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package com.termux.shared.settings.preferences;
|
||||
|
||||
/*
|
||||
* Version: v0.9.0
|
||||
* Version: v0.10.0
|
||||
*
|
||||
* Changelog
|
||||
*
|
||||
@@ -40,6 +40,10 @@ package com.termux.shared.settings.preferences;
|
||||
*
|
||||
* - 0.9.0 (2021-04-07)
|
||||
* - Updated javadocs.
|
||||
*
|
||||
* - 0.10.0 (2021-05-12)
|
||||
* - Added following to `TERMUX_APP`:
|
||||
* `KEY_SOFT_KEYBOARD_ENABLED_ONLY_IF_NO_HARDWARE` and `DEFAULT_VALUE_KEY_SOFT_KEYBOARD_ENABLED_ONLY_IF_NO_HARDWARE`.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -70,6 +74,13 @@ public final class TermuxPreferenceConstants {
|
||||
public static final String KEY_SOFT_KEYBOARD_ENABLED = "soft_keyboard_enabled";
|
||||
public static final boolean DEFAULT_VALUE_KEY_SOFT_KEYBOARD_ENABLED = true;
|
||||
|
||||
/**
|
||||
* Defines the key for whether the soft keyboard will be enabled only if no hardware keyboard
|
||||
* attached, for cases where users want to use a hardware keyboard instead.
|
||||
*/
|
||||
public static final String KEY_SOFT_KEYBOARD_ENABLED_ONLY_IF_NO_HARDWARE = "soft_keyboard_enabled_only_if_no_hardware";
|
||||
public static final boolean DEFAULT_VALUE_KEY_SOFT_KEYBOARD_ENABLED_ONLY_IF_NO_HARDWARE = false;
|
||||
|
||||
|
||||
/**
|
||||
* Defines the key for whether to always keep screen on.
|
||||
|
Reference in New Issue
Block a user