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

Commit 39841920 authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Increase the size of the 'target' that bubble is dragged to for dismiss"

parents dc3241f3 6dfef975
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -998,4 +998,6 @@
    <dimen name="bubble_pointer_height">4dp</dimen>
    <dimen name="bubble_pointer_height">4dp</dimen>
    <!-- Width of the triangle that points to the expanded bubble -->
    <!-- Width of the triangle that points to the expanded bubble -->
    <dimen name="bubble_pointer_width">6dp</dimen>
    <dimen name="bubble_pointer_width">6dp</dimen>
    <!-- Extra padding around the dismiss target for bubbles -->
    <dimen name="bubble_dismiss_slop">16dp</dimen>
</resources>
</resources>
+20 −8
Original line number Original line Diff line number Diff line
@@ -51,6 +51,8 @@ public class PipDismissViewController {


    // Used for dismissing a bubble -- bubble should be in the target to be considered a dismiss
    // Used for dismissing a bubble -- bubble should be in the target to be considered a dismiss
    private View mTargetView;
    private View mTargetView;
    private int mTargetSlop;
    private Point mWindowSize;
    private int[] mLoc = new int[2];
    private int[] mLoc = new int[2];
    private boolean mIntersecting;
    private boolean mIntersecting;
    private Vibrator mVibe;
    private Vibrator mVibe;
@@ -69,12 +71,14 @@ public class PipDismissViewController {
            // Determine sizes for the view
            // Determine sizes for the view
            final Rect stableInsets = new Rect();
            final Rect stableInsets = new Rect();
            WindowManagerWrapper.getInstance().getStableInsets(stableInsets);
            WindowManagerWrapper.getInstance().getStableInsets(stableInsets);
            final Point windowSize = new Point();
            mWindowSize = new Point();
            mWindowManager.getDefaultDisplay().getRealSize(windowSize);
            mWindowManager.getDefaultDisplay().getRealSize(mWindowSize);
            final int gradientHeight = mContext.getResources().getDimensionPixelSize(
            final int gradientHeight = mContext.getResources().getDimensionPixelSize(
                    R.dimen.pip_dismiss_gradient_height);
                    R.dimen.pip_dismiss_gradient_height);
            final int bottomMargin = mContext.getResources().getDimensionPixelSize(
            final int bottomMargin = mContext.getResources().getDimensionPixelSize(
                    R.dimen.pip_dismiss_text_bottom_margin);
                    R.dimen.pip_dismiss_text_bottom_margin);
            mTargetSlop = mContext.getResources().getDimensionPixelSize(
                    R.dimen.bubble_dismiss_slop);


            // Create a new view for the dismiss target
            // Create a new view for the dismiss target
            LayoutInflater inflater = LayoutInflater.from(mContext);
            LayoutInflater inflater = LayoutInflater.from(mContext);
@@ -96,7 +100,7 @@ public class PipDismissViewController {
            // Add the target to the window
            // Add the target to the window
            LayoutParams lp =  new LayoutParams(
            LayoutParams lp =  new LayoutParams(
                    LayoutParams.MATCH_PARENT, gradientHeight,
                    LayoutParams.MATCH_PARENT, gradientHeight,
                    0, windowSize.y - gradientHeight,
                    0, mWindowSize.y - gradientHeight,
                    LayoutParams.TYPE_NAVIGATION_BAR_PANEL,
                    LayoutParams.TYPE_NAVIGATION_BAR_PANEL,
                    LayoutParams.FLAG_LAYOUT_IN_SCREEN
                    LayoutParams.FLAG_LAYOUT_IN_SCREEN
                            | LayoutParams.FLAG_NOT_TOUCHABLE
                            | LayoutParams.FLAG_NOT_TOUCHABLE
@@ -112,7 +116,7 @@ public class PipDismissViewController {




    /**
    /**
     * Updates the dismiss target based on location of the view.
     * Updates the dismiss target based on location of the view, only used for bubbles not for PIP.
     *
     *
     * @return whether the view is within the dismiss target.
     * @return whether the view is within the dismiss target.
     */
     */
@@ -127,11 +131,13 @@ public class PipDismissViewController {
            mTargetView.getLocationOnScreen(mLoc);
            mTargetView.getLocationOnScreen(mLoc);
            Rect targetRect = new Rect(mLoc[0], mLoc[1], mLoc[0] + mTargetView.getWidth(),
            Rect targetRect = new Rect(mLoc[0], mLoc[1], mLoc[0] + mTargetView.getWidth(),
                    mLoc[1] + mTargetView.getHeight());
                    mLoc[1] + mTargetView.getHeight());
            expandRect(targetRect, mTargetSlop);
            boolean intersecting = targetRect.intersect(viewRect);
            boolean intersecting = targetRect.intersect(viewRect);
            if (intersecting && !mIntersecting) {
            if (intersecting != mIntersecting) {
                // TODO: is this the right effect?
                // TODO: is this the right effect?
                mVibe.vibrate(VibrationEffect.get(VibrationEffect.EFFECT_CLICK));
                mVibe.vibrate(VibrationEffect.get(intersecting
                mIntersecting = true;
                        ? VibrationEffect.EFFECT_CLICK
                        : VibrationEffect.EFFECT_TICK));
            }
            }
            mIntersecting = intersecting;
            mIntersecting = intersecting;
            return intersecting;
            return intersecting;
@@ -139,7 +145,6 @@ public class PipDismissViewController {
        return false;
        return false;
    }
    }



    /**
    /**
     * Shows the dismiss target.
     * Shows the dismiss target.
     */
     */
@@ -172,4 +177,11 @@ public class PipDismissViewController {
                    .start();
                    .start();
        }
        }
    }
    }

    private void expandRect(Rect outRect, int expandAmount) {
        outRect.left = Math.max(0, outRect.left - expandAmount);
        outRect.top = Math.max(0, outRect.top - expandAmount);
        outRect.right = Math.min(mWindowSize.x, outRect.right + expandAmount);
        outRect.bottom = Math.min(mWindowSize.y, outRect.bottom + expandAmount);
    }
}
}