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

Commit d7116b6e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Include call person name in CallStyle AOD RONs" into main

parents bbfb7e42 fb935199
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -455,6 +455,7 @@ class PromotedNotificationContentExtractorImplTest : SysuiTestCase() {

        assertThat(content).isNotNull()
        assertThat(content?.style).isEqualTo(Style.Call)
        assertThat(content?.title).isEqualTo(TEST_PERSON_NAME)
    }

    @Test
+17 −22
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.app.Notification.BigPictureStyle
import android.app.Notification.BigTextStyle
import android.app.Notification.CallStyle
import android.app.Notification.EXTRA_BIG_TEXT
import android.app.Notification.EXTRA_CALL_PERSON
import android.app.Notification.EXTRA_CHRONOMETER_COUNT_DOWN
import android.app.Notification.EXTRA_PROGRESS
import android.app.Notification.EXTRA_PROGRESS_INDETERMINATE
@@ -33,6 +34,7 @@ import android.app.Notification.EXTRA_VERIFICATION_ICON
import android.app.Notification.EXTRA_VERIFICATION_TEXT
import android.app.Notification.InboxStyle
import android.app.Notification.ProgressStyle
import android.app.Person
import android.content.Context
import android.graphics.drawable.Icon
import com.android.systemui.Flags
@@ -108,12 +110,12 @@ constructor(
        contentBuilder.shortCriticalText = notification.shortCriticalText()
        contentBuilder.lastAudiblyAlertedMs = entry.lastAudiblyAlertedMs
        contentBuilder.profileBadgeResId = null // TODO
        contentBuilder.title = notification.resolveTitle(recoveredBuilder.style)
        contentBuilder.text = notification.resolveText(recoveredBuilder.style)
        contentBuilder.title = notification.title(recoveredBuilder.style)
        contentBuilder.text = notification.text(recoveredBuilder.style)
        contentBuilder.skeletonLargeIcon = notification.skeletonLargeIcon(imageModelProvider)
        contentBuilder.oldProgress = notification.oldProgress()

        val colorsFromNotif = recoveredBuilder.getColors(/* header= */ false)
        val colorsFromNotif = recoveredBuilder.getColors(/* isHeader= */ false)
        contentBuilder.colors =
            PromotedNotificationContentModel.Colors(
                backgroundColor = colorsFromNotif.backgroundColor,
@@ -132,20 +134,16 @@ constructor(

    private fun Notification.bigTitle(): CharSequence? = extras?.getCharSequence(EXTRA_TITLE_BIG)

    private fun Notification.Style.bigTitleOverridesTitle(): Boolean {
        return when (this) {
    private fun Notification.callPerson(): Person? =
        extras?.getParcelable(EXTRA_CALL_PERSON, Person::class.java)

    private fun Notification.title(style: Notification.Style?): CharSequence? {
        return when (style) {
            is BigTextStyle,
            is BigPictureStyle,
            is InboxStyle -> true
            else -> false
        }
    }

    private fun Notification.resolveTitle(style: Notification.Style?): CharSequence? {
        return if (style?.bigTitleOverridesTitle() == true) {
            bigTitle()
        } else {
            null
            is InboxStyle -> bigTitle()
            is CallStyle -> callPerson()?.name
            else -> null
        } ?: title()
    }

@@ -153,13 +151,10 @@ constructor(

    private fun Notification.bigText(): CharSequence? = extras?.getCharSequence(EXTRA_BIG_TEXT)

    private fun Notification.Style.bigTextOverridesText(): Boolean = this is BigTextStyle

    private fun Notification.resolveText(style: Notification.Style?): CharSequence? {
        return if (style?.bigTextOverridesText() == true) {
            bigText()
        } else {
            null
    private fun Notification.text(style: Notification.Style?): CharSequence? {
        return when (style) {
            is BigTextStyle -> bigText()
            else -> null
        } ?: text()
    }