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

Commit 9b093db2 authored by Liran Binyamin's avatar Liran Binyamin Committed by Android (Google) Code Review
Browse files

Merge "Rename bubble bar flyout fields" into main

parents e79a786b 75675e12
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
    xmlns:tools="http://schemas.android.com/tools">

    <ImageView
        android:id="@+id/bubble_flyout_avatar"
        android:id="@+id/bubble_flyout_icon"
        android:layout_width="50dp"
        android:layout_height="36dp"
        android:paddingEnd="@dimen/bubblebar_flyout_avatar_message_space"
@@ -30,14 +30,14 @@
        tools:src="#ff0000"/>

    <TextView
        android:id="@+id/bubble_flyout_name"
        android:id="@+id/bubble_flyout_title"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:fontFamily="@*android:string/config_bodyFontFamilyMedium"
        android:maxLines="1"
        android:ellipsize="end"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toEndOf="@id/bubble_flyout_avatar"
        app:layout_constraintStart_toEndOf="@id/bubble_flyout_icon"
        tools:text="Sender"/>

    <TextView
@@ -47,8 +47,8 @@
        android:fontFamily="@*android:string/config_bodyFontFamily"
        android:maxLines="2"
        android:ellipsize="end"
        app:layout_constraintTop_toBottomOf="@id/bubble_flyout_name"
        app:layout_constraintStart_toEndOf="@id/bubble_flyout_avatar"
        app:layout_constraintTop_toBottomOf="@id/bubble_flyout_title"
        app:layout_constraintStart_toEndOf="@id/bubble_flyout_icon"
        tools:text="This is a message"/>

</merge>
+1 −6
Original line number Diff line number Diff line
@@ -18,9 +18,4 @@ package com.android.launcher3.taskbar.bubbles.flyout

import android.graphics.drawable.Drawable

data class BubbleBarFlyoutMessage(
    val senderAvatar: Drawable?,
    val senderName: CharSequence,
    val message: CharSequence,
    val isGroupChat: Boolean,
)
data class BubbleBarFlyoutMessage(val icon: Drawable?, val title: String, val message: String)
+24 −24
Original line number Diff line number Diff line
@@ -44,11 +44,11 @@ class BubbleBarFlyoutView(context: Context, private val positioner: BubbleBarFly
        const val MIN_EXPANSION_PROGRESS_FOR_CONTENT_ALPHA = 0.75f
    }

    private val sender: TextView by
        lazy(LazyThreadSafetyMode.NONE) { findViewById(R.id.bubble_flyout_name) }
    private val title: TextView by
        lazy(LazyThreadSafetyMode.NONE) { findViewById(R.id.bubble_flyout_title) }

    private val avatar: ImageView by
        lazy(LazyThreadSafetyMode.NONE) { findViewById(R.id.bubble_flyout_avatar) }
    private val icon: ImageView by
        lazy(LazyThreadSafetyMode.NONE) { findViewById(R.id.bubble_flyout_icon) }

    private val message: TextView by
        lazy(LazyThreadSafetyMode.NONE) { findViewById(R.id.bubble_flyout_text) }
@@ -171,8 +171,8 @@ class BubbleBarFlyoutView(context: Context, private val positioner: BubbleBarFly

    /** Sets the data for the flyout and starts playing the expand animation. */
    fun showFromCollapsed(flyoutMessage: BubbleBarFlyoutMessage, expandAnimation: () -> Unit) {
        avatar.alpha = 0f
        sender.alpha = 0f
        icon.alpha = 0f
        title.alpha = 0f
        message.alpha = 0f
        setData(flyoutMessage)
        val txToCollapsedPosition =
@@ -202,18 +202,18 @@ class BubbleBarFlyoutView(context: Context, private val positioner: BubbleBarFly

    private fun setData(flyoutMessage: BubbleBarFlyoutMessage) {
        // the avatar is only displayed in group chat messages
        if (flyoutMessage.senderAvatar != null && flyoutMessage.isGroupChat) {
            avatar.visibility = VISIBLE
            avatar.setImageDrawable(flyoutMessage.senderAvatar)
        if (flyoutMessage.icon != null) {
            icon.visibility = VISIBLE
            icon.setImageDrawable(flyoutMessage.icon)
        } else {
            avatar.visibility = GONE
            icon.visibility = GONE
        }

        val minTextViewWidth: Int
        val maxTextViewWidth: Int
        if (avatar.visibility == VISIBLE) {
            minTextViewWidth = minFlyoutWidth - avatar.width - flyoutPadding * 2
            maxTextViewWidth = maxFlyoutWidth - avatar.width - flyoutPadding * 2
        if (icon.visibility == VISIBLE) {
            minTextViewWidth = minFlyoutWidth - icon.width - flyoutPadding * 2
            maxTextViewWidth = maxFlyoutWidth - icon.width - flyoutPadding * 2
        } else {
            // when there's no avatar, the width of the text view is constant, so we're setting the
            // min and max to the same value
@@ -221,13 +221,13 @@ class BubbleBarFlyoutView(context: Context, private val positioner: BubbleBarFly
            maxTextViewWidth = minTextViewWidth
        }

        if (flyoutMessage.senderName.isEmpty()) {
            sender.visibility = GONE
        if (flyoutMessage.title.isEmpty()) {
            title.visibility = GONE
        } else {
            sender.minWidth = minTextViewWidth
            sender.maxWidth = maxTextViewWidth
            sender.text = flyoutMessage.senderName
            sender.visibility = VISIBLE
            title.minWidth = minTextViewWidth
            title.maxWidth = maxTextViewWidth
            title.text = flyoutMessage.title
            title.visibility = VISIBLE
        }

        message.minWidth = minTextViewWidth
@@ -240,17 +240,17 @@ class BubbleBarFlyoutView(context: Context, private val positioner: BubbleBarFly
        expansionProgress = fraction

        updateTranslationForAnimation(message)
        updateTranslationForAnimation(sender)
        updateTranslationForAnimation(avatar)
        updateTranslationForAnimation(title)
        updateTranslationForAnimation(icon)

        // start fading in the content only after we're past the threshold
        val alpha =
            ((expansionProgress - MIN_EXPANSION_PROGRESS_FOR_CONTENT_ALPHA) /
                    (1f - MIN_EXPANSION_PROGRESS_FOR_CONTENT_ALPHA))
                .coerceIn(0f, 1f)
        sender.alpha = alpha
        title.alpha = alpha
        message.alpha = alpha
        avatar.alpha = alpha
        icon.alpha = alpha

        translationZ =
            collapsedElevation + (flyoutElevation - collapsedElevation) * expansionProgress
@@ -368,7 +368,7 @@ class BubbleBarFlyoutView(context: Context, private val positioner: BubbleBarFly
                )
            )
        backgroundColor = ta.getColor(0, defaultBackgroundColor)
        sender.setTextColor(ta.getColor(1, defaultTextColor))
        title.setTextColor(ta.getColor(1, defaultTextColor))
        message.setTextColor(ta.getColor(2, defaultTextColor))
        ta.recycle()
        backgroundPaint.color = backgroundColor
+18 −36
Original line number Diff line number Diff line
@@ -63,12 +63,7 @@ class BubbleBarFlyoutViewScreenshotTest(emulationSpec: DeviceEmulationSpec) {
            val flyout =
                BubbleBarFlyoutView(context, FakeBubbleBarFlyoutPositioner(isOnLeft = false))
            flyout.showFromCollapsed(
                BubbleBarFlyoutMessage(
                    senderAvatar = null,
                    senderName = "sender",
                    message = "message",
                    isGroupChat = false,
                )
                BubbleBarFlyoutMessage(icon = null, title = "sender", message = "message")
            ) {}
            flyout.updateExpansionProgress(1f)
            flyout
@@ -82,12 +77,7 @@ class BubbleBarFlyoutViewScreenshotTest(emulationSpec: DeviceEmulationSpec) {
            val flyout =
                BubbleBarFlyoutView(context, FakeBubbleBarFlyoutPositioner(isOnLeft = true))
            flyout.showFromCollapsed(
                BubbleBarFlyoutMessage(
                    senderAvatar = null,
                    senderName = "sender",
                    message = "message",
                    isGroupChat = false,
                )
                BubbleBarFlyoutMessage(icon = null, title = "sender", message = "message")
            ) {}
            flyout.updateExpansionProgress(1f)
            flyout
@@ -102,10 +92,9 @@ class BubbleBarFlyoutViewScreenshotTest(emulationSpec: DeviceEmulationSpec) {
                BubbleBarFlyoutView(context, FakeBubbleBarFlyoutPositioner(isOnLeft = true))
            flyout.showFromCollapsed(
                BubbleBarFlyoutMessage(
                    senderAvatar = null,
                    senderName = "sender",
                    icon = null,
                    title = "sender",
                    message = "really, really, really, really, really long message. like really.",
                    isGroupChat = false,
                )
            ) {}
            flyout.updateExpansionProgress(1f)
@@ -121,10 +110,9 @@ class BubbleBarFlyoutViewScreenshotTest(emulationSpec: DeviceEmulationSpec) {
                BubbleBarFlyoutView(context, FakeBubbleBarFlyoutPositioner(isOnLeft = false))
            flyout.showFromCollapsed(
                BubbleBarFlyoutMessage(
                    senderAvatar = ColorDrawable(Color.RED),
                    senderName = "sender",
                    icon = ColorDrawable(Color.RED),
                    title = "sender",
                    message = "message",
                    isGroupChat = true,
                )
            ) {}
            flyout.updateExpansionProgress(1f)
@@ -140,10 +128,9 @@ class BubbleBarFlyoutViewScreenshotTest(emulationSpec: DeviceEmulationSpec) {
                BubbleBarFlyoutView(context, FakeBubbleBarFlyoutPositioner(isOnLeft = true))
            flyout.showFromCollapsed(
                BubbleBarFlyoutMessage(
                    senderAvatar = ColorDrawable(Color.RED),
                    senderName = "sender",
                    icon = ColorDrawable(Color.RED),
                    title = "sender",
                    message = "message",
                    isGroupChat = true,
                )
            ) {}
            flyout.updateExpansionProgress(1f)
@@ -159,10 +146,9 @@ class BubbleBarFlyoutViewScreenshotTest(emulationSpec: DeviceEmulationSpec) {
                BubbleBarFlyoutView(context, FakeBubbleBarFlyoutPositioner(isOnLeft = true))
            flyout.showFromCollapsed(
                BubbleBarFlyoutMessage(
                    senderAvatar = ColorDrawable(Color.RED),
                    senderName = "sender",
                    icon = ColorDrawable(Color.RED),
                    title = "sender",
                    message = "really, really, really, really, really long message. like really.",
                    isGroupChat = true,
                )
            ) {}
            flyout.updateExpansionProgress(1f)
@@ -178,10 +164,9 @@ class BubbleBarFlyoutViewScreenshotTest(emulationSpec: DeviceEmulationSpec) {
                BubbleBarFlyoutView(context, FakeBubbleBarFlyoutPositioner(isOnLeft = true))
            flyout.showFromCollapsed(
                BubbleBarFlyoutMessage(
                    senderAvatar = ColorDrawable(Color.RED),
                    senderName = "sender",
                    icon = ColorDrawable(Color.RED),
                    title = "sender",
                    message = "collapsed on left",
                    isGroupChat = true,
                )
            ) {}
            flyout.updateExpansionProgress(0f)
@@ -197,10 +182,9 @@ class BubbleBarFlyoutViewScreenshotTest(emulationSpec: DeviceEmulationSpec) {
                BubbleBarFlyoutView(context, FakeBubbleBarFlyoutPositioner(isOnLeft = false))
            flyout.showFromCollapsed(
                BubbleBarFlyoutMessage(
                    senderAvatar = ColorDrawable(Color.RED),
                    senderName = "sender",
                    icon = ColorDrawable(Color.RED),
                    title = "sender",
                    message = "collapsed on right",
                    isGroupChat = true,
                )
            ) {}
            flyout.updateExpansionProgress(0f)
@@ -222,10 +206,9 @@ class BubbleBarFlyoutViewScreenshotTest(emulationSpec: DeviceEmulationSpec) {
                )
            flyout.showFromCollapsed(
                BubbleBarFlyoutMessage(
                    senderAvatar = ColorDrawable(Color.RED),
                    senderName = "sender",
                    icon = ColorDrawable(Color.RED),
                    title = "sender",
                    message = "expanded 90% on left",
                    isGroupChat = true,
                )
            ) {}
            flyout.updateExpansionProgress(0.9f)
@@ -247,10 +230,9 @@ class BubbleBarFlyoutViewScreenshotTest(emulationSpec: DeviceEmulationSpec) {
                )
            flyout.showFromCollapsed(
                BubbleBarFlyoutMessage(
                    senderAvatar = ColorDrawable(Color.RED),
                    senderName = "sender",
                    icon = ColorDrawable(Color.RED),
                    title = "sender",
                    message = "expanded 80% on right",
                    isGroupChat = true,
                )
            ) {}
            flyout.updateExpansionProgress(0.8f)
+2 −3
Original line number Diff line number Diff line
@@ -39,8 +39,7 @@ class BubbleBarFlyoutControllerTest {
    private lateinit var flyoutController: BubbleBarFlyoutController
    private lateinit var flyoutContainer: FrameLayout
    private val context = ApplicationProvider.getApplicationContext<Context>()
    private val flyoutMessage =
        BubbleBarFlyoutMessage(senderAvatar = null, "sender name", "message", isGroupChat = false)
    private val flyoutMessage = BubbleBarFlyoutMessage(icon = null, "sender name", "message")
    private var onLeft = true

    @Before
@@ -87,7 +86,7 @@ class BubbleBarFlyoutControllerTest {
        flyoutController.setUpFlyout(flyoutMessage)
        assertThat(flyoutContainer.childCount).isEqualTo(1)
        val flyout = flyoutContainer.getChildAt(0)
        val sender = flyout.findViewById<TextView>(R.id.bubble_flyout_name)
        val sender = flyout.findViewById<TextView>(R.id.bubble_flyout_title)
        assertThat(sender.text).isEqualTo("sender name")
        val message = flyout.findViewById<TextView>(R.id.bubble_flyout_text)
        assertThat(message.text).isEqualTo("message")