summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hawkwood Glazier <jglazier@google.com> 2024-02-15 04:29:42 +0000
committer Hawkwood Glazier <jglazier@google.com> 2024-02-15 17:48:41 +0000
commit6014473f4e7d07b6bcabe4c95e00e6c1d15d23ff (patch)
tree8a59f73ef89829f5658ee499723d18565c7ca8a8
parent08e44ec955c72f53b5a3d10169ac12f7008debab (diff)
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
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInLayer.kt28
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt4
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 9a1fcc1a6a51..08bdd4649656 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
@@ -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)
}
}