Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91b35e23 authored by Sally Yuen's avatar Sally Yuen Committed by Automerger Merge Worker
Browse files

Merge "Fixes for a11y selection" into tm-dev am: 8c3314f7

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17198946

Change-Id: I3792d41a856095cfadf37aa3b17eb2189a4bc6c7
parents fe251188 8c3314f7
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -14649,6 +14649,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        int selectionStart;
        int selectionEnd;
        if (extendSelection && isAccessibilitySelectionExtendable()) {
            prepareForExtendedAccessibilitySelection();
            selectionStart = getAccessibilitySelectionStart();
            if (selectionStart == ACCESSIBILITY_CURSOR_POSITION_UNDEFINED) {
                selectionStart = forward ? segmentStart : segmentEnd;
@@ -14687,6 +14688,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        return false;
    }
    /**
     * Prepare for extended selection.
     * @hide
     */
    public void prepareForExtendedAccessibilitySelection() {
        return;
    }
    /**
     * @hide
     */
+30 −10
Original line number Diff line number Diff line
@@ -12390,9 +12390,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        }
        // A view should not be exposed as clickable/long-clickable to a service because of a
        // LinkMovementMethod.
        // LinkMovementMethod or because it has selectable and non-editable text.
        if ((info.isClickable() || info.isLongClickable())
                && mMovement instanceof LinkMovementMethod) {
                && (mMovement instanceof LinkMovementMethod
                || (isTextSelectable() && !isTextEditable()))) {
            if (!hasOnClickListeners()) {
                info.setClickable(false);
                info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK);
@@ -12624,11 +12625,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                        return true;
                    }
                    if (start >= 0 && start <= end && end <= text.length()) {
                        requestFocusOnNonEditableSelectableText();
                        Selection.setSelection((Spannable) text, start, end);
                        // Make sure selection mode is engaged.
                        if (mEditor != null) {
                            mEditor.startSelectionActionModeAsync(false);
                        }
                        hideAccessibilitySelectionControllers();
                        return true;
                    }
                }
@@ -12722,6 +12721,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        return handled;
    }
    private void requestFocusOnNonEditableSelectableText() {
        if (!isTextEditable() && isTextSelectable()) {
            if (!isEnabled()) {
                return;
            }
            if (isFocusable() && !isFocused()) {
                requestFocus();
            }
        }
    }
    private boolean hasSpannableText() {
        return mText != null && mText instanceof Spannable;
    }
@@ -12750,9 +12761,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    /**
     * Returns the text that should be exposed to accessibility services.
     * <p>
     * This approximates what is displayed visually. If the user has specified
     * that accessibility services should speak passwords, this method will
     * bypass any password transformation method and return unobscured text.
     * This approximates what is displayed visually.
     *
     * @return the text that should be exposed to accessibility services, may
     *         be {@code null} if no text is set
@@ -13730,6 +13739,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        return true;
    }
    /**
     * @hide
     */
    public void prepareForExtendedAccessibilitySelection() {
        requestFocusOnNonEditableSelectableText();
    }
    /**
     * @hide
     */
@@ -13754,8 +13770,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            Selection.removeSelection((Spannable) text);
        }
        // Hide all selection controllers used for adjusting selection
        // since we are doing so explicitlty by other means and these
        // since we are doing so explicitly by other means and these
        // controllers interact with how selection behaves.
        hideAccessibilitySelectionControllers();
    }
    private void hideAccessibilitySelectionControllers() {
        if (mEditor != null) {
            mEditor.hideCursorAndSpanControllers();
            mEditor.stopTextActionMode();