Loading packages/SystemUI/compose/core/src/com/android/compose/PlatformButtons.kt +7 −17 Original line number Diff line number Diff line Loading @@ -28,11 +28,11 @@ import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.IconButtonColors import androidx.compose.material3.IconButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import com.android.compose.theme.LocalAndroidColorScheme @Composable fun PlatformButton( Loading Loading @@ -100,12 +100,7 @@ fun PlatformIconButton( @DrawableRes iconResource: Int, contentDescription: String?, ) { IconButton( modifier = modifier, onClick = onClick, enabled = enabled, colors = colors, ) { IconButton(modifier = modifier, onClick = onClick, enabled = enabled, colors = colors) { Icon( painter = painterResource(id = iconResource), contentDescription = contentDescription, Loading @@ -118,7 +113,7 @@ private val ButtonPaddings = PaddingValues(horizontal = 16.dp, vertical = 8.dp) @Composable private fun filledButtonColors(): ButtonColors { val colors = LocalAndroidColorScheme.current val colors = MaterialTheme.colorScheme return ButtonDefaults.buttonColors( containerColor = colors.primary, contentColor = colors.onPrimary, Loading @@ -127,27 +122,22 @@ private fun filledButtonColors(): ButtonColors { @Composable private fun outlineButtonColors(): ButtonColors { return ButtonDefaults.outlinedButtonColors( contentColor = LocalAndroidColorScheme.current.onSurface, ) return ButtonDefaults.outlinedButtonColors(contentColor = MaterialTheme.colorScheme.onSurface) } @Composable private fun iconButtonColors(): IconButtonColors { return IconButtonDefaults.filledIconButtonColors( contentColor = LocalAndroidColorScheme.current.onSurface, contentColor = MaterialTheme.colorScheme.onSurface ) } @Composable private fun outlineButtonBorder(): BorderStroke { return BorderStroke( width = 1.dp, color = LocalAndroidColorScheme.current.primary, ) return BorderStroke(width = 1.dp, color = MaterialTheme.colorScheme.primary) } @Composable private fun textButtonColors(): ButtonColors { return ButtonDefaults.textButtonColors(contentColor = LocalAndroidColorScheme.current.primary) return ButtonDefaults.textButtonColors(contentColor = MaterialTheme.colorScheme.primary) } packages/SystemUI/compose/features/src/com/android/systemui/dialog/ui/composable/AlertDialogContent.kt +4 −5 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ import androidx.compose.ui.layout.Placeable import androidx.compose.ui.layout.layoutId import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.android.compose.theme.LocalAndroidColorScheme import kotlin.math.roundToInt /** Loading Loading @@ -69,7 +68,7 @@ fun AlertDialogContent( Modifier.defaultMinSize(minWidth = defaultSize, minHeight = defaultSize), propagateMinConstraints = true, ) { val iconColor = LocalAndroidColorScheme.current.primary val iconColor = MaterialTheme.colorScheme.primary CompositionLocalProvider(LocalContentColor provides iconColor) { icon() } } Loading @@ -77,7 +76,7 @@ fun AlertDialogContent( } // Title. val titleColor = LocalAndroidColorScheme.current.onSurface val titleColor = MaterialTheme.colorScheme.onSurface CompositionLocalProvider(LocalContentColor provides titleColor) { ProvideTextStyle( MaterialTheme.typography.headlineSmall.copy(textAlign = TextAlign.Center) Loading @@ -88,7 +87,7 @@ fun AlertDialogContent( Spacer(Modifier.height(16.dp)) // Content. val contentColor = LocalAndroidColorScheme.current.onSurfaceVariant val contentColor = MaterialTheme.colorScheme.onSurfaceVariant Box { CompositionLocalProvider(LocalContentColor provides contentColor) { ProvideTextStyle( Loading Loading @@ -169,7 +168,7 @@ private fun AlertDialogButtons( negative.width - positive.width - horizontalSpacing.roundToInt(), 0 0, ) } } Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/ModesDialogDelegate.kt +35 −30 Original line number Diff line number Diff line Loading @@ -19,8 +19,10 @@ package com.android.systemui.statusbar.policy.ui.dialog import android.content.Intent import android.provider.Settings import android.util.Log import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource Loading @@ -30,6 +32,7 @@ import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import com.android.compose.PlatformButton import com.android.compose.PlatformOutlinedButton import com.android.compose.theme.PlatformTheme import com.android.internal.annotations.VisibleForTesting import com.android.internal.jank.InteractionJankMonitor import com.android.systemui.animation.DialogCuj Loading Loading @@ -74,7 +77,7 @@ constructor( currentDialog?.dismiss() } currentDialog = sysuiDialogFactory.create() { ModesDialogContent(it) } currentDialog = sysuiDialogFactory.create { ModesDialogContent(it) } currentDialog ?.lifecycle ?.addObserver( Loading @@ -91,14 +94,19 @@ constructor( @Composable private fun ModesDialogContent(dialog: SystemUIDialog) { // TODO(b/369376884): The composable does correctly update when the theme changes // while the dialog is open, but the background (which we don't control here) // doesn't, which causes us to show things like white text on a white background. // as a workaround, we remember the original theme and keep it on recomposition. val isCurrentlyInDarkTheme = isSystemInDarkTheme() val cachedDarkTheme = remember { isCurrentlyInDarkTheme } PlatformTheme(isDarkTheme = cachedDarkTheme) { AlertDialogContent( modifier = Modifier.semantics { testTagsAsResourceId = true }, modifier = Modifier.semantics { testTagsAsResourceId = true }, title = { Text( modifier = Modifier.testTag("modes_title"), text = stringResource(R.string.zen_modes_dialog_title) text = stringResource(R.string.zen_modes_dialog_title), ) }, content = { ModeTileGrid(viewModel.get()) }, Loading @@ -114,6 +122,7 @@ constructor( }, ) } } @VisibleForTesting fun openSettings(dialog: SystemUIDialog) { Loading @@ -129,7 +138,7 @@ constructor( activityStarter.startActivity( ZEN_MODE_SETTINGS_INTENT, true /* dismissShade */, animationController animationController, ) } Loading Loading @@ -163,7 +172,7 @@ constructor( Log.w( TAG, "Cannot launch from dialog, the dialog is not present. " + "Will launch activity without animating." "Will launch activity without animating.", ) } Loading @@ -172,11 +181,7 @@ constructor( if (animationController == null) { currentDialog?.dismiss() } activityStarter.startActivity( intent, true, /* dismissShade */ animationController, ) activityStarter.startActivity(intent, true, /* dismissShade */ animationController) } companion object { Loading Loading
packages/SystemUI/compose/core/src/com/android/compose/PlatformButtons.kt +7 −17 Original line number Diff line number Diff line Loading @@ -28,11 +28,11 @@ import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.IconButtonColors import androidx.compose.material3.IconButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import com.android.compose.theme.LocalAndroidColorScheme @Composable fun PlatformButton( Loading Loading @@ -100,12 +100,7 @@ fun PlatformIconButton( @DrawableRes iconResource: Int, contentDescription: String?, ) { IconButton( modifier = modifier, onClick = onClick, enabled = enabled, colors = colors, ) { IconButton(modifier = modifier, onClick = onClick, enabled = enabled, colors = colors) { Icon( painter = painterResource(id = iconResource), contentDescription = contentDescription, Loading @@ -118,7 +113,7 @@ private val ButtonPaddings = PaddingValues(horizontal = 16.dp, vertical = 8.dp) @Composable private fun filledButtonColors(): ButtonColors { val colors = LocalAndroidColorScheme.current val colors = MaterialTheme.colorScheme return ButtonDefaults.buttonColors( containerColor = colors.primary, contentColor = colors.onPrimary, Loading @@ -127,27 +122,22 @@ private fun filledButtonColors(): ButtonColors { @Composable private fun outlineButtonColors(): ButtonColors { return ButtonDefaults.outlinedButtonColors( contentColor = LocalAndroidColorScheme.current.onSurface, ) return ButtonDefaults.outlinedButtonColors(contentColor = MaterialTheme.colorScheme.onSurface) } @Composable private fun iconButtonColors(): IconButtonColors { return IconButtonDefaults.filledIconButtonColors( contentColor = LocalAndroidColorScheme.current.onSurface, contentColor = MaterialTheme.colorScheme.onSurface ) } @Composable private fun outlineButtonBorder(): BorderStroke { return BorderStroke( width = 1.dp, color = LocalAndroidColorScheme.current.primary, ) return BorderStroke(width = 1.dp, color = MaterialTheme.colorScheme.primary) } @Composable private fun textButtonColors(): ButtonColors { return ButtonDefaults.textButtonColors(contentColor = LocalAndroidColorScheme.current.primary) return ButtonDefaults.textButtonColors(contentColor = MaterialTheme.colorScheme.primary) }
packages/SystemUI/compose/features/src/com/android/systemui/dialog/ui/composable/AlertDialogContent.kt +4 −5 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ import androidx.compose.ui.layout.Placeable import androidx.compose.ui.layout.layoutId import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.android.compose.theme.LocalAndroidColorScheme import kotlin.math.roundToInt /** Loading Loading @@ -69,7 +68,7 @@ fun AlertDialogContent( Modifier.defaultMinSize(minWidth = defaultSize, minHeight = defaultSize), propagateMinConstraints = true, ) { val iconColor = LocalAndroidColorScheme.current.primary val iconColor = MaterialTheme.colorScheme.primary CompositionLocalProvider(LocalContentColor provides iconColor) { icon() } } Loading @@ -77,7 +76,7 @@ fun AlertDialogContent( } // Title. val titleColor = LocalAndroidColorScheme.current.onSurface val titleColor = MaterialTheme.colorScheme.onSurface CompositionLocalProvider(LocalContentColor provides titleColor) { ProvideTextStyle( MaterialTheme.typography.headlineSmall.copy(textAlign = TextAlign.Center) Loading @@ -88,7 +87,7 @@ fun AlertDialogContent( Spacer(Modifier.height(16.dp)) // Content. val contentColor = LocalAndroidColorScheme.current.onSurfaceVariant val contentColor = MaterialTheme.colorScheme.onSurfaceVariant Box { CompositionLocalProvider(LocalContentColor provides contentColor) { ProvideTextStyle( Loading Loading @@ -169,7 +168,7 @@ private fun AlertDialogButtons( negative.width - positive.width - horizontalSpacing.roundToInt(), 0 0, ) } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/ModesDialogDelegate.kt +35 −30 Original line number Diff line number Diff line Loading @@ -19,8 +19,10 @@ package com.android.systemui.statusbar.policy.ui.dialog import android.content.Intent import android.provider.Settings import android.util.Log import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource Loading @@ -30,6 +32,7 @@ import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import com.android.compose.PlatformButton import com.android.compose.PlatformOutlinedButton import com.android.compose.theme.PlatformTheme import com.android.internal.annotations.VisibleForTesting import com.android.internal.jank.InteractionJankMonitor import com.android.systemui.animation.DialogCuj Loading Loading @@ -74,7 +77,7 @@ constructor( currentDialog?.dismiss() } currentDialog = sysuiDialogFactory.create() { ModesDialogContent(it) } currentDialog = sysuiDialogFactory.create { ModesDialogContent(it) } currentDialog ?.lifecycle ?.addObserver( Loading @@ -91,14 +94,19 @@ constructor( @Composable private fun ModesDialogContent(dialog: SystemUIDialog) { // TODO(b/369376884): The composable does correctly update when the theme changes // while the dialog is open, but the background (which we don't control here) // doesn't, which causes us to show things like white text on a white background. // as a workaround, we remember the original theme and keep it on recomposition. val isCurrentlyInDarkTheme = isSystemInDarkTheme() val cachedDarkTheme = remember { isCurrentlyInDarkTheme } PlatformTheme(isDarkTheme = cachedDarkTheme) { AlertDialogContent( modifier = Modifier.semantics { testTagsAsResourceId = true }, modifier = Modifier.semantics { testTagsAsResourceId = true }, title = { Text( modifier = Modifier.testTag("modes_title"), text = stringResource(R.string.zen_modes_dialog_title) text = stringResource(R.string.zen_modes_dialog_title), ) }, content = { ModeTileGrid(viewModel.get()) }, Loading @@ -114,6 +122,7 @@ constructor( }, ) } } @VisibleForTesting fun openSettings(dialog: SystemUIDialog) { Loading @@ -129,7 +138,7 @@ constructor( activityStarter.startActivity( ZEN_MODE_SETTINGS_INTENT, true /* dismissShade */, animationController animationController, ) } Loading Loading @@ -163,7 +172,7 @@ constructor( Log.w( TAG, "Cannot launch from dialog, the dialog is not present. " + "Will launch activity without animating." "Will launch activity without animating.", ) } Loading @@ -172,11 +181,7 @@ constructor( if (animationController == null) { currentDialog?.dismiss() } activityStarter.startActivity( intent, true, /* dismissShade */ animationController, ) activityStarter.startActivity(intent, true, /* dismissShade */ animationController) } companion object { Loading