Skip to content

Commit

Permalink
Added: Allow users to disable auto capitalization of extra keys text
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
agnostic-apollo committed Sep 4, 2021
1 parent b62645c commit 5c72c3c
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/com/termux/app/TermuxActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ private void reloadActivityStyling() {
mProperties.loadTermuxPropertiesFromDisk();

if (mExtraKeysView != null) {
mExtraKeysView.setButtonTextAllCaps(mProperties.shouldExtraKeysTextBeAllCaps());
mExtraKeysView.reload(mProperties.getExtraKeysInfo());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public Object instantiateItem(@NonNull ViewGroup collection, int position) {
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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Set;

/*
* Version: v0.14.0
* Version: v0.15.0
*
* Changelog
*
Expand Down Expand Up @@ -63,6 +63,9 @@
*
* - 0.14.0 (2021-09-02)
* - Add `getTermuxFloatPropertiesFile()`.
*
* - 0.15.0 (2021-09-05)
* - Add `KEY_EXTRA_KEYS_TEXT_ALL_CAPS`.
*/

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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,18 @@ public static Object getInternalTermuxPropertyValueFromValue(Context context, St
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;
Expand Down Expand Up @@ -517,6 +523,10 @@ public boolean isEnforcingCharBasedInput() {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ public interface IExtraKeysView {
* {@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
Expand Down Expand Up @@ -305,6 +308,11 @@ public void setButtonActiveBackgroundColor(int buttonActiveBackgroundColor) {
mButtonActiveBackgroundColor = buttonActiveBackgroundColor;
}

/** Set {@link #mButtonTextAllCaps}. */
public void setButtonTextAllCaps(boolean buttonTextAllCaps) {
mButtonTextAllCaps = buttonTextAllCaps;
}


/** Get {@link #mLongPressTimeout}. */
public int getLongPressTimeout() {
Expand Down Expand Up @@ -382,6 +390,7 @@ public void reload(ExtraKeysInfo extraKeysInfo) {

button.setText(buttonInfo.getDisplay());
button.setTextColor(mButtonTextColor);
button.setAllCaps(mButtonTextAllCaps);
button.setPadding(0, 0, 0, 0);

button.setOnClickListener(view -> {
Expand Down Expand Up @@ -564,6 +573,7 @@ void showPopup(View view, ExtraKeyButton extraButton) {
button.setTextColor(mButtonTextColor);
}
button.setText(extraButton.getDisplay());
button.setAllCaps(mButtonTextAllCaps);
button.setPadding(0, 0, 0, 0);
button.setMinHeight(0);
button.setMinWidth(0);
Expand Down

0 comments on commit 5c72c3c

Please sign in to comment.