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

Commit 136d1ec8 authored by Winson Chung's avatar Winson Chung
Browse files

Apply static offset to PiP IME adjustment.

Bug: 63581892
Test: Enter PiP, launch an app with a bottom aligned input view and focus
      it. Ensure that the PiP is offset sufficiently to see the view.

Change-Id: Ice0d77b25b34d389f604f8154bdf7c866be668e5
parent 8aaa5ada
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -781,6 +781,9 @@
    <!-- The shortest-edge size of the expanded PiP. -->
    <!-- The shortest-edge size of the expanded PiP. -->
    <dimen name="pip_expanded_shortest_edge_size">160dp</dimen>
    <dimen name="pip_expanded_shortest_edge_size">160dp</dimen>


    <!-- The additional offset to apply to the IME animation to account for the input field. -->
    <dimen name="pip_ime_offset">48dp</dimen>

    <!-- The padding between actions in the PiP in landscape  Note that the PiP does not reflect
    <!-- The padding between actions in the PiP in landscape  Note that the PiP does not reflect
         the configuration of the device, so we can't use -land resources. -->
         the configuration of the device, so we can't use -land resources. -->
    <dimen name="pip_between_action_padding_land">8dp</dimen>
    <dimen name="pip_between_action_padding_land">8dp</dimen>
+16 −8
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.app.IActivityManager;
import android.app.IActivityManager;
import android.content.ComponentName;
import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.Rect;
@@ -122,6 +123,7 @@ public class PipTouchHandler {
    private boolean mIsMinimized;
    private boolean mIsMinimized;
    private boolean mIsImeShowing;
    private boolean mIsImeShowing;
    private int mImeHeight;
    private int mImeHeight;
    private int mImeOffset;
    private float mSavedSnapFraction = -1f;
    private float mSavedSnapFraction = -1f;
    private boolean mSendingHoverAccessibilityEvents;
    private boolean mSendingHoverAccessibilityEvents;
    private boolean mMovementWithinMinimize;
    private boolean mMovementWithinMinimize;
@@ -192,8 +194,11 @@ public class PipTouchHandler {
        };
        };
        mMotionHelper = new PipMotionHelper(mContext, mActivityManager, mMenuController,
        mMotionHelper = new PipMotionHelper(mContext, mActivityManager, mMenuController,
                mSnapAlgorithm, mFlingAnimationUtils);
                mSnapAlgorithm, mFlingAnimationUtils);
        mExpandedShortestEdgeSize = context.getResources().getDimensionPixelSize(

        Resources res = context.getResources();
        mExpandedShortestEdgeSize = res.getDimensionPixelSize(
                R.dimen.pip_expanded_shortest_edge_size);
                R.dimen.pip_expanded_shortest_edge_size);
        mImeOffset = res.getDimensionPixelSize(R.dimen.pip_ime_offset);


        // Register the listener for input consumer touch events
        // Register the listener for input consumer touch events
        inputConsumerController.setTouchListener(this::handleTouchEvent);
        inputConsumerController.setTouchListener(this::handleTouchEvent);
@@ -265,7 +270,6 @@ public class PipTouchHandler {
        mSnapAlgorithm.getMovementBounds(mExpandedBounds, insetBounds, expandedMovementBounds,
        mSnapAlgorithm.getMovementBounds(mExpandedBounds, insetBounds, expandedMovementBounds,
                mIsImeShowing ? mImeHeight : 0);
                mIsImeShowing ? mImeHeight : 0);



        // If this is from an IME adjustment, then we should move the PiP so that it is not occluded
        // If this is from an IME adjustment, then we should move the PiP so that it is not occluded
        // by the IME
        // by the IME
        if (fromImeAdjustement) {
        if (fromImeAdjustement) {
@@ -278,18 +282,22 @@ public class PipTouchHandler {
                        ? expandedMovementBounds
                        ? expandedMovementBounds
                        : normalMovementBounds;
                        : normalMovementBounds;
                if (mIsImeShowing) {
                if (mIsImeShowing) {
                    // IME visible
                    // IME visible, apply the IME offset if the space allows for it
                    final int imeOffset = toMovementBounds.bottom - Math.max(toMovementBounds.top,
                            toMovementBounds.bottom - mImeOffset);
                    if (bounds.top == mMovementBounds.bottom) {
                    if (bounds.top == mMovementBounds.bottom) {
                        // If the PIP is currently resting on top of the IME, then adjust it with
                        // If the PIP is currently resting on top of the IME, then adjust it with
                        // the hiding IME
                        // the showing IME
                        bounds.offsetTo(bounds.left, toMovementBounds.bottom);
                        bounds.offsetTo(bounds.left, toMovementBounds.bottom - imeOffset);
                    } else {
                    } else {
                        bounds.offset(0, Math.min(0, toMovementBounds.bottom - bounds.top));
                        bounds.offset(0, Math.min(0, toMovementBounds.bottom - imeOffset
                                - bounds.top));
                    }
                    }
                } else {
                } else {
                    // IME hidden
                    // IME hidden
                    if (bounds.top == mMovementBounds.bottom) {
                    if (bounds.top >= (mMovementBounds.bottom - mImeOffset)) {
                        // If the PIP is resting on top of the IME, then adjust it with the hiding IME
                        // If the PIP is resting on top of the IME, then adjust it with the hiding
                        // IME
                        bounds.offsetTo(bounds.left, toMovementBounds.bottom);
                        bounds.offsetTo(bounds.left, toMovementBounds.bottom);
                    }
                    }
                }
                }