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

Commit c0666f58 authored by Chandru S's avatar Chandru S Committed by Automerger Merge Worker
Browse files

Merge "Remove duplicated path scaling of camera protection and scanning rim."...

Merge "Remove duplicated path scaling of camera protection and scanning rim." into tm-qpr-dev am: ec30c5a9 am: eafb3bf8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20256123



Change-Id: I122dd7467c38cc27f162628ac9f3b934269d1760
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 78cb767a eafb3bf8
Loading
Loading
Loading
Loading
+42 −31
Original line number Original line Diff line number Diff line
@@ -55,7 +55,7 @@ class FaceScanningOverlay(
    private val rimRect = RectF()
    private val rimRect = RectF()
    private var cameraProtectionColor = Color.BLACK
    private var cameraProtectionColor = Color.BLACK
    var faceScanningAnimColor = Utils.getColorAttrDefaultColor(context,
    var faceScanningAnimColor = Utils.getColorAttrDefaultColor(context,
            com.android.systemui.R.attr.wallpaperTextColorAccent)
            R.attr.wallpaperTextColorAccent)
    private var cameraProtectionAnimator: ValueAnimator? = null
    private var cameraProtectionAnimator: ValueAnimator? = null
    var hideOverlayRunnable: Runnable? = null
    var hideOverlayRunnable: Runnable? = null
    var faceAuthSucceeded = false
    var faceAuthSucceeded = false
@@ -84,39 +84,38 @@ class FaceScanningOverlay(
    }
    }


    override fun drawCutoutProtection(canvas: Canvas) {
    override fun drawCutoutProtection(canvas: Canvas) {
        if (rimProgress > HIDDEN_RIM_SCALE && !protectionRect.isEmpty) {
        if (protectionRect.isEmpty) {
            val rimPath = Path(protectionPath)
            return
            val scaleMatrix = Matrix().apply {
        }
                val rimBounds = RectF()
        if (rimProgress > HIDDEN_RIM_SCALE) {
                rimPath.computeBounds(rimBounds, true)
            drawFaceScanningRim(canvas)
                setScale(rimProgress, rimProgress, rimBounds.centerX(), rimBounds.centerY())
        }
        }
            rimPath.transform(scaleMatrix)
        if (cameraProtectionProgress > HIDDEN_CAMERA_PROTECTION_SCALE) {
            drawCameraProtection(canvas)
        }
    }

    private fun drawFaceScanningRim(canvas: Canvas) {
        val rimPath = Path(protectionPath)
        scalePath(rimPath, rimProgress)
        rimPaint.style = Paint.Style.FILL
        rimPaint.style = Paint.Style.FILL
        val rimPaintAlpha = rimPaint.alpha
        val rimPaintAlpha = rimPaint.alpha
        rimPaint.color = ColorUtils.blendARGB(
        rimPaint.color = ColorUtils.blendARGB(
            faceScanningAnimColor,
            faceScanningAnimColor,
            Color.WHITE,
            Color.WHITE,
                    statusBarStateController.dozeAmount)
            statusBarStateController.dozeAmount
        )
        rimPaint.alpha = rimPaintAlpha
        rimPaint.alpha = rimPaintAlpha
        canvas.drawPath(rimPath, rimPaint)
        canvas.drawPath(rimPath, rimPaint)
    }
    }


        if (cameraProtectionProgress > HIDDEN_CAMERA_PROTECTION_SCALE &&
    private fun drawCameraProtection(canvas: Canvas) {
                !protectionRect.isEmpty) {
        val scaledProtectionPath = Path(protectionPath)
        val scaledProtectionPath = Path(protectionPath)
            val scaleMatrix = Matrix().apply {
        scalePath(scaledProtectionPath, cameraProtectionProgress)
                val protectionPathRect = RectF()
                scaledProtectionPath.computeBounds(protectionPathRect, true)
                setScale(cameraProtectionProgress, cameraProtectionProgress,
                        protectionPathRect.centerX(), protectionPathRect.centerY())
            }
            scaledProtectionPath.transform(scaleMatrix)
        paint.style = Paint.Style.FILL
        paint.style = Paint.Style.FILL
        paint.color = cameraProtectionColor
        paint.color = cameraProtectionColor
        canvas.drawPath(scaledProtectionPath, paint)
        canvas.drawPath(scaledProtectionPath, paint)
    }
    }
    }


    override fun updateVisOnUpdateCutout(): Boolean {
    override fun updateVisOnUpdateCutout(): Boolean {
        return false // instead, we always update the visibility whenever face scanning starts/ends
        return false // instead, we always update the visibility whenever face scanning starts/ends
@@ -371,5 +370,17 @@ class FaceScanningOverlay(


        private const val PULSE_ERROR_DISAPPEAR_DURATION = 200L
        private const val PULSE_ERROR_DISAPPEAR_DURATION = 200L
        private const val CAMERA_PROTECTION_ERROR_DISAPPEAR_DURATION = 300L // without start delay
        private const val CAMERA_PROTECTION_ERROR_DISAPPEAR_DURATION = 300L // without start delay

        private fun scalePath(path: Path, scalingFactor: Float) {
            val scaleMatrix = Matrix().apply {
                val boundingRectangle = RectF()
                path.computeBounds(boundingRectangle, true)
                setScale(
                    scalingFactor, scalingFactor,
                    boundingRectangle.centerX(), boundingRectangle.centerY()
                )
            }
            path.transform(scaleMatrix)
        }
    }
    }
}
}