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

Commit 2f6de35b authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

[Compose Notifs] Allow longer text when expanded

This implements the behavior we need for BigTextStyle notifications.

Bug: 431222735
Test: manual, in the gallery app
Flag: EXEMPT code not in production yet
Change-Id: Ibd6d0d4683ca3730785881e262f99d4df37e1501
parent 1f1a8d92
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -42,13 +42,12 @@ internal fun CollapsedText(content: String, modifier: Modifier = Modifier) {
}

@Composable
internal fun ExpandedText(content: String, modifier: Modifier = Modifier) {
internal fun ExpandedText(content: String, maxLines: Int, modifier: Modifier = Modifier) {
    Text(
        content,
        modifier,
        style = MaterialTheme.typography.bodyMediumEmphasized,
        // TODO: b/431222735 - This should support longer text (à la BigTextStyle)
        maxLines = 2,
        maxLines = maxLines,
        overflow = Ellipsis,
    )
}
+6 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
@@ -36,7 +37,10 @@ import com.android.systemui.notifications.ui.viewmodel.NotificationViewModel

@Composable
public fun NotificationContent(viewModel: NotificationViewModel, modifier: Modifier = Modifier) {
    Row(modifier.padding(16.dp), verticalAlignment = Alignment.Top) {
    Row(
        modifier.padding(16.dp).heightIn(max = viewModel.maxHeightDp.dp),
        verticalAlignment = Alignment.Top,
    ) {
        AppIcon(viewModel.appIcon)
        Spacer(Modifier.width(16.dp))
        Column(Modifier.weight(1f)) {
@@ -53,7 +57,7 @@ public fun NotificationContent(viewModel: NotificationViewModel, modifier: Modif
@Composable
private fun MainContent(viewModel: NotificationViewModel) {
    return if (viewModel.isExpanded) {
        ExpandedText(viewModel.text)
        ExpandedText(viewModel.text, maxLines = viewModel.maxLinesWhenExpanded)
    } else {
        CollapsedText(viewModel.text)
    }
+5 −0
Original line number Diff line number Diff line
@@ -33,4 +33,9 @@ public interface NotificationViewModel {
    public val title: String
    /** The content text of the notification, shown below the title. */
    public val text: String

    /** How many lines of text can be displayed when the notification is expanded. */
    public val maxLinesWhenExpanded: Int
    /** The maximum height of the notification. */
    public val maxHeightDp: Int
}