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

Commit 6183b722 authored by Justin Klaassen's avatar Justin Klaassen
Browse files

Support view transformations when positioning floating CAB

Bug: 24088745

Use ViewGroup#getChildVisibleRect to transform the reported content
rect into the coordinate system of the root view. This allows the
floating CAB to be positioned correctly for views that may have a
scale (or other transforms) applied.

Change-Id: Ia6733a461b44070e7f6bab42f0b6fe2aed6870e5
parent 25459e13
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;

import com.android.internal.R;
import com.android.internal.util.Preconditions;
@@ -165,7 +167,17 @@ public class FloatingActionMode extends ActionMode {
        checkToolbarInitialized();

        mContentRectOnScreen.set(mContentRect);

        // Offset the content rect into screen coordinates, taking into account any transformations
        // that may be applied to the originating view or its ancestors.
        final ViewParent parent = mOriginatingView.getParent();
        if (parent instanceof ViewGroup) {
            ((ViewGroup) parent).getChildVisibleRect(
                    mOriginatingView, mContentRectOnScreen, null /* offset */);
            mContentRectOnScreen.offset(mRootViewPositionOnScreen[0], mRootViewPositionOnScreen[1]);
        } else {
            mContentRectOnScreen.offset(mViewPositionOnScreen[0], mViewPositionOnScreen[1]);
        }

        if (isContentRectWithinBounds()) {
            mFloatingToolbarVisibilityHelper.setOutOfBounds(false);