From 5e2310030b538d934606e29dbd11bc5736c3c1c5 Mon Sep 17 00:00:00 2001 From: Abodunrinwa Toki Date: Tue, 30 Jun 2015 16:42:27 -0700 Subject: [PATCH] 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 --- core/java/com/android/internal/view/FloatingActionMode.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/java/com/android/internal/view/FloatingActionMode.java b/core/java/com/android/internal/view/FloatingActionMode.java index b2699f8d64bf4..ef2fef0e4d68d 100644 --- a/core/java/com/android/internal/view/FloatingActionMode.java +++ b/core/java/com/android/internal/view/FloatingActionMode.java @@ -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)) {