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

Commit ea3b2e40 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

[AOD RONs] Fix header centering logic

When updateHeader is called on a "expanded" notification, the titleView was null (because the title is not in the header). This tricked the singleLine logic into triggering even though there was a title on the second line.

This only triggered if there was no text in the notification.

This CL also clarified the naming of various params in order to add clarity about this oddness that the title can be in multiple different places.

Fix: 421938041
Test: checked redacted and unredacted, both with and without text
FLag: android.app.ui_rich_ongoing
Change-Id: I905c2c70e1a43b9a6f4db32bb3b8568240b05535
parent 65a298f0
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -385,7 +385,7 @@ private class AODPromotedNotificationViewUpdater(root: View) {
        textView: ImageFloatingTextView? = text,
    ) {
        val headerTitleView = if (collapsed) title else null
        updateHeader(content, titleView = headerTitleView, collapsed = collapsed)
        updateHeader(content, headerTitleView = headerTitleView, collapsed = collapsed)

        if (headerTitleView == null) {
            updateTitle(title, content)
@@ -451,15 +451,18 @@ private class AODPromotedNotificationViewUpdater(root: View) {
    private fun updateHeader(
        content: PromotedNotificationContentModel,
        collapsed: Boolean,
        titleView: TextView?,
        headerTitleView: TextView?,
    ) {
        val hasTitle = titleView != null && content.title != null
        val hasTitleInHeader = headerTitleView != null && content.title != null
        val hasSubText = content.subText != null
        val hasText = content.text != null
        val isSingleLine = !hasTitle && !hasText

        // Determine if the notification has no content *below* the header/top line
        val hasTextBelowHeader = content.text != null
        val hasTitleBelowHeader = content.title != null && headerTitleView == null
        val isSingleLine = !hasTitleBelowHeader && !hasTextBelowHeader

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

        // We're only showing the top line (e.g. for redacted notifs), so center it
@@ -470,11 +473,11 @@ private class AODPromotedNotificationViewUpdater(root: View) {

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

        updateHeaderDividers(content, hideTitle = !hasTitle, hideAppName = hideAppName)
        updateHeaderDividers(content, hideTitle = !hasTitleInHeader, hideAppName = hideAppName)
    }

    private fun updateHeaderDividers(