|
24 | 24 | import android.view.MenuItem;
|
25 | 25 | import android.view.MotionEvent;
|
26 | 26 | import android.view.View;
|
| 27 | +import android.view.accessibility.AccessibilityManager; |
27 | 28 | import android.view.inputmethod.BaseInputConnection;
|
28 | 29 | import android.view.inputmethod.EditorInfo;
|
29 | 30 | import android.view.inputmethod.InputConnection;
|
@@ -102,6 +103,8 @@ public final class TerminalView extends View {
|
102 | 103 | */
|
103 | 104 | private boolean mEnableWordBasedIme = false;
|
104 | 105 |
|
| 106 | + private boolean mAccessibilityEnabled; |
| 107 | + |
105 | 108 | public TerminalView(Context context) {
|
106 | 109 | super(context);
|
107 | 110 | commonInit(context);
|
@@ -283,6 +286,8 @@ public void onLongPress(MotionEvent e) {
|
283 | 286 | }
|
284 | 287 | });
|
285 | 288 | mScroller = new Scroller(context);
|
| 289 | + AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); |
| 290 | + mAccessibilityEnabled = am != null && am.isEnabled(); |
286 | 291 | }
|
287 | 292 |
|
288 | 293 | /**
|
@@ -460,8 +465,8 @@ public void onScreenUpdated() {
|
460 | 465 | // 如果二者不一样,即 mTop != 0,则说明用户在脚本输出的时候滚动了屏幕
|
461 | 466 | // 很有可能时用户需要观察上面脚本的输出结果
|
462 | 467 | // 那么这个时候我们就不跟随输出滚动屏幕
|
463 |
| -// int currentScroll = computeVerticalScrollOffset(); |
464 |
| -// int expectedScroll = mEmulator.getScreen().getActiveRows() - mEmulator.mRows; |
| 468 | + // int currentScroll = computeVerticalScrollOffset(); |
| 469 | + // int expectedScroll = mEmulator.getScreen().getActiveRows() - mEmulator.mRows; |
465 | 470 |
|
466 | 471 | if (mTopRow != 0) {
|
467 | 472 | isScreenHeld = true;
|
@@ -508,8 +513,10 @@ public void onScreenUpdated() {
|
508 | 513 |
|
509 | 514 | // Basic accessibility service
|
510 | 515 | String contentText = mEmulator.getScreen()
|
511 |
| - .getSelectedText(0, mTopRow, mEmulator.mColumns, mTopRow +mEmulator.mRows); |
512 |
| - setContentDescription(contentText); |
| 516 | + .getSelectedText(0, mTopRow, mEmulator.mColumns, mTopRow + mEmulator.mRows); |
| 517 | + if (mAccessibilityEnabled) { |
| 518 | + setContentDescription(contentText); |
| 519 | + } |
513 | 520 | }
|
514 | 521 |
|
515 | 522 | public int getTextSize() {
|
|
0 commit comments