Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/WeatherData.kt +27 −3 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import android.os.Bundle import android.util.Log import android.view.View import androidx.annotation.VisibleForTesting import androidx.core.text.util.LocalePreferences typealias WeatherTouchAction = (View) -> Unit Loading Loading @@ -54,11 +55,34 @@ data class WeatherData( } } private fun readIntFromBundle(extras: Bundle, key: String): Int? = private fun readIntFromBundle(extras: Bundle, key: String): Int? { try { extras.getString(key)?.toInt() return extras.getString(key)?.toInt() } catch (e: Exception) { null return null } } fun getPlaceholderWeatherData(): WeatherData { return getPlaceholderWeatherData( LocalePreferences.getTemperatureUnit() == LocalePreferences.TemperatureUnit.CELSIUS ) } private const val DESCRIPTION_PLACEHODLER = "" private const val TEMPERATURE_FAHRENHEIT_PLACEHOLDER = 58 private const val TEMPERATURE_CELSIUS_PLACEHOLDER = 21 private val WEATHERICON_PLACEHOLDER = WeatherData.WeatherStateIcon.MOSTLY_SUNNY fun getPlaceholderWeatherData(useCelsius: Boolean): WeatherData { return WeatherData( description = DESCRIPTION_PLACEHODLER, state = WEATHERICON_PLACEHOLDER, temperature = if (useCelsius) TEMPERATURE_CELSIUS_PLACEHOLDER else TEMPERATURE_FAHRENHEIT_PLACEHOLDER, useCelsius = useCelsius, ) } } Loading packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +6 −0 Original line number Diff line number Diff line Loading @@ -477,6 +477,12 @@ constructor( smallClockFrame?.viewTreeObserver?.removeOnGlobalLayoutListener(onGlobalLayoutListener) } fun setFallbackWeatherData(data: WeatherData) { if (weatherData != null) return weatherData = data clock?.run { events.onWeatherDataChanged(data) } } /** * Sets this clock as showing in a secondary display. * Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt +2 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ import com.android.systemui.keyguard.ui.viewmodel.OccludingAppDeviceEntryMessage import com.android.systemui.monet.ColorScheme import com.android.systemui.monet.Style import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.plugins.clocks.WeatherData import com.android.systemui.res.R import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.shared.clocks.ClockRegistry Loading Loading @@ -188,6 +189,7 @@ constructor( init { coroutineScope = CoroutineScope(applicationScope.coroutineContext + Job()) disposables += DisposableHandle { coroutineScope.cancel() } clockController.setFallbackWeatherData(WeatherData.getPlaceholderWeatherData()) if (KeyguardBottomAreaRefactor.isEnabled) { quickAffordancesCombinedViewModel.enablePreviewMode( Loading Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/WeatherData.kt +27 −3 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import android.os.Bundle import android.util.Log import android.view.View import androidx.annotation.VisibleForTesting import androidx.core.text.util.LocalePreferences typealias WeatherTouchAction = (View) -> Unit Loading Loading @@ -54,11 +55,34 @@ data class WeatherData( } } private fun readIntFromBundle(extras: Bundle, key: String): Int? = private fun readIntFromBundle(extras: Bundle, key: String): Int? { try { extras.getString(key)?.toInt() return extras.getString(key)?.toInt() } catch (e: Exception) { null return null } } fun getPlaceholderWeatherData(): WeatherData { return getPlaceholderWeatherData( LocalePreferences.getTemperatureUnit() == LocalePreferences.TemperatureUnit.CELSIUS ) } private const val DESCRIPTION_PLACEHODLER = "" private const val TEMPERATURE_FAHRENHEIT_PLACEHOLDER = 58 private const val TEMPERATURE_CELSIUS_PLACEHOLDER = 21 private val WEATHERICON_PLACEHOLDER = WeatherData.WeatherStateIcon.MOSTLY_SUNNY fun getPlaceholderWeatherData(useCelsius: Boolean): WeatherData { return WeatherData( description = DESCRIPTION_PLACEHODLER, state = WEATHERICON_PLACEHOLDER, temperature = if (useCelsius) TEMPERATURE_CELSIUS_PLACEHOLDER else TEMPERATURE_FAHRENHEIT_PLACEHOLDER, useCelsius = useCelsius, ) } } Loading
packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +6 −0 Original line number Diff line number Diff line Loading @@ -477,6 +477,12 @@ constructor( smallClockFrame?.viewTreeObserver?.removeOnGlobalLayoutListener(onGlobalLayoutListener) } fun setFallbackWeatherData(data: WeatherData) { if (weatherData != null) return weatherData = data clock?.run { events.onWeatherDataChanged(data) } } /** * Sets this clock as showing in a secondary display. * Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt +2 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ import com.android.systemui.keyguard.ui.viewmodel.OccludingAppDeviceEntryMessage import com.android.systemui.monet.ColorScheme import com.android.systemui.monet.Style import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.plugins.clocks.WeatherData import com.android.systemui.res.R import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.shared.clocks.ClockRegistry Loading Loading @@ -188,6 +189,7 @@ constructor( init { coroutineScope = CoroutineScope(applicationScope.coroutineContext + Job()) disposables += DisposableHandle { coroutineScope.cancel() } clockController.setFallbackWeatherData(WeatherData.getPlaceholderWeatherData()) if (KeyguardBottomAreaRefactor.isEnabled) { quickAffordancesCombinedViewModel.enablePreviewMode( Loading