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

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

Hide unconstrained views in blueprints.

Set visibility to unconstrained views to GONE. Also add a boolean in case
we want to override this behavior.

Bug: 295553416
Test: Remove a section from default blueprints and observe that the view
is not longer visible.

Change-Id: Ie133ceb96f5c4bca444883db19680553a63e39d4
parent 6359df40
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -17,7 +17,10 @@

package com.android.systemui.keyguard.data.repository

import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.view.children
import com.android.systemui.common.ui.data.repository.ConfigurationRepository
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
@@ -96,8 +99,16 @@ constructor(
/** Determines the constraints for the ConstraintSet in the lockscreen root view. */
interface KeyguardBlueprint {
    val id: String
    val shouldRemoveUnconstrainedViews: Boolean
        get() = true

    fun apply(constraintSet: ConstraintSet)
    fun apply(constraintLayout: ConstraintSet)
    fun removeUnConstrainedViews(constraintLayout: ConstraintLayout, constraintSet: ConstraintSet) {
        constraintLayout.children
            .map { it.id }
            .filterNot { constraintSet.knownIds.contains(it) }
            .forEach { constraintSet.setVisibility(it, View.GONE) }
    }
}

/**
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ class KeyguardBlueprintViewBinder {
                                val emptyLayout = ConstraintSet.Layout()
                                knownIds.forEach { getConstraint(it).layout.copyFrom(emptyLayout) }
                                blueprint?.apply(this)
                                blueprint?.removeUnConstrainedViews(constraintLayout, this)
                                applyTo(constraintLayout)
                            }
                            Trace.endSection()