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

Commit 1e73681f authored by Hawkwood Glazier's avatar Hawkwood Glazier
Browse files

Move Sample WeatherData to be available in more places

Bug: 285877857
Flag: NONE small bugfix
Test: Maually checked the preview case
Change-Id: Ie5398d0ddc7225d754354e7f011b3ad7068ccaa1
parent f705dddb
Loading
Loading
Loading
Loading
+1 −22
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.graphics.Rect
import android.view.View
import android.widget.FrameLayout
import androidx.annotation.ColorInt
import androidx.core.text.util.LocalePreferences
import androidx.lifecycle.LifecycleOwner
import com.android.internal.policy.SystemBarUtils
import com.android.systemui.plugins.clocks.ClockController
@@ -201,21 +200,7 @@ class ClockViewFactoryImpl(
                .toFloat()
        )
        controller.smallClock.events.onTargetRegionChanged(getSmallClockRegion())

        // Use placeholder for weather clock preview in picker.
        // Use locale default temp unit since assistant default is not available in this context.
        val useCelsius =
            LocalePreferences.getTemperatureUnit() == LocalePreferences.TemperatureUnit.CELSIUS
        controller.events.onWeatherDataChanged(
            WeatherData(
                description = DESCRIPTION_PLACEHODLER,
                state = WEATHERICON_PLACEHOLDER,
                temperature =
                    if (useCelsius) TEMPERATURE_CELSIUS_PLACEHOLDER
                    else TEMPERATURE_FAHRENHEIT_PLACEHOLDER,
                useCelsius = useCelsius,
            )
        )
        controller.events.onWeatherDataChanged(WeatherData.getPlaceholderWeatherData())
        return controller
    }

@@ -252,13 +237,7 @@ class ClockViewFactoryImpl(
    }

    companion object {
        const val DESCRIPTION_PLACEHODLER = ""
        const val TEMPERATURE_FAHRENHEIT_PLACEHOLDER = 58
        const val TEMPERATURE_CELSIUS_PLACEHOLDER = 21
        val WEATHERICON_PLACEHOLDER = WeatherData.WeatherStateIcon.MOSTLY_SUNNY

        private fun getStatusBarHeight(context: Context): Int {

            val display = context.displayNoVerify
            if (display != null) {
                return SystemBarUtils.getStatusBarHeight(context.resources, display.cutout)