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

Commit 6014473f authored by Hawkwood Glazier's avatar Hawkwood Glazier
Browse files

AodBurnInLayer now enforces it's translation and scale values during predraw

Bug: 322199980
Test: Manually checked for visual gliitches when entering and leaving aod
Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint DEVELOPMENT
Change-Id: I47e25976d2976df4378965d11175afacaac632c5
parent 08e44ec9
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
@@ -24,6 +24,7 @@ import androidx.constraintlayout.widget.ConstraintSet
import com.android.systemui.Flags.migrateClocksToBlueprint
import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl
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
@@ -33,6 +34,7 @@ class AodBurnInSection
@Inject
constructor(
    private val context: Context,
    private val rootView: KeyguardRootView,
    private val clockViewModel: KeyguardClockViewModel,
) : KeyguardSection() {
    private lateinit var burnInLayer: AodBurnInLayer
@@ -47,6 +49,7 @@ constructor(
        burnInLayer =
            AodBurnInLayer(context).apply {
                id = R.id.burn_in_layer
                registerListener(rootView)
                addView(emptyView)
                if (!migrateClocksToBlueprint()) {
                    val statusView =
@@ -73,6 +76,7 @@ constructor(
    }

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