Loading core/java/android/widget/EditText.java +0 −10 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.text.TextUtils; import android.text.method.ArrowKeyMovementMethod; import android.text.method.MovementMethod; import android.util.AttributeSet; import android.view.accessibility.AccessibilityNodeInfo; /* * This is supposed to be a *very* thin veneer over TextView. Loading Loading @@ -179,13 +178,4 @@ public class EditText extends TextView { protected boolean supportsAutoSizeText() { return false; } /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); if (isEnabled()) { info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_TEXT); } } } core/java/android/widget/Editor.java +16 −5 Original line number Diff line number Diff line Loading @@ -317,6 +317,7 @@ public class Editor { private SelectionActionModeHelper mSelectionActionModeHelper; boolean mIsBeingLongClicked; boolean mIsBeingLongClickedByAccessibility; private SuggestionsPopupWindow mSuggestionsPopupWindow; SuggestionRangeSpan mSuggestionRangeSpan; Loading Loading @@ -1312,6 +1313,12 @@ public class Editor { if (TextView.DEBUG_CURSOR) { logCursor("performLongClick", "handled=%s", handled); } if (mIsBeingLongClickedByAccessibility) { if (!handled) { toggleInsertionActionMode(); } return true; } // Long press in empty space moves cursor and starts the insertion action mode. if (!handled && !isPositionOnText(mTouchState.getLastDownX(), mTouchState.getLastDownY()) && !mTouchState.isOnHandle() && mInsertionControllerEnabled) { Loading Loading @@ -1359,6 +1366,14 @@ public class Editor { return handled; } private void toggleInsertionActionMode() { if (mTextActionMode != null) { stopTextActionMode(); } else { startInsertionActionMode(); } } float getLastUpPositionX() { return mTouchState.getLastUpX(); } Loading Loading @@ -5436,11 +5451,7 @@ public class Editor { config.getScaledTouchSlop()); if (isWithinTouchSlop) { // Tapping on the handle toggles the insertion action mode. if (mTextActionMode != null) { stopTextActionMode(); } else { startInsertionActionMode(); } toggleInsertionActionMode(); } } else { if (mTextActionMode != null) { Loading core/java/android/widget/TextView.java +17 −0 Original line number Diff line number Diff line Loading @@ -12108,6 +12108,23 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener onEditorAction(getImeActionId()); } } return true; case AccessibilityNodeInfo.ACTION_LONG_CLICK: { if (isLongClickable()) { boolean handled; if (isEnabled() && (mBufferType == BufferType.EDITABLE)) { mEditor.mIsBeingLongClickedByAccessibility = true; try { handled = performLongClick(); } finally { mEditor.mIsBeingLongClickedByAccessibility = false; } } else { handled = performLongClick(); } return handled; } } return false; default: { return super.performAccessibilityActionInternal(action, arguments); } Loading core/tests/coretests/src/android/widget/TextViewActivityTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ import android.app.Activity; import android.app.Instrumentation; import android.content.ClipData; import android.content.ClipboardManager; import android.os.Bundle; import android.support.test.uiautomator.UiDevice; import android.text.InputType; import android.text.Selection; Loading @@ -75,6 +76,7 @@ import android.view.ActionMode; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.accessibility.AccessibilityNodeInfo; import android.view.textclassifier.SelectionEvent; import android.view.textclassifier.TextClassificationManager; import android.view.textclassifier.TextClassifier; Loading Loading @@ -357,6 +359,20 @@ public class TextViewActivityTest { assertFalse(textView.hasSelection()); } @Test public void testToolbarAppearsAccessibilityLongClick() throws Throwable { final String text = "Toolbar appears after performing accessibility's ACTION_LONG_CLICK."; mActivityRule.runOnUiThread(() -> { final TextView textView = mActivity.findViewById(R.id.textview); final Bundle args = new Bundle(); textView.performAccessibilityAction(AccessibilityNodeInfo.ACTION_LONG_CLICK, args); }); mInstrumentation.waitForIdleSync(); sleepForFloatingToolbarPopup(); assertFloatingToolbarIsDisplayed(); } @Test public void testSelectionRemovedWhenNonselectableTextLosesFocus() throws Throwable { final TextLinks.TextLink textLink = addLinkifiedTextToTextView(R.id.nonselectable_textview); Loading Loading
core/java/android/widget/EditText.java +0 −10 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.text.TextUtils; import android.text.method.ArrowKeyMovementMethod; import android.text.method.MovementMethod; import android.util.AttributeSet; import android.view.accessibility.AccessibilityNodeInfo; /* * This is supposed to be a *very* thin veneer over TextView. Loading Loading @@ -179,13 +178,4 @@ public class EditText extends TextView { protected boolean supportsAutoSizeText() { return false; } /** @hide */ @Override public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); if (isEnabled()) { info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_TEXT); } } }
core/java/android/widget/Editor.java +16 −5 Original line number Diff line number Diff line Loading @@ -317,6 +317,7 @@ public class Editor { private SelectionActionModeHelper mSelectionActionModeHelper; boolean mIsBeingLongClicked; boolean mIsBeingLongClickedByAccessibility; private SuggestionsPopupWindow mSuggestionsPopupWindow; SuggestionRangeSpan mSuggestionRangeSpan; Loading Loading @@ -1312,6 +1313,12 @@ public class Editor { if (TextView.DEBUG_CURSOR) { logCursor("performLongClick", "handled=%s", handled); } if (mIsBeingLongClickedByAccessibility) { if (!handled) { toggleInsertionActionMode(); } return true; } // Long press in empty space moves cursor and starts the insertion action mode. if (!handled && !isPositionOnText(mTouchState.getLastDownX(), mTouchState.getLastDownY()) && !mTouchState.isOnHandle() && mInsertionControllerEnabled) { Loading Loading @@ -1359,6 +1366,14 @@ public class Editor { return handled; } private void toggleInsertionActionMode() { if (mTextActionMode != null) { stopTextActionMode(); } else { startInsertionActionMode(); } } float getLastUpPositionX() { return mTouchState.getLastUpX(); } Loading Loading @@ -5436,11 +5451,7 @@ public class Editor { config.getScaledTouchSlop()); if (isWithinTouchSlop) { // Tapping on the handle toggles the insertion action mode. if (mTextActionMode != null) { stopTextActionMode(); } else { startInsertionActionMode(); } toggleInsertionActionMode(); } } else { if (mTextActionMode != null) { Loading
core/java/android/widget/TextView.java +17 −0 Original line number Diff line number Diff line Loading @@ -12108,6 +12108,23 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener onEditorAction(getImeActionId()); } } return true; case AccessibilityNodeInfo.ACTION_LONG_CLICK: { if (isLongClickable()) { boolean handled; if (isEnabled() && (mBufferType == BufferType.EDITABLE)) { mEditor.mIsBeingLongClickedByAccessibility = true; try { handled = performLongClick(); } finally { mEditor.mIsBeingLongClickedByAccessibility = false; } } else { handled = performLongClick(); } return handled; } } return false; default: { return super.performAccessibilityActionInternal(action, arguments); } Loading
core/tests/coretests/src/android/widget/TextViewActivityTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ import android.app.Activity; import android.app.Instrumentation; import android.content.ClipData; import android.content.ClipboardManager; import android.os.Bundle; import android.support.test.uiautomator.UiDevice; import android.text.InputType; import android.text.Selection; Loading @@ -75,6 +76,7 @@ import android.view.ActionMode; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.accessibility.AccessibilityNodeInfo; import android.view.textclassifier.SelectionEvent; import android.view.textclassifier.TextClassificationManager; import android.view.textclassifier.TextClassifier; Loading Loading @@ -357,6 +359,20 @@ public class TextViewActivityTest { assertFalse(textView.hasSelection()); } @Test public void testToolbarAppearsAccessibilityLongClick() throws Throwable { final String text = "Toolbar appears after performing accessibility's ACTION_LONG_CLICK."; mActivityRule.runOnUiThread(() -> { final TextView textView = mActivity.findViewById(R.id.textview); final Bundle args = new Bundle(); textView.performAccessibilityAction(AccessibilityNodeInfo.ACTION_LONG_CLICK, args); }); mInstrumentation.waitForIdleSync(); sleepForFloatingToolbarPopup(); assertFloatingToolbarIsDisplayed(); } @Test public void testSelectionRemovedWhenNonselectableTextLosesFocus() throws Throwable { final TextLinks.TextLink textLink = addLinkifiedTextToTextView(R.id.nonselectable_textview); Loading