Skip to content

Commit

Permalink
Added: Extra keys accessibility, setTextEntryKey via delegate
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alzwded committed Aug 18, 2024
1 parent c05d111 commit 155efaa
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.GridLayout;
import android.widget.PopupWindow;

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

button.setText(buttonInfo.getDisplay());
button.setTextColor(mButtonTextColor);
Expand Down

0 comments on commit 155efaa

Please sign in to comment.