Loading packages/SystemUI/res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -998,4 +998,6 @@ <dimen name="bubble_pointer_height">4dp</dimen> <!-- Width of the triangle that points to the expanded bubble --> <dimen name="bubble_pointer_width">6dp</dimen> <!-- Extra padding around the dismiss target for bubbles --> <dimen name="bubble_dismiss_slop">16dp</dimen> </resources> packages/SystemUI/src/com/android/systemui/pip/phone/PipDismissViewController.java +20 −8 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ public class PipDismissViewController { // Used for dismissing a bubble -- bubble should be in the target to be considered a dismiss private View mTargetView; private int mTargetSlop; private Point mWindowSize; private int[] mLoc = new int[2]; private boolean mIntersecting; private Vibrator mVibe; Loading @@ -69,12 +71,14 @@ public class PipDismissViewController { // Determine sizes for the view final Rect stableInsets = new Rect(); WindowManagerWrapper.getInstance().getStableInsets(stableInsets); final Point windowSize = new Point(); mWindowManager.getDefaultDisplay().getRealSize(windowSize); mWindowSize = new Point(); mWindowManager.getDefaultDisplay().getRealSize(mWindowSize); final int gradientHeight = mContext.getResources().getDimensionPixelSize( R.dimen.pip_dismiss_gradient_height); final int bottomMargin = mContext.getResources().getDimensionPixelSize( R.dimen.pip_dismiss_text_bottom_margin); mTargetSlop = mContext.getResources().getDimensionPixelSize( R.dimen.bubble_dismiss_slop); // Create a new view for the dismiss target LayoutInflater inflater = LayoutInflater.from(mContext); Loading @@ -96,7 +100,7 @@ public class PipDismissViewController { // Add the target to the window LayoutParams lp = new LayoutParams( LayoutParams.MATCH_PARENT, gradientHeight, 0, windowSize.y - gradientHeight, 0, mWindowSize.y - gradientHeight, LayoutParams.TYPE_NAVIGATION_BAR_PANEL, LayoutParams.FLAG_LAYOUT_IN_SCREEN | LayoutParams.FLAG_NOT_TOUCHABLE Loading @@ -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. */ Loading @@ -127,11 +131,13 @@ public class PipDismissViewController { mTargetView.getLocationOnScreen(mLoc); Rect targetRect = new Rect(mLoc[0], mLoc[1], mLoc[0] + mTargetView.getWidth(), mLoc[1] + mTargetView.getHeight()); expandRect(targetRect, mTargetSlop); boolean intersecting = targetRect.intersect(viewRect); if (intersecting && !mIntersecting) { if (intersecting != mIntersecting) { // TODO: is this the right effect? mVibe.vibrate(VibrationEffect.get(VibrationEffect.EFFECT_CLICK)); mIntersecting = true; mVibe.vibrate(VibrationEffect.get(intersecting ? VibrationEffect.EFFECT_CLICK : VibrationEffect.EFFECT_TICK)); } mIntersecting = intersecting; return intersecting; Loading @@ -139,7 +145,6 @@ public class PipDismissViewController { return false; } /** * Shows the dismiss target. */ Loading Loading @@ -172,4 +177,11 @@ public class PipDismissViewController { .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); } } Loading
packages/SystemUI/res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -998,4 +998,6 @@ <dimen name="bubble_pointer_height">4dp</dimen> <!-- Width of the triangle that points to the expanded bubble --> <dimen name="bubble_pointer_width">6dp</dimen> <!-- Extra padding around the dismiss target for bubbles --> <dimen name="bubble_dismiss_slop">16dp</dimen> </resources>
packages/SystemUI/src/com/android/systemui/pip/phone/PipDismissViewController.java +20 −8 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ public class PipDismissViewController { // Used for dismissing a bubble -- bubble should be in the target to be considered a dismiss private View mTargetView; private int mTargetSlop; private Point mWindowSize; private int[] mLoc = new int[2]; private boolean mIntersecting; private Vibrator mVibe; Loading @@ -69,12 +71,14 @@ public class PipDismissViewController { // Determine sizes for the view final Rect stableInsets = new Rect(); WindowManagerWrapper.getInstance().getStableInsets(stableInsets); final Point windowSize = new Point(); mWindowManager.getDefaultDisplay().getRealSize(windowSize); mWindowSize = new Point(); mWindowManager.getDefaultDisplay().getRealSize(mWindowSize); final int gradientHeight = mContext.getResources().getDimensionPixelSize( R.dimen.pip_dismiss_gradient_height); final int bottomMargin = mContext.getResources().getDimensionPixelSize( R.dimen.pip_dismiss_text_bottom_margin); mTargetSlop = mContext.getResources().getDimensionPixelSize( R.dimen.bubble_dismiss_slop); // Create a new view for the dismiss target LayoutInflater inflater = LayoutInflater.from(mContext); Loading @@ -96,7 +100,7 @@ public class PipDismissViewController { // Add the target to the window LayoutParams lp = new LayoutParams( LayoutParams.MATCH_PARENT, gradientHeight, 0, windowSize.y - gradientHeight, 0, mWindowSize.y - gradientHeight, LayoutParams.TYPE_NAVIGATION_BAR_PANEL, LayoutParams.FLAG_LAYOUT_IN_SCREEN | LayoutParams.FLAG_NOT_TOUCHABLE Loading @@ -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. */ Loading @@ -127,11 +131,13 @@ public class PipDismissViewController { mTargetView.getLocationOnScreen(mLoc); Rect targetRect = new Rect(mLoc[0], mLoc[1], mLoc[0] + mTargetView.getWidth(), mLoc[1] + mTargetView.getHeight()); expandRect(targetRect, mTargetSlop); boolean intersecting = targetRect.intersect(viewRect); if (intersecting && !mIntersecting) { if (intersecting != mIntersecting) { // TODO: is this the right effect? mVibe.vibrate(VibrationEffect.get(VibrationEffect.EFFECT_CLICK)); mIntersecting = true; mVibe.vibrate(VibrationEffect.get(intersecting ? VibrationEffect.EFFECT_CLICK : VibrationEffect.EFFECT_TICK)); } mIntersecting = intersecting; return intersecting; Loading @@ -139,7 +145,6 @@ public class PipDismissViewController { return false; } /** * Shows the dismiss target. */ Loading Loading @@ -172,4 +177,11 @@ public class PipDismissViewController { .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); } }