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

Commit 23e5b918 authored by Luca Zuccarini's avatar Luca Zuccarini
Browse files

Update the gradient search to go deeper down the tree of drawables.

Before we only inspected the top level of drawables inside a
LayerDrawable, which didn't work in case this was in turn one of the
intermediate categories (in the related bug, an InsetsDrawable).

This new approach allows us to continue going down the tree to find any
GradientDrawable.

Bug: 321654048
Flag: NA
Test: see videos in the bug
Change-Id: Icb6f4b001c66bd78c3eb8167cb163d4823e4258f
parent 5e0cc0b9
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -353,7 +353,7 @@ constructor(

        /**
         * Return the first [GradientDrawable] found in [drawable], or null if none is found. If
         * [drawable] is a [LayerDrawable], this will return the first layer that is a
         * [drawable] is a [LayerDrawable], this will return the first layer that has a
         * [GradientDrawable].
         */
        fun findGradientDrawable(drawable: Drawable): GradientDrawable? {
@@ -367,8 +367,8 @@ constructor(

            if (drawable is LayerDrawable) {
                for (i in 0 until drawable.numberOfLayers) {
                    val maybeGradient = drawable.getDrawable(i)
                    if (maybeGradient is GradientDrawable) {
                    val maybeGradient = findGradientDrawable(drawable.getDrawable(i))
                    if (maybeGradient != null) {
                        return maybeGradient
                    }
                }