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

Commit a77d2c58 authored by Selim Cinek's avatar Selim Cinek
Browse files

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
parent b172d5b4
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -51,12 +51,10 @@

        <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:paddingStart="12dp"
                android:paddingEnd="24dp"
                android:paddingTop="16dp"
                android:paddingBottom="16dp"
                android:id="@+id/remote_input_send"
                android:src="@drawable/ic_send"
                android:contentDescription="@*android:string/ime_action_send"
+37 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.service.notification.StatusBarNotification;
import android.util.ArraySet;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.NotificationHeaderView;
import android.view.View;
import android.view.ViewGroup;
@@ -1631,6 +1632,42 @@ public class NotificationContentView extends FrameLayout {
        return null;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        float y = ev.getY();
        // We still want to distribute touch events to the remote input even if it's outside the
        // view boundary. We're therefore manually dispatching these events to the remote view
        RemoteInputView riv = getRemoteInputForView(getViewForVisibleType(mVisibleType));
        if (riv != null && riv.getVisibility() == VISIBLE) {
            int inputStart = mUnrestrictedContentHeight - riv.getHeight();
            if (y <= mUnrestrictedContentHeight && y >= 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) {
+9 −6
Original line number Diff line number Diff line
@@ -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)