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

Commit cec94f25 authored by Olivier St-Onge's avatar Olivier St-Onge Committed by Android (Google) Code Review
Browse files

Merge "Update UI for large single target tiles" into main

parents 59e7fe45 df0a6620
Loading
Loading
Loading
Loading
+0 −77
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.qs.panels.ui.compose.icons

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.StrokeJoin
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp

public val DualTargetArrow: ImageVector
    get() {
        if (_DualTargetArrow != null) {
            return _DualTargetArrow!!
        }
        _DualTargetArrow =
            ImageVector.Builder(
                    name = "DualTargetArrow",
                    defaultWidth = 24.dp,
                    defaultHeight = 24.dp,
                    viewportWidth = 960f,
                    viewportHeight = 960f,
                )
                .apply {
                    path(
                        fill = SolidColor(Color(0xFFFFFFFF)),
                        fillAlpha = 1.0f,
                        stroke = null,
                        strokeAlpha = 1.0f,
                        strokeLineWidth = 1.0f,
                        strokeLineCap = StrokeCap.Butt,
                        strokeLineJoin = StrokeJoin.Miter,
                        strokeLineMiter = 1.0f,
                        pathFillType = PathFillType.NonZero,
                    ) {
                        moveTo(480f, 599f)
                        quadTo(472f, 599f, 465f, 596.5f)
                        quadTo(458f, 594f, 452f, 588f)
                        lineTo(268f, 404f)
                        quadTo(257f, 393f, 257f, 376f)
                        quadTo(257f, 359f, 268f, 348f)
                        quadTo(279f, 337f, 296f, 337f)
                        quadTo(313f, 337f, 324f, 348f)
                        lineTo(480f, 504f)
                        lineTo(636f, 348f)
                        quadTo(647f, 337f, 664f, 337f)
                        quadTo(681f, 337f, 692f, 348f)
                        quadTo(703f, 359f, 703f, 376f)
                        quadTo(703f, 393f, 692f, 404f)
                        lineTo(508f, 588f)
                        quadTo(502f, 594f, 495f, 596.5f)
                        quadTo(488f, 599f, 480f, 599f)
                        close()
                    }
                }
                .build()
        return _DualTargetArrow!!
    }

private var _DualTargetArrow: ImageVector? = null
+23 −35
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
@@ -95,8 +94,6 @@ import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.ui.compose.Icon
import com.android.systemui.common.ui.compose.load
import com.android.systemui.compose.modifiers.sysuiResTag
import com.android.systemui.qs.panels.ui.compose.icons.DualTargetArrow
import com.android.systemui.qs.panels.ui.compose.infinitegrid.CommonTileDefaults.ChevronSize
import com.android.systemui.qs.panels.ui.compose.infinitegrid.CommonTileDefaults.SideIconHeight
import com.android.systemui.qs.panels.ui.compose.infinitegrid.CommonTileDefaults.SideIconWidth
import com.android.systemui.qs.panels.ui.compose.infinitegrid.CommonTileDefaults.TILE_INITIAL_DELAY_MILLIS
@@ -113,7 +110,6 @@ import kotlin.math.abs

private const val TEST_TAG_TOGGLE = "qs_tile_toggle_target"

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun LargeTileContent(
    label: String,
@@ -142,12 +138,11 @@ fun LargeTileContent(
        val focusBorderColor = MaterialTheme.colorScheme.secondary
        Box(
            modifier =
                Modifier.size(CommonTileDefaults.ToggleTargetSize)
                Modifier.size(CommonTileDefaults.ToggleTargetSize).thenIf(isDualTarget) {
                    Modifier.borderOnFocus(color = focusBorderColor, iconShape.topEnd)
                        .clip(iconShape)
                        .verticalSquish(squishiness)
                        .drawBehind { drawRect(animatedBackgroundColor) }
                    .thenIf(isDualTarget) {
                        Modifier.borderOnFocus(color = focusBorderColor, iconShape.topEnd)
                        .combinedClickable(
                            onClick = toggleClick!!,
                            onLongClick = onLongClick,
@@ -192,13 +187,6 @@ fun LargeTileContent(
                contentDescription = null,
                modifier = Modifier.width(SideIconWidth).height(SideIconHeight),
            )
        } else if (isDualTarget) {
            Icon(
                DualTargetArrow,
                contentDescription = null,
                tint = colors.label,
                modifier = Modifier.size(ChevronSize),
            )
        }
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -416,10 +416,10 @@ private object TileDefaults {
    val ActiveIconCornerRadius = 16.dp
    val ActiveTileCornerRadius = 24.dp

    /** An active icon tile uses the active color as background */
    /** An active tile uses the active color as background */
    @Composable
    @ReadOnlyComposable
    fun activeIconTileColors(): TileColors =
    fun activeTileColors(): TileColors =
        TileColors(
            background = MaterialTheme.colorScheme.primary,
            iconBackground = MaterialTheme.colorScheme.primary,
@@ -480,10 +480,10 @@ private object TileDefaults {
    fun getColorForState(uiState: TileUiState, iconOnly: Boolean): TileColors {
        return when (uiState.state) {
            STATE_ACTIVE -> {
                if (!iconOnly) {
                if (uiState.handlesSecondaryClick && !iconOnly) {
                    activeDualTargetTileColors()
                } else {
                    activeIconTileColors()
                    activeTileColors()
                }
            }