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
This commit is contained in:
Abodunrinwa Toki
2015-06-30 16:42:27 -07:00
parent 392527c4cc
commit 5e2310030b

View File

@@ -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)) {