Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleExpandedViewPinController.kt +13 −19 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ package com.android.wm.shell.bubbles.bar import android.content.Context import android.graphics.Point import android.graphics.Rect import android.graphics.RectF import android.view.LayoutInflater import android.view.View import android.widget.FrameLayout Loading @@ -37,31 +37,25 @@ class BubbleExpandedViewPinController( private val context: Context, private val container: FrameLayout, private val positioner: BubblePositioner ) : BaseBubblePinController() { ) : BaseBubblePinController({ positioner.availableRect.let { Point(it.width(), it.height()) } }) { private var dropTargetView: View? = null private val tempRect: Rect by lazy(LazyThreadSafetyMode.NONE) { Rect() } override fun getScreenCenterX(): Int { return positioner.screenRect.centerX() private val exclRectWidth: Float by lazy { context.resources.getDimension(R.dimen.bubble_bar_dismiss_zone_width) } override fun getExclusionRect(): RectF { val rect = RectF( 0f, 0f, context.resources.getDimension(R.dimen.bubble_bar_dismiss_zone_width), private val exclRectHeight: Float by lazy { context.resources.getDimension(R.dimen.bubble_bar_dismiss_zone_height) ) } override fun getExclusionRectWidth(): Float { return exclRectWidth } val screenRect = positioner.screenRect // Center it around the bottom center of the screen rect.offsetTo( screenRect.exactCenterX() - rect.width() / 2f, screenRect.bottom - rect.height() ) return rect override fun getExclusionRectHeight(): Float { return exclRectHeight } override fun createDropTargetView(): View { Loading libs/WindowManager/Shell/src/com/android/wm/shell/common/bubbles/BaseBubblePinController.kt +15 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.common.bubbles import android.graphics.Point import android.graphics.RectF import android.view.View import androidx.annotation.VisibleForTesting Loading @@ -35,7 +36,7 @@ import com.android.wm.shell.common.bubbles.BubbleBarLocation.RIGHT * * Shows a drop target when releasing a view would update the [BubbleBarLocation]. */ abstract class BaseBubblePinController { abstract class BaseBubblePinController(private val screenSizeProvider: () -> Point) { private var onLeft = false private var dismissZone: RectF? = null Loading @@ -50,8 +51,8 @@ abstract class BaseBubblePinController { */ fun onDragStart(initialLocationOnLeft: Boolean) { onLeft = initialLocationOnLeft screenCenterX = screenSizeProvider.invoke().x / 2 dismissZone = getExclusionRect() screenCenterX = getScreenCenterX() } /** View has moved to [x] and [y] screen coordinates */ Loading Loading @@ -91,11 +92,10 @@ abstract class BaseBubblePinController { this.listener = listener } /** Get screen center coordinate on the x axis. */ protected abstract fun getScreenCenterX(): Int /** Optional exclusion rect where drag interactions are not processed */ protected abstract fun getExclusionRect(): RectF? /** Get width for exclusion rect where dismiss takes over drag */ protected abstract fun getExclusionRectWidth(): Float /** Get height for exclusion rect where dismiss takes over drag */ protected abstract fun getExclusionRectHeight(): Float /** Create the drop target view and attach it to the parent */ protected abstract fun createDropTargetView(): View Loading @@ -114,6 +114,14 @@ abstract class BaseBubblePinController { listener?.onChange(location) } private fun getExclusionRect(): RectF { val rect = RectF(0f, 0f, getExclusionRectWidth(), getExclusionRectHeight()) // Center it around the bottom center of the screen val screenBottom = screenSizeProvider.invoke().y rect.offsetTo(screenCenterX - rect.width() / 2, screenBottom - rect.height()) return rect } private fun showDropTarget(location: BubbleBarLocation) { val targetView = getDropTargetView() ?: createDropTargetView().apply { alpha = 0f } if (targetView.alpha > 0) { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleExpandedViewPinController.kt +13 −19 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ package com.android.wm.shell.bubbles.bar import android.content.Context import android.graphics.Point import android.graphics.Rect import android.graphics.RectF import android.view.LayoutInflater import android.view.View import android.widget.FrameLayout Loading @@ -37,31 +37,25 @@ class BubbleExpandedViewPinController( private val context: Context, private val container: FrameLayout, private val positioner: BubblePositioner ) : BaseBubblePinController() { ) : BaseBubblePinController({ positioner.availableRect.let { Point(it.width(), it.height()) } }) { private var dropTargetView: View? = null private val tempRect: Rect by lazy(LazyThreadSafetyMode.NONE) { Rect() } override fun getScreenCenterX(): Int { return positioner.screenRect.centerX() private val exclRectWidth: Float by lazy { context.resources.getDimension(R.dimen.bubble_bar_dismiss_zone_width) } override fun getExclusionRect(): RectF { val rect = RectF( 0f, 0f, context.resources.getDimension(R.dimen.bubble_bar_dismiss_zone_width), private val exclRectHeight: Float by lazy { context.resources.getDimension(R.dimen.bubble_bar_dismiss_zone_height) ) } override fun getExclusionRectWidth(): Float { return exclRectWidth } val screenRect = positioner.screenRect // Center it around the bottom center of the screen rect.offsetTo( screenRect.exactCenterX() - rect.width() / 2f, screenRect.bottom - rect.height() ) return rect override fun getExclusionRectHeight(): Float { return exclRectHeight } override fun createDropTargetView(): View { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/common/bubbles/BaseBubblePinController.kt +15 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.common.bubbles import android.graphics.Point import android.graphics.RectF import android.view.View import androidx.annotation.VisibleForTesting Loading @@ -35,7 +36,7 @@ import com.android.wm.shell.common.bubbles.BubbleBarLocation.RIGHT * * Shows a drop target when releasing a view would update the [BubbleBarLocation]. */ abstract class BaseBubblePinController { abstract class BaseBubblePinController(private val screenSizeProvider: () -> Point) { private var onLeft = false private var dismissZone: RectF? = null Loading @@ -50,8 +51,8 @@ abstract class BaseBubblePinController { */ fun onDragStart(initialLocationOnLeft: Boolean) { onLeft = initialLocationOnLeft screenCenterX = screenSizeProvider.invoke().x / 2 dismissZone = getExclusionRect() screenCenterX = getScreenCenterX() } /** View has moved to [x] and [y] screen coordinates */ Loading Loading @@ -91,11 +92,10 @@ abstract class BaseBubblePinController { this.listener = listener } /** Get screen center coordinate on the x axis. */ protected abstract fun getScreenCenterX(): Int /** Optional exclusion rect where drag interactions are not processed */ protected abstract fun getExclusionRect(): RectF? /** Get width for exclusion rect where dismiss takes over drag */ protected abstract fun getExclusionRectWidth(): Float /** Get height for exclusion rect where dismiss takes over drag */ protected abstract fun getExclusionRectHeight(): Float /** Create the drop target view and attach it to the parent */ protected abstract fun createDropTargetView(): View Loading @@ -114,6 +114,14 @@ abstract class BaseBubblePinController { listener?.onChange(location) } private fun getExclusionRect(): RectF { val rect = RectF(0f, 0f, getExclusionRectWidth(), getExclusionRectHeight()) // Center it around the bottom center of the screen val screenBottom = screenSizeProvider.invoke().y rect.offsetTo(screenCenterX - rect.width() / 2, screenBottom - rect.height()) return rect } private fun showDropTarget(location: BubbleBarLocation) { val targetView = getDropTargetView() ?: createDropTargetView().apply { alpha = 0f } if (targetView.alpha > 0) { Loading