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

Commit d0356314 authored by Aaron Liu's avatar Aaron Liu
Browse files

Change rootview to general constraintlayout.

Make parameter more generalized so that we can possibly bind blueprints
to other constraint layouts.

Bug: 295555276
Test: Ensure that it builds properly.
Change-Id: Ic440ee3866d317aaa64368b242fa5043046a2cd5
parent cb8ddff0
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -19,10 +19,10 @@ package com.android.systemui.keyguard.ui.binder

import android.os.Trace
import android.util.Log
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.keyguard.ui.view.KeyguardRootView
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBlueprintViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
import kotlinx.coroutines.launch
@@ -31,19 +31,19 @@ class KeyguardBlueprintViewBinder {
    companion object {
        private const val TAG = "KeyguardBlueprintViewBinder"

        fun bind(keyguardRootView: KeyguardRootView, viewModel: KeyguardBlueprintViewModel) {
            keyguardRootView.repeatWhenAttached {
        fun bind(constraintLayout: ConstraintLayout, viewModel: KeyguardBlueprintViewModel) {
            constraintLayout.repeatWhenAttached {
                repeatOnLifecycle(Lifecycle.State.CREATED) {
                    launch {
                        viewModel.blueprint.collect { blueprint ->
                            Trace.beginSection("KeyguardBlueprintController#applyBlueprint")
                            Log.d(TAG, "applying blueprint: $blueprint")
                            ConstraintSet().apply {
                                clone(keyguardRootView)
                                clone(constraintLayout)
                                val emptyLayout = ConstraintSet.Layout()
                                knownIds.forEach { getConstraint(it).layout.copyFrom(emptyLayout) }
                                blueprint?.apply(this)
                                applyTo(keyguardRootView)
                                applyTo(constraintLayout)
                            }
                            Trace.endSection()
                        }