diff --git a/app/src/main/java/com/termux/app/TermuxActivity.java b/app/src/main/java/com/termux/app/TermuxActivity.java index ee27624844..7a55489223 100644 --- a/app/src/main/java/com/termux/app/TermuxActivity.java +++ b/app/src/main/java/com/termux/app/TermuxActivity.java @@ -880,6 +880,7 @@ private void reloadActivityStyling() { mProperties.loadTermuxPropertiesFromDisk(); if (mExtraKeysView != null) { + mExtraKeysView.setButtonTextAllCaps(mProperties.shouldExtraKeysTextBeAllCaps()); mExtraKeysView.reload(mProperties.getExtraKeysInfo()); } } diff --git a/app/src/main/java/com/termux/app/terminal/io/TerminalToolbarViewPager.java b/app/src/main/java/com/termux/app/terminal/io/TerminalToolbarViewPager.java index 56f28fc0c2..de49b3cd0d 100644 --- a/app/src/main/java/com/termux/app/terminal/io/TerminalToolbarViewPager.java +++ b/app/src/main/java/com/termux/app/terminal/io/TerminalToolbarViewPager.java @@ -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()); diff --git a/termux-shared/src/main/java/com/termux/shared/settings/properties/TermuxPropertyConstants.java b/termux-shared/src/main/java/com/termux/shared/settings/properties/TermuxPropertyConstants.java index 42d4832195..c868450b62 100644 --- a/termux-shared/src/main/java/com/termux/shared/settings/properties/TermuxPropertyConstants.java +++ b/termux-shared/src/main/java/com/termux/shared/settings/properties/TermuxPropertyConstants.java @@ -14,7 +14,7 @@ import java.util.Set; /* - * Version: v0.14.0 + * Version: v0.15.0 * * Changelog * @@ -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`. */ /** @@ -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 TERMUX_DEFAULT_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList( + */ + public static final Set 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 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 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 TERMUX_DEFAULT_INVERETED_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList( + */ + public static final Set 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} diff --git a/termux-shared/src/main/java/com/termux/shared/settings/properties/TermuxSharedProperties.java b/termux-shared/src/main/java/com/termux/shared/settings/properties/TermuxSharedProperties.java index 23a3faac73..9ea06acc2b 100644 --- a/termux-shared/src/main/java/com/termux/shared/settings/properties/TermuxSharedProperties.java +++ b/termux-shared/src/main/java/com/termux/shared/settings/properties/TermuxSharedProperties.java @@ -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; @@ -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); } diff --git a/termux-shared/src/main/java/com/termux/shared/terminal/io/extrakeys/ExtraKeysView.java b/termux-shared/src/main/java/com/termux/shared/terminal/io/extrakeys/ExtraKeysView.java index 2749787ff0..e149e36dcc 100644 --- a/termux-shared/src/main/java/com/termux/shared/terminal/io/extrakeys/ExtraKeysView.java +++ b/termux-shared/src/main/java/com/termux/shared/terminal/io/extrakeys/ExtraKeysView.java @@ -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 @@ -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() { @@ -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 -> { @@ -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);