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

Commit 1c8e18c1 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

[AOD RONs] Center text in redacted notifs

When a notification is redacted, it only has the top line showing the
app name and timestamp. In this case, the text has to be centered
vertically.

Also fixed the height being to tall in this case due to the actions
container.

Fix: 417591288
Test: checked that both redacted and unredacted notifications are
aligned correctly and have the right bottom space
FLag: android.app.ui_rich_ongoing

Change-Id: I6b4619b1f9bf436d7d61ff83ff76a256f1ccd565
parent 357db9df
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.graphics.drawable.Drawable
import android.util.Log
import android.util.Size
import android.view.LayoutInflater
import android.view.NotificationHeaderView
import android.view.NotificationTopLineView
import android.view.View
import android.view.View.GONE
@@ -284,7 +285,9 @@ private class AODPromotedNotificationViewUpdater(root: View) {
    private val time: DateTimeView? = root.findViewById(R.id.time)
    private val timeDivider: TextView? = root.findViewById(R.id.time_divider)
    private val title: TextView? = root.findViewById(R.id.title)
    private val header: NotificationHeaderView? = root.findViewById(R.id.notification_header)
    private val topLine: NotificationTopLineView? = root.findViewById(R.id.notification_top_line)
    private val actionsContainer: FrameLayout? = root.findViewById(R.id.actions_container)
    private val verificationDivider: TextView? = root.findViewById(R.id.verification_divider)
    private val verificationIcon: ImageView? = root.findViewById(R.id.verification_icon)
    private val verificationText: TextView? = root.findViewById(R.id.verification_text)
@@ -434,10 +437,19 @@ private class AODPromotedNotificationViewUpdater(root: View) {
    ) {
        val hasTitle = titleView != null && content.title != null
        val hasSubText = content.subText != null
        val hasText = content.text != null
        val isSingleLine = !hasTitle && !hasText

        // the collapsed form doesn't show the app name unless there is no other text in the header
        val appNameRequired = !hasTitle && !hasSubText
        val hideAppName = (!appNameRequired && collapsed)

        // We're only showing the top line (e.g. for redacted notifs), so center it
        header?.centerTopLine(isSingleLine)
        // We normally use the (empty) actions container for the bottom padding of the notification,
        // but that's not necessary when single line
        actionsContainer?.isVisible = !isSingleLine

        updateAppName(content, forceHide = hideAppName)
        updateTextView(headerTextSecondary, content.subText)
        updateTitle(titleView, content)