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

Commit 91380375 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Date weather should fall below small clock upon wide font axes" into main

parents ff32aeb5 14a062fe
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context
import android.os.UserHandle
import android.provider.Settings
import com.android.keyguard.ClockEventController
import com.android.systemui.animation.GSFAxes
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
@@ -65,6 +66,8 @@ interface KeyguardClockRepository {
    /** clock id, selected from clock carousel in wallpaper picker */
    val currentClockId: Flow<ClockId>

    val currentClockFontAxesWidth: Float?

    val currentClock: StateFlow<ClockController?>

    val clockEventController: ClockEventController
@@ -128,6 +131,9 @@ constructor(
            }
            .mapNotNull { it }

    override val currentClockFontAxesWidth: Float?
        get() = clockRegistry.settings?.axes?.get(GSFAxes.WIDTH.tag)

    override val currentClock: StateFlow<ClockController?> =
        currentClockId
            .map {
+3 −0
Original line number Diff line number Diff line
@@ -81,6 +81,9 @@ constructor(

    val currentClockId: Flow<ClockId> = keyguardClockRepository.currentClockId

    val currentClockFontAxesWidth: Float?
        get() = keyguardClockRepository.currentClockFontAxesWidth

    val currentClock: StateFlow<ClockController?> = keyguardClockRepository.currentClock

    val clockEventController: ClockEventController = keyguardClockRepository.clockEventController
+15 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.ClockSize
import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransition.Config
import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransition.Type
import com.android.systemui.keyguard.ui.view.layout.sections.ClockSection
import com.android.systemui.keyguard.ui.viewmodel.AodBurnInViewModel
@@ -159,6 +160,20 @@ object KeyguardClockViewBinder {
                                ?.onFontSettingChanged(fontSizePx = fontSizePx.toFloat())
                        }
                    }

                    if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
                        launch("$TAG#clockViewModel.shouldDateWeatherBeBelowSmallClock") {
                            viewModel.shouldDateWeatherBeBelowSmallClock.collect {
                                blueprintInteractor.refreshBlueprint(
                                    Config(
                                        Type.SmartspaceVisibility,
                                        checkPriority = false,
                                        terminatePrevious = false,
                                    )
                                )
                            }
                        }
                    }
                }
            }

+23 −3
Original line number Diff line number Diff line
@@ -205,12 +205,25 @@ constructor(
                    hasCustomWeatherDataDisplay,
                    shadeModeInteractor.isShadeLayoutWide,
                    configurationInteractor.configurationValues,
                ) { hasCustomWeatherDataDisplay, isShadeLayoutWide, configurationValues ->
                    keyguardClockInteractor.currentClock,
                ) { hasCustomWeatherDataDisplay, isShadeLayoutWide, configurationValues, _ ->
                    var fallBelow = false
                    if (hasCustomWeatherDataDisplay) {
                        return@combine true
                    }

                    keyguardClockInteractor.currentClockFontAxesWidth?.let { fontWidth ->
                        if (fontWidth >= FONT_WIDTH_MAX_CUTOFF) {
                            smallClockLogBuffer.log(
                                TAG,
                                LogLevel.INFO,
                                { int1 = FONT_WIDTH_MAX_CUTOFF },
                                { "fallBelowClock:true, FontAxesWidth:$int1" },
                            )
                            return@combine true
                        }
                    }

                    val screenWidthDp = configurationValues.screenWidthDp

                    // if the shade is wide, we should account for the possibility of date/weather
@@ -233,7 +246,10 @@ constructor(
                            bool1 = fallBelow
                            bool2 = isShadeLayoutWide
                        },
                        { "fallBelowClock:$bool1, isShadeWide:$bool2, Width:$int1, Font:$double1" },
                        {
                            "fallBelowClock:$bool1, isShadeWide:$bool2, " +
                                "Width:$int1, FontScale:$double1"
                        },
                    )
                    fallBelow
                }
@@ -257,7 +273,7 @@ constructor(
        // font size to display size
        // These values come from changing the font size and display size on a non-foldable.
        // Visually looked at which configs cause the date/weather to push off of the screen
        val BREAKING_PAIRS =
        private val BREAKING_PAIRS =
            listOf(
                0.85f to 320, // tiny font size but large display size
                1f to 346,
@@ -265,5 +281,9 @@ constructor(
                1.5f to 376,
                1.8f to 411, // large font size but tiny display size
            )

        // Font axes width max cutoff
        // A font with a wider font axes than this is at risk of being pushed off screen
        private const val FONT_WIDTH_MAX_CUTOFF = 110
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -40,6 +40,10 @@ class FakeKeyguardClockRepository() : KeyguardClockRepository {
    private val _currentClockId = MutableStateFlow(DEFAULT_CLOCK_ID)
    override val currentClockId: Flow<ClockId> = _currentClockId

    private var _currentClockFontAxesWidth: Float? = 0f
    override val currentClockFontAxesWidth: Float?
        get() = _currentClockFontAxesWidth

    private val _currentClock: MutableStateFlow<ClockController?> = MutableStateFlow(null)
    override val currentClock = _currentClock