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

Commit 201cfc0a authored by Hawkwood Glazier's avatar Hawkwood Glazier Committed by Automerger Merge Worker
Browse files

Merge "Log weather information parsing" into udc-dev am: 5c0ab458

parents 5c35ee1c 5c0ab458
Loading
Loading
Loading
Loading
+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
@@ -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"
@@ -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? =
+7 −1
Original line number Diff line number Diff line
@@ -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
@@ -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?) {