Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
// NOTE: Version Code Format (TargetSDK, Version Name, Build Number, Variant Code (Android: 00, WearOS: 01)
versionCode 335810200
versionName "5.8.1"
versionCode 335820100
versionName "5.8.2"

vectorDrawables.useSupportLibrary true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import android.app.Application
import androidx.annotation.MainThread
import androidx.arch.core.util.Function
import androidx.core.util.ObjectsCompat
import androidx.lifecycle.*
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.viewModelScope
import com.thewizrd.common.controls.AirQualityViewModel
import com.thewizrd.shared_resources.database.WeatherDatabase
import com.thewizrd.shared_resources.locationdata.LocationData
Expand Down Expand Up @@ -49,7 +53,7 @@ class AirQualityForecastViewModel(app: Application) : AndroidViewModel(app) {
}
}

private val forecastObserver = Observer<Forecasts> { forecastData ->
private val forecastObserver = Observer<Forecasts?> { forecastData ->
this.aqiForecastData.postValue(forecastData?.aqiForecast)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import android.app.Application
import androidx.annotation.MainThread
import androidx.arch.core.util.Function
import androidx.core.util.ObjectsCompat
import androidx.lifecycle.*
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.viewModelScope
import com.thewizrd.shared_resources.database.WeatherDatabase
import com.thewizrd.shared_resources.locationdata.LocationData
import com.thewizrd.shared_resources.locationdata.LocationQuery
Expand Down Expand Up @@ -85,7 +89,7 @@ class ChartsViewModel(app: Application) : AndroidViewModel(app) {
}
}

private val forecastObserver = Observer<Forecasts> { forecastData ->
private val forecastObserver = Observer<Forecasts?> { forecastData ->
this.forecastData.postValue(
graphDataMapper.apply(
Pair(
Expand All @@ -96,7 +100,7 @@ class ChartsViewModel(app: Application) : AndroidViewModel(app) {
)
}

private val hrforecastObserver = Observer<List<HourlyForecast>> { forecastData ->
private val hrforecastObserver = Observer<List<HourlyForecast>?> { forecastData ->
this.forecastData.postValue(
graphDataMapper.apply(
Pair(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ class WeatherNowFragment : AbstractWeatherListDetailFragment(), BannerManagerInt
.transition(BitmapTransitionOptions.withCrossFade(300))
.addListener(object : RequestListener<Bitmap?> {
override fun onLoadFailed(
e: GlideException?, model: Any,
e: GlideException?, model: Any?,
target: Target<Bitmap?>,
isFirstResource: Boolean
): Boolean {
Expand All @@ -1155,7 +1155,7 @@ class WeatherNowFragment : AbstractWeatherListDetailFragment(), BannerManagerInt
}

override fun onResourceReady(
resource: Bitmap?, model: Any,
resource: Bitmap, model: Any,
target: Target<Bitmap?>,
dataSource: DataSource,
isFirstResource: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void onCreate() {

@Override
public void onDestroy() {
String json = JSONParser.serializer(mNotifications, HashMap.class);
String json = JSONParser.serializer(mNotifications, Map.class);
notifPrefs.edit().putString(KEY_NOTIFS, json).apply();

super.onDestroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,16 @@ class SettingsFragment : BaseSettingsFragment(),
}

registerPref = findPreference(KEY_APIREGISTER)!!
registerPref.setOnPreferenceClickListener { preference ->
preference.intent?.let {
runCatching {
if (it.resolveActivity(preference.context.packageManager) != null) {
startActivity(it)
}
}
}
true
}

// Set key as verified if API Key is req for API and its set
if (weatherModule.weatherManager.isKeyRequired()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ class SetupProviderFragment : CustomPreferenceFragmentCompat(), StepperFragment
}

registerPref = findPreference(KEY_APIREGISTER)!!
registerPref.setOnPreferenceClickListener { preference ->
preference.intent?.let {
runCatching {
if (it.resolveActivity(preference.context.packageManager) != null) {
startActivity(it)
}
}
}
true
}

providerPref.value = settingsManager.getAPI()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ import com.thewizrd.simpleweather.R
import com.thewizrd.simpleweather.controls.ImageDataViewModel
import com.thewizrd.weather_api.weatherModule
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

Expand Down Expand Up @@ -230,8 +234,9 @@ class WeatherNowViewModel(app: Application) : AndroidViewModel(app) {
if (state.locationData?.countryCode?.let { !wm.isRegionSupported(it) } == true) {
Logger.writeLine(
Log.WARN,
"Location: %s",
JSONParser.serializer(state.locationData)
"Location: %s; countryCode: %s",
JSONParser.serializer(state.locationData),
state.locationData.countryCode
)
Logger.writeLine(
Log.WARN,
Expand Down Expand Up @@ -288,8 +293,9 @@ class WeatherNowViewModel(app: Application) : AndroidViewModel(app) {
if (state.locationData?.countryCode?.let { !wm.isRegionSupported(it) } == true) {
Logger.writeLine(
Log.WARN,
"Location: %s",
JSONParser.serializer(state.locationData)
"Location: %s; countryCode: %s",
JSONParser.serializer(state.locationData),
state.locationData.countryCode
)
Logger.writeLine(
Log.WARN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ abstract class CustomBackgroundWidgetRemoteViewCreator(
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Bitmap>?,
target: Target<Bitmap>,
isFirstResource: Boolean
): Boolean {
if (it.isActive) {
Expand All @@ -250,10 +250,10 @@ abstract class CustomBackgroundWidgetRemoteViewCreator(
}

override fun onResourceReady(
resource: Bitmap?,
model: Any?,
resource: Bitmap,
model: Any,
target: Target<Bitmap>?,
dataSource: DataSource?,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
if (it.isActive) {
Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ buildscript {
ext {
compileSdkVersion = 34
minSdkVersion = 21
targetSdkVersion = 34
targetSdkVersion = 33

kotlin_version = '1.9.0'
kotlinx_version = '1.7.3'
ksp_version = '1.9.0-1.0.13'

desugar_version = '2.0.3'

firebase_version = '32.2.2'
firebase_version = '32.2.3'
gms_location_version = '21.0.1'

annotation_version = '1.6.0'
Expand All @@ -23,7 +23,7 @@ buildscript {
arch_core_runtime_version = '2.2.0'
fragment_version = '1.6.1'
lifecycle_version = '2.6.1'
nav_version = '2.7.0'
nav_version = '2.7.1'
paging_version = '3.2.0'
preference_version = '1.2.1'
recyclerview_version = '1.3.1'
Expand All @@ -40,13 +40,13 @@ buildscript {

material_version = '1.9.0'

compose_compiler_version = '1.5.1'
compose_compiler_version = '1.5.2'
compose_version = '1.5.0'
wear_compose_version = '1.2.0'
horologist_version = '0.4.12'
accompanist_version = '0.30.1'

glide_version = '4.15.1'
glide_version = '4.16.0'
icu4j_version = '73.2'
moshi_version = '1.15.0'
okhttp_version = '4.11.0'
Expand All @@ -60,10 +60,10 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.1.0'
classpath 'com.android.tools.build:gradle:8.1.1'
classpath "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:$ksp_version"
classpath 'com.google.gms:google-services:4.3.15'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.8'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
classpath 'com.google.firebase:perf-plugin:1.4.2'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.thewizrd.common.viewmodels

import android.app.Application
import android.util.Log
import androidx.annotation.StringRes
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.viewModelScope
Expand All @@ -16,6 +17,8 @@ import com.thewizrd.shared_resources.locationdata.LocationQuery
import com.thewizrd.shared_resources.locationdata.toLocationData
import com.thewizrd.shared_resources.remoteconfig.remoteConfigService
import com.thewizrd.shared_resources.utils.Coordinate
import com.thewizrd.shared_resources.utils.JSONParser
import com.thewizrd.shared_resources.utils.Logger
import com.thewizrd.weather_api.weatherModule
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
Expand Down Expand Up @@ -162,6 +165,12 @@ class LocationSearchViewModel(app: Application) : AndroidViewModel(app) {
}

if (!wm.isRegionSupported(locQuery.locationCountry)) {
Logger.writeLine(
Log.WARN,
"Location: %s; countryCode: %s",
JSONParser.serializer(locQuery.toLocationData()),
locQuery.locationCountry
)
postErrorMessage(R.string.error_message_weather_region_unsupported)
viewModelState.update {
it.copy(isLoading = false)
Expand Down Expand Up @@ -286,6 +295,12 @@ class LocationSearchViewModel(app: Application) : AndroidViewModel(app) {
}

if (!wm.isRegionSupported(queryResult.locationCountry)) {
Logger.writeLine(
Log.WARN,
"Location: %s; countryCode: %s",
JSONParser.serializer(queryResult.toLocationData()),
locQuery.locationCountry
)
postErrorMessage(R.string.error_message_weather_region_unsupported)
viewModelState.update {
it.copy(isLoading = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ class WeatherDataLoader {
if (weather == null) {
Logger.writeLine(
Log.WARN,
"Location: %s",
JSONParser.serializer(location, LocationData::class.java)
"Location: %s; countryCode: %s",
JSONParser.serializer(location),
location.countryCode
)
throw WeatherException(ErrorStatus.QUERYNOTFOUND).initCause(CustomException(R.string.error_message_weather_region_unsupported))
}
Expand Down
Loading