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

Commit 355b76ab authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13770794 from 9aec2cd7 to 25Q4-release

Change-Id: I2d58223911ba1918e81ef440a53a4175879caad5
parents 9d586817 9aec2cd7
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -192,6 +192,16 @@ flag {
    }
}

flag {
    name: "notification_dot_contrast_border"
    namespace: "launcher"
    description: "Draws a small black or white contrast border around notification dots according to the dot color's luminescence."
    bug: "378990749"
    metadata {
         purpose: PURPOSE_BUGFIX
    }
}

flag {
  name: "extendible_theme_manager"
  namespace: "launcher"
+4 −1
Original line number Diff line number Diff line
@@ -213,12 +213,15 @@ data class BitmapInfo(
    companion object {
        const val TAG: String = "BitmapInfo"

        // Persisted BitmapInfo flags. Reset the cache whenever making any changes here.
        // Persisted BitmapInfo flags.
        // Reset the cache by changing RELEASE_VERSION whenever making any changes here.
        // LINT.IfChange
        const val FLAG_WORK: Int = 1 shl 0
        const val FLAG_INSTANT: Int = 1 shl 1
        const val FLAG_CLONE: Int = 1 shl 2
        const val FLAG_PRIVATE: Int = 1 shl 3
        const val FLAG_FULL_BLEED: Int = 1 shl 4
        // LINT.ThenChange(src/com/android/launcher3/icons/cache/BaseIconCache.kt:cache_release_version)

        // Drawable creation flags
        const val FLAG_THEMED: Int = 1 shl 0
+5 −7
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.graphics.drawable.LayerDrawable
import android.os.SystemClock
import android.util.Log
import com.android.launcher3.icons.BitmapInfo.Extender
import com.android.launcher3.icons.FastBitmapDrawableDelegate.Companion.drawShaderInBounds
import com.android.launcher3.icons.FastBitmapDrawableDelegate.DelegateFactory
import com.android.launcher3.icons.GraphicsUtils.getColorMultipliedFilter
import com.android.launcher3.icons.GraphicsUtils.resizeToContentSize
@@ -66,7 +67,7 @@ private constructor(base: AdaptiveIconDrawable, private val animationInfo: Clock
            delegateFactory =
                animationInfo.copy(
                    themeFgColor = NO_COLOR,
                    shaderProvider = { BitmapShader(flattenBG, CLAMP, CLAMP) },
                    shader = BitmapShader(flattenBG, CLAMP, CLAMP),
                )
        )
    }
@@ -91,7 +92,7 @@ private constructor(base: AdaptiveIconDrawable, private val animationInfo: Clock
        val defaultSecond: Int,
        val baseDrawableState: ConstantState,
        val themeFgColor: Int = NO_COLOR,
        val shaderProvider: (IconShape) -> Shader? = { null },
        val shader: Shader? = null,
    ) : DelegateFactory {

        fun applyTime(time: Calendar, foregroundDrawable: LayerDrawable): Boolean {
@@ -150,21 +151,18 @@ private constructor(base: AdaptiveIconDrawable, private val animationInfo: Clock
                    colorFilter = getColorMultipliedFilter(themedFgColor, paint.colorFilter)
                }

        override fun createPaintShader(bitmapInfo: BitmapInfo, shape: IconShape): Shader? =
            animInfo.shaderProvider.invoke(shape)

        override fun setAlpha(alpha: Int) {
            foreground.alpha = alpha
        }

        override fun drawContent(
            info: BitmapInfo,
            host: FastBitmapDrawable,
            iconShape: IconShape,
            canvas: Canvas,
            bounds: Rect,
            paint: Paint,
        ) {
            host.drawShaderInBounds(canvas, bounds)
            canvas.drawShaderInBounds(bounds, iconShape, paint, animInfo.shader)

            // prepare and draw the foreground
            animInfo.applyTime(time, foreground)
+1 −18
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.graphics.Paint.ANTI_ALIAS_FLAG
import android.graphics.Paint.FILTER_BITMAP_FLAG
import android.graphics.PixelFormat
import android.graphics.Rect
import android.graphics.Shader
import android.graphics.drawable.Drawable
import android.graphics.drawable.Drawable.Callback
import android.util.FloatProperty
@@ -41,7 +40,6 @@ import com.android.launcher3.icons.BitmapInfo.Companion.LOW_RES_INFO
import com.android.launcher3.icons.BitmapInfo.DrawableCreationFlags
import com.android.launcher3.icons.FastBitmapDrawableDelegate.DelegateFactory
import com.android.launcher3.icons.FastBitmapDrawableDelegate.SimpleDelegateFactory
import com.android.launcher3.icons.GraphicsUtils.resizeToContentSize
import kotlin.math.min

class FastBitmapDrawable
@@ -61,7 +59,6 @@ constructor(
    @JvmField protected val paint: Paint = Paint(FILTER_BITMAP_FLAG or ANTI_ALIAS_FLAG)

    val delegate = delegateFactory.newDelegate(bitmapInfo, iconShape, paint, this)
    private val shader: Shader? = delegate.createPaintShader(bitmapInfo, iconShape)

    @JvmField @VisibleForTesting var isPressed: Boolean = false
    @JvmField @VisibleForTesting var isHovered: Boolean = false
@@ -123,24 +120,10 @@ constructor(
    }

    private fun drawInternal(canvas: Canvas, bounds: Rect) {
        delegate.drawContent(bitmapInfo, this, canvas, bounds, paint)
        delegate.drawContent(bitmapInfo, iconShape, canvas, bounds, paint)
        badge?.draw(canvas)
    }

    /**
     * Draws the shader created using [FastBitmapDrawableDelegate.createPaintShader] in the provided
     * bounds
     */
    fun drawShaderInBounds(canvas: Canvas, bounds: Rect) {
        canvas.drawBitmap(iconShape.shadowLayer, null, bounds, paint)

        canvas.resizeToContentSize(bounds, iconShape.pathSize.toFloat()) {
            paint.shader = shader
            iconShape.shapeRenderer.render(canvas, paint)
            paint.shader = null
        }
    }

    /** Returns the primary icon color, slightly tinted white */
    fun getIconColor(): Int = delegate.getIconColor(bitmapInfo)

+54 −18
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.graphics.Shader
import android.graphics.Shader.TileMode.CLAMP
import androidx.core.graphics.ColorUtils
import com.android.launcher3.icons.BitmapInfo.Companion.FLAG_FULL_BLEED
import com.android.launcher3.icons.GraphicsUtils.resizeToContentSize

/** A delegate for changing the rendering of [FastBitmapDrawable], to support multi-inheritance */
interface FastBitmapDrawableDelegate {
@@ -36,17 +37,11 @@ interface FastBitmapDrawableDelegate {
    /** [android.graphics.drawable.Drawable.draw] */
    fun drawContent(
        info: BitmapInfo,
        host: FastBitmapDrawable,
        iconShape: IconShape,
        canvas: Canvas,
        bounds: Rect,
        paint: Paint,
    ) {
        if ((info.flags and FLAG_FULL_BLEED) != 0) {
            host.drawShaderInBounds(canvas, bounds)
        } else {
            canvas.drawBitmap(info.icon, null, bounds, paint)
        }
    }
    )

    /** [FastBitmapDrawable.getIconColor] */
    fun getIconColor(info: BitmapInfo): Int =
@@ -70,15 +65,6 @@ interface FastBitmapDrawableDelegate {
    /** [android.graphics.drawable.Drawable.onLevelChange] */
    fun onLevelChange(level: Int): Boolean = false

    /** Creates a default shader to be used for drawing the drawable */
    fun createPaintShader(bitmapInfo: BitmapInfo, shape: IconShape): Shader? {
        return if ((bitmapInfo.flags and FLAG_FULL_BLEED) != 0) {
            BitmapShader(bitmapInfo.icon, CLAMP, CLAMP)
        } else {
            null
        }
    }

    /**
     * Interface for creating new delegates. This should not store any state information and can
     * safely be stored in a [android.graphics.drawable.Drawable.ConstantState]
@@ -93,12 +79,62 @@ interface FastBitmapDrawableDelegate {
        ): FastBitmapDrawableDelegate
    }

    class FullBleedDrawableDelegate(bitmapInfo: BitmapInfo) : FastBitmapDrawableDelegate {
        private val shader = BitmapShader(bitmapInfo.icon, CLAMP, CLAMP)

        override fun drawContent(
            info: BitmapInfo,
            iconShape: IconShape,
            canvas: Canvas,
            bounds: Rect,
            paint: Paint,
        ) {
            canvas.drawShaderInBounds(bounds, iconShape, paint, shader)
        }
    }

    object SimpleDrawableDelegate : FastBitmapDrawableDelegate {

        override fun drawContent(
            info: BitmapInfo,
            iconShape: IconShape,
            canvas: Canvas,
            bounds: Rect,
            paint: Paint,
        ) {
            canvas.drawBitmap(info.icon, null, bounds, paint)
        }
    }

    object SimpleDelegateFactory : DelegateFactory {
        override fun newDelegate(
            bitmapInfo: BitmapInfo,
            iconShape: IconShape,
            paint: Paint,
            host: FastBitmapDrawable,
        ) = object : FastBitmapDrawableDelegate {}
        ) =
            if ((bitmapInfo.flags and FLAG_FULL_BLEED) != 0) FullBleedDrawableDelegate(bitmapInfo)
            else SimpleDrawableDelegate
    }

    companion object {

        /**
         * Draws the shader created using [FastBitmapDrawableDelegate.createPaintShader] in the
         * provided bounds
         */
        fun Canvas.drawShaderInBounds(
            bounds: Rect,
            iconShape: IconShape,
            paint: Paint,
            shader: Shader?,
        ) {
            drawBitmap(iconShape.shadowLayer, null, bounds, paint)
            resizeToContentSize(bounds, iconShape.pathSize.toFloat()) {
                paint.shader = shader
                iconShape.shapeRenderer.render(this, paint)
                paint.shader = null
            }
        }
    }
}
Loading