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

Commit 2f229ca2 authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Show selection handles at the correct position for view transformation

The selection handles are implemented based on PopupWindow hence it is
necessary to calculate the transformed location from the TextView's
local coordinates.

This CL only addresses the selection handle locations. Many
functionalities (e.g. selection handle moving direction, handle angle)
doesn't work on transformed view since many components are calculated
on the TextView's local coordinates.

Bug: 24902578
Change-Id: Iaa5fd2812969d097e3bf3219a818ffbc67aaef54
parent 598255ae
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -18916,7 +18916,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        transformFromViewToWindowSpace(outLocation);
    }
    void transformFromViewToWindowSpace(@Size(2) int[] inOutLocation) {
    /** @hide */
    public void transformFromViewToWindowSpace(@Size(2) int[] inOutLocation) {
        if (inOutLocation == null || inOutLocation.length < 2) {
            throw new IllegalArgumentException("inOutLocation must be an array of two integers");
        }
+7 −5
Original line number Diff line number Diff line
@@ -4131,13 +4131,15 @@ public class Editor {
                }

                if (isVisible()) {
                    final int positionX = parentPositionX + mPositionX;
                    final int positionY = parentPositionY + mPositionY;
                    // Transform to the window coordinates to follow the view tranformation.
                    final int[] pts = { mPositionX + mHotspotX + getHorizontalOffset(), mPositionY};
                    mTextView.transformFromViewToWindowSpace(pts);
                    pts[0] -= mHotspotX + getHorizontalOffset();

                    if (isShowing()) {
                        mContainer.update(positionX, positionY, -1, -1);
                        mContainer.update(pts[0], pts[1], -1, -1);
                    } else {
                        mContainer.showAtLocation(mTextView, Gravity.NO_GRAVITY,
                                positionX, positionY);
                        mContainer.showAtLocation(mTextView, Gravity.NO_GRAVITY, pts[0], pts[1]);
                    }
                } else {
                    if (isShowing()) {