From a77d2c58e7edac338a69864c8970b794df401614 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Mon, 9 Apr 2018 10:44:52 -0700 Subject: [PATCH] Fixed the touch targets when replying Because part of the reply field was outside the notification, clicks on the remote input or the send button could be discarded and go to the view instead. We're not manually dispatching those touches to the remoteInput. Additionally are we now closing the input field first and only then opening the app. Change-Id: Iaea3fb78347dfc3a3e22b0d7155e6d2e50c82285 Fixes: 74161213 Fixes: 77482496 Test: open inline reply, click on very bottom below text, observe that app isn't opened --- packages/SystemUI/res/layout/remote_input.xml | 4 +-- .../statusbar/NotificationContentView.java | 37 ++++++++++++++++++++++ .../systemui/statusbar/phone/StatusBar.java | 15 +++++---- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/res/layout/remote_input.xml b/packages/SystemUI/res/layout/remote_input.xml index e4ea08edbc89..b5d48b4636a8 100644 --- a/packages/SystemUI/res/layout/remote_input.xml +++ b/packages/SystemUI/res/layout/remote_input.xml @@ -51,12 +51,10 @@ = inputStart) { + ev.offsetLocation(0, -inputStart); + return riv.dispatchTouchEvent(ev); + } + } + return super.dispatchTouchEvent(ev); + } + + /** + * Overridden to make sure touches to the reply action bar actually go through to this view + */ + @Override + public boolean pointInView(float localX, float localY, float slop) { + float top = mClipTopAmount; + float bottom = mUnrestrictedContentHeight; + return localX >= -slop && localY >= top - slop && localX < ((mRight - mLeft) + slop) && + localY < (bottom + slop); + } + + private RemoteInputView getRemoteInputForView(View child) { + if (child == mExpandedChild) { + return mExpandedRemoteInput; + } else if (child == mHeadsUpChild) { + return mHeadsUpRemoteInput; + } + return null; + } + public int getExpandHeight() { int viewType = VISIBLE_TYPE_EXPANDED; if (mExpandedChild == null) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 7987bfd9bfb8..0c516c729b1f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -4994,6 +4994,14 @@ public class StatusBar extends SystemUI implements DemoMode, @Override public void onNotificationClicked(StatusBarNotification sbn, ExpandableNotificationRow row) { + RemoteInputController controller = mRemoteInputManager.getController(); + if (controller.isRemoteInputActive(row.getEntry()) + && !TextUtils.isEmpty(row.getActiveRemoteInputText())) { + // We have an active remote input typed and the user clicked on the notification. + // this was probably unintentional, so we're closing the edit text instead. + controller.closeRemoteInputs(); + return; + } Notification notification = sbn.getNotification(); final PendingIntent intent = notification.contentIntent != null ? notification.contentIntent @@ -5057,12 +5065,7 @@ public class StatusBar extends SystemUI implements DemoMode, Intent fillInIntent = null; Entry entry = row.getEntry(); CharSequence remoteInputText = null; - RemoteInputController controller = mRemoteInputManager.getController(); - if (controller.isRemoteInputActive(entry)) { - remoteInputText = row.getActiveRemoteInputText(); - } - if (TextUtils.isEmpty(remoteInputText) - && !TextUtils.isEmpty(entry.remoteInputText)) { + if (!TextUtils.isEmpty(entry.remoteInputText)) { remoteInputText = entry.remoteInputText; } if (!TextUtils.isEmpty(remoteInputText) -- 2.11.0