From 507a76a7f8a70a65d20040389900920c8c2d4490 Mon Sep 17 00:00:00 2001 From: Steve Elliott Date: Thu, 22 Apr 2021 00:28:48 -0400 Subject: [PATCH] Add callbacks for remote input send / bounced Bug: 170647553 Test: manual, atest Change-Id: I47cd16337bbcabbdeb05d60641ff6f41ff294f26 --- .../statusbar/policy/RemoteInputView.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index a3fd92f8e186c..d86ef3208f7e7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -112,6 +112,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene private final TextView.OnEditorActionListener mEditorActionHandler; private final NotificationRemoteInputManager mRemoteInputManager; private final List mEditTextFocusChangeListeners = new ArrayList<>(); + private final List mOnSendListeners = new ArrayList<>(); private RemoteEditText mEditText; private ImageButton mSendButton; private GradientDrawable mContentBackground; @@ -357,6 +358,9 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene private void sendRemoteInput(Intent intent) { if (mBouncerChecker != null && mBouncerChecker.showBouncerIfNecessary()) { mEditText.hideIme(); + for (OnSendRemoteInputListener listener : mOnSendListeners) { + listener.onSendRequestBounced(); + } return; } @@ -370,6 +374,10 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene mController.remoteInputSent(mEntry); mEntry.setHasSentReply(); + for (OnSendRemoteInputListener listener : mOnSendListeners) { + listener.onSendRemoteInput(); + } + // Tell ShortcutManager that this package has been "activated". ShortcutManager // will reset the throttling for this package. // 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. */ private class EditorActionHandler implements TextView.OnEditorActionListener {