Add callbacks for remote input send / bounced
Bug: 170647553 Test: manual, atest Change-Id: I47cd16337bbcabbdeb05d60641ff6f41ff294f26
This commit is contained in:
@@ -112,6 +112,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
|
||||
private final TextView.OnEditorActionListener mEditorActionHandler;
|
||||
private final NotificationRemoteInputManager mRemoteInputManager;
|
||||
private final List<OnFocusChangeListener> mEditTextFocusChangeListeners = new ArrayList<>();
|
||||
private final List<OnSendRemoteInputListener> 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 {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user