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

Commit 36cc93d8 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz
Browse files

[RON-AOD] Fix NotificationToplineView Margin in Skeleton

This CL makes the alignment of NotificationToplineView in AOD skeleton in line with Notification.java.

Fixes: 408312509
Flag: android.app.ui_rich_ongoing
Test: Post a RON with a large subtext to have a long ToplineView. Observe it has enough margin end. Repeat it with largeIcon.
Change-Id: I6ab6f2095f5bcb5654b52c2b848dddf6b8da8e12
parent 621ef044
Loading
Loading
Loading
Loading
+23 −5
Original line number Diff line number Diff line
@@ -302,7 +302,7 @@ private class AODPromotedNotificationViewUpdater(root: View) {
            if (!skeletonLargeIcon.isNullOrEmpty()) {
                imageEndMarginPx
            } else {
                0
                endMarginPx
            }

    private data class SmallIconSavedState(val background: Drawable?, val padding: Rect)
@@ -326,10 +326,12 @@ private class AODPromotedNotificationViewUpdater(root: View) {
            ?.mutate()
            ?.setColorFilter(SecondaryText.colorInt, PorterDuff.Mode.SRC_IN)

        (rightIcon?.layoutParams as? MarginLayoutParams)?.let {
            it.marginEnd = endMarginPx
            rightIcon.layoutParams = it
        }
        rightIcon?.setRightIconState(
            width = largeIconSizePx,
            height = largeIconSizePx,
            marginEnd = endMarginPx,
        )

        bigText?.setImageEndMargin(largeIconSizePx + endMarginPx)
        text?.setImageEndMargin(largeIconSizePx + endMarginPx)

@@ -706,6 +708,22 @@ private fun TextView.appendFontFeatureSetting(newSetting: String) {
    fontFeatureSettings = (fontFeatureSettings?.let { "$it," } ?: "") + newSetting
}

private fun ImageView.setRightIconState(width: Int, height: Int, marginEnd: Int) {

    val lp = (layoutParams as? MarginLayoutParams) ?: return
    lp.width = width
    lp.height = height
    lp.marginEnd = marginEnd

    layoutParams = lp
}

private fun NotificationTopLineView.setEndMargin(marginEnd: Int) {
    val lp = (layoutParams as? MarginLayoutParams) ?: return
    lp.marginEnd = marginEnd
    layoutParams = lp
}

private enum class AodPromotedNotificationColor(val colorInt: Int) {
    Background(android.graphics.Color.BLACK),
    PrimaryText(android.graphics.Color.WHITE),