Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic accessibility support for the terminal view #344

Merged
merged 4 commits into from
Jun 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions terminal-view/src/main/java/com/termux/view/TerminalView.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.accessibility.AccessibilityManager;
import android.view.ActionMode;
import android.view.HapticFeedbackConstants;
import android.view.InputDevice;
Expand Down Expand Up @@ -75,6 +76,8 @@ public final class TerminalView extends View {
/** If non-zero, this is the last unicode code point received if that was a combining character. */
int mCombiningAccent;

private boolean mAccessibilityEnabled;

public TerminalView(Context context, AttributeSet attributes) { // NO_UCD (unused code)
super(context, attributes);
mGestureRecognizer = new GestureAndScaleRecognizer(context, new GestureAndScaleRecognizer.Listener() {
Expand Down Expand Up @@ -197,6 +200,8 @@ public void onLongPress(MotionEvent e) {
}
});
mScroller = new Scroller(context);
AccessibilityManager am = (AccessibilityManager) context.getSystemService(context.ACCESSIBILITY_SERVICE);
mAccessibilityEnabled = am.isEnabled();
}

/**
Expand Down Expand Up @@ -384,6 +389,7 @@ public void onScreenUpdated() {
mEmulator.clearScrollCounter();

invalidate();
if (mAccessibilityEnabled) setContentDescription(getText());
}

/**
Expand Down Expand Up @@ -913,4 +919,8 @@ public TerminalSession getCurrentSession() {
return mTermSession;
}

private CharSequence getText() {
return mEmulator.getScreen().getSelectedText(0, mTopRow, mEmulator.mColumns, mTopRow +mEmulator.mRows);
}

}