Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/WeatherData.kt +21 −10 Original line number Diff line number Diff line package com.android.systemui.plugins import android.os.Bundle import android.util.Log import androidx.annotation.VisibleForTesting class WeatherData Loading @@ -11,6 +12,7 @@ constructor( val temperature: Int, ) { companion object { const val DEBUG = true private const val TAG = "WeatherData" @VisibleForTesting const val DESCRIPTION_KEY = "description" @VisibleForTesting const val STATE_KEY = "state" Loading @@ -23,20 +25,29 @@ constructor( val state = WeatherStateIcon.fromInt(extras.getInt(STATE_KEY, INVALID_WEATHER_ICON_STATE)) val temperature = readIntFromBundle(extras, TEMPERATURE_KEY) return if ( if ( description == null || state == null || !extras.containsKey(USE_CELSIUS_KEY) || temperature == null ) null else ) { if (DEBUG) { Log.w(TAG, "Weather data did not parse from $extras") } return null } else { val result = WeatherData( description = description, state = state, useCelsius = extras.getBoolean(USE_CELSIUS_KEY), temperature = temperature ) if (DEBUG) { Log.i(TAG, "Weather data parsed $result from $extras") } return result } } private fun readIntFromBundle(extras: Bundle, key: String): Int? = Loading packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +7 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.content.IntentFilter import android.content.res.Resources import android.text.format.DateFormat import android.util.TypedValue import android.util.Log import android.view.View import android.view.View.OnAttachStateChangeListener import android.view.ViewTreeObserver Loading Loading @@ -101,7 +102,12 @@ constructor( } updateFontSizes() updateTimeListeners() cachedWeatherData?.let { value.events.onWeatherDataChanged(it) } cachedWeatherData?.let { if (WeatherData.DEBUG) { Log.i(TAG, "Pushing cached weather data to new clock: $it") } value.events.onWeatherDataChanged(it) } value.smallClock.view.addOnAttachStateChangeListener( object : OnAttachStateChangeListener { override fun onViewAttachedToWindow(p0: View?) { Loading Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/WeatherData.kt +21 −10 Original line number Diff line number Diff line package com.android.systemui.plugins import android.os.Bundle import android.util.Log import androidx.annotation.VisibleForTesting class WeatherData Loading @@ -11,6 +12,7 @@ constructor( val temperature: Int, ) { companion object { const val DEBUG = true private const val TAG = "WeatherData" @VisibleForTesting const val DESCRIPTION_KEY = "description" @VisibleForTesting const val STATE_KEY = "state" Loading @@ -23,20 +25,29 @@ constructor( val state = WeatherStateIcon.fromInt(extras.getInt(STATE_KEY, INVALID_WEATHER_ICON_STATE)) val temperature = readIntFromBundle(extras, TEMPERATURE_KEY) return if ( if ( description == null || state == null || !extras.containsKey(USE_CELSIUS_KEY) || temperature == null ) null else ) { if (DEBUG) { Log.w(TAG, "Weather data did not parse from $extras") } return null } else { val result = WeatherData( description = description, state = state, useCelsius = extras.getBoolean(USE_CELSIUS_KEY), temperature = temperature ) if (DEBUG) { Log.i(TAG, "Weather data parsed $result from $extras") } return result } } private fun readIntFromBundle(extras: Bundle, key: String): Int? = Loading
packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +7 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.content.IntentFilter import android.content.res.Resources import android.text.format.DateFormat import android.util.TypedValue import android.util.Log import android.view.View import android.view.View.OnAttachStateChangeListener import android.view.ViewTreeObserver Loading Loading @@ -101,7 +102,12 @@ constructor( } updateFontSizes() updateTimeListeners() cachedWeatherData?.let { value.events.onWeatherDataChanged(it) } cachedWeatherData?.let { if (WeatherData.DEBUG) { Log.i(TAG, "Pushing cached weather data to new clock: $it") } value.events.onWeatherDataChanged(it) } value.smallClock.view.addOnAttachStateChangeListener( object : OnAttachStateChangeListener { override fun onViewAttachedToWindow(p0: View?) { Loading