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

Commit 4e7094f4 authored by Hawkwood Glazier's avatar Hawkwood Glazier Committed by Android (Google) Code Review
Browse files

Merge "Listen for Weather settings changes in SmartspaceViewBinder" into main

parents c114ac95 07b211c1
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.res.R
import com.android.systemui.shared.R as sharedR
import kotlinx.coroutines.DisposableHandle
import kotlinx.coroutines.flow.combine

object KeyguardSmartspaceViewBinder {
    @JvmStatic
@@ -43,8 +44,12 @@ object KeyguardSmartspaceViewBinder {
        return keyguardRootView.repeatWhenAttached {
            repeatOnLifecycle(Lifecycle.State.CREATED) {
                launch("$TAG#clockViewModel.hasCustomWeatherDataDisplay") {
                    clockViewModel.hasCustomWeatherDataDisplay.collect { hasCustomWeatherDataDisplay
                        ->
                    combine(
                            smartspaceViewModel.isWeatherVisible,
                            clockViewModel.hasCustomWeatherDataDisplay,
                            ::Pair,
                        )
                        .collect {
                            updateDateWeatherToBurnInLayer(
                                keyguardRootView,
                                clockViewModel,
+9 −18
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.view.ViewTreeObserver.OnGlobalLayoutListener
import androidx.constraintlayout.widget.Barrier
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.constraintlayout.widget.ConstraintSet.GONE
import androidx.constraintlayout.widget.ConstraintSet.VISIBLE
import com.android.systemui.customization.R as customR
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.KeyguardUnlockAnimationController
@@ -195,24 +197,13 @@ constructor(
        smartspaceController.requestSmartspaceUpdate()

        constraintSet.apply {
            val weatherVisibility =
                when (keyguardSmartspaceViewModel.isWeatherVisible.value) {
                    true -> ConstraintSet.VISIBLE
                    false -> ConstraintSet.GONE
                }
            setVisibility(sharedR.id.weather_smartspace_view, weatherVisibility)
            setAlpha(
                sharedR.id.weather_smartspace_view,
                if (weatherVisibility == View.VISIBLE) 1f else 0f,
            )
            val dateVisibility =
                if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) ConstraintSet.GONE
                else ConstraintSet.VISIBLE
            setVisibility(sharedR.id.date_smartspace_view, dateVisibility)
            setAlpha(
                sharedR.id.date_smartspace_view,
                if (dateVisibility == ConstraintSet.VISIBLE) 1f else 0f,
            )
            val showWeather = keyguardSmartspaceViewModel.isWeatherVisible.value
            setVisibility(sharedR.id.weather_smartspace_view, if (showWeather) VISIBLE else GONE)
            setAlpha(sharedR.id.weather_smartspace_view, if (showWeather) 1f else 0f)

            val showDateView = !keyguardClockViewModel.hasCustomWeatherDataDisplay.value
            setVisibility(sharedR.id.date_smartspace_view, if (showDateView) VISIBLE else GONE)
            setAlpha(sharedR.id.date_smartspace_view, if (showDateView) 1f else 0f)
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ constructor(
                    isWeatherVisible(
                        clockIncludesCustomWeatherDisplay =
                            keyguardClockViewModel.hasCustomWeatherDataDisplay.value,
                        isWeatherEnabled = smartspaceInteractor.isWeatherEnabled.value,
                        isWeatherEnabled = isWeatherEnabled.value,
                    ),
            )