Skip to content

Commit ccb246d

Browse files
committed
Added: Extra keys accessibility, setTextEntryKey via delegate
This makes the additional soft keys behave like soft keyboard keys (if Android and TalkBack are recent enough). There is a setting where text entry keys may be activated on touch up, activated on double tap, or a mix of both. This makes the soft arrow keys easier to use, since there's less tapping.
1 parent e2fefa5 commit ccb246d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import android.view.View;
2626
import android.view.ViewConfiguration;
2727
import android.view.ViewGroup;
28+
import android.view.accessibility.AccessibilityNodeInfo;
2829
import android.widget.GridLayout;
2930
import android.widget.PopupWindow;
3031

@@ -408,6 +409,19 @@ public void reload(ExtraKeysInfo extraKeysInfo, float heightPx) {
408409
} else {
409410
button = new MaterialButton(getContext(), null, android.R.attr.buttonBarButtonStyle);
410411
}
412+
button.setAccessibilityDelegate(new AccessibilityDelegate() {
413+
@Override
414+
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
415+
super.onInitializeAccessibilityNodeInfo(host, info);
416+
// these should funtion like soft keyboard keys;
417+
// with this flag set, they honor the TalkBack setting
418+
// of hold/release to activate, 2x tap to activate or hybrid;
419+
// assuming your Android and TalkBack are recent enough
420+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
421+
info.setTextEntryKey(true);
422+
}
423+
}
424+
});
411425

412426
button.setText(buttonInfo.getDisplay());
413427
button.setTextColor(mButtonTextColor);

0 commit comments

Comments
 (0)