diff --git a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/mvvm/utils/DateUtilsKtTest.kt b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/utils/DateUtilsKtTest.kt similarity index 89% rename from app/src/androidTest/java/com/appttude/h_mal/atlas_weather/mvvm/utils/DateUtilsKtTest.kt rename to app/src/androidTest/java/com/appttude/h_mal/atlas_weather/utils/DateUtilsKtTest.kt index 3b24c9a..d87ea41 100644 --- a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/mvvm/utils/DateUtilsKtTest.kt +++ b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/utils/DateUtilsKtTest.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.utils +package com.appttude.h_mal.atlas_weather.utils import org.junit.Assert.assertEquals import org.junit.Test diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1506342..56ae5a5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,14 +16,14 @@ android:required="true" /> - @@ -35,8 +35,12 @@ + + diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/application/AppClass.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/application/AppClass.kt similarity index 65% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/application/AppClass.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/application/AppClass.kt index 0bab97f..8b302d5 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/application/AppClass.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/application/AppClass.kt @@ -1,17 +1,17 @@ -package com.appttude.h_mal.atlas_weather.mvvm.application +package com.appttude.h_mal.atlas_weather.application import android.app.Application import androidx.test.espresso.idling.CountingIdlingResource -import com.appttude.h_mal.atlas_weather.mvvm.data.location.LocationProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.network.WeatherApi -import com.appttude.h_mal.atlas_weather.mvvm.data.network.interceptors.NetworkConnectionInterceptor -import com.appttude.h_mal.atlas_weather.mvvm.data.network.interceptors.QueryParamsInterceptor -import com.appttude.h_mal.atlas_weather.mvvm.data.prefs.PreferenceProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.repository.RepositoryImpl -import com.appttude.h_mal.atlas_weather.mvvm.data.repository.SettingsRepositoryImpl -import com.appttude.h_mal.atlas_weather.mvvm.data.room.AppDatabase -import com.appttude.h_mal.atlas_weather.mvvm.viewmodel.ApplicationViewModelFactory -import com.appttude.h_mal.atlas_weather.notifcation.ServicesHelper +import com.appttude.h_mal.atlas_weather.data.location.LocationProvider +import com.appttude.h_mal.atlas_weather.data.network.WeatherApi +import com.appttude.h_mal.atlas_weather.data.network.interceptors.NetworkConnectionInterceptor +import com.appttude.h_mal.atlas_weather.data.network.interceptors.QueryParamsInterceptor +import com.appttude.h_mal.atlas_weather.data.prefs.PreferenceProvider +import com.appttude.h_mal.atlas_weather.data.repository.RepositoryImpl +import com.appttude.h_mal.atlas_weather.data.repository.SettingsRepositoryImpl +import com.appttude.h_mal.atlas_weather.data.room.AppDatabase +import com.appttude.h_mal.atlas_weather.viewmodel.ApplicationViewModelFactory +import com.appttude.h_mal.atlas_weather.notification.ServicesHelper import com.google.gson.Gson import org.kodein.di.Kodein import org.kodein.di.KodeinAware diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/location/LocationProvider.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/location/LocationProvider.kt similarity index 96% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/location/LocationProvider.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/location/LocationProvider.kt index 85e65d3..5d67ec3 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/location/LocationProvider.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/location/LocationProvider.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.location +package com.appttude.h_mal.atlas_weather.data.location import android.Manifest.permission.ACCESS_FINE_LOCATION import android.content.Context diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/ResponseUnwrap.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/ResponseUnwrap.kt similarity index 93% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/ResponseUnwrap.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/ResponseUnwrap.kt index a173f75..106237c 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/ResponseUnwrap.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/ResponseUnwrap.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.network +package com.appttude.h_mal.atlas_weather.data.network import org.json.JSONException import org.json.JSONObject diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/WeatherApi.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/WeatherApi.kt similarity index 80% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/WeatherApi.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/WeatherApi.kt index d29693e..0b41f6d 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/WeatherApi.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/WeatherApi.kt @@ -1,8 +1,8 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.network +package com.appttude.h_mal.atlas_weather.data.network -import com.appttude.h_mal.atlas_weather.mvvm.data.network.interceptors.NetworkConnectionInterceptor -import com.appttude.h_mal.atlas_weather.mvvm.data.network.interceptors.QueryParamsInterceptor -import com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast.WeatherResponse +import com.appttude.h_mal.atlas_weather.data.network.interceptors.NetworkConnectionInterceptor +import com.appttude.h_mal.atlas_weather.data.network.interceptors.QueryParamsInterceptor +import com.appttude.h_mal.atlas_weather.data.network.response.forecast.WeatherResponse import okhttp3.OkHttpClient import retrofit2.Response import retrofit2.Retrofit diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/interceptors/NetworkConnectionInterceptor.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/interceptors/NetworkConnectionInterceptor.kt similarity index 94% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/interceptors/NetworkConnectionInterceptor.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/interceptors/NetworkConnectionInterceptor.kt index 26c6724..c655446 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/interceptors/NetworkConnectionInterceptor.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/interceptors/NetworkConnectionInterceptor.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.network.interceptors +package com.appttude.h_mal.atlas_weather.data.network.interceptors import android.content.Context import android.net.ConnectivityManager diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/interceptors/QueryParamsInterceptor.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/interceptors/QueryParamsInterceptor.kt similarity index 92% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/interceptors/QueryParamsInterceptor.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/interceptors/QueryParamsInterceptor.kt index f2d376b..091dcd4 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/interceptors/QueryParamsInterceptor.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/interceptors/QueryParamsInterceptor.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.network.interceptors +package com.appttude.h_mal.atlas_weather.data.network.interceptors import com.appttude.h_mal.atlas_weather.BuildConfig import okhttp3.Interceptor diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/Current.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/Current.kt similarity index 92% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/Current.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/Current.kt index 7647de2..4859de6 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/Current.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/Current.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast +package com.appttude.h_mal.atlas_weather.data.network.response.forecast import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/DailyItem.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/DailyItem.kt similarity index 92% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/DailyItem.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/DailyItem.kt index c26fcea..d04a820 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/DailyItem.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/DailyItem.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast +package com.appttude.h_mal.atlas_weather.data.network.response.forecast import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/FeelsLike.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/FeelsLike.kt similarity index 80% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/FeelsLike.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/FeelsLike.kt index 20ec345..f08d021 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/FeelsLike.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/FeelsLike.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast +package com.appttude.h_mal.atlas_weather.data.network.response.forecast import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/Response.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/Response.kt similarity index 86% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/Response.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/Response.kt index e150500..f9b1c23 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/Response.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/Response.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast +package com.appttude.h_mal.atlas_weather.data.network.response.forecast import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/Temp.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/Temp.kt similarity index 84% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/Temp.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/Temp.kt index 9a4869b..09ffabd 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/Temp.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/Temp.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast +package com.appttude.h_mal.atlas_weather.data.network.response.forecast import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/WeatherItem.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/WeatherItem.kt similarity index 80% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/WeatherItem.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/WeatherItem.kt index 1d61b9c..da25be4 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/WeatherItem.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/WeatherItem.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast +package com.appttude.h_mal.atlas_weather.data.network.response.forecast import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/WeatherResponse.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/WeatherResponse.kt similarity index 86% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/WeatherResponse.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/WeatherResponse.kt index 0fe990d..5eab5c3 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/network/response/forecast/WeatherResponse.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/network/response/forecast/WeatherResponse.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast +package com.appttude.h_mal.atlas_weather.data.network.response.forecast import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/prefs/PreferencesProvider.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/prefs/PreferencesProvider.kt similarity index 82% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/prefs/PreferencesProvider.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/prefs/PreferencesProvider.kt index fc5f35f..b5e8631 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/prefs/PreferencesProvider.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/prefs/PreferencesProvider.kt @@ -1,9 +1,9 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.prefs +package com.appttude.h_mal.atlas_weather.data.prefs import android.content.Context import android.content.SharedPreferences import androidx.preference.PreferenceManager -import com.appttude.h_mal.atlas_weather.mvvm.data.room.entity.CURRENT_LOCATION +import com.appttude.h_mal.atlas_weather.data.room.entity.CURRENT_LOCATION /** * Shared preferences to save & load last timestamp @@ -43,4 +43,8 @@ class PreferenceProvider( preference.edit().putBoolean("FIRST_TIME_RUN", false).apply() } + fun isWidgetBlackground(): Boolean { + return preference.getBoolean("widget_black_background", false) + } + } \ No newline at end of file diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/Repository.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/repository/Repository.kt similarity index 75% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/Repository.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/repository/Repository.kt index 364614a..f3b9b2d 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/Repository.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/repository/Repository.kt @@ -1,8 +1,8 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.repository +package com.appttude.h_mal.atlas_weather.data.repository import androidx.lifecycle.LiveData -import com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast.WeatherResponse -import com.appttude.h_mal.atlas_weather.mvvm.data.room.entity.EntityItem +import com.appttude.h_mal.atlas_weather.data.network.response.forecast.WeatherResponse +import com.appttude.h_mal.atlas_weather.data.room.entity.EntityItem interface Repository { diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/RepositoryImpl.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/repository/RepositoryImpl.kt similarity index 73% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/RepositoryImpl.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/repository/RepositoryImpl.kt index 9901765..612168d 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/RepositoryImpl.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/repository/RepositoryImpl.kt @@ -1,13 +1,13 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.repository +package com.appttude.h_mal.atlas_weather.data.repository -import com.appttude.h_mal.atlas_weather.mvvm.data.network.ResponseUnwrap -import com.appttude.h_mal.atlas_weather.mvvm.data.network.WeatherApi -import com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast.WeatherResponse -import com.appttude.h_mal.atlas_weather.mvvm.data.prefs.LOCATION_CONST -import com.appttude.h_mal.atlas_weather.mvvm.data.prefs.PreferenceProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.room.AppDatabase -import com.appttude.h_mal.atlas_weather.mvvm.data.room.entity.EntityItem -import com.appttude.h_mal.atlas_weather.mvvm.model.weather.FullWeather +import com.appttude.h_mal.atlas_weather.data.network.ResponseUnwrap +import com.appttude.h_mal.atlas_weather.data.network.WeatherApi +import com.appttude.h_mal.atlas_weather.data.network.response.forecast.WeatherResponse +import com.appttude.h_mal.atlas_weather.data.prefs.LOCATION_CONST +import com.appttude.h_mal.atlas_weather.data.prefs.PreferenceProvider +import com.appttude.h_mal.atlas_weather.data.room.AppDatabase +import com.appttude.h_mal.atlas_weather.data.room.entity.EntityItem +import com.appttude.h_mal.atlas_weather.model.weather.FullWeather private const val FIVE_MINS = 300000L class RepositoryImpl( diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/SettingsRepository.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/repository/SettingsRepository.kt similarity index 50% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/SettingsRepository.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/repository/SettingsRepository.kt index 2b5efa1..8eb6b51 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/SettingsRepository.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/repository/SettingsRepository.kt @@ -1,6 +1,7 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.repository +package com.appttude.h_mal.atlas_weather.data.repository interface SettingsRepository { fun isNotificationsEnabled(): Boolean fun setFirstTime() + fun isBlackBackground(): Boolean } \ No newline at end of file diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/SettingsRepositoryImpl.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/repository/SettingsRepositoryImpl.kt similarity index 54% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/SettingsRepositoryImpl.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/repository/SettingsRepositoryImpl.kt index 894f6f7..8139307 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/SettingsRepositoryImpl.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/repository/SettingsRepositoryImpl.kt @@ -1,6 +1,6 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.repository +package com.appttude.h_mal.atlas_weather.data.repository -import com.appttude.h_mal.atlas_weather.mvvm.data.prefs.PreferenceProvider +import com.appttude.h_mal.atlas_weather.data.prefs.PreferenceProvider class SettingsRepositoryImpl( val prefs: PreferenceProvider @@ -9,4 +9,6 @@ class SettingsRepositoryImpl( override fun isNotificationsEnabled(): Boolean = prefs.isNotificationsEnabled() override fun setFirstTime() = prefs.setFirstTimeRun() + + override fun isBlackBackground() = prefs.isWidgetBlackground() } \ No newline at end of file diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/room/AppDatabase.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/room/AppDatabase.kt similarity index 61% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/room/AppDatabase.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/room/AppDatabase.kt index c97408b..123f16e 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/room/AppDatabase.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/room/AppDatabase.kt @@ -1,15 +1,16 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.room +package com.appttude.h_mal.atlas_weather.data.room import android.content.Context import androidx.room.Database import androidx.room.Room import androidx.room.RoomDatabase import androidx.room.TypeConverters -import com.appttude.h_mal.atlas_weather.mvvm.data.room.entity.EntityItem +import com.appttude.h_mal.atlas_weather.data.room.entity.EntityItem @Database( - entities = [EntityItem::class], - version = 1 + entities = [EntityItem::class], + version = 1, + exportSchema = false ) @TypeConverters(Converter::class) abstract class AppDatabase : RoomDatabase() { @@ -30,12 +31,12 @@ abstract class AppDatabase : RoomDatabase() { } private fun buildDatabase(context: Context) = - Room.databaseBuilder( - context.applicationContext, - AppDatabase::class.java, - "MyDatabase.db" - ).addTypeConverter(Converter(context)) - .build() + Room.databaseBuilder( + context.applicationContext, + AppDatabase::class.java, + "MyDatabase.db" + ).addTypeConverter(Converter(context)) + .build() } } diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/room/Converter.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/room/Converter.kt similarity index 84% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/room/Converter.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/room/Converter.kt index c1256a8..684062e 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/room/Converter.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/room/Converter.kt @@ -1,9 +1,9 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.room +package com.appttude.h_mal.atlas_weather.data.room import android.content.Context import androidx.room.ProvidedTypeConverter import androidx.room.TypeConverter -import com.appttude.h_mal.atlas_weather.mvvm.model.weather.FullWeather +import com.appttude.h_mal.atlas_weather.model.weather.FullWeather import com.google.gson.Gson import org.kodein.di.KodeinAware import org.kodein.di.android.kodein diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/room/WeatherDao.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/room/WeatherDao.kt similarity index 81% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/room/WeatherDao.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/room/WeatherDao.kt index 06f9c41..99e75bc 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/room/WeatherDao.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/room/WeatherDao.kt @@ -1,12 +1,12 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.room +package com.appttude.h_mal.atlas_weather.data.room import androidx.lifecycle.LiveData import androidx.room.Dao import androidx.room.Insert import androidx.room.OnConflictStrategy import androidx.room.Query -import com.appttude.h_mal.atlas_weather.mvvm.data.room.entity.CURRENT_LOCATION -import com.appttude.h_mal.atlas_weather.mvvm.data.room.entity.EntityItem +import com.appttude.h_mal.atlas_weather.data.room.entity.CURRENT_LOCATION +import com.appttude.h_mal.atlas_weather.data.room.entity.EntityItem @Dao interface WeatherDao { diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/room/entity/EntityItem.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/room/entity/EntityItem.kt similarity index 62% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/room/entity/EntityItem.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/data/room/entity/EntityItem.kt index f161f00..a9c5667 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/data/room/entity/EntityItem.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/data/room/entity/EntityItem.kt @@ -1,8 +1,8 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.room.entity +package com.appttude.h_mal.atlas_weather.data.room.entity import androidx.room.Entity import androidx.room.PrimaryKey -import com.appttude.h_mal.atlas_weather.mvvm.model.weather.FullWeather +import com.appttude.h_mal.atlas_weather.model.weather.FullWeather const val CURRENT_LOCATION = "CurrentLocation" diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/forecast/Forecast.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/forecast/Forecast.kt similarity index 86% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/forecast/Forecast.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/model/forecast/Forecast.kt index 36639ad..37a589f 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/forecast/Forecast.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/forecast/Forecast.kt @@ -1,10 +1,11 @@ -package com.appttude.h_mal.atlas_weather.mvvm.model.forecast +package com.appttude.h_mal.atlas_weather.model.forecast import android.os.Parcel import android.os.Parcelable -import com.appttude.h_mal.atlas_weather.mvvm.model.weather.DailyWeather -import com.appttude.h_mal.atlas_weather.mvvm.utils.toDayName -import com.appttude.h_mal.atlas_weather.mvvm.utils.toDayString +import com.appttude.h_mal.atlas_weather.model.weather.DailyWeather +import com.appttude.h_mal.atlas_weather.utils.toDayName +import com.appttude.h_mal.atlas_weather.utils.toDayString +import com.appttude.h_mal.atlas_weather.utils.toTime data class Forecast( val date: String?, @@ -34,10 +35,12 @@ data class Forecast( (dailyWeather.pop?.times(100)).toString(), dailyWeather.humidity?.toString(), dailyWeather.uvi?.toInt().toString(), - dailyWeather.sunrise?.toString(), - dailyWeather.sunset?.toString() + dailyWeather.sunrise?.toTime(), + dailyWeather.sunset?.toTime() ) + + constructor(parcel: Parcel) : this( parcel.readString(), parcel.readString(), diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/forecast/WeatherDisplay.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/forecast/WeatherDisplay.kt similarity index 94% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/forecast/WeatherDisplay.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/model/forecast/WeatherDisplay.kt index 3309147..ac0c6f9 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/forecast/WeatherDisplay.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/forecast/WeatherDisplay.kt @@ -1,8 +1,8 @@ -package com.appttude.h_mal.atlas_weather.mvvm.model.forecast +package com.appttude.h_mal.atlas_weather.model.forecast import android.os.Parcel import android.os.Parcelable -import com.appttude.h_mal.atlas_weather.mvvm.model.weather.FullWeather +import com.appttude.h_mal.atlas_weather.model.weather.FullWeather data class WeatherDisplay( diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/weather/Current.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/Current.kt similarity index 87% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/weather/Current.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/Current.kt index ec60a87..443fe50 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/weather/Current.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/Current.kt @@ -1,6 +1,6 @@ -package com.appttude.h_mal.atlas_weather.mvvm.model.weather +package com.appttude.h_mal.atlas_weather.model.weather -import com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast.Current +import com.appttude.h_mal.atlas_weather.data.network.response.forecast.Current data class Current( val dt: Int? = null, diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/weather/DailyWeather.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/DailyWeather.kt similarity index 90% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/weather/DailyWeather.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/DailyWeather.kt index a5a150d..39c55fd 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/weather/DailyWeather.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/DailyWeather.kt @@ -1,6 +1,6 @@ -package com.appttude.h_mal.atlas_weather.mvvm.model.weather +package com.appttude.h_mal.atlas_weather.model.weather -import com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast.DailyItem +import com.appttude.h_mal.atlas_weather.data.network.response.forecast.DailyItem data class DailyWeather( diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/weather/FullWeather.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/FullWeather.kt similarity index 76% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/weather/FullWeather.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/FullWeather.kt index 9a36321..b6ceb89 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/model/weather/FullWeather.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/FullWeather.kt @@ -1,6 +1,6 @@ -package com.appttude.h_mal.atlas_weather.mvvm.model.weather +package com.appttude.h_mal.atlas_weather.model.weather -import com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast.WeatherResponse +import com.appttude.h_mal.atlas_weather.data.network.response.forecast.WeatherResponse data class FullWeather( val current: Current? = null, diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/notifcation/WidgetData.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/widget/WidgetData.kt similarity index 97% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/notifcation/WidgetData.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/model/widget/WidgetData.kt index 16a66fe..5554039 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/notifcation/WidgetData.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/widget/WidgetData.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.notifcation +package com.appttude.h_mal.atlas_weather.model.widget import android.graphics.Bitmap import android.os.Parcel diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/utils/SecondsToDateUtils.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/utils/SecondsToDateUtils.kt deleted file mode 100644 index 0fd2afd..0000000 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/utils/SecondsToDateUtils.kt +++ /dev/null @@ -1,136 +0,0 @@ -package com.appttude.h_mal.atlas_weather.mvvm.utils - - -import android.os.Build -import java.text.SimpleDateFormat -import java.time.LocalDate -import java.time.format.DateTimeFormatter -import java.time.temporal.ChronoUnit -import java.util.* - -fun Int.toDayString(): String { - return try { - val date = Date(this.makeMilliseconds()) - val format = SimpleDateFormat("MMM d", Locale.getDefault()) - format.format(date) - } catch (e: Exception) { - e.printStackTrace() - "Unable to parse date" - } -} - -fun Int.makeMilliseconds(): Long = this * 1000L - -fun Int.toDayName(): String { - return try { - val date = Date(this.makeMilliseconds()) - val format = SimpleDateFormat("EEEE", Locale.getDefault()) - format.format(date) - } catch (e: Exception) { - e.printStackTrace() - "Unable to parse date" - } -} - -fun Int.toSmallDayName(): String { - return try { - val date = Date(this.makeMilliseconds()) - val format = SimpleDateFormat("EEE", Locale.getDefault()) - format.format(date) - } catch (e: Exception) { - e.printStackTrace() - "Unable to parse date" - } -} - -fun String.changeDateFormat(): String { - return try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - val formatter = DateTimeFormatter.ofPattern("dd MMMM, yyyy") - val date = LocalDate.parse(this) - date.format(formatter) - } else { - var format = SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH) - val date = format.parse(this) - format = SimpleDateFormat("dd MMMM, yyyy", Locale.ENGLISH) - format.format(date) - - } - } catch (e: Exception) { - e.printStackTrace() - "Unable to parse date" - } - -} - -fun String.transformDateTimeString(): String { - return try { - val inputFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm", Locale.ENGLISH) - val outputFormat = SimpleDateFormat("EEE, dd MMM yyyy HH:mm", Locale.ENGLISH) - val dateIn = inputFormat.parse(substringBeforeLast(":")) - outputFormat.format(dateIn) - } catch (e: Exception) { - e.printStackTrace() - this - } -} - -fun String.transformDateString(): String { - return try { - val inputFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm", Locale.ENGLISH) - val outputFormat = SimpleDateFormat("EEE, dd MMM yyyy", Locale.ENGLISH) - val dateIn = inputFormat.parse(substringBeforeLast(":")) - outputFormat.format(dateIn) - } catch (e: Exception) { - e.printStackTrace() - this - } -} - -fun String.transformPassportData(): String { - return try { - val formatIn = SimpleDateFormat("yyMMdd", Locale.ENGLISH) - val formatOut = SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH) - val dateIn = formatIn.parse(this) - formatOut.format(dateIn) - } catch (e: Exception) { - e.printStackTrace() - this - } - -} - -fun String.getYearsSinceNow(): String? { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - val formatter = DateTimeFormatter.ofPattern("dd MMMM, yyyy") - val now = LocalDate.now() - val date = LocalDate.parse(this, formatter) - ChronoUnit.YEARS.between(date, now).toString() - } else { - val now = Calendar.getInstance() - - val date = Calendar.getInstance() - val simpleDateFormat = SimpleDateFormat("dd MMMM, yyyy", Locale.ENGLISH) - date.time = simpleDateFormat.parse(this) - val years = now.get(Calendar.YEAR) - date.get(Calendar.YEAR) - years.toString() - } - -} - -fun String?.changeDateToSeconds(): Long { -// if (isNullOrBlank()){ -// val time = System.currentTimeMillis() / 1000 -// return time + 2592000 -// } - - return try { - val sdf = SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH) - val convertedCurrentDate = sdf.parse(this) - convertedCurrentDate.time / 1000 - } catch (e: Exception) { - val time = System.currentTimeMillis() / 1000 - time + 2592000 - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/notifcation/NotificationData.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/notification/NotificationData.kt similarity index 67% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/notifcation/NotificationData.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/notification/NotificationData.kt index 597f391..f7dedd9 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/notifcation/NotificationData.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/notification/NotificationData.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.notifcation +package com.appttude.h_mal.atlas_weather.notification import android.graphics.Bitmap diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/notifcation/ServicesHelper.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/notification/ServicesHelper.kt similarity index 66% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/notifcation/ServicesHelper.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/notification/ServicesHelper.kt index 81abe40..d11d280 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/notifcation/ServicesHelper.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/notification/ServicesHelper.kt @@ -1,16 +1,18 @@ -package com.appttude.h_mal.atlas_weather.notifcation +package com.appttude.h_mal.atlas_weather.notification import android.Manifest import android.graphics.Bitmap import android.graphics.BitmapFactory +import android.graphics.Color import androidx.annotation.RequiresPermission -import com.appttude.h_mal.atlas_weather.mvvm.data.location.LocationProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.repository.Repository -import com.appttude.h_mal.atlas_weather.mvvm.data.repository.SettingsRepository -import com.appttude.h_mal.atlas_weather.mvvm.data.room.entity.CURRENT_LOCATION -import com.appttude.h_mal.atlas_weather.mvvm.model.weather.FullWeather -import com.appttude.h_mal.atlas_weather.mvvm.utils.toDayName -import com.appttude.h_mal.atlas_weather.mvvm.utils.toSmallDayName +import com.appttude.h_mal.atlas_weather.data.location.LocationProvider +import com.appttude.h_mal.atlas_weather.data.repository.Repository +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.model.weather.FullWeather +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.utils.toSmallDayName import java.io.IOException import java.net.URL @@ -87,34 +89,6 @@ class ServicesHelper( } catch (e: Exception) { null } } - @RequiresPermission(Manifest.permission.ACCESS_FINE_LOCATION) - suspend fun getWidgetData(): WidgetData? { - return try { - val latLon = locationProvider.getLatLong() - val result = - repository.getWeatherFromApi( - latLon.first.toString(), - latLon.second.toString() - ) - val list = result.daily?.drop(0)?.map { - InnerWidgetData( - it.dt?.toDayName(), - getBitmapFromUrl(it.weather?.get(0)?.icon), - it.temp?.max?.toInt().toString() - ) - } - - WidgetData( - locationProvider.getLocationName(latLon.first, latLon.second), - getBitmapFromUrl(result.current?.weather?.get(0)?.icon), - result.current?.temp?.toInt().toString(), - list - ) - } catch (e: Exception) { - - null - } - } fun getBitmapFromUrl(imageAddress: String?): Bitmap? { return try { @@ -128,5 +102,14 @@ class ServicesHelper( fun isEnabled() = settingsRepository.isNotificationsEnabled() + fun getWidgetBackground(): Int { + return if (settingsRepository.isBlackBackground()){ + Color.BLACK + }else{ + Color.TRANSPARENT + } + } + + fun setFirstTimer() = settingsRepository.setFirstTime() } \ No newline at end of file diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/BaseFragment.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/BaseFragment.kt similarity index 83% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/BaseFragment.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/ui/BaseFragment.kt index f4e529b..a748605 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/BaseFragment.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/BaseFragment.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.ui +package com.appttude.h_mal.atlas_weather.ui import android.annotation.SuppressLint import android.content.pm.PackageManager @@ -6,10 +6,10 @@ import android.view.View import androidx.core.app.ActivityCompat import androidx.fragment.app.Fragment import androidx.lifecycle.Observer -import com.appttude.h_mal.atlas_weather.mvvm.utils.Event -import com.appttude.h_mal.atlas_weather.mvvm.utils.displayToast -import com.appttude.h_mal.atlas_weather.mvvm.utils.hide -import com.appttude.h_mal.atlas_weather.mvvm.utils.show +import com.appttude.h_mal.atlas_weather.utils.Event +import com.appttude.h_mal.atlas_weather.utils.displayToast +import com.appttude.h_mal.atlas_weather.utils.hide +import com.appttude.h_mal.atlas_weather.utils.show import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/MainActivity.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/MainActivity.kt similarity index 92% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/MainActivity.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/ui/MainActivity.kt index 8562012..32dbae5 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/MainActivity.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/MainActivity.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.ui +package com.appttude.h_mal.atlas_weather.ui import android.content.Intent import android.os.Bundle @@ -10,8 +10,8 @@ import androidx.navigation.ui.AppBarConfiguration import androidx.navigation.ui.setupActionBarWithNavController import androidx.navigation.ui.setupWithNavController import com.appttude.h_mal.atlas_weather.R -import com.appttude.h_mal.atlas_weather.mvvm.ui.home.BaseActivity -import com.appttude.h_mal.atlas_weather.mvvm.ui.settings.UnitSettingsActivity +import com.appttude.h_mal.atlas_weather.ui.home.BaseActivity +import com.appttude.h_mal.atlas_weather.ui.settings.UnitSettingsActivity import com.google.android.material.bottomnavigation.BottomNavigationView import kotlinx.android.synthetic.main.activity_main_navigation.* diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/WeatherRecyclerAdapter.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/WeatherRecyclerAdapter.kt similarity index 94% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/WeatherRecyclerAdapter.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/ui/WeatherRecyclerAdapter.kt index d45567b..d5d5386 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/WeatherRecyclerAdapter.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/WeatherRecyclerAdapter.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.ui +package com.appttude.h_mal.atlas_weather.ui import android.view.View import android.view.ViewGroup @@ -6,10 +6,10 @@ import android.widget.ImageView import android.widget.TextView import androidx.recyclerview.widget.RecyclerView import com.appttude.h_mal.atlas_weather.R -import com.appttude.h_mal.atlas_weather.mvvm.model.forecast.Forecast -import com.appttude.h_mal.atlas_weather.mvvm.model.forecast.WeatherDisplay -import com.appttude.h_mal.atlas_weather.mvvm.utils.generateView -import com.appttude.h_mal.atlas_weather.mvvm.utils.loadImage +import com.appttude.h_mal.atlas_weather.model.forecast.Forecast +import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay +import com.appttude.h_mal.atlas_weather.utils.generateView +import com.appttude.h_mal.atlas_weather.utils.loadImage class WeatherRecyclerAdapter( val itemClick: (Forecast) -> Unit diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/WorldItemFragment.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/WorldItemFragment.kt similarity index 88% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/WorldItemFragment.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/ui/WorldItemFragment.kt index c151504..60e6c46 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/WorldItemFragment.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/WorldItemFragment.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.ui +package com.appttude.h_mal.atlas_weather.ui import android.os.Bundle import android.view.LayoutInflater @@ -7,8 +7,8 @@ import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager import com.appttude.h_mal.atlas_weather.R -import com.appttude.h_mal.atlas_weather.mvvm.model.forecast.WeatherDisplay -import com.appttude.h_mal.atlas_weather.mvvm.utils.navigateTo +import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay +import com.appttude.h_mal.atlas_weather.utils.navigateTo import kotlinx.android.synthetic.main.fragment_main.* diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/details/FurtherInfoFragment.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/details/FurtherInfoFragment.kt similarity index 67% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/details/FurtherInfoFragment.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/ui/details/FurtherInfoFragment.kt index fe0eeea..21f7853 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/details/FurtherInfoFragment.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/details/FurtherInfoFragment.kt @@ -1,13 +1,12 @@ -package com.appttude.h_mal.atlas_weather.mvvm.ui.details +package com.appttude.h_mal.atlas_weather.ui.details import android.os.Bundle -import android.os.Parcelable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import com.appttude.h_mal.atlas_weather.R -import com.appttude.h_mal.atlas_weather.mvvm.model.forecast.Forecast +import com.appttude.h_mal.atlas_weather.model.forecast.Forecast import kotlinx.android.synthetic.main.activity_further_info.* @@ -42,21 +41,4 @@ class FurtherInfoFragment : Fragment() { sunrisetext.text = param1?.sunrise sunsettext.text = param1?.sunset } - - companion object { - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param param1 Parameter 1. - * @return A new instance of fragment FurtherInfoFragment. - */ - @JvmStatic - fun newInstance(param1: Parcelable) = - FurtherInfoFragment().apply { - arguments = Bundle().apply { - putParcelable(WEATHER, param1) - } - } - } } \ No newline at end of file diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/home/BaseActivity.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/home/BaseActivity.kt similarity index 93% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/home/BaseActivity.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/ui/home/BaseActivity.kt index e4e8939..235c0cb 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/home/BaseActivity.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/home/BaseActivity.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.ui.home +package com.appttude.h_mal.atlas_weather.ui.home import android.annotation.SuppressLint import android.content.pm.PackageManager diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/home/HomeFragment.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/home/HomeFragment.kt similarity index 85% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/home/HomeFragment.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/ui/home/HomeFragment.kt index 598eae0..5259b0c 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/home/HomeFragment.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.ui.home +package com.appttude.h_mal.atlas_weather.ui.home import android.Manifest import android.annotation.SuppressLint @@ -12,13 +12,13 @@ import androidx.fragment.app.activityViewModels import androidx.lifecycle.observe import androidx.recyclerview.widget.LinearLayoutManager import com.appttude.h_mal.atlas_weather.R -import com.appttude.h_mal.atlas_weather.mvvm.application.LOCATION_PERMISSION_REQUEST -import com.appttude.h_mal.atlas_weather.mvvm.ui.BaseFragment -import com.appttude.h_mal.atlas_weather.mvvm.ui.WeatherRecyclerAdapter -import com.appttude.h_mal.atlas_weather.mvvm.utils.displayToast -import com.appttude.h_mal.atlas_weather.mvvm.utils.navigateTo -import com.appttude.h_mal.atlas_weather.mvvm.viewmodel.ApplicationViewModelFactory -import com.appttude.h_mal.atlas_weather.mvvm.viewmodel.MainViewModel +import com.appttude.h_mal.atlas_weather.application.LOCATION_PERMISSION_REQUEST +import com.appttude.h_mal.atlas_weather.ui.BaseFragment +import com.appttude.h_mal.atlas_weather.ui.WeatherRecyclerAdapter +import com.appttude.h_mal.atlas_weather.utils.displayToast +import com.appttude.h_mal.atlas_weather.utils.navigateTo +import com.appttude.h_mal.atlas_weather.viewmodel.ApplicationViewModelFactory +import com.appttude.h_mal.atlas_weather.viewmodel.MainViewModel import kotlinx.android.synthetic.main.activity_add_forecast.* import kotlinx.android.synthetic.main.fragment_main.* import org.kodein.di.KodeinAware diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/settings/UnitSettingsActivity.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/settings/UnitSettingsActivity.kt similarity index 78% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/settings/UnitSettingsActivity.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/ui/settings/UnitSettingsActivity.kt index 56ad171..034eab0 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/settings/UnitSettingsActivity.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/settings/UnitSettingsActivity.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.ui.settings +package com.appttude.h_mal.atlas_weather.ui.settings import android.app.AlarmManager import android.app.PendingIntent @@ -10,9 +10,9 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener import android.os.Bundle import android.preference.PreferenceActivity import android.preference.PreferenceFragment -import android.preference.PreferenceManager +import androidx.preference.PreferenceManager import com.appttude.h_mal.atlas_weather.R -import com.appttude.h_mal.atlas_weather.notifcation.NotificationReceiver +import com.appttude.h_mal.atlas_weather.notification.NotificationReceiver import com.appttude.h_mal.atlas_weather.widget.NewAppWidget import java.util.* @@ -27,7 +27,7 @@ class UnitSettingsActivity : PreferenceActivity() { //listener on changed sort order preference: val prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext) - prefListener = OnSharedPreferenceChangeListener { prefs, key -> + prefListener = OnSharedPreferenceChangeListener { _, key -> if (key == "temp_units") { val intent = Intent(baseContext, NewAppWidget::class.java) intent.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE @@ -38,6 +38,15 @@ class UnitSettingsActivity : PreferenceActivity() { if (key == "notif_boolean") { setupNotificationBroadcaster(baseContext) } + + if (key == "widget_black_background"){ + val intent = Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE) + val widgetManager = AppWidgetManager.getInstance(this) + val ids = widgetManager.getAppWidgetIds(ComponentName(this, NewAppWidget::class.java)) + AppWidgetManager.getInstance(this).notifyAppWidgetViewDataChanged(ids, R.id.whole_widget_view) + intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids) + sendBroadcast(intent) + } } prefs.registerOnSharedPreferenceChangeListener(prefListener) } @@ -51,7 +60,7 @@ class UnitSettingsActivity : PreferenceActivity() { cal.set(Calendar.HOUR_OF_DAY, 6) cal.set(Calendar.MINUTE, 8) cal.set(Calendar.SECOND, 5) - alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), AlarmManager.INTERVAL_DAY, broadcast) + alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, cal.timeInMillis, AlarmManager.INTERVAL_DAY, broadcast) } override fun onBackPressed() { diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/world/AddLocationFragment.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/world/AddLocationFragment.kt similarity index 82% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/world/AddLocationFragment.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/ui/world/AddLocationFragment.kt index 9865d20..fab3591 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/world/AddLocationFragment.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/world/AddLocationFragment.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.ui.world +package com.appttude.h_mal.atlas_weather.ui.world import android.os.Bundle import android.view.LayoutInflater @@ -7,11 +7,11 @@ import android.view.ViewGroup import androidx.fragment.app.viewModels import androidx.lifecycle.observe import com.appttude.h_mal.atlas_weather.R -import com.appttude.h_mal.atlas_weather.mvvm.ui.BaseFragment -import com.appttude.h_mal.atlas_weather.mvvm.utils.displayToast -import com.appttude.h_mal.atlas_weather.mvvm.utils.goBack -import com.appttude.h_mal.atlas_weather.mvvm.viewmodel.ApplicationViewModelFactory -import com.appttude.h_mal.atlas_weather.mvvm.viewmodel.WorldViewModel +import com.appttude.h_mal.atlas_weather.ui.BaseFragment +import com.appttude.h_mal.atlas_weather.utils.displayToast +import com.appttude.h_mal.atlas_weather.utils.goBack +import com.appttude.h_mal.atlas_weather.viewmodel.ApplicationViewModelFactory +import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel import kotlinx.android.synthetic.main.activity_add_forecast.* import org.kodein.di.KodeinAware import org.kodein.di.android.x.kodein diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/world/WorldFragment.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/world/WorldFragment.kt similarity index 86% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/world/WorldFragment.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/ui/world/WorldFragment.kt index e28b98f..a1c1011 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/world/WorldFragment.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/world/WorldFragment.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.ui.world +package com.appttude.h_mal.atlas_weather.ui.world import android.os.Bundle import android.view.LayoutInflater @@ -9,10 +9,10 @@ import androidx.fragment.app.viewModels import androidx.lifecycle.observe import androidx.recyclerview.widget.LinearLayoutManager import com.appttude.h_mal.atlas_weather.R -import com.appttude.h_mal.atlas_weather.mvvm.ui.BaseFragment -import com.appttude.h_mal.atlas_weather.mvvm.utils.navigateTo -import com.appttude.h_mal.atlas_weather.mvvm.viewmodel.ApplicationViewModelFactory -import com.appttude.h_mal.atlas_weather.mvvm.viewmodel.WorldViewModel +import com.appttude.h_mal.atlas_weather.ui.BaseFragment +import com.appttude.h_mal.atlas_weather.utils.navigateTo +import com.appttude.h_mal.atlas_weather.viewmodel.ApplicationViewModelFactory +import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel import kotlinx.android.synthetic.main.fragment_add_location.* import org.kodein.di.KodeinAware import org.kodein.di.android.x.kodein diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/world/WorldRecyclerAdapter.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/world/WorldRecyclerAdapter.kt similarity index 92% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/world/WorldRecyclerAdapter.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/ui/world/WorldRecyclerAdapter.kt index 46d55ad..f52740f 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/ui/world/WorldRecyclerAdapter.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/world/WorldRecyclerAdapter.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.ui.world +package com.appttude.h_mal.atlas_weather.ui.world import android.view.View import android.view.ViewGroup @@ -6,9 +6,9 @@ import android.widget.ImageView import android.widget.TextView import androidx.recyclerview.widget.RecyclerView import com.appttude.h_mal.atlas_weather.R -import com.appttude.h_mal.atlas_weather.mvvm.model.forecast.WeatherDisplay -import com.appttude.h_mal.atlas_weather.mvvm.utils.generateView -import com.appttude.h_mal.atlas_weather.mvvm.utils.loadImage +import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay +import com.appttude.h_mal.atlas_weather.utils.generateView +import com.appttude.h_mal.atlas_weather.utils.loadImage class WorldRecyclerAdapter( val itemClick: (WeatherDisplay) -> Unit diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/utils/Event.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/Event.kt similarity index 90% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/utils/Event.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/utils/Event.kt index d7e741d..b7040b5 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/utils/Event.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/Event.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.utils +package com.appttude.h_mal.atlas_weather.utils /** * Used with livedata to make observation lifecycle aware diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/utils/NavigationUtils.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/NavigationUtils.kt similarity index 92% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/utils/NavigationUtils.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/utils/NavigationUtils.kt index 24dbbbf..f66a0cb 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/utils/NavigationUtils.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/NavigationUtils.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.utils +package com.appttude.h_mal.atlas_weather.utils import android.view.View import androidx.fragment.app.Fragment diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/SecondsToDateUtils.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/SecondsToDateUtils.kt new file mode 100644 index 0000000..7f895ce --- /dev/null +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/SecondsToDateUtils.kt @@ -0,0 +1,63 @@ +package com.appttude.h_mal.atlas_weather.utils + + +import android.os.Build +import java.text.SimpleDateFormat +import java.time.Instant +import java.time.LocalDate +import java.time.OffsetTime +import java.time.ZoneOffset +import java.time.format.DateTimeFormatter +import java.time.temporal.ChronoUnit +import java.util.* + +fun Int.toDayString(): String { + return try { + val date = Date(this.makeMilliseconds()) + val format = SimpleDateFormat("MMM d", Locale.getDefault()) + format.format(date) + } catch (e: Exception) { + e.printStackTrace() + "Unable to parse date" + } +} + +fun Int.makeMilliseconds(): Long = this * 1000L + +fun Int.toDayName(): String { + return try { + val date = Date(this.makeMilliseconds()) + val format = SimpleDateFormat("EEEE", Locale.getDefault()) + format.format(date) + } catch (e: Exception) { + e.printStackTrace() + "Unable to parse date" + } +} + +fun Int.toSmallDayName(): String { + return try { + val date = Date(this.makeMilliseconds()) + val format = SimpleDateFormat("EEE", Locale.getDefault()) + format.format(date) + } catch (e: Exception) { + e.printStackTrace() + "Unable to parse date" + } +} + +fun Int?.toTime(): String? { + return this?.makeMilliseconds()?.let { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + OffsetTime.ofInstant(Instant.ofEpochMilli(it), ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("HH:mm")) + } else { + val date = Date(it) + val format = SimpleDateFormat("HH:mm", Locale.getDefault()) + format.format(date) + } + } +} + + + + diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/utils/ViewUtils.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/ViewUtils.kt similarity index 96% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/utils/ViewUtils.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/utils/ViewUtils.kt index 593c7f0..ef7b510 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/utils/ViewUtils.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/ViewUtils.kt @@ -1,4 +1,4 @@ -package com.appttude.h_mal.atlas_weather.mvvm.utils +package com.appttude.h_mal.atlas_weather.utils import android.content.Context import android.view.LayoutInflater diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/ApplicationViewModelFactory.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/ApplicationViewModelFactory.kt similarity index 77% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/ApplicationViewModelFactory.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/ApplicationViewModelFactory.kt index 3ce43aa..6f610f3 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/ApplicationViewModelFactory.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/ApplicationViewModelFactory.kt @@ -1,9 +1,9 @@ -package com.appttude.h_mal.atlas_weather.mvvm.viewmodel +package com.appttude.h_mal.atlas_weather.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.location.LocationProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.repository.RepositoryImpl +import com.appttude.h_mal.atlas_weather.data.location.LocationProvider +import com.appttude.h_mal.atlas_weather.data.repository.RepositoryImpl class ApplicationViewModelFactory( private val locationProvider: LocationProvider, diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/MainViewModel.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/MainViewModel.kt similarity index 81% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/MainViewModel.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/MainViewModel.kt index de87481..b430b89 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/MainViewModel.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/MainViewModel.kt @@ -1,15 +1,15 @@ -package com.appttude.h_mal.atlas_weather.mvvm.viewmodel +package com.appttude.h_mal.atlas_weather.viewmodel import android.Manifest import androidx.annotation.RequiresPermission import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -import com.appttude.h_mal.atlas_weather.mvvm.data.location.LocationProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.repository.Repository -import com.appttude.h_mal.atlas_weather.mvvm.data.room.entity.CURRENT_LOCATION -import com.appttude.h_mal.atlas_weather.mvvm.model.forecast.WeatherDisplay -import com.appttude.h_mal.atlas_weather.mvvm.model.weather.Current -import com.appttude.h_mal.atlas_weather.mvvm.utils.Event +import com.appttude.h_mal.atlas_weather.data.location.LocationProvider +import com.appttude.h_mal.atlas_weather.data.repository.Repository +import com.appttude.h_mal.atlas_weather.data.room.entity.CURRENT_LOCATION +import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay +import com.appttude.h_mal.atlas_weather.model.weather.Current +import com.appttude.h_mal.atlas_weather.utils.Event import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/MainViewModelFactory.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/MainViewModelFactory.kt similarity index 72% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/MainViewModelFactory.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/MainViewModelFactory.kt index 97ac848..ade91f4 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/MainViewModelFactory.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/MainViewModelFactory.kt @@ -1,9 +1,9 @@ -package com.appttude.h_mal.atlas_weather.mvvm.viewmodel +package com.appttude.h_mal.atlas_weather.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.location.LocationProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.repository.RepositoryImpl +import com.appttude.h_mal.atlas_weather.data.location.LocationProvider +import com.appttude.h_mal.atlas_weather.data.repository.RepositoryImpl class MainViewModelFactory( private val locationProvider: LocationProvider, diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/WorldViewModel.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/WorldViewModel.kt similarity index 87% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/WorldViewModel.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/WorldViewModel.kt index 23e78a7..5ceff18 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/WorldViewModel.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/WorldViewModel.kt @@ -1,13 +1,13 @@ -package com.appttude.h_mal.atlas_weather.mvvm.viewmodel +package com.appttude.h_mal.atlas_weather.viewmodel import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -import com.appttude.h_mal.atlas_weather.mvvm.data.location.LocationProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.repository.Repository -import com.appttude.h_mal.atlas_weather.mvvm.data.room.entity.EntityItem -import com.appttude.h_mal.atlas_weather.mvvm.model.forecast.WeatherDisplay -import com.appttude.h_mal.atlas_weather.mvvm.model.weather.FullWeather -import com.appttude.h_mal.atlas_weather.mvvm.utils.Event +import com.appttude.h_mal.atlas_weather.data.location.LocationProvider +import com.appttude.h_mal.atlas_weather.data.repository.Repository +import com.appttude.h_mal.atlas_weather.data.room.entity.EntityItem +import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay +import com.appttude.h_mal.atlas_weather.model.weather.FullWeather +import com.appttude.h_mal.atlas_weather.utils.Event import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/WorldViewModelFactory.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/WorldViewModelFactory.kt similarity index 72% rename from app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/WorldViewModelFactory.kt rename to app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/WorldViewModelFactory.kt index bded1ae..c8bcee7 100644 --- a/app/src/main/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/WorldViewModelFactory.kt +++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/WorldViewModelFactory.kt @@ -1,9 +1,9 @@ -package com.appttude.h_mal.atlas_weather.mvvm.viewmodel +package com.appttude.h_mal.atlas_weather.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.location.LocationProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.repository.RepositoryImpl +import com.appttude.h_mal.atlas_weather.data.location.LocationProvider +import com.appttude.h_mal.atlas_weather.data.repository.RepositoryImpl class WorldViewModelFactory( private val locationProvider: LocationProvider, diff --git a/app/src/main/res/layout/activity_further_info.xml b/app/src/main/res/layout/activity_further_info.xml index 990e43b..e54df45 100644 --- a/app/src/main/res/layout/activity_further_info.xml +++ b/app/src/main/res/layout/activity_further_info.xml @@ -3,8 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".legacy.ui.FurtherInfoActivity"> + android:layout_height="match_parent"> - + android:layout_weight="1"> + + + - @@ -66,14 +63,14 @@ @@ -84,14 +81,14 @@ @@ -106,14 +103,16 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:layout_weight="1"> + + + - @@ -155,14 +150,16 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:layout_weight="1"> + + + - @@ -207,14 +200,14 @@ @@ -229,14 +222,16 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:layout_weight="1"> + + + - @@ -282,14 +273,14 @@ @@ -300,14 +291,14 @@ diff --git a/app/src/main/res/layout/list_item3.xml b/app/src/main/res/layout/list_item3.xml index 9cb782d..cf3f40e 100644 --- a/app/src/main/res/layout/list_item3.xml +++ b/app/src/main/res/layout/list_item3.xml @@ -15,11 +15,8 @@ android:layout_weight="1"> + style="@style/icon_style__further_deatils" /> - - + android:layout_height="wrap_content" + android:layout_weight="1"> + android:layout_height="wrap_content" + android:layout_weight="1"> @@ -99,11 +92,8 @@ android:layout_weight="1"> + style="@style/icon_style__further_deatils" + android:src="@drawable/water_drop" /> - - @@ -153,14 +137,14 @@ @@ -183,12 +167,8 @@ android:layout_weight="1"> + style="@style/icon_style__further_deatils" + android:src="@drawable/cloud_symbol" /> - - diff --git a/app/src/main/res/layout/list_item4.xml b/app/src/main/res/layout/list_item4.xml index 960cf36..83247cf 100644 --- a/app/src/main/res/layout/list_item4.xml +++ b/app/src/main/res/layout/list_item4.xml @@ -28,7 +28,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:textColor="@color/colour_five" - android:textSize="28sp" + android:textSize="22sp" tools:text="Brisbane" /> diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index fef68be..e4244dc 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -6,5 +6,6 @@ android:id="@+id/action_settings" android:orderInCategory="100" android:title="@string/action_settings" + android:icon="@android:drawable/ic_menu_preferences" app:showAsAction="ifRoom" /> diff --git a/app/src/main/res/navigation/main_navigation.xml b/app/src/main/res/navigation/main_navigation.xml index 9f26260..27b1a2d 100644 --- a/app/src/main/res/navigation/main_navigation.xml +++ b/app/src/main/res/navigation/main_navigation.xml @@ -8,7 +8,7 @@ + app:argType="com.appttude.h_mal.atlas_weather.model.forecast.Forecast" /> + app:argType="com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay" /> \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index a59132e..a87ec58 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -45,4 +45,12 @@ 32sp + + diff --git a/app/src/main/res/xml/prefs.xml b/app/src/main/res/xml/prefs.xml index 6144ad5..25afebd 100644 --- a/app/src/main/res/xml/prefs.xml +++ b/app/src/main/res/xml/prefs.xml @@ -33,4 +33,10 @@ android:key="notif_boolean" android:title="Notification" /> + + + \ No newline at end of file diff --git a/app/src/test/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/RepositoryImplTest.kt b/app/src/test/java/com/appttude/h_mal/atlas_weather/data/repository/RepositoryImplTest.kt similarity index 86% rename from app/src/test/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/RepositoryImplTest.kt rename to app/src/test/java/com/appttude/h_mal/atlas_weather/data/repository/RepositoryImplTest.kt index d9d8cf7..c234934 100644 --- a/app/src/test/java/com/appttude/h_mal/atlas_weather/mvvm/data/repository/RepositoryImplTest.kt +++ b/app/src/test/java/com/appttude/h_mal/atlas_weather/data/repository/RepositoryImplTest.kt @@ -1,8 +1,8 @@ -package com.appttude.h_mal.atlas_weather.mvvm.data.repository +package com.appttude.h_mal.atlas_weather.data.repository -import com.appttude.h_mal.atlas_weather.mvvm.data.network.WeatherApi -import com.appttude.h_mal.atlas_weather.mvvm.data.prefs.PreferenceProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.room.AppDatabase +import com.appttude.h_mal.atlas_weather.data.network.WeatherApi +import com.appttude.h_mal.atlas_weather.data.prefs.PreferenceProvider +import com.appttude.h_mal.atlas_weather.data.room.AppDatabase import io.mockk.MockKAnnotations import io.mockk.every import io.mockk.impl.annotations.MockK diff --git a/app/src/test/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/MainViewModelTest.kt b/app/src/test/java/com/appttude/h_mal/atlas_weather/viewmodel/MainViewModelTest.kt similarity index 80% rename from app/src/test/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/MainViewModelTest.kt rename to app/src/test/java/com/appttude/h_mal/atlas_weather/viewmodel/MainViewModelTest.kt index 597fc0c..805dddf 100644 --- a/app/src/test/java/com/appttude/h_mal/atlas_weather/mvvm/viewmodel/MainViewModelTest.kt +++ b/app/src/test/java/com/appttude/h_mal/atlas_weather/viewmodel/MainViewModelTest.kt @@ -1,13 +1,13 @@ -package com.appttude.h_mal.atlas_weather.mvvm.viewmodel +package com.appttude.h_mal.atlas_weather.viewmodel import androidx.arch.core.executor.testing.InstantTaskExecutorRule import androidx.lifecycle.LiveData import androidx.lifecycle.Observer -import com.appttude.h_mal.atlas_weather.mvvm.data.location.LocationProvider -import com.appttude.h_mal.atlas_weather.mvvm.data.network.response.forecast.WeatherResponse -import com.appttude.h_mal.atlas_weather.mvvm.data.repository.Repository -import com.appttude.h_mal.atlas_weather.mvvm.data.room.entity.EntityItem -import com.appttude.h_mal.atlas_weather.mvvm.utils.Event +import com.appttude.h_mal.atlas_weather.data.location.LocationProvider +import com.appttude.h_mal.atlas_weather.data.network.response.forecast.WeatherResponse +import com.appttude.h_mal.atlas_weather.data.repository.Repository +import com.appttude.h_mal.atlas_weather.data.room.entity.EntityItem +import com.appttude.h_mal.atlas_weather.utils.Event import io.mockk.MockKAnnotations import io.mockk.coEvery import io.mockk.every