Loading packages/SystemUI/compose/features/src/com/android/systemui/qs/footer/ui/compose/FooterActions.kt +17 −25 Original line number Diff line number Diff line Loading @@ -80,11 +80,10 @@ import androidx.compose.ui.unit.em import androidx.compose.ui.unit.sp import androidx.core.graphics.drawable.toBitmap import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.repeatOnLifecycle import com.android.compose.animation.Expandable import com.android.compose.animation.scene.ContentScope import com.android.compose.lifecycle.LaunchedEffectWithLifecycle import com.android.compose.modifiers.animatedBackground import com.android.compose.theme.LocalAndroidColorScheme import com.android.compose.theme.colorAttr Loading Loading @@ -117,7 +116,6 @@ fun ContentScope.FooterActionsWithAnimatedVisibility( viewModel: FooterActionsViewModel, isCustomizing: Boolean, customizingAnimationDuration: Int, lifecycleOwner: LifecycleOwner, modifier: Modifier = Modifier, ) { AnimatedVisibility( Loading @@ -138,7 +136,7 @@ fun ContentScope.FooterActionsWithAnimatedVisibility( // This view has its own horizontal padding // TODO(b/321716470) This should use a lifecycle tied to the scene. Element(QuickSettings.Elements.FooterActions, Modifier) { FooterActions(viewModel = viewModel, qsVisibilityLifecycleOwner = lifecycleOwner) FooterActions(viewModel = viewModel) } } } Loading @@ -146,11 +144,7 @@ fun ContentScope.FooterActionsWithAnimatedVisibility( /** The Quick Settings footer actions row. */ @Composable fun FooterActions( viewModel: FooterActionsViewModel, qsVisibilityLifecycleOwner: LifecycleOwner, modifier: Modifier = Modifier, ) { fun FooterActions(viewModel: FooterActionsViewModel, modifier: Modifier = Modifier) { val context = LocalContext.current // Collect alphas as soon as we are composed, even when not visible. Loading @@ -167,28 +161,26 @@ fun FooterActions( mutableStateOf<TextFeedbackViewModel>(TextFeedbackViewModel.NoFeedback) } LaunchedEffect( context, qsVisibilityLifecycleOwner, viewModel, viewModel.security, viewModel.foregroundServices, viewModel.userSwitcher, viewModel.textFeedback, ) { LaunchedEffect(context, viewModel) { launch { // Listen for dialog requests as soon as we are composed, even when not visible. viewModel.observeDeviceMonitoringDialogRequests(context) } } // Listen for model changes only when QS are visible. qsVisibilityLifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) { LaunchedEffectWithLifecycle( viewModel.security, viewModel.foregroundServices, viewModel.userSwitcher, viewModel.textFeedback, minActiveState = Lifecycle.State.RESUMED, ) { launch { viewModel.security.collect { security = it } } launch { viewModel.foregroundServices.collect { foregroundServices = it } } launch { viewModel.userSwitcher.collect { userSwitcher = it } } launch { viewModel.textFeedback.collect { textFeedback = it } } } } val backgroundColor = if (!notificationShadeBlur()) colorAttr(R.attr.underSurface) else Color.Transparent Loading packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt +0 −1 Original line number Diff line number Diff line Loading @@ -375,7 +375,6 @@ private fun ContentScope.QuickSettingsContent( viewModel = footerActionsViewModel, isCustomizing = false, customizingAnimationDuration = 0, lifecycleOwner = lifecycleOwner, modifier = Modifier.align(Alignment.CenterHorizontally) .sysuiResTag("qs_footer_actions") Loading packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt +0 −1 Original line number Diff line number Diff line Loading @@ -517,7 +517,6 @@ private fun ContentScope.SplitShade( viewModel = footerActionsViewModel, isCustomizing = false, customizingAnimationDuration = 0, lifecycleOwner = lifecycleOwner, modifier = Modifier.align(Alignment.CenterHorizontally) .sysuiResTag("qs_footer_actions"), Loading packages/SystemUI/src/com/android/systemui/qs/QSUtils.kt +4 −6 Original line number Diff line number Diff line package com.android.systemui.qs import android.content.Context import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Modifier import androidx.compose.ui.platform.ComposeView import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.compose.LocalLifecycleOwner import com.android.compose.theme.PlatformTheme import com.android.internal.policy.SystemBarUtils import com.android.systemui.compose.modifiers.sysUiResTagContainer Loading Loading @@ -36,12 +38,8 @@ object QSUtils { qsVisibilityLifecycleOwner: LifecycleOwner, ) { view.setContent { PlatformTheme { FooterActions( viewModel, qsVisibilityLifecycleOwner, Modifier.sysUiResTagContainer(), ) CompositionLocalProvider(LocalLifecycleOwner provides qsVisibilityLifecycleOwner) { PlatformTheme { FooterActions(viewModel, Modifier.sysUiResTagContainer()) } } } } Loading packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt +1 −4 Original line number Diff line number Diff line Loading @@ -963,10 +963,7 @@ constructor( Elements.FooterActions, Modifier.sysuiResTag(ResIdTags.qsFooterActions), ) { FooterActions( viewModel = viewModel.footerActionsViewModel, qsVisibilityLifecycleOwner = this@QSFragmentCompose, ) FooterActions(viewModel = viewModel.footerActionsViewModel) } } } Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/qs/footer/ui/compose/FooterActions.kt +17 −25 Original line number Diff line number Diff line Loading @@ -80,11 +80,10 @@ import androidx.compose.ui.unit.em import androidx.compose.ui.unit.sp import androidx.core.graphics.drawable.toBitmap import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.repeatOnLifecycle import com.android.compose.animation.Expandable import com.android.compose.animation.scene.ContentScope import com.android.compose.lifecycle.LaunchedEffectWithLifecycle import com.android.compose.modifiers.animatedBackground import com.android.compose.theme.LocalAndroidColorScheme import com.android.compose.theme.colorAttr Loading Loading @@ -117,7 +116,6 @@ fun ContentScope.FooterActionsWithAnimatedVisibility( viewModel: FooterActionsViewModel, isCustomizing: Boolean, customizingAnimationDuration: Int, lifecycleOwner: LifecycleOwner, modifier: Modifier = Modifier, ) { AnimatedVisibility( Loading @@ -138,7 +136,7 @@ fun ContentScope.FooterActionsWithAnimatedVisibility( // This view has its own horizontal padding // TODO(b/321716470) This should use a lifecycle tied to the scene. Element(QuickSettings.Elements.FooterActions, Modifier) { FooterActions(viewModel = viewModel, qsVisibilityLifecycleOwner = lifecycleOwner) FooterActions(viewModel = viewModel) } } } Loading @@ -146,11 +144,7 @@ fun ContentScope.FooterActionsWithAnimatedVisibility( /** The Quick Settings footer actions row. */ @Composable fun FooterActions( viewModel: FooterActionsViewModel, qsVisibilityLifecycleOwner: LifecycleOwner, modifier: Modifier = Modifier, ) { fun FooterActions(viewModel: FooterActionsViewModel, modifier: Modifier = Modifier) { val context = LocalContext.current // Collect alphas as soon as we are composed, even when not visible. Loading @@ -167,28 +161,26 @@ fun FooterActions( mutableStateOf<TextFeedbackViewModel>(TextFeedbackViewModel.NoFeedback) } LaunchedEffect( context, qsVisibilityLifecycleOwner, viewModel, viewModel.security, viewModel.foregroundServices, viewModel.userSwitcher, viewModel.textFeedback, ) { LaunchedEffect(context, viewModel) { launch { // Listen for dialog requests as soon as we are composed, even when not visible. viewModel.observeDeviceMonitoringDialogRequests(context) } } // Listen for model changes only when QS are visible. qsVisibilityLifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) { LaunchedEffectWithLifecycle( viewModel.security, viewModel.foregroundServices, viewModel.userSwitcher, viewModel.textFeedback, minActiveState = Lifecycle.State.RESUMED, ) { launch { viewModel.security.collect { security = it } } launch { viewModel.foregroundServices.collect { foregroundServices = it } } launch { viewModel.userSwitcher.collect { userSwitcher = it } } launch { viewModel.textFeedback.collect { textFeedback = it } } } } val backgroundColor = if (!notificationShadeBlur()) colorAttr(R.attr.underSurface) else Color.Transparent Loading
packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt +0 −1 Original line number Diff line number Diff line Loading @@ -375,7 +375,6 @@ private fun ContentScope.QuickSettingsContent( viewModel = footerActionsViewModel, isCustomizing = false, customizingAnimationDuration = 0, lifecycleOwner = lifecycleOwner, modifier = Modifier.align(Alignment.CenterHorizontally) .sysuiResTag("qs_footer_actions") Loading
packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt +0 −1 Original line number Diff line number Diff line Loading @@ -517,7 +517,6 @@ private fun ContentScope.SplitShade( viewModel = footerActionsViewModel, isCustomizing = false, customizingAnimationDuration = 0, lifecycleOwner = lifecycleOwner, modifier = Modifier.align(Alignment.CenterHorizontally) .sysuiResTag("qs_footer_actions"), Loading
packages/SystemUI/src/com/android/systemui/qs/QSUtils.kt +4 −6 Original line number Diff line number Diff line package com.android.systemui.qs import android.content.Context import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Modifier import androidx.compose.ui.platform.ComposeView import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.compose.LocalLifecycleOwner import com.android.compose.theme.PlatformTheme import com.android.internal.policy.SystemBarUtils import com.android.systemui.compose.modifiers.sysUiResTagContainer Loading Loading @@ -36,12 +38,8 @@ object QSUtils { qsVisibilityLifecycleOwner: LifecycleOwner, ) { view.setContent { PlatformTheme { FooterActions( viewModel, qsVisibilityLifecycleOwner, Modifier.sysUiResTagContainer(), ) CompositionLocalProvider(LocalLifecycleOwner provides qsVisibilityLifecycleOwner) { PlatformTheme { FooterActions(viewModel, Modifier.sysUiResTagContainer()) } } } } Loading
packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt +1 −4 Original line number Diff line number Diff line Loading @@ -963,10 +963,7 @@ constructor( Elements.FooterActions, Modifier.sysuiResTag(ResIdTags.qsFooterActions), ) { FooterActions( viewModel = viewModel.footerActionsViewModel, qsVisibilityLifecycleOwner = this@QSFragmentCompose, ) FooterActions(viewModel = viewModel.footerActionsViewModel) } } } Loading