diff options
| author | 2024-02-15 19:52:51 +0000 | |
|---|---|---|
| committer | 2024-02-15 19:52:51 +0000 | |
| commit | 833cf624a1e4202a05677deae8f5b98423bb68fd (patch) | |
| tree | 8e63326fdf2a5d8065ad534ac16790254423efaa | |
| parent | ed98dc37d971352cd8bff7f10350fd63e634e2b8 (diff) | |
| parent | 6014473f4e7d07b6bcabe4c95e00e6c1d15d23ff (diff) | |
Merge "AodBurnInLayer now enforces it's translation and scale values during predraw" into main
2 files changed, 29 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInLayer.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInLayer.kt index 67a20e588198..dc2eeac872f5 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInLayer.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInLayer.kt @@ -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) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt index 282c4952d557..98bebd091f1a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt @@ -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) } } |