Fix Calligraphy Clock overlapping with UDFPS in preview
Caused by UDFPS preview icon is not added to ConstraintLayout
(keyguardRootView)
Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint DEVELOPMENT
Test: manual
Bug: 324597611
Change-Id: I5e724c922e80f3d75b6f2b8ba6eee8883d5c80dd
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt
index c14917b..0d59bc5 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt
@@ -42,6 +42,10 @@
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
+import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
+import androidx.constraintlayout.widget.ConstraintSet.START
+import androidx.constraintlayout.widget.ConstraintSet.TOP
+import androidx.constraintlayout.widget.ConstraintSet.WRAP_CONTENT
import androidx.core.view.isInvisible
import com.android.keyguard.ClockEventController
import com.android.keyguard.KeyguardClockSwitch
@@ -392,7 +396,7 @@
),
)
- setUpUdfps(previewContext, rootView)
+ setUpUdfps(previewContext, if (migrateClocksToBlueprint()) keyguardRootView else rootView)
if (keyguardBottomAreaRefactor()) {
setupShortcuts(keyguardRootView)
@@ -467,15 +471,6 @@
return
}
- // Place the UDFPS view in the proper sensor location
- val fingerprintLayoutParams =
- FrameLayout.LayoutParams(sensorBounds.width(), sensorBounds.height())
- fingerprintLayoutParams.setMarginsRelative(
- sensorBounds.left,
- sensorBounds.top,
- sensorBounds.right,
- sensorBounds.bottom
- )
val finger =
LayoutInflater.from(previewContext)
.inflate(
@@ -483,7 +478,31 @@
parentView,
false,
) as View
- parentView.addView(finger, fingerprintLayoutParams)
+
+ // Place the UDFPS view in the proper sensor location
+ if (migrateClocksToBlueprint()) {
+ finger.id = R.id.lock_icon_view
+ parentView.addView(finger)
+ val cs = ConstraintSet()
+ cs.clone(parentView as ConstraintLayout)
+ cs.apply {
+ constrainWidth(R.id.lock_icon_view, sensorBounds.width())
+ constrainHeight(R.id.lock_icon_view, sensorBounds.height())
+ connect(R.id.lock_icon_view, TOP, PARENT_ID, TOP, sensorBounds.top)
+ connect(R.id.lock_icon_view, START, PARENT_ID, START, sensorBounds.left)
+ }
+ cs.applyTo(parentView)
+ } else {
+ val fingerprintLayoutParams =
+ FrameLayout.LayoutParams(sensorBounds.width(), sensorBounds.height())
+ fingerprintLayoutParams.setMarginsRelative(
+ sensorBounds.left,
+ sensorBounds.top,
+ sensorBounds.right,
+ sensorBounds.bottom
+ )
+ parentView.addView(finger, fingerprintLayoutParams)
+ }
}
private fun setUpClock(previewContext: Context, parentView: ViewGroup) {