Skip to content

Commit 5c72c3c

Browse files
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.
1 parent b62645c commit 5c72c3c

File tree

5 files changed

+61
-12
lines changed

5 files changed

+61
-12
lines changed

app/src/main/java/com/termux/app/TermuxActivity.java

+1
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ private void reloadActivityStyling() {
880880
mProperties.loadTermuxPropertiesFromDisk();
881881

882882
if (mExtraKeysView != null) {
883+
mExtraKeysView.setButtonTextAllCaps(mProperties.shouldExtraKeysTextBeAllCaps());
883884
mExtraKeysView.reload(mProperties.getExtraKeysInfo());
884885
}
885886
}

app/src/main/java/com/termux/app/terminal/io/TerminalToolbarViewPager.java

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public Object instantiateItem(@NonNull ViewGroup collection, int position) {
4646
ExtraKeysView extraKeysView = (ExtraKeysView) layout;
4747
extraKeysView.setExtraKeysViewClient(new TermuxTerminalExtraKeys(mActivity.getTerminalView(),
4848
mActivity.getTermuxTerminalViewClient(), mActivity.getTermuxTerminalSessionClient()));
49+
extraKeysView.setButtonTextAllCaps(mActivity.getProperties().shouldExtraKeysTextBeAllCaps());
4950
mActivity.setExtraKeysView(extraKeysView);
5051
extraKeysView.reload(mActivity.getProperties().getExtraKeysInfo());
5152

termux-shared/src/main/java/com/termux/shared/settings/properties/TermuxPropertyConstants.java

+34-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import java.util.Set;
1515

1616
/*
17-
* Version: v0.14.0
17+
* Version: v0.15.0
1818
*
1919
* Changelog
2020
*
@@ -63,6 +63,9 @@
6363
*
6464
* - 0.14.0 (2021-09-02)
6565
* - Add `getTermuxFloatPropertiesFile()`.
66+
*
67+
* - 0.15.0 (2021-09-05)
68+
* - Add `KEY_EXTRA_KEYS_TEXT_ALL_CAPS`.
6669
*/
6770

6871
/**
@@ -94,6 +97,11 @@ public final class TermuxPropertyConstants {
9497

9598

9699

100+
/** Defines the key for whether text for the extra keys buttons should be all capitalized automatically */
101+
public static final String KEY_EXTRA_KEYS_TEXT_ALL_CAPS = "extra-keys-text-all-caps"; // Default: "extra-keys-text-all-caps"
102+
103+
104+
97105
/** Defines the key for whether to hide soft keyboard when termux app is started */
98106
public static final String KEY_HIDE_SOFT_KEYBOARD_ON_STARTUP = "hide-soft-keyboard-on-startup"; // Default: "hide-soft-keyboard-on-startup"
99107

@@ -324,6 +332,7 @@ public final class TermuxPropertyConstants {
324332
KEY_DISABLE_HARDWARE_KEYBOARD_SHORTCUTS,
325333
KEY_DISABLE_TERMINAL_SESSION_CHANGE_TOAST,
326334
KEY_ENFORCE_CHAR_BASED_INPUT,
335+
KEY_EXTRA_KEYS_TEXT_ALL_CAPS,
327336
KEY_HIDE_SOFT_KEYBOARD_ON_STARTUP,
328337
KEY_TERMINAL_ONCLICK_URL_OPEN,
329338
KEY_USE_BLACK_UI,
@@ -358,12 +367,12 @@ public final class TermuxPropertyConstants {
358367
KEY_VOLUME_KEYS_BEHAVIOUR
359368
));
360369

361-
/** Defines the set for keys loaded by termux that have default boolean behaviour
370+
/** Defines the set for keys loaded by termux that have default boolean behaviour with false as default.
362371
* "true" -> true
363372
* "false" -> false
364373
* default: false
365-
* */
366-
public static final Set<String> TERMUX_DEFAULT_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
374+
*/
375+
public static final Set<String> TERMUX_DEFAULT_FALSE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
367376
KEY_DISABLE_HARDWARE_KEYBOARD_SHORTCUTS,
368377
KEY_DISABLE_TERMINAL_SESSION_CHANGE_TOAST,
369378
KEY_ENFORCE_CHAR_BASED_INPUT,
@@ -375,17 +384,35 @@ public final class TermuxPropertyConstants {
375384
TermuxConstants.PROP_ALLOW_EXTERNAL_APPS
376385
));
377386

378-
/** Defines the set for keys loaded by termux that have default inverted boolean behaviour
387+
/** Defines the set for keys loaded by termux that have default boolean behaviour with true as default.
388+
* "true" -> true
389+
* "false" -> false
390+
* default: true
391+
*/
392+
public static final Set<String> TERMUX_DEFAULT_TRUE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
393+
KEY_EXTRA_KEYS_TEXT_ALL_CAPS
394+
));
395+
396+
/** Defines the set for keys loaded by termux that have default inverted boolean behaviour with false as default.
397+
* "false" -> true
398+
* "true" -> false
399+
* default: false
400+
*/
401+
public static final Set<String> TERMUX_DEFAULT_INVERETED_FALSE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
402+
));
403+
404+
/** Defines the set for keys loaded by termux that have default inverted boolean behaviour with true as default.
379405
* "false" -> true
380406
* "true" -> false
381407
* default: true
382-
* */
383-
public static final Set<String> TERMUX_DEFAULT_INVERETED_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
408+
*/
409+
public static final Set<String> TERMUX_DEFAULT_INVERETED_TRUE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
384410
));
385411

