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

Commit ec77b218 authored by amehfooz's avatar amehfooz Committed by Ahmed Mehfooz
Browse files

[DesktopStatusBar] Move HighlightChip

We will need to use ShadeHighlightChip in the status_bar.
This change moves it into a separate file and makes it
public.

Bug: 433589833
Flag: com.android.systemui.status_bar_for_desktop
Test: N/A
Change-Id: Ia437b78018714258312810e7faee1db8f58302d2
parent 13b039d6
Loading
Loading
Loading
Loading
+4 −39
Original line number Diff line number Diff line
@@ -22,14 +22,11 @@ import android.view.ViewGroup
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxSize
@@ -39,7 +36,6 @@ import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@@ -50,7 +46,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.graphicsLayer
@@ -94,8 +89,6 @@ import com.android.systemui.privacy.PrivacyItem
import com.android.systemui.res.R
import com.android.systemui.scene.shared.model.DualShadeEducationElement
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.ui.composable.ShadeHeader.Dimensions.ChipPaddingHorizontal
import com.android.systemui.shade.ui.composable.ShadeHeader.Dimensions.ChipPaddingVertical
import com.android.systemui.shade.ui.composable.ShadeHeader.Values.ClockScale
import com.android.systemui.shade.ui.viewmodel.ShadeHeaderViewModel
import com.android.systemui.statusbar.core.NewStatusBarIcons
@@ -234,7 +227,7 @@ fun ContentScope.CollapsedShadeHeader(
                    if (isSplitShade) {
                        ShadeCarrierGroup(viewModel = viewModel)
                    }
                    HighlightChip(
                    ShadeHighlightChip(
                        onClick = {
                            if (isSplitShade) {
                                viewModel.onSystemIconChipClicked()
@@ -317,7 +310,7 @@ fun ContentScope.ExpandedShadeHeader(
                    textColor = colorAttr(android.R.attr.textColorPrimary),
                    modifier = Modifier.widthIn(max = 90.dp),
                )
                HighlightChip {
                ShadeHighlightChip {
                    val paddingEnd =
                        with(LocalDensity.current) {
                            (if (NewStatusBarIcons.isEnabled) 3.sp else 6.sp).toDp()
@@ -359,7 +352,7 @@ fun ContentScope.OverlayShadeHeader(
        modifier = modifier,
        startContent = {
            Box(modifier = Modifier.padding(horizontal = horizontalPadding)) {
                HighlightChip(
                ShadeHighlightChip(
                    backgroundColor = notificationsHighlight.backgroundColor,
                    horizontalArrangement = Arrangement.spacedBy(5.dp),
                    onClick = viewModel::onNotificationIconChipClicked,
@@ -392,7 +385,7 @@ fun ContentScope.OverlayShadeHeader(
                verticalAlignment = Alignment.CenterVertically,
                modifier = Modifier.padding(horizontal = horizontalPadding),
            ) {
                HighlightChip(
                ShadeHighlightChip(
                    backgroundColor = quickSettingsHighlight.backgroundColor,
                    onClick = viewModel::onSystemIconChipClicked,
                    modifier =
@@ -785,34 +778,6 @@ private fun ContentScope.StatusIcons(
    )
}

@Composable
private fun HighlightChip(
    modifier: Modifier = Modifier,
    backgroundColor: Color = Color.Unspecified,
    horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
    onClick: () -> Unit = {},
    content: @Composable RowScope.() -> Unit,
) {
    val interactionSource = remember { MutableInteractionSource() }
    Row(
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = horizontalArrangement,
        modifier =
            modifier
                .clip(RoundedCornerShape(25.dp))
                .clickable(
                    interactionSource = interactionSource,
                    indication = null,
                    onClick = onClick,
                )
                .thenIf(backgroundColor != Color.Unspecified) {
                    Modifier.background(backgroundColor)
                        .padding(horizontal = ChipPaddingHorizontal, vertical = ChipPaddingVertical)
                },
        content = content,
    )
}

@Composable
private fun ContentScope.PrivacyChip(
    privacyList: List<PrivacyItem>,
+65 −0
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.shade.ui.composable

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.android.compose.modifiers.thenIf
import com.android.systemui.shade.ui.composable.ShadeHeader.Dimensions.ChipPaddingHorizontal
import com.android.systemui.shade.ui.composable.ShadeHeader.Dimensions.ChipPaddingVertical

/** A chip with a colored highlight. Used as an entry point for the shade. */
@Composable
fun ShadeHighlightChip(
    modifier: Modifier = Modifier,
    backgroundColor: Color = Color.Unspecified,
    horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
    onClick: () -> Unit = {},
    content: @Composable RowScope.() -> Unit,
) {
    val interactionSource = remember { MutableInteractionSource() }
    Row(
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = horizontalArrangement,
        modifier =
            modifier
                .clip(RoundedCornerShape(25.dp))
                .clickable(
                    interactionSource = interactionSource,
                    indication = null,
                    onClick = onClick,
                )
                .thenIf(backgroundColor != Color.Unspecified) {
                    Modifier.background(backgroundColor)
                        .padding(horizontal = ChipPaddingHorizontal, vertical = ChipPaddingVertical)
                },
        content = content,
    )
}