From 79a5acf475b0d0cdf593f32d71f038b4f67ac596 Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Wed, 3 Apr 2024 16:16:59 -0700 Subject: [PATCH] Update bubble bar pin controller after parent class refactor Some of the common logic related to exclusion zone calculation moved to parent class. Update the bubble bar controller based on the refactor. Bug: 330585402 Flag: ACONFIG com.android.wm.shell.enable_bubble_bar DEVELOPMENT Test: run shell unit tests, manual test Change-Id: I5910f76f26aaf6d15a5f6f7c1399b36b80296aeb --- .../taskbar/bubbles/BubbleBarPinController.kt | 47 ++++++++----------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarPinController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarPinController.kt index 8ed994966c..9e5ffc9dc4 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarPinController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarPinController.kt @@ -19,7 +19,6 @@ package com.android.launcher3.taskbar.bubbles import android.annotation.SuppressLint import android.content.Context import android.graphics.Point -import android.graphics.RectF import android.view.Gravity.BOTTOM import android.view.Gravity.LEFT import android.view.Gravity.RIGHT @@ -37,44 +36,29 @@ import com.android.wm.shell.common.bubbles.BubbleBarLocation class BubbleBarPinController( private val context: Context, private val container: FrameLayout, - private val screenSizeProvider: () -> Point -) : BaseBubblePinController() { + screenSizeProvider: () -> Point +) : BaseBubblePinController(screenSizeProvider) { private lateinit var bubbleBarViewController: BubbleBarViewController private lateinit var bubbleStashController: BubbleStashController + private var exclRectWidth: Float = 0f + private var exclRectHeight: Float = 0f + private var dropTargetView: View? = null fun init(bubbleControllers: BubbleControllers) { bubbleBarViewController = bubbleControllers.bubbleBarViewController bubbleStashController = bubbleControllers.bubbleStashController + exclRectWidth = context.resources.getDimension(R.dimen.bubblebar_dismiss_zone_width) + exclRectHeight = context.resources.getDimension(R.dimen.bubblebar_dismiss_zone_height) } - override fun getScreenCenterX(): Int { - return screenSizeProvider.invoke().x / 2 + override fun getExclusionRectWidth(): Float { + return exclRectWidth } - override fun getExclusionRect(): RectF { - val rect = - RectF( - 0f, - 0f, - context.resources.getDimension(R.dimen.bubblebar_dismiss_zone_width), - context.resources.getDimension(R.dimen.bubblebar_dismiss_zone_height) - ) - val screenSize = screenSizeProvider.invoke() - val middleX = screenSize.x / 2 - // Center it around the bottom center of the screen - rect.offsetTo(middleX - rect.width() / 2, screenSize.y - rect.height()) - return rect - } - - override fun createDropTargetView(): View { - return LayoutInflater.from(context) - .inflate(R.layout.bubble_bar_drop_target, container, false) - .also { view -> - dropTargetView = view - container.addView(view) - } + override fun getExclusionRectHeight(): Float { + return exclRectHeight } override fun getDropTargetView(): View? { @@ -86,6 +70,15 @@ class BubbleBarPinController( dropTargetView = null } + override fun createDropTargetView(): View { + return LayoutInflater.from(context) + .inflate(R.layout.bubble_bar_drop_target, container, false) + .also { view -> + dropTargetView = view + container.addView(view) + } + } + @SuppressLint("RtlHardcoded") override fun updateLocation(location: BubbleBarLocation) { val onLeft = location.isOnLeft(container.isLayoutRtl)