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

Commit 833cf624 authored by Hawkwood Glazier's avatar Hawkwood Glazier Committed by Android (Google) Code Review
Browse files

Merge "AodBurnInLayer now enforces it's translation and scale values during predraw" into main

parents ed98dc37 6014473f
Loading
Loading
Loading
Loading
+25 −3
Original line number Diff line number Diff line
@@ -18,9 +18,12 @@ package com.android.systemui.keyguard.ui.view.layout.sections

import android.content.Context
import android.view.View
import android.view.ViewTreeObserver.OnPreDrawListener
import androidx.constraintlayout.helper.widget.Layer

class AodBurnInLayer(context: Context) : Layer(context) {
class AodBurnInLayer(
    context: Context,
) : Layer(context) {
    // For setScale in Layer class, it stores it in mScaleX/Y and directly apply scale to
    // referenceViews instead of keeping the value in fields of View class
    // when we try to clone ConstraintSet, it will call getScaleX from View class and return 1.0
@@ -28,13 +31,32 @@ class AodBurnInLayer(context: Context) : Layer(context) {
    // which cause the flicker from AOD to LS
    private var _scaleX = 1F
    private var _scaleY = 1F

    // As described for _scaleX and _scaleY, we have similar issue with translation
    private var _translationX = 1F
    private var _translationY = 1F
    private var _translationX = 0F
    private var _translationY = 0F

    private val _predrawListener = OnPreDrawListener {
        super.setScaleX(_scaleX)
        super.setScaleY(_scaleY)
        super.setTranslationX(_translationX)
        super.setTranslationY(_translationY)
        true
    }

    // avoid adding views with same ids
    override fun addView(view: View?) {
        view?.let { if (it.id !in referencedIds) super.addView(view) }
    }

    fun registerListener(rootView: View) {
        rootView.viewTreeObserver.addOnPreDrawListener(_predrawListener)
    }

    fun unregisterListener(rootView: View) {
        rootView.viewTreeObserver.removeOnPreDrawListener(_predrawListener)
    }

    override fun setScaleX(scaleX: Float) {
        _scaleX = scaleX
        super.setScaleX(scaleX)
+4 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import com.android.systemui.Flags.migrateClocksToBlueprint
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.view.KeyguardRootView
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.res.R
import javax.inject.Inject
@@ -32,6 +33,7 @@ class AodBurnInSection
@Inject
constructor(
    private val context: Context,
    private val rootView: KeyguardRootView,
    private val clockViewModel: KeyguardClockViewModel,
) : KeyguardSection() {
    private lateinit var burnInLayer: AodBurnInLayer
@@ -46,6 +48,7 @@ constructor(
        burnInLayer =
            AodBurnInLayer(context).apply {
                id = R.id.burn_in_layer
                registerListener(rootView)
                addView(emptyView)
                if (!migrateClocksToBlueprint()) {
                    val statusView =
@@ -70,6 +73,7 @@ constructor(
    }

    override fun removeViews(constraintLayout: ConstraintLayout) {
        burnInLayer.unregisterListener(rootView)
        constraintLayout.removeView(R.id.burn_in_layer)
    }
}