@@ -44,6 +44,7 @@ import de.mm20.launcher2.database.migrations.Migration_27_28
|
||||
import de.mm20.launcher2.database.migrations.Migration_28_29
|
||||
import de.mm20.launcher2.database.migrations.Migration_29_30
|
||||
import de.mm20.launcher2.database.migrations.Migration_30_31
|
||||
import de.mm20.launcher2.database.migrations.Migration_31_32
|
||||
import de.mm20.launcher2.database.migrations.Migration_6_7
|
||||
import de.mm20.launcher2.database.migrations.Migration_7_8
|
||||
import de.mm20.launcher2.database.migrations.Migration_8_9
|
||||
@@ -67,7 +68,7 @@ import java.util.UUID
|
||||
ShapesEntity::class,
|
||||
TransparenciesEntity::class,
|
||||
TypographyEntity::class,
|
||||
], version = 31, exportSchema = true
|
||||
], version = 32, exportSchema = true
|
||||
)
|
||||
@TypeConverters(ComponentNameConverter::class)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
@@ -175,6 +176,7 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
Migration_28_29(),
|
||||
Migration_29_30(),
|
||||
Migration_30_31(),
|
||||
Migration_31_32(),
|
||||
).build()
|
||||
if (_instance == null) _instance = instance
|
||||
return instance
|
||||
|
||||
@@ -24,7 +24,9 @@ data class ForecastEntity(
|
||||
val provider: String,
|
||||
val providerUrl: String = "",
|
||||
@ColumnInfo(name = "rainProbability") val precipProbability: Int = -1,
|
||||
@Deprecated("Deprecated")
|
||||
val snowProbability: Int = -1,
|
||||
val uvIndex: Double = -1.0,
|
||||
val updateTime: Long
|
||||
) {
|
||||
companion object {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package de.mm20.launcher2.database.migrations
|
||||
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import de.mm20.launcher2.ktx.toBytes
|
||||
import de.mm20.launcher2.preferences.WidgetScreenTarget
|
||||
|
||||
class Migration_31_32 : Migration(31, 32) {
|
||||
|
||||
override fun migrate(db: SupportSQLiteDatabase) {
|
||||
db.execSQL(
|
||||
"""
|
||||
ALTER TABLE `forecasts` ADD COLUMN `uvIndex` REAL NOT NULL DEFAULT -1.0;
|
||||
""".trimIndent(),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,8 @@ data class Forecast(
|
||||
val windDirection: Double? = null,
|
||||
/** rain, in mm per hour **/
|
||||
val precipitation: Double? = null,
|
||||
/** UV index **/
|
||||
val uvIndex: Double? = null,
|
||||
/** whether this forecast is during nighttime (whether a moon icon should be used instead of sun) **/
|
||||
val night: Boolean = false,
|
||||
/** Location string **/
|
||||
@@ -79,7 +81,7 @@ data class Forecast(
|
||||
windDirection = windDirection ?: -1.0,
|
||||
windSpeed = windSpeed ?: -1.0,
|
||||
snow = -1.0,
|
||||
snowProbability = -1
|
||||
uvIndex = uvIndex ?: -1.0,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -102,6 +104,7 @@ data class Forecast(
|
||||
updateTime = entity.updateTime,
|
||||
windDirection = entity.windDirection.takeIf { it >= 0.0 },
|
||||
windSpeed = entity.windSpeed.takeIf { it >= 0.0 },
|
||||
uvIndex = entity.uvIndex.takeIf { it >= 0.0 },
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -86,6 +86,7 @@ class BreezyWeatherProvider(
|
||||
windSpeed = hourly.windSpeed?.toDouble()?.div(3.6),
|
||||
precipProbability = hourly.precipProbability,
|
||||
windDirection = hourly.windDirection?.toDouble(),
|
||||
uvIndex = hourly.uvIndex?.toDouble(),
|
||||
updateTime = lastUpdate,
|
||||
night = isNight
|
||||
)
|
||||
|
||||
@@ -49,12 +49,12 @@ internal data class LocationForecast(
|
||||
) {
|
||||
@Serializable
|
||||
internal data class Details(
|
||||
@SerialName("air_temperature") val airTemperature: Double,
|
||||
@SerialName("cloud_area_fraction") val cloudAreaFraction: Double,
|
||||
@SerialName("relative_humidity") val relativeHumidity: Double,
|
||||
@SerialName("wind_from_direction") val windFromDirection: Double,
|
||||
@SerialName("wind_speed") val windSpeed: Double,
|
||||
@SerialName("air_pressure_at_sea_level") val airPressureAtSeaLevel: Double,
|
||||
@SerialName("air_temperature") val airTemperature: Double?,
|
||||
@SerialName("cloud_area_fraction") val cloudAreaFraction: Double?,
|
||||
@SerialName("relative_humidity") val relativeHumidity: Double?,
|
||||
@SerialName("wind_from_direction") val windFromDirection: Double?,
|
||||
@SerialName("wind_speed") val windSpeed: Double?,
|
||||
@SerialName("air_pressure_at_sea_level") val airPressureAtSeaLevel: Double?,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -70,7 +70,8 @@ internal data class LocationForecast(
|
||||
|
||||
@Serializable
|
||||
internal data class Details(
|
||||
@SerialName("precipitation_amount") val precipitationAmount: Double?
|
||||
@SerialName("precipitation_amount") val precipitationAmount: Double?,
|
||||
@SerialName("ultraviolet_index_clear_sky_max") val ultravioletIndexClearSkyMax: Double?,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,9 +97,9 @@ internal class MetNoProvider(
|
||||
forecasts.add(
|
||||
Forecast(
|
||||
timestamp = timestamp,
|
||||
temperature = details.airTemperature + 273.15,
|
||||
temperature = (details.airTemperature ?: continue) + 273.15,
|
||||
updateTime = updatedAt,
|
||||
clouds = details.cloudAreaFraction.roundToInt(),
|
||||
clouds = details.cloudAreaFraction?.roundToInt(),
|
||||
humidity = details.relativeHumidity,
|
||||
windDirection = details.windFromDirection,
|
||||
windSpeed = details.windSpeed,
|
||||
@@ -110,6 +110,7 @@ internal class MetNoProvider(
|
||||
icon = iconForCode(symbolCode),
|
||||
condition = conditionForCode(symbolCode),
|
||||
precipitation = precipitationAmount,
|
||||
uvIndex = nextHours.details?.ultravioletIndexClearSkyMax,
|
||||
night = isNight(timestamp, lat, lon)
|
||||
|
||||
)
|
||||
@@ -239,7 +240,7 @@ internal class MetNoProvider(
|
||||
|
||||
"lightrain", "lightrainshowers" -> Forecast.LIGHT_RAIN
|
||||
"heavyrain", "heavyrainshowers" -> Forecast.HEAVY_RAIN
|
||||
"rain" -> Forecast.RAIN
|
||||
"rain", "rainshowers" -> Forecast.RAIN
|
||||
|
||||
"lightsleet", "lightsleetshowers", "heavysleet", "heavysleetshowers", "sleet" -> Forecast.SLEET
|
||||
|
||||
|
||||
@@ -68,14 +68,14 @@ data class WeatherResultClouds(
|
||||
|
||||
@Serializable
|
||||
data class CurrentWeatherResultRain(
|
||||
@SerialName("1h") val oneHour: Double,
|
||||
@SerialName("3h") val threeHours: Double,
|
||||
@SerialName("1h") val oneHour: Double?,
|
||||
@SerialName("3h") val threeHours: Double?,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class CurrentWeatherResultSnow(
|
||||
@SerialName("1h") val oneHour: Double,
|
||||
@SerialName("3h") val threeHours: Double,
|
||||
@SerialName("1h") val oneHour: Double?,
|
||||
@SerialName("3h") val threeHours: Double?,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@@ -117,7 +117,7 @@ data class ForecastResultSnow(
|
||||
|
||||
@Serializable
|
||||
data class ForecastResultSys(
|
||||
val pod: String,
|
||||
val pod: String?,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -118,6 +118,7 @@ internal class PluginWeatherProvider(
|
||||
provider = cursor[ForecastColumns.Provider] ?: continue,
|
||||
providerUrl = cursor[ForecastColumns.ProviderUrl] ?: "",
|
||||
clouds = cursor[ForecastColumns.Clouds],
|
||||
uvIndex = cursor[ForecastColumns.UvIndex],
|
||||
humidity = cursor[ForecastColumns.Humidity]?.toDouble(),
|
||||
precipitation = cursor[ForecastColumns.Precipitation],
|
||||
precipProbability = cursor[ForecastColumns.RainProbability],
|
||||
|
||||
Reference in New Issue
Block a user