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

Commit 3fd02660 authored by Sherry Zhou's avatar Sherry Zhou
Browse files

Add clockSection to splitShadeBlueprint

Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint
DEVELOPMENT
Bug: 310989339
Test: atest ClockSectionTest, SmartspaceSectionTest

Change-Id: I60fad56afe0795a567e4adf6b7f2c5a767284747
parent 185ece07
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@ import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.res.R
import kotlinx.coroutines.launch

private val TAG = KeyguardClockViewBinder::class.simpleName

object KeyguardClockViewBinder {
    @JvmStatic
    fun bind(
@@ -74,12 +72,6 @@ object KeyguardClockViewBinder {
                        applyConstraints(clockSection, keyguardRootView, true)
                    }
                }
                launch {
                    if (!migrateClocksToBlueprint()) return@launch
                    viewModel.hasCustomWeatherDataDisplay.collect {
                        applyConstraints(clockSection, keyguardRootView, true)
                    }
                }
            }
        }
    }
@@ -132,7 +124,7 @@ object KeyguardClockViewBinder {
    fun applyConstraints(
        clockSection: ClockSection,
        rootView: ConstraintLayout,
        animated: Boolean
        animated: Boolean,
    ) {
        val constraintSet = ConstraintSet().apply { clone(rootView) }
        clockSection.applyConstraints(constraintSet)
+58 −4
Original line number Diff line number Diff line
@@ -16,13 +16,19 @@

package com.android.systemui.keyguard.ui.binder

import android.transition.TransitionManager
import android.view.View
import androidx.constraintlayout.helper.widget.Layer
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.keyguard.ui.view.layout.sections.SmartspaceSection
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.res.R
import kotlinx.coroutines.launch

object KeyguardSmartspaceViewBinder {
    @JvmStatic
@@ -30,15 +36,63 @@ object KeyguardSmartspaceViewBinder {
        smartspaceSection: SmartspaceSection,
        keyguardRootView: ConstraintLayout,
        clockViewModel: KeyguardClockViewModel,
        smartspaceViewModel: KeyguardSmartspaceViewModel,
    ) {
        keyguardRootView.repeatWhenAttached {
            repeatOnLifecycle(Lifecycle.State.STARTED) {
                clockViewModel.hasCustomWeatherDataDisplay.collect {
                launch {
                    clockViewModel.hasCustomWeatherDataDisplay.collect { hasCustomWeatherDataDisplay
                        ->
                        if (hasCustomWeatherDataDisplay) {
                            removeDateWeatherToBurnInLayer(keyguardRootView, smartspaceViewModel)
                        } else {
                            addDateWeatherToBurnInLayer(keyguardRootView, smartspaceViewModel)
                        }
                        clockViewModel.burnInLayer?.updatePostLayout(keyguardRootView)
                        val constraintSet = ConstraintSet().apply { clone(keyguardRootView) }
                        smartspaceSection.applyConstraints(constraintSet)
                        TransitionManager.beginDelayedTransition(keyguardRootView)
                        constraintSet.applyTo(keyguardRootView)
                    }
                }
            }
        }
    }

    private fun addDateWeatherToBurnInLayer(
        constraintLayout: ConstraintLayout,
        smartspaceViewModel: KeyguardSmartspaceViewModel
    ) {
        val burnInLayer = constraintLayout.requireViewById<Layer>(R.id.burn_in_layer)
        burnInLayer.apply {
            if (
                smartspaceViewModel.isSmartspaceEnabled &&
                    smartspaceViewModel.isDateWeatherDecoupled
            ) {
                val dateView = constraintLayout.requireViewById<View>(smartspaceViewModel.dateId)
                val weatherView =
                    constraintLayout.requireViewById<View>(smartspaceViewModel.weatherId)
                addView(weatherView)
                addView(dateView)
            }
        }
    }

    private fun removeDateWeatherToBurnInLayer(
        constraintLayout: ConstraintLayout,
        smartspaceViewModel: KeyguardSmartspaceViewModel
    ) {
        val burnInLayer = constraintLayout.requireViewById<Layer>(R.id.burn_in_layer)
        burnInLayer.apply {
            if (
                smartspaceViewModel.isSmartspaceEnabled &&
                    smartspaceViewModel.isDateWeatherDecoupled
            ) {
                val dateView = smartspaceViewModel.dateView
                val weatherView = smartspaceViewModel.weatherView
                removeView(weatherView)
                removeView(dateView)
            }
        }
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import com.android.systemui.keyguard.ui.view.layout.sections.DefaultShortcutsSec
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusBarSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusViewSection
import com.android.systemui.keyguard.ui.view.layout.sections.KeyguardSectionsModule
import com.android.systemui.keyguard.ui.view.layout.sections.SmartspaceSection
import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeClockSection
import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeGuidelines
import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeNotificationStackScrollLayoutSection
import com.android.systemui.util.kotlin.getOrNull
@@ -59,6 +61,8 @@ constructor(
    aodNotificationIconsSection: AodNotificationIconsSection,
    aodBurnInSection: AodBurnInSection,
    communalTutorialIndicatorSection: CommunalTutorialIndicatorSection,
    smartspaceSection: SmartspaceSection,
    clockSection: SplitShadeClockSection,
) : KeyguardBlueprint {
    override val id: String = ID

@@ -73,8 +77,10 @@ constructor(
            splitShadeNotificationStackScrollLayoutSection,
            splitShadeGuidelines,
            aodNotificationIconsSection,
            smartspaceSection,
            aodBurnInSection,
            communalTutorialIndicatorSection,
            clockSection,
            defaultDeviceEntrySection, // Add LAST: Intentionally has z-order above other views.
        )

+2 −10
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import androidx.constraintlayout.helper.widget.Layer
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import com.android.systemui.Flags.migrateClocksToBlueprint
import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
@@ -38,7 +37,6 @@ constructor(
    private val context: Context,
    private val clockViewModel: KeyguardClockViewModel,
    private val smartspaceViewModel: KeyguardSmartspaceViewModel,
    private val featureFlags: FeatureFlagsClassic,
) : KeyguardSection() {
    lateinit var burnInLayer: Layer

@@ -59,6 +57,8 @@ constructor(
                }
            }
        if (migrateClocksToBlueprint()) {
            // weather and date parts won't be added here, cause their visibility doesn't align
            // with others in burnInLayer
            addSmartspaceViews(constraintLayout)
        }
        constraintLayout.addView(burnInLayer)
@@ -89,14 +89,6 @@ constructor(
                val smartspaceView =
                    constraintLayout.requireViewById<View>(smartspaceViewModel.smartspaceViewId)
                addView(smartspaceView)
                if (smartspaceViewModel.isDateWeatherDecoupled) {
                    val dateView =
                        constraintLayout.requireViewById<View>(smartspaceViewModel.dateId)
                    val weatherView =
                        constraintLayout.requireViewById<View>(smartspaceViewModel.weatherId)
                    addView(weatherView)
                    addView(dateView)
                }
            }
        }
    }
+2 −10
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import androidx.constraintlayout.widget.ConstraintSet.START
import androidx.constraintlayout.widget.ConstraintSet.TOP
import com.android.systemui.Flags.migrateClocksToBlueprint
import com.android.systemui.common.ui.ConfigurationState
import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
@@ -49,7 +48,6 @@ class AodNotificationIconsSection
constructor(
    private val context: Context,
    private val configurationState: ConfigurationState,
    private val featureFlags: FeatureFlagsClassic,
    private val iconBindingFailureTracker: StatusBarIconViewBindingFailureTracker,
    private val nicAodViewModel: NotificationIconContainerAlwaysOnDisplayViewModel,
    private val nicAodIconViewStore: AlwaysOnDisplayNotificationIconViewStore,
@@ -119,14 +117,8 @@ constructor(
            }
        constraintSet.apply {
            if (migrateClocksToBlueprint()) {
                connect(
                    nicId,
                    TOP,
                    smartspaceViewModel.smartspaceViewId,
                    topAlignment,
                    bottomMargin
                )
                setGoneMargin(nicId, topAlignment, bottomMargin)
                connect(nicId, TOP, smartspaceViewModel.smartspaceViewId, BOTTOM, bottomMargin)
                setGoneMargin(nicId, BOTTOM, bottomMargin)
            } else {
                connect(nicId, TOP, R.id.keyguard_status_view, topAlignment, bottomMargin)
            }
Loading