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

Commit 5e231003 authored by Abodunrinwa Toki's avatar Abodunrinwa Toki
Browse files

FloatingToolbar: Offset visible rect by the rootview's offset

windowSoftInputMode="adjustPan" config causes the root view to be
offset if necessary when the soft keyboard is shown to keep the text
selection visible. Account for this offset when calculating the
global visible rect of the textview in relation to the screen.

Bug: 21687644
Change-Id: Id44cad387d0a3f1f063880497c234052924717ea
parent 392527c4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ public class FloatingActionMode extends ActionMode {
    private final Rect mPreviousContentRectOnWindow;
    private final int[] mViewPosition;
    private final int[] mPreviousViewPosition;
    private final int[] mRootViewPosition;
    private final Rect mViewRect;
    private final Rect mPreviousViewRect;
    private final Rect mScreenRect;
@@ -80,6 +81,7 @@ public class FloatingActionMode extends ActionMode {
        mPreviousContentRectOnWindow = new Rect();
        mViewPosition = new int[2];
        mPreviousViewPosition = new int[2];
        mRootViewPosition = new int[2];
        mViewRect = new Rect();
        mPreviousViewRect = new Rect();
        mScreenRect = new Rect();
@@ -137,7 +139,9 @@ public class FloatingActionMode extends ActionMode {
        checkToolbarInitialized();

        mOriginatingView.getLocationInWindow(mViewPosition);
        mOriginatingView.getRootView().getLocationInWindow(mRootViewPosition);
        mOriginatingView.getGlobalVisibleRect(mViewRect);
        mViewRect.offset(mRootViewPosition[0], mRootViewPosition[1]);

        if (!Arrays.equals(mViewPosition, mPreviousViewPosition)
                || !mViewRect.equals(mPreviousViewRect)) {