386412

387413

388414

415+
389416
/** Returns the first {@link File} found at
390417
* {@link TermuxConstants#TERMUX_PROPERTIES_PRIMARY_FILE_PATH} or
391418
* {@link TermuxConstants#TERMUX_PROPERTIES_SECONDARY_FILE_PATH}

termux-shared/src/main/java/com/termux/shared/settings/properties/TermuxSharedProperties.java

+15-5
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,18 @@ public static Object getInternalTermuxPropertyValueFromValue(Context context, St
257257
return (String) getVolumeKeysBehaviourInternalPropertyValueFromValue(value);
258258

259259
default:
260-
// default boolean behaviour
261-
if (TermuxPropertyConstants.TERMUX_DEFAULT_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key))
260+
// default false boolean behaviour
261+
if (TermuxPropertyConstants.TERMUX_DEFAULT_FALSE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key))
262262
return (boolean) SharedProperties.getBooleanValueForStringValue(key, value, false, true, LOG_TAG);
263-
// default inverted boolean behaviour
264-
else if (TermuxPropertyConstants.TERMUX_DEFAULT_INVERETED_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key))
265-
return (boolean) SharedProperties.getInvertedBooleanValueForStringValue(key, value, true, true, LOG_TAG);
263+
// default true boolean behaviour
264+
if (TermuxPropertyConstants.TERMUX_DEFAULT_TRUE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key))
265+
return (boolean) SharedProperties.getBooleanValueForStringValue(key, value, true, true, LOG_TAG);
266+
// default inverted false boolean behaviour
267+
//else if (TermuxPropertyConstants.TERMUX_DEFAULT_INVERETED_FALSE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key))
268+
// return (boolean) SharedProperties.getInvertedBooleanValueForStringValue(key, value, false, true, LOG_TAG);
269+
// default inverted true boolean behaviour
270+
// else if (TermuxPropertyConstants.TERMUX_DEFAULT_INVERETED_TRUE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST.contains(key))
271+
// return (boolean) SharedProperties.getInvertedBooleanValueForStringValue(key, value, true, true, LOG_TAG);
266272
// just use String object as is (may be null)
267273
else
268274
return value;
@@ -517,6 +523,10 @@ public boolean isEnforcingCharBasedInput() {
517523
return (boolean) getInternalPropertyValue(TermuxPropertyConstants.KEY_ENFORCE_CHAR_BASED_INPUT, true);
518524
}
519525

526+
public boolean shouldExtraKeysTextBeAllCaps() {
527+
return (boolean) getInternalPropertyValue(TermuxPropertyConstants.KEY_EXTRA_KEYS_TEXT_ALL_CAPS, true);
528+
}
529+
520530
public boolean shouldSoftKeyboardBeHiddenOnStartup() {
521531
return (boolean) getInternalPropertyValue(TermuxPropertyConstants.KEY_HIDE_SOFT_KEYBOARD_ON_STARTUP, true);
522532
}

termux-shared/src/main/java/com/termux/shared/terminal/io/extrakeys/ExtraKeysView.java

+10
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ public interface IExtraKeysView {
163163
* {@link #DEFAULT_BUTTON_ACTIVE_BACKGROUND_COLOR}. */
164164
private int mButtonActiveBackgroundColor;
165165

166+
/** Defines whether text for the extra keys button should be all capitalized automatically. */
167+
private boolean mButtonTextAllCaps = true;
168+
166169

167170
/**
168171
* Defines the duration in milliseconds before a press turns into a long press. The default
@@ -305,6 +308,11 @@ public void setButtonActiveBackgroundColor(int buttonActiveBackgroundColor) {
305308
mButtonActiveBackgroundColor = buttonActiveBackgroundColor;
306309
}
307310

311+
/** Set {@link #mButtonTextAllCaps}. */
312+
public void setButtonTextAllCaps(boolean buttonTextAllCaps) {
313+
mButtonTextAllCaps = buttonTextAllCaps;
314+
}
315+
308316

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

383391
button.setText(buttonInfo.getDisplay());
384392
button.setTextColor(mButtonTextColor);
393+
button.setAllCaps(mButtonTextAllCaps);
385394
button.setPadding(0, 0, 0, 0);
386395

387396
button.setOnClickListener(view -> {
@@ -564,6 +573,7 @@ void showPopup(View view, ExtraKeyButton extraButton) {
564573
button.setTextColor(mButtonTextColor);
565574
}
566575
button.setText(extraButton.getDisplay());
576+
button.setAllCaps(mButtonTextAllCaps);
567577
button.setPadding(0, 0, 0, 0);
568578
button.setMinHeight(0);
569579
button.setMinWidth(0);

0 commit comments

Comments
 (0)