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

Commit 3a7f16b1 authored by Feng Cao's avatar Feng Cao Committed by Automerger Merge Worker
Browse files

Merge "Support receiving touch event in the inline suggestion view" into...

Merge "Support receiving touch event in the inline suggestion view" into rvc-dev am: 4e20f2b9 am: 7783a9a8 am: 2c0f5180 am: b462d37a

Change-Id: I9ed24e99cc862a739cef76d6614a54491305ed9d
parents 1de1507f b462d37a
Loading
Loading
Loading
Loading
+11 −9
Original line number Original line Diff line number Diff line
@@ -144,22 +144,24 @@ public abstract class InlineSuggestionRenderService extends Service {
            final SurfaceControlViewHost host = new SurfaceControlViewHost(this, getDisplay(),
            final SurfaceControlViewHost host = new SurfaceControlViewHost(this, getDisplay(),
                    hostInputToken);
                    hostInputToken);
            host.setView(suggestionRoot, lp);
            host.setView(suggestionRoot, lp);
            suggestionRoot.setOnClickListener((v) -> {

            // Set the suggestion view to be non-focusable so that if its background is set to a
            // ripple drawable, the ripple won't be shown initially.
            suggestionView.setFocusable(false);
            suggestionView.setOnClickListener((v) -> {
                try {
                try {
                    if (suggestionView.hasOnClickListeners()) {
                        suggestionView.callOnClick();
                    }
                    callback.onClick();
                    callback.onClick();
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                    Log.w(TAG, "RemoteException calling onClick()");
                    Log.w(TAG, "RemoteException calling onClick()");
                }
                }
            });
            });

            final View.OnLongClickListener onLongClickListener =
            suggestionRoot.setOnLongClickListener((v) -> {
                    suggestionView.getOnLongClickListener();
                try {
            suggestionView.setOnLongClickListener((v) -> {
                    if (suggestionView.hasOnLongClickListeners()) {
                if (onLongClickListener != null) {
                        suggestionView.performLongClick();
                    onLongClickListener.onLongClick(v);
                }
                }
                try {
                    callback.onLongClick();
                    callback.onLongClick();
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                    Log.w(TAG, "RemoteException calling onLongClick()");
                    Log.w(TAG, "RemoteException calling onLongClick()");
+2 −7
Original line number Original line Diff line number Diff line
@@ -51,14 +51,9 @@ public class InlineSuggestionRoot extends FrameLayout {
        setFocusable(false);
        setFocusable(false);
    }
    }


    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return true;
    }

    @Override
    @Override
    @SuppressLint("ClickableViewAccessibility")
    @SuppressLint("ClickableViewAccessibility")
    public boolean onTouchEvent(@NonNull MotionEvent event) {
    public boolean dispatchTouchEvent(@NonNull MotionEvent event) {
        switch (event.getActionMasked()) {
        switch (event.getActionMasked()) {
            case MotionEvent.ACTION_DOWN: {
            case MotionEvent.ACTION_DOWN: {
                mDownX = event.getX();
                mDownX = event.getX();
@@ -80,6 +75,6 @@ public class InlineSuggestionRoot extends FrameLayout {
                }
                }
            } break;
            } break;
        }
        }
        return super.onTouchEvent(event);
        return super.dispatchTouchEvent(event);
    }
    }
}
}
+10 −0
Original line number Original line Diff line number Diff line
@@ -7285,6 +7285,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        return (li != null && li.mOnLongClickListener != null);
        return (li != null && li.mOnLongClickListener != null);
    }
    }
    /**
     * @return the registered {@link OnLongClickListener} if there is one, {@code null} otherwise.
     * @hide
     */
    @Nullable
    public OnLongClickListener getOnLongClickListener() {
        ListenerInfo li = mListenerInfo;
        return (li != null) ? li.mOnLongClickListener : null;
    }
    /**
    /**
     * Register a callback to be invoked when this view is context clicked. If the view is not
     * Register a callback to be invoked when this view is context clicked. If the view is not
     * context clickable, it becomes context clickable.
     * context clickable, it becomes context clickable.