diff --git a/app/build.gradle b/app/build.gradle index b406a6f..70dda46 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,12 +5,12 @@ plugins { id 'androidx.navigation.safeargs' } -def relStorePassword = System.getenv("RELEASE_STORE_PASSWORD") -def relKeyPassword = System.getenv("RELEASE_KEY_PASSWORD") -def relKeyAlias = System.getenv("RELEASE_KEY_ALIAS") +Properties properties = new Properties() +boolean propertiesFileExists = project.rootProject.file('local.properties').canRead() +if (propertiesFileExists) properties.load(project.rootProject.file('local.properties').newDataInputStream()) + +def keystoreFile = project.rootProject.file("app/keystore.jks") -def keystorePath = System.getenv('PWD') + "/app/keystore.jks" -def keystore = file(keystorePath).exists() ? file(keystorePath) : null android { namespace 'com.appttude.h_mal.atlas_weather' compileSdk = Integer.parseInt(TARGET_SDK_VERSION) @@ -23,15 +23,8 @@ android { testInstrumentationRunner "com.appttude.h_mal.atlas_weather.application.TestRunner" vectorDrawables.useSupportLibrary = true - Properties properties = new Properties() - if (project.rootProject.file('local.properties').canRead()) { - properties.load(project.rootProject.file('local.properties').newDataInputStream()) - buildConfigField "String", "ParamOne", properties.getProperty('WEATHER_API') - buildConfigField "String", "ParamTwo", properties.getProperty('SEARCH_API') - } else { - buildConfigField "String", "ParamOne", System.getenv('WEATHER_API') - buildConfigField "String", "ParamTwo", System.getenv('SEARCH_API') - } + buildConfigField "String", "ParamOne", System.getenv('WEATHER_API') ?: properties.getProperty('WEATHER_API') + buildConfigField "String", "ParamTwo", System.getenv('SEARCH_API') ?: properties.getProperty('SEARCH_API') packagingOptions { resources.excludes.add("META-INF/*") @@ -50,10 +43,10 @@ android { } signingConfigs { release { - storePassword relStorePassword - keyPassword relKeyPassword - keyAlias relKeyAlias - storeFile keystore + storePassword System.getProperty("RELEASE_STORE_PASSWORD") ?: properties.getProperty('RELEASE_STORE_PASSWORD') + keyPassword System.getProperty("RELEASE_KEY_PASSWORD") ?: properties.getProperty('RELEASE_KEY_PASSWORD') + keyAlias System.getProperty("RELEASE_KEY_ALIAS") ?: properties.getProperty('RELEASE_KEY_ALIAS') + storeFile keystoreFile.exists() ? keystoreFile : null } } testOptions { @@ -221,4 +214,6 @@ dependencies { implementation "com.github.permissions-dispatcher:permissionsdispatcher:$PERMISSIONS_DISPATCHER" kapt "com.github.permissions-dispatcher:permissionsdispatcher-processor:$PERMISSIONS_DISPATCHER" implementation "com.github.permissions-dispatcher:permissionsdispatcher-annotation:$PERMISSIONS_DISPATCHER" + / * kotlinx-coroutines-rx2 * / + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:$KOTLINX_COROUTINES_RX2" } diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/CurrentConditions.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/CurrentConditions.kt index 6370dae..b2f69ed 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/CurrentConditions.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/CurrentConditions.kt @@ -12,8 +12,8 @@ data class CurrentConditions( @SerializedName("dew") var dew: Double? = null, @SerializedName("precip") var precip: Double? = null, @SerializedName("precipprob") var precipprob: Double? = null, - @SerializedName("snow") var snow: Int? = null, - @SerializedName("snowdepth") var snowdepth: Int? = null, + @SerializedName("snow") var snow: Double? = null, + @SerializedName("snowdepth") var snowdepth: Double? = null, @SerializedName("preciptype") var preciptype: ArrayList = arrayListOf(), @SerializedName("windgust") var windgust: Double? = null, @SerializedName("windspeed") var windspeed: Double? = null, @@ -23,7 +23,7 @@ data class CurrentConditions( @SerializedName("cloudcover") var cloudcover: Double? = null, @SerializedName("solarradiation") var solarradiation: Double? = null, @SerializedName("solarenergy") var solarenergy: Double? = null, - @SerializedName("uvindex") var uvindex: Int? = null, + @SerializedName("uvindex") var uvindex: Double? = null, @SerializedName("conditions") var conditions: String? = null, @SerializedName("icon") var icon: String? = null, @SerializedName("stations") var stations: ArrayList = arrayListOf(), diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/Days.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/Days.kt index a2f66ec..06cc025 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/Days.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/Days.kt @@ -14,12 +14,12 @@ data class Days( @SerializedName("feelslike") var feelslike: Double? = null, @SerializedName("dew") var dew: Double? = null, @SerializedName("humidity") var humidity: Double? = null, - @SerializedName("precip") var precip: Number? = null, + @SerializedName("precip") var precip: Double? = null, @SerializedName("precipprob") var precipprob: Double? = null, @SerializedName("precipcover") var precipcover: Double? = null, @SerializedName("preciptype") var preciptype: ArrayList = arrayListOf(), - @SerializedName("snow") var snow: Int? = null, - @SerializedName("snowdepth") var snowdepth: Int? = null, + @SerializedName("snow") var snow: Double? = null, + @SerializedName("snowdepth") var snowdepth: Double? = null, @SerializedName("windgust") var windgust: Double? = null, @SerializedName("windspeed") var windspeed: Double? = null, @SerializedName("winddir") var winddir: Double? = null, @@ -28,8 +28,8 @@ data class Days( @SerializedName("visibility") var visibility: Double? = null, @SerializedName("solarradiation") var solarradiation: Double? = null, @SerializedName("solarenergy") var solarenergy: Double? = null, - @SerializedName("uvindex") var uvindex: Int? = null, - @SerializedName("severerisk") var severerisk: Int? = null, + @SerializedName("uvindex") var uvindex: Double? = null, + @SerializedName("severerisk") var severerisk: Double? = null, @SerializedName("sunrise") var sunrise: String? = null, @SerializedName("sunriseEpoch") var sunriseEpoch: Int? = null, @SerializedName("sunset") var sunset: String? = null, diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/Hours.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/Hours.kt index 22d3043..e26a7bf 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/Hours.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/Hours.kt @@ -10,10 +10,10 @@ data class Hours( @SerializedName("feelslike") var feelslike: Double? = null, @SerializedName("humidity") var humidity: Double? = null, @SerializedName("dew") var dew: Double? = null, - @SerializedName("precip") var precip: Number? = null, + @SerializedName("precip") var precip: Double? = null, @SerializedName("precipprob") var precipprob: Double? = null, - @SerializedName("snow") var snow: Int? = null, - @SerializedName("snowdepth") var snowdepth: Int? = null, + @SerializedName("snow") var snow: Double? = null, + @SerializedName("snowdepth") var snowdepth: Double? = null, @SerializedName("preciptype") var preciptype: ArrayList = arrayListOf(), @SerializedName("windgust") var windgust: Double? = null, @SerializedName("windspeed") var windspeed: Double? = null, @@ -23,8 +23,8 @@ data class Hours( @SerializedName("cloudcover") var cloudcover: Double? = null, @SerializedName("solarradiation") var solarradiation: Double? = null, @SerializedName("solarenergy") var solarenergy: Double? = null, - @SerializedName("uvindex") var uvindex: Int? = null, - @SerializedName("severerisk") var severerisk: Int? = null, + @SerializedName("uvindex") var uvindex: Double? = null, + @SerializedName("severerisk") var severerisk: Double? = null, @SerializedName("conditions") var conditions: String? = null, @SerializedName("icon") var icon: String? = null, @SerializedName("stations") var stations: ArrayList = arrayListOf(), diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/WeatherApiResponse.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/WeatherApiResponse.kt index e5aebe8..629dfe1 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/WeatherApiResponse.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/weather/WeatherApiResponse.kt @@ -15,7 +15,7 @@ data class WeatherApiResponse( @SerializedName("resolvedAddress") var resolvedAddress: String? = null, @SerializedName("address") var address: String? = null, @SerializedName("timezone") var timezone: String? = null, - @SerializedName("tzoffset") var tzoffset: Int? = null, + @SerializedName("tzoffset") var tzoffset: Double? = null, @SerializedName("description") var description: String? = null, @SerializedName("days") var days: ArrayList = arrayListOf(), @SerializedName("alerts") var alerts: ArrayList = arrayListOf(), @@ -28,7 +28,7 @@ data class WeatherApiResponse( return FullWeather( current = Current(currentConditions), timezone = timezone, - timezoneOffset = tzoffset, + timezoneOffset = tzoffset?.toInt(), hourly = hours, daily = collectedDays, lat = latitude, diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/helper/ServicesHelper.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/helper/ServicesHelper.kt index 6a5bab0..fb49850 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/helper/ServicesHelper.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/helper/ServicesHelper.kt @@ -12,7 +12,6 @@ import com.appttude.h_mal.atlas_weather.data.repository.SettingsRepository import com.appttude.h_mal.atlas_weather.data.room.entity.CURRENT_LOCATION import com.appttude.h_mal.atlas_weather.data.room.entity.EntityItem import com.appttude.h_mal.atlas_weather.model.widget.InnerWidgetCellData -import com.appttude.h_mal.atlas_weather.model.widget.InnerWidgetData import com.appttude.h_mal.atlas_weather.model.widget.WidgetData import com.appttude.h_mal.atlas_weather.model.widget.WidgetError import com.appttude.h_mal.atlas_weather.model.widget.WidgetState @@ -21,8 +20,6 @@ import com.appttude.h_mal.atlas_weather.utils.getSymbol import com.appttude.h_mal.atlas_weather.utils.toSmallDayName import com.squareup.picasso.Picasso import com.squareup.picasso.Target -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext import java.io.IOException import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine @@ -137,44 +134,6 @@ class ServicesHelper( return WidgetState.HasData(data) } - suspend fun getWidgetWeather(): WidgetData? { - return try { - val result = repository.loadSingleCurrentWeatherFromRoom(CURRENT_LOCATION) - val epoc = System.currentTimeMillis() - - result.weather.let { - val bitmap = it.current?.icon - val location = locationProvider.getLocationNameFromLatLong(it.lat!!, it.lon!!) - val temp = it.current?.temp?.toInt().toString() - - WidgetData(location, bitmap, temp, epoc) - } - } catch (e: Exception) { - null - } - } - - suspend fun getWidgetInnerWeather(): List? { - return try { - val result = repository.loadSingleCurrentWeatherFromRoom(CURRENT_LOCATION) - val list = mutableListOf() - - result.weather.daily?.drop(1)?.dropLast(2)?.forEach { dailyWeather -> - val day = dailyWeather.dt?.toSmallDayName() - val bitmap = withContext(Dispatchers.Main) { - getBitmapFromUrl(dailyWeather.icon) - } - val temp = dailyWeather.max?.toInt().toString() - - val item = InnerWidgetData(day, bitmap, temp) - list.add(item) - } - list.toList() - } catch (e: Exception) { - null - } - } - suspend fun getWidgetWeatherCollection(): WidgetWeatherCollection? { return try { val result = repository.loadSingleCurrentWeatherFromRoom(CURRENT_LOCATION) diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/DailyWeather.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/DailyWeather.kt index b723fdd..3ac942a 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/DailyWeather.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/DailyWeather.kt @@ -49,8 +49,8 @@ data class DailyWeather( days.datetimeEpoch, days.cloudcover?.toInt(), days.precipprob, - days.uvindex?.toDouble(), - days.precip?.toDouble() + days.uvindex, + days.precipprob ) } \ No newline at end of file diff --git a/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/world/WorldFragment.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/world/WorldFragment.kt index b9a870a..51b7518 100644 --- a/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/world/WorldFragment.kt +++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/world/WorldFragment.kt @@ -2,7 +2,6 @@ package com.appttude.h_mal.monoWeather.ui.world import android.os.Bundle import android.view.View -import android.widget.Button import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView diff --git a/gradle.properties b/gradle.properties index 443342e..cd89a83 100644 --- a/gradle.properties +++ b/gradle.properties @@ -62,6 +62,7 @@ GRADLE_PLUGIN_VERSION = 8.5.0 KOTLIN_VERSION = 2.0.0 KOTLIN_GRADLE_PLUGIN = 1.6.21 GRADLE_ANALYZE_VERSION = 1.20.0 +KOTLINX_COROUTINES_RX2 = 1.9.0 # Android configuration TARGET_SDK_VERSION = 34