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

Commit c421ef13 authored by Ats Jenk's avatar Ats Jenk
Browse files

Update bubble bar expanded view drop target size

Drop target should have 28dp corner radius and 24dp padding compared to
the expanded view size.

Bug: 331641352
Test: atest WMShellRobolectricTests:BubbleExpandedViewPinControllerTest
Test: atest WMShellMultivalentTestsOnDevice:BubbleExpandedViewPinControllerTest
Change-Id: I47b29df413d51b70df40e68b4ba36cdef00032ff
parent 99c0de24
Loading
Loading
Loading
Loading
+2 −10
Original line number Original line Diff line number Diff line
@@ -31,7 +31,6 @@ import com.android.internal.protolog.common.ProtoLog
import com.android.wm.shell.R
import com.android.wm.shell.R
import com.android.wm.shell.bubbles.BubblePositioner
import com.android.wm.shell.bubbles.BubblePositioner
import com.android.wm.shell.bubbles.DeviceConfig
import com.android.wm.shell.bubbles.DeviceConfig
import com.android.wm.shell.bubbles.bar.BubbleExpandedViewPinController.Companion.DROP_TARGET_SCALE
import com.android.wm.shell.common.bubbles.BaseBubblePinController
import com.android.wm.shell.common.bubbles.BaseBubblePinController
import com.android.wm.shell.common.bubbles.BaseBubblePinController.Companion.DROP_TARGET_ALPHA_IN_DURATION
import com.android.wm.shell.common.bubbles.BaseBubblePinController.Companion.DROP_TARGET_ALPHA_IN_DURATION
import com.android.wm.shell.common.bubbles.BaseBubblePinController.Companion.DROP_TARGET_ALPHA_OUT_DURATION
import com.android.wm.shell.common.bubbles.BaseBubblePinController.Companion.DROP_TARGET_ALPHA_OUT_DURATION
@@ -248,15 +247,8 @@ class BubbleExpandedViewPinControllerTest {
    private val dropTargetView: View?
    private val dropTargetView: View?
        get() = container.findViewById(R.id.bubble_bar_drop_target)
        get() = container.findViewById(R.id.bubble_bar_drop_target)


    private fun getExpectedDropTargetBounds(onLeft: Boolean): Rect {
    private fun getExpectedDropTargetBounds(onLeft: Boolean): Rect = Rect().also {
        val rect = Rect()
        positioner.getBubbleBarExpandedViewBounds(onLeft, false /* isOveflowExpanded */, it)
        positioner.getBubbleBarExpandedViewBounds(onLeft, false /* isOveflowExpanded */, rect)
        // Scale the rect to expected size, but keep the center point the same
        val centerX = rect.centerX()
        val centerY = rect.centerY()
        rect.scale(DROP_TARGET_SCALE)
        rect.offset(centerX - rect.centerX(), centerY - rect.centerY())
        return rect
    }
    }


    private fun runOnMainSync(runnable: Runnable) {
    private fun runOnMainSync(runnable: Runnable) {
+10 −8
Original line number Original line Diff line number Diff line
@@ -13,12 +13,14 @@
  ~ See the License for the specific language governing permissions and
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  ~ limitations under the License.
  -->
  -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    android:shape="rectangle">
    android:inset="@dimen/bubble_bar_expanded_view_drop_target_padding">
    <corners android:radius="@dimen/bubble_bar_expanded_view_corner_radius" />
    <shape android:shape="rectangle">
        <corners android:radius="@dimen/bubble_bar_expanded_view_drop_target_corner" />
        <solid android:color="@color/bubble_drop_target_background_color" />
        <solid android:color="@color/bubble_drop_target_background_color" />
        <stroke
        <stroke
            android:width="1dp"
            android:width="1dp"
            android:color="?androidprv:attr/materialColorPrimaryContainer" />
            android:color="?androidprv:attr/materialColorPrimaryContainer" />
    </shape>
    </shape>
</inset>
+3 −0
Original line number Original line Diff line number Diff line
@@ -274,6 +274,9 @@
    <dimen name="bubble_bar_expanded_view_corner_radius">16dp</dimen>
    <dimen name="bubble_bar_expanded_view_corner_radius">16dp</dimen>
    <!-- Corner radius for expanded view while it is being dragged -->
    <!-- Corner radius for expanded view while it is being dragged -->
    <dimen name="bubble_bar_expanded_view_corner_radius_dragged">28dp</dimen>
    <dimen name="bubble_bar_expanded_view_corner_radius_dragged">28dp</dimen>
    <!-- Corner radius for expanded view drop target -->
    <dimen name="bubble_bar_expanded_view_drop_target_corner">28dp</dimen>
    <dimen name="bubble_bar_expanded_view_drop_target_padding">24dp</dimen>
    <!-- Width of the box around bottom center of the screen where drag only leads to dismiss -->
    <!-- Width of the box around bottom center of the screen where drag only leads to dismiss -->
    <dimen name="bubble_bar_dismiss_zone_width">192dp</dimen>
    <dimen name="bubble_bar_dismiss_zone_width">192dp</dimen>
    <!-- Height of the box around bottom center of the screen where drag only leads to dismiss -->
    <!-- Height of the box around bottom center of the screen where drag only leads to dismiss -->
+5 −15
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@ import android.graphics.Rect
import android.view.LayoutInflater
import android.view.LayoutInflater
import android.view.View
import android.view.View
import android.widget.FrameLayout
import android.widget.FrameLayout
import androidx.annotation.VisibleForTesting
import androidx.core.view.updateLayoutParams
import androidx.core.view.updateLayoutParams
import com.android.wm.shell.R
import com.android.wm.shell.R
import com.android.wm.shell.bubbles.BubblePositioner
import com.android.wm.shell.bubbles.BubblePositioner
@@ -79,7 +78,11 @@ class BubbleExpandedViewPinController(


    override fun updateLocation(location: BubbleBarLocation) {
    override fun updateLocation(location: BubbleBarLocation) {
        val view = dropTargetView ?: return
        val view = dropTargetView ?: return
        getBounds(location.isOnLeft(view.isLayoutRtl), tempRect)
        positioner.getBubbleBarExpandedViewBounds(
            location.isOnLeft(view.isLayoutRtl),
            false /* isOverflowExpanded */,
            tempRect
        )
        view.updateLayoutParams<FrameLayout.LayoutParams> {
        view.updateLayoutParams<FrameLayout.LayoutParams> {
            width = tempRect.width()
            width = tempRect.width()
            height = tempRect.height()
            height = tempRect.height()
@@ -87,17 +90,4 @@ class BubbleExpandedViewPinController(
        view.x = tempRect.left.toFloat()
        view.x = tempRect.left.toFloat()
        view.y = tempRect.top.toFloat()
        view.y = tempRect.top.toFloat()
    }
    }

    private fun getBounds(onLeft: Boolean, out: Rect) {
        positioner.getBubbleBarExpandedViewBounds(onLeft, false /* isOverflowExpanded */, out)
        val centerX = out.centerX()
        val centerY = out.centerY()
        out.scale(DROP_TARGET_SCALE)
        // Move rect center back to the same position as before scale
        out.offset(centerX - out.centerX(), centerY - out.centerY())
    }

    companion object {
        @VisibleForTesting const val DROP_TARGET_SCALE = 0.9f
    }
}
}