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

Commit f7cf9b14 authored by Adrian Roos's avatar Adrian Roos Committed by android-build-merger
Browse files

A11y: Prevent utterance from resetting RemoteInputView

am: f17c86b8

Change-Id: I3f8b99e1177cc6893e540149718a76dacf1a669d
parents ec36ab27 f17c86b8
Loading
Loading
Loading
Loading
+18 −0
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@ import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewAnimationUtils;
import android.view.ViewGroup;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputConnection;
@@ -86,6 +87,8 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
    private int mRevealCy;
    private int mRevealCy;
    private int mRevealR;
    private int mRevealR;


    private boolean mResetting;

    public RemoteInputView(Context context, AttributeSet attrs) {
    public RemoteInputView(Context context, AttributeSet attrs) {
        super(context, attrs);
        super(context, attrs);
    }
    }
@@ -281,6 +284,8 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
    }
    }


    private void reset() {
    private void reset() {
        mResetting = true;

        mEditText.getText().clear();
        mEditText.getText().clear();
        mEditText.setEnabled(true);
        mEditText.setEnabled(true);
        mSendButton.setVisibility(VISIBLE);
        mSendButton.setVisibility(VISIBLE);
@@ -288,6 +293,19 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
        mController.removeSpinning(mEntry.key);
        mController.removeSpinning(mEntry.key);
        updateSendButton();
        updateSendButton();
        onDefocus(false /* animate */);
        onDefocus(false /* animate */);

        mResetting = false;
    }

    @Override
    public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
        if (mResetting && child == mEditText) {
            // Suppress text events if it happens during resetting. Ideally this would be
            // suppressed by the text view not being shown, but that doesn't work here because it
            // needs to stay visible for the animation.
            return false;
        }
        return super.onRequestSendAccessibilityEvent(child, event);
    }
    }


    private void updateSendButton() {
    private void updateSendButton() {