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

Commit fa5d3284 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Add unit tests for combined QS headers

Also, some minor fixes in the constraints.

Bug: 215584502
Test: atest SystemUITests
Change-Id: I23e5e4927010d60084e4b89c05f990fa268c2f2c
parent 0ab0199c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@
        android:paddingStart="@dimen/status_bar_left_clock_starting_padding"
        android:paddingEnd="@dimen/status_bar_left_clock_end_padding"
        android:singleLine="true"
        android:textDirection="locale"
        android:textAppearance="@style/TextAppearance.QS.Status"
        android:transformPivotX="0sp"
        android:transformPivotY="20sp"
@@ -85,6 +86,7 @@
        android:layout_gravity="start|center_vertical"
        android:gravity="center_vertical"
        android:singleLine="true"
        android:textDirection="locale"
        android:textAppearance="@style/TextAppearance.QS.Status"
        app:longDatePattern="@string/abbrev_wday_month_day_no_year_alarm"
        app:shortDatePattern="@string/abbrev_month_day_no_year"
+1 −0
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@
            app:layout_constraintTop_toTopOf="@id/date"
            app:layout_constraintBottom_toBottomOf="@id/date"
            app:layout_constraintStart_toEndOf="@id/batteryRemainingIcon"
            app:layout_constraintHorizontal_bias="1"
        />
    </Constraint>

+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@
            app:layout_constraintTop_toTopOf="parent"
            />
        <PropertySet
            app:alpha="0"
            android:alpha="0"
        />
    </Constraint>

+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
            app:layout_constraintEnd_toEndOf="@id/end_guide"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toTopOf="@id/carrier_group"
            app:layout_constraintHorizontal_bias="1"
            />
    </Constraint>

+79 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.systemui.shade

import androidx.constraintlayout.widget.ConstraintSet

typealias ConstraintChange = ConstraintSet.() -> Unit

operator fun ConstraintChange?.plus(other: ConstraintChange?): ConstraintChange? {
    // Prevent wrapping
    if (this == null) return other
    if (other == null) return this
    else return {
        this@plus()
        other()
    }
}

/**
 * Contains all changes that need to be performed to the different [ConstraintSet] in
 * [LargeScreenShadeHeaderController].
 */
data class ConstraintsChanges(
    val qqsConstraintsChanges: ConstraintChange? = null,
    val qsConstraintsChanges: ConstraintChange? = null,
    val largeScreenConstraintsChanges: ConstraintChange? = null
) {
    operator fun plus(other: ConstraintsChanges) = ConstraintsChanges(
        qqsConstraintsChanges + other.qqsConstraintsChanges,
        qsConstraintsChanges + other.qsConstraintsChanges,
        largeScreenConstraintsChanges + other.largeScreenConstraintsChanges
    )
}

/**
 * Determines [ConstraintChanges] for [LargeScreenShadeHeaderController] based on configurations.
 *
 * Given that the number of different scenarios is not that large, having specific methods instead
 * of a full map between state and [ConstraintSet] was preferred.
 */
interface CombinedShadeHeadersConstraintManager {
    /**
     * Changes for when the visibility of the privacy chip changes
     */
    fun privacyChipVisibilityConstraints(visible: Boolean): ConstraintsChanges

    /**
     * Changes for situations with no top center cutout (there may be a corner cutout)
     */
    fun emptyCutoutConstraints(): ConstraintsChanges

    /**
     * Changes to incorporate side insets due to rounded corners/corner cutouts
     */
    fun edgesGuidelinesConstraints(
        cutoutStart: Int,
        paddingStart: Int,
        cutoutEnd: Int,
        paddingEnd: Int
    ): ConstraintsChanges

    /**
     * Changes for situations with top center cutout (in this case, there are no corner cutouts).
     */
    fun centerCutoutConstraints(rtl: Boolean, offsetFromEdge: Int): ConstraintsChanges
}
Loading