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

Commit 36b5ef22 authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Create BubbleBarFlyoutView

Initial version of the flyout view for displaying bubble bar
notification.

Flag: com.android.wm.shell.enable_bubble_bar
Bug: 277815200
Test: atest BubbleBarFlyoutViewScreenshotTest
Test: atest BubbleBarFlyoutControllerTest
Change-Id: I5d0643fe5d2691ad2349b45eaaad6cd2660d9df0
parent ccd58ab9
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2024 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<merge
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <ImageView
        android:id="@+id/bubble_flyout_avatar"
        android:layout_width="36dp"
        android:layout_height="36dp"
        android:padding="@dimen/bubblebar_flyout_avatar_message_space"
        android:scaleType="centerInside"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        tools:src="#ff0000"/>

    <TextView
        android:id="@+id/bubble_flyout_name"
        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"
        tools:text="Sender"/>

    <TextView
        android:id="@+id/bubble_flyout_text"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        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"
        tools:text="This is a message"/>

</merge>
+7 −0
Original line number Diff line number Diff line
@@ -480,6 +480,13 @@
    <dimen name="bubble_expanded_view_drop_target_padding">24dp</dimen>
    <dimen name="bubble_expanded_view_drop_target_margin">16dp</dimen>

    <!-- Bubble bar flyout view -->
    <dimen name="bubblebar_flyout_padding_horizontal">14dp</dimen>
    <dimen name="bubblebar_flyout_padding_vertical">10dp</dimen>
    <dimen name="bubblebar_flyout_elevation">4dp</dimen>
    <dimen name="bubblebar_flyout_avatar_message_space">6dp</dimen>
    <dimen name="bubblebar_flyout_max_width">96dp</dimen>

    <!-- Launcher splash screen -->
    <!-- Note: keep this value in sync with the WindowManager/Shell dimens.xml -->
    <!--     starting_surface_exit_animation_window_shift_length -->
+59 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.launcher3.taskbar.bubbles.flyout

import android.view.Gravity
import android.view.ViewGroup
import android.widget.FrameLayout
import com.android.launcher3.R

/** Creates and manages the visibility of the [BubbleBarFlyoutView]. */
class BubbleBarFlyoutController(
    private val container: FrameLayout,
    private val positioner: BubbleBarFlyoutPositioner,
) {

    private var flyout: BubbleBarFlyoutView? = null
    val horizontalMargin =
        container.context.resources.getDimensionPixelSize(R.dimen.transient_taskbar_bottom_margin)

    fun setUpFlyout(message: BubbleBarFlyoutMessage) {
        flyout?.let(container::removeView)
        val flyout = BubbleBarFlyoutView(container.context)

        flyout.translationY = positioner.targetTy

        val lp =
            FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT,
                Gravity.BOTTOM or if (positioner.isOnLeft) Gravity.LEFT else Gravity.RIGHT,
            )
        lp.marginStart = horizontalMargin
        lp.marginEnd = horizontalMargin
        container.addView(flyout, lp)

        flyout.setData(message)
        this.flyout = flyout
    }

    fun hideFlyout() {
        val flyout = this.flyout ?: return
        container.removeView(flyout)
        this.flyout = null
    }
}
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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,
)
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.launcher3.taskbar.bubbles.flyout

/** Provides positioning data to the flyout view. */
interface BubbleBarFlyoutPositioner {

    /** Whether the flyout view should be positioned on left or the right edge. */
    val isOnLeft: Boolean

    /** The target translation Y that the flyout view should have when displayed. */
    val targetTy: Float
}
Loading