mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 03:05:18 +08:00
Added: Allow users to disable auto capitalization of extra keys text
The user can add `extra-keys-text-all-cap=false` entry to `termux.properties` file to disable auto capitalization of extra keys text for both normal and popup buttons. The default value is `true`. Running `termux-reload-settings` command will also update the behaviour instantaneously if changed.
This commit is contained in:
@@ -880,6 +880,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
mProperties.loadTermuxPropertiesFromDisk();
|
||||
|
||||
if (mExtraKeysView != null) {
|
||||
mExtraKeysView.setButtonTextAllCaps(mProperties.shouldExtraKeysTextBeAllCaps());
|
||||
mExtraKeysView.reload(mProperties.getExtraKeysInfo());
|
||||
}
|
||||
}
|
||||
|
@@ -46,6 +46,7 @@ public class TerminalToolbarViewPager {
|
||||
ExtraKeysView extraKeysView = (ExtraKeysView) layout;
|
||||
extraKeysView.setExtraKeysViewClient(new TermuxTerminalExtraKeys(mActivity.getTerminalView(),
|
||||
mActivity.getTermuxTerminalViewClient(), mActivity.getTermuxTerminalSessionClient()));
|
||||
extraKeysView.setButtonTextAllCaps(mActivity.getProperties().shouldExtraKeysTextBeAllCaps());
|
||||
mActivity.setExtraKeysView(extraKeysView);
|
||||
extraKeysView.reload(mActivity.getProperties().getExtraKeysInfo());
|
||||
|
||||
|
@@ -14,7 +14,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/*
|
||||
* Version: v0.14.0
|
||||
* Version: v0.15.0
|
||||
*
|
||||
* Changelog
|
||||
*
|
||||
@@ -63,6 +63,9 @@ import java.util.Set;
|
||||
*
|
||||
* - 0.14.0 (2021-09-02)
|
||||
* - Add `getTermuxFloatPropertiesFile()`.
|
||||
*
|
||||
* - 0.15.0 (2021-09-05)
|
||||
* - Add `KEY_EXTRA_KEYS_TEXT_ALL_CAPS`.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -94,6 +97,11 @@ public final class TermuxPropertyConstants {
|
||||
|
||||
|
||||
|
||||
/** Defines the key for whether text for the extra keys buttons should be all capitalized automatically */
|
||||
public static final String KEY_EXTRA_KEYS_TEXT_ALL_CAPS = "extra-keys-text-all-caps"; // Default: "extra-keys-text-all-caps"
|
||||
|
||||
|
||||
|
||||
/** 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"
|
||||
|
||||
@@ -324,6 +332,7 @@ public final class TermuxPropertyConstants {
|
||||
KEY_DISABLE_HARDWARE_KEYBOARD_SHORTCUTS,
|
||||
KEY_DISABLE_TERMINAL_SESSION_CHANGE_TOAST,
|
||||
KEY_ENFORCE_CHAR_BASED_INPUT,
|
||||
KEY_EXTRA_KEYS_TEXT_ALL_CAPS,
|
||||
KEY_HIDE_SOFT_KEYBOARD_ON_STARTUP,
|
||||
KEY_TERMINAL_ONCLICK_URL_OPEN,
|
||||
KEY_USE_BLACK_UI,
|
||||
@@ -358,12 +367,12 @@ public final class TermuxPropertyConstants {
|
||||
KEY_VOLUME_KEYS_BEHAVIOUR
|
||||
));
|
||||
|
||||
/** Defines the set for keys loaded by termux that have default boolean behaviour
|
||||
/** Defines the set for keys loaded by termux that have default boolean behaviour with false as default.
|
||||
* "true" -> true
|
||||
* "false" -> false
|
||||
* default: false
|
||||
* */
|
||||
public static final Set<String> TERMUX_DEFAULT_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
|
||||
*/
|
||||
public static final Set<String> TERMUX_DEFAULT_FALSE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
|
||||
KEY_DISABLE_HARDWARE_KEYBOARD_SHORTCUTS,
|
||||
KEY_DISABLE_TERMINAL_SESSION_CHANGE_TOAST,
|
||||
KEY_ENFORCE_CHAR_BASED_INPUT,
|
||||
@@ -375,17 +384,35 @@ public final class TermuxPropertyConstants {
|
||||
TermuxConstants.PROP_ALLOW_EXTERNAL_APPS
|
||||
));
|
||||
|
||||
/** Defines the set for keys loaded by termux that have default inverted boolean behaviour
|
||||
/** Defines the set for keys loaded by termux that have default boolean behaviour with true as default.
|
||||
* "true" -> true
|
||||
* "false" -> false
|
||||
* default: true
|
||||
*/
|
||||
public static final Set<String> TERMUX_DEFAULT_TRUE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
|
||||
KEY_EXTRA_KEYS_TEXT_ALL_CAPS
|
||||
));
|
||||
|
||||
/** Defines the set for keys loaded by termux that have default inverted boolean behaviour with false as default.
|
||||
* "false" -> true
|
||||
* "true" -> false
|
||||
* default: false
|
||||
*/
|
||||
public static final Set<String> TERMUX_DEFAULT_INVERETED_FALSE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
|
||||
));
|
||||
|
||||
/** Defines the set for keys loaded by termux that have default inverted boolean behaviour with true as default.
|
||||
* "false" -> true
|
||||
* "true" -> false
|
||||
* default: true
|
||||
* */
|
||||
public static final Set<String> TERMUX_DEFAULT_INVERETED_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
|
||||
*/
|
||||
public static final Set<String> TERMUX_DEFAULT_INVERETED_TRUE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
|
||||
));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Returns the first {@link File} found at
|
||||
* {@link TermuxConstants#TERMUX_PROPERTIES_PRIMARY_FILE_PATH} or
|
||||
* {@link TermuxConstants#TERMUX_PROPERTIES_SECONDARY_FILE_PATH}
|
||||
|
@@ -257,12 +257,18 @@ public abstract class TermuxSharedProperties {
|
||||
return (String) getVolumeKeysBehaviourInternalPropertyValueFromValue(value);
|
||||
|
||||
default:
|
||||
// default boolean behaviour
|
||||
if (TermuxPropertyConstants.TERMUX_DEFAULT_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key))
|
||||
// default false boolean behaviour
|
||||
if (TermuxPropertyConstants.TERMUX_DEFAULT_FALSE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key))
|
||||
return (boolean) SharedProperties.getBooleanValueForStringValue(key, value, false, true, LOG_TAG);
|
||||
// default inverted boolean behaviour
|
||||
else if (TermuxPropertyConstants.TERMUX_DEFAULT_INVERETED_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key))
|
||||
return (boolean) SharedProperties.getInvertedBooleanValueForStringValue(key, value, true, true, LOG_TAG);
|
||||
// default true boolean behaviour
|
||||
if (TermuxPropertyConstants.TERMUX_DEFAULT_TRUE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key))
|
||||
return (boolean) SharedProperties.getBooleanValueForStringValue(key, value, true, true, LOG_TAG);
|
||||
// default inverted false boolean behaviour
|
||||
//else if (TermuxPropertyConstants.TERMUX_DEFAULT_INVERETED_FALSE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key))
|
||||
// return (boolean) SharedProperties.getInvertedBooleanValueForStringValue(key, value, false, true, LOG_TAG);
|
||||
// default inverted true boolean behaviour
|
||||
// else if (TermuxPropertyConstants.TERMUX_DEFAULT_INVERETED_TRUE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key))
|
||||
// return (boolean) SharedProperties.getInvertedBooleanValueForStringValue(key, value, true, true, LOG_TAG);
|
||||
// just use String object as is (may be null)
|
||||
else
|
||||
return value;
|
||||
@@ -517,6 +523,10 @@ public abstract class TermuxSharedProperties {
|
||||
return (boolean) getInternalPropertyValue(TermuxPropertyConstants.KEY_ENFORCE_CHAR_BASED_INPUT, true);
|
||||
}
|
||||
|
||||
public boolean shouldExtraKeysTextBeAllCaps() {
|
||||
return (boolean) getInternalPropertyValue(TermuxPropertyConstants.KEY_EXTRA_KEYS_TEXT_ALL_CAPS, true);
|
||||
}
|
||||
|
||||
public boolean shouldSoftKeyboardBeHiddenOnStartup() {
|
||||
return (boolean) getInternalPropertyValue(TermuxPropertyConstants.KEY_HIDE_SOFT_KEYBOARD_ON_STARTUP, true);
|
||||
}
|
||||
|
@@ -163,6 +163,9 @@ public final class ExtraKeysView extends GridLayout {
|
||||
* {@link #DEFAULT_BUTTON_ACTIVE_BACKGROUND_COLOR}. */
|
||||
private int mButtonActiveBackgroundColor;
|
||||
|
||||
/** Defines whether text for the extra keys button should be all capitalized automatically. */
|
||||
private boolean mButtonTextAllCaps = true;
|
||||
|
||||
|
||||
/**
|
||||
* Defines the duration in milliseconds before a press turns into a long press. The default
|
||||
@@ -305,6 +308,11 @@ public final class ExtraKeysView extends GridLayout {
|
||||
mButtonActiveBackgroundColor = buttonActiveBackgroundColor;
|
||||
}
|
||||
|
||||
/** Set {@link #mButtonTextAllCaps}. */
|
||||
public void setButtonTextAllCaps(boolean buttonTextAllCaps) {
|
||||
mButtonTextAllCaps = buttonTextAllCaps;
|
||||
}
|
||||
|
||||
|
||||
/** Get {@link #mLongPressTimeout}. */
|
||||
public int getLongPressTimeout() {
|
||||
@@ -382,6 +390,7 @@ public final class ExtraKeysView extends GridLayout {
|
||||
|
||||
button.setText(buttonInfo.getDisplay());
|
||||
button.setTextColor(mButtonTextColor);
|
||||
button.setAllCaps(mButtonTextAllCaps);
|
||||
button.setPadding(0, 0, 0, 0);
|
||||
|
||||
button.setOnClickListener(view -> {
|
||||
@@ -564,6 +573,7 @@ public final class ExtraKeysView extends GridLayout {
|
||||
button.setTextColor(mButtonTextColor);
|
||||
}
|
||||
button.setText(extraButton.getDisplay());
|
||||
button.setAllCaps(mButtonTextAllCaps);
|
||||
button.setPadding(0, 0, 0, 0);
|
||||
button.setMinHeight(0);
|
||||
button.setMinWidth(0);
|
||||
|
Reference in New Issue
Block a user