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

Commit 1a133717 authored by Steve Elliott's avatar Steve Elliott Committed by Automerger Merge Worker
Browse files

Merge "Add callbacks for remote input send / bounced" into sc-dev am: e3cb11af

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

Change-Id: Icc740ecd70630a987a628f3608f9379af2847d31
parents 0f5c7f3b e3cb11af
Loading
Loading
Loading
Loading
+29 −0
Original line number Original line Diff line number Diff line
@@ -112,6 +112,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
    private final TextView.OnEditorActionListener mEditorActionHandler;
    private final TextView.OnEditorActionListener mEditorActionHandler;
    private final NotificationRemoteInputManager mRemoteInputManager;
    private final NotificationRemoteInputManager mRemoteInputManager;
    private final List<OnFocusChangeListener> mEditTextFocusChangeListeners = new ArrayList<>();
    private final List<OnFocusChangeListener> mEditTextFocusChangeListeners = new ArrayList<>();
    private final List<OnSendRemoteInputListener> mOnSendListeners = new ArrayList<>();
    private RemoteEditText mEditText;
    private RemoteEditText mEditText;
    private ImageButton mSendButton;
    private ImageButton mSendButton;
    private GradientDrawable mContentBackground;
    private GradientDrawable mContentBackground;
@@ -357,6 +358,9 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
    private void sendRemoteInput(Intent intent) {
    private void sendRemoteInput(Intent intent) {
        if (mBouncerChecker != null && mBouncerChecker.showBouncerIfNecessary()) {
        if (mBouncerChecker != null && mBouncerChecker.showBouncerIfNecessary()) {
            mEditText.hideIme();
            mEditText.hideIme();
            for (OnSendRemoteInputListener listener : mOnSendListeners) {
                listener.onSendRequestBounced();
            }
            return;
            return;
        }
        }


@@ -370,6 +374,10 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
        mController.remoteInputSent(mEntry);
        mController.remoteInputSent(mEntry);
        mEntry.setHasSentReply();
        mEntry.setHasSentReply();


        for (OnSendRemoteInputListener listener : mOnSendListeners) {
            listener.onSendRemoteInput();
        }

        // Tell ShortcutManager that this package has been "activated".  ShortcutManager
        // Tell ShortcutManager that this package has been "activated".  ShortcutManager
        // will reset the throttling for this package.
        // will reset the throttling for this package.
        // Strictly speaking, the intent receiver may be different from the notification publisher,
        // Strictly speaking, the intent receiver may be different from the notification publisher,
@@ -754,6 +762,27 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
        }
        }
    }
    }


    /** Registers a listener for send events on this RemoteInputView */
    public void addOnSendRemoteInputListener(OnSendRemoteInputListener listener) {
        mOnSendListeners.add(listener);
    }

    /** Removes a previously-added listener for send events on this RemoteInputView */
    public void removeOnSendRemoteInputListener(OnSendRemoteInputListener listener) {
        mOnSendListeners.remove(listener);
    }

    /** Listener for send events */
    public interface OnSendRemoteInputListener {
        /** Invoked when the remote input has been sent successfully. */
        void onSendRemoteInput();
        /**
         * Invoked when the user had requested to send the remote input, but authentication was
         * required and the bouncer was shown instead.
         */
        void onSendRequestBounced();
    }

    /** Handler for button click on send action in IME. */
    /** Handler for button click on send action in IME. */
    private class EditorActionHandler implements TextView.OnEditorActionListener {
    private class EditorActionHandler implements TextView.OnEditorActionListener {