- Changed package layout

- added black background feature to Widget
 - Update to MyWidgetRemoteViewsFactory.kt
This commit is contained in:
2020-11-28 22:09:05 +00:00
parent 4db91cd3c1
commit a84a8bcb40
62 changed files with 364 additions and 467 deletions

View File

@@ -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

View File

@@ -16,14 +16,14 @@
android:required="true" />
<application
android:name=".mvvm.application.AppClass"
android:name="com.appttude.h_mal.atlas_weather.application.AppClass"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".mvvm.ui.MainActivity"
<activity android:name="com.appttude.h_mal.atlas_weather.ui.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/AppTheme.NoActionBar">
@@ -35,8 +35,12 @@
</intent-filter>
</activity>
<activity
android:name="com.appttude.h_mal.atlas_weather.ui.settings.UnitSettingsActivity"
android:label="Settings" />
<receiver
android:name=".notifcation.NotificationReceiver"
android:name=".notification.NotificationReceiver"
android:parentActivityName="com.appttude.h_mal.atlas_weather.MainActivity" />
<receiver android:name=".widget.NewAppWidget">

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)
}
}

View File

@@ -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 {

View File

@@ -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(

View File

@@ -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
}

View File

@@ -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()
}

View File

@@ -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
version = 1,
exportSchema = false
)
@TypeConverters(Converter::class)
abstract class AppDatabase : RoomDatabase() {

View File

@@ -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

View File

@@ -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 {

View File

@@ -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"

View File

@@ -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(),

View File

@@ -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(

View File

@@ -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,

View File

@@ -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(

View File

@@ -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,

View File

@@ -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

View File

@@ -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
}
}

View File

@@ -1,4 +1,4 @@
package com.appttude.h_mal.atlas_weather.notifcation
package com.appttude.h_mal.atlas_weather.notification
import android.graphics.Bitmap

View File

@@ -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()
}

View File

@@ -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

View File

@@ -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.*

View File

@@ -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

View File

@@ -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.*

View File

@@ -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)
}
}
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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() {

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,4 +1,4 @@
package com.appttude.h_mal.atlas_weather.mvvm.utils
package com.appttude.h_mal.atlas_weather.utils
/**
* Used with livedata<T> to make observation lifecycle aware

View File

@@ -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

View File

@@ -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)
}
}
}

View File

@@ -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

View File

@@ -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,

View File

@@ -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

View File

@@ -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,

View File

@@ -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

View File

@@ -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,

View File

@@ -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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -14,14 +13,16 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/thermom"
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_margin="12dp"
android:layout_weight="1"
android:tint="@color/colour_five"
app:srcCompat="@drawable/somethingnew" />
android:layout_weight="1">
<ImageView
android:src="@drawable/somethingnew"
style="@style/icon_style__further_deatils" />
</FrameLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
@@ -30,10 +31,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="0dp"
@@ -48,14 +45,14 @@
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="Maximum: " />
<TextView
android:id="@+id/maxtemp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="85%"
android:textColor="#000000" />
</LinearLayout>
@@ -66,14 +63,14 @@
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="Average: " />
<TextView
android:id="@+id/averagetemp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="11mm"
android:textColor="#000000" />
</LinearLayout>
@@ -84,14 +81,14 @@
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="Minimum: " />
<TextView
android:id="@+id/minimumtemp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="11mm"
android:textColor="#000000" />
</LinearLayout>
@@ -106,14 +103,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_margin="12dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:layout_weight="1">
<ImageView
android:src="@drawable/breeze"
android:tint="@color/colour_five" />
style="@style/icon_style__further_deatils" />
</FrameLayout>
<RelativeLayout
android:layout_weight="2"
android:layout_width="0dp"
@@ -123,10 +122,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="0dp"
@@ -137,14 +132,14 @@
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="Wind: " />
<TextView
android:id="@+id/windtext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="7mph"
android:textColor="#000000" />
</LinearLayout>
@@ -155,14 +150,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_margin="12dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:layout_weight="1">
<ImageView
android:src="@drawable/water_drop"
android:tint="@color/colour_five" />
style="@style/icon_style__further_deatils" />
</FrameLayout>
<RelativeLayout
android:layout_weight="2"
android:layout_width="0dp"
@@ -171,10 +168,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="0dp"
@@ -189,14 +182,14 @@
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="Humidity: " />
<TextView
android:id="@+id/humiditytext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="85%"
android:textColor="#000000" />
</LinearLayout>
@@ -207,14 +200,14 @@
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="Precipitation: " />
<TextView
android:id="@+id/preciptext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="11mm"
android:textColor="#000000" />
</LinearLayout>
@@ -229,14 +222,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_margin="12dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:layout_weight="1">
<ImageView
android:src="@drawable/sunrise"
android:tint="@color/colour_five" />
style="@style/icon_style__further_deatils" />
</FrameLayout>
<RelativeLayout
android:layout_weight="2"
android:layout_width="0dp"
@@ -245,10 +240,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="0dp"
@@ -263,14 +254,14 @@
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="UV: " />
<TextView
android:id="@+id/uvtext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="7"
android:textColor="#000000" />
</LinearLayout>
@@ -282,14 +273,14 @@
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="Sunrise:" />
<TextView
android:id="@+id/sunrisetext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="05:30am"
android:textColor="#000000" />
</LinearLayout>
@@ -300,14 +291,14 @@
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="Sunset:" />
<TextView
android:id="@+id/sunsettext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="06:12pm"
android:textColor="#000000" />
</LinearLayout>

View File

@@ -15,11 +15,8 @@
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:src="@drawable/breeze"
android:tint="@color/colour_five" />
style="@style/icon_style__further_deatils" />
</FrameLayout>
<RelativeLayout
@@ -32,51 +29,47 @@
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="Speed:" />
<TextView
android:id="@+id/windspeed"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="11kmp"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="Direction:" />
<TextView
android:id="@+id/winddirection"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="SW"
android:textColor="#000000" />
</LinearLayout>
@@ -99,11 +92,8 @@
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:src="@drawable/water_drop"
android:tint="@color/colour_five" />
style="@style/icon_style__further_deatils"
android:src="@drawable/water_drop" />
</FrameLayout>
<RelativeLayout
@@ -116,15 +106,9 @@
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical">
<LinearLayout
@@ -134,14 +118,14 @@
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="Humidity: " />
<TextView
android:id="@+id/humidity_"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="85%"
android:textColor="#000000" />
</LinearLayout>
@@ -153,14 +137,14 @@
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="Precipitation: " />
<TextView
android:id="@+id/precip_"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="11mm"
android:textColor="#000000" />
</LinearLayout>
@@ -183,12 +167,8 @@
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:backgroundTint="#000000"
android:src="@drawable/cloud_symbol"
android:tint="@color/colour_five" />
style="@style/icon_style__further_deatils"
android:src="@drawable/cloud_symbol" />
</FrameLayout>
<RelativeLayout
@@ -201,11 +181,6 @@
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
@@ -219,14 +194,14 @@
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:text="Clouds: " />
<TextView
android:id="@+id/clouds_"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="3"
android:text="85%"
android:textColor="#000000" />
</LinearLayout>

View File

@@ -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" />
</LinearLayout>

View File

@@ -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" />
</menu>

View File

@@ -8,7 +8,7 @@
<fragment
android:id="@+id/nav_home"
android:name="com.appttude.h_mal.atlas_weather.mvvm.ui.home.HomeFragment"
android:name="com.appttude.h_mal.atlas_weather.ui.home.HomeFragment"
android:label="Home"
tools:layout="@layout/fragment_home">
<action
@@ -22,16 +22,16 @@
<fragment
android:id="@+id/furtherDetailsFragment"
android:name="com.appttude.h_mal.atlas_weather.mvvm.ui.details.FurtherInfoFragment"
android:name="com.appttude.h_mal.atlas_weather.ui.details.FurtherInfoFragment"
android:label="Further Details">
<argument
android:name="forecast"
app:argType="com.appttude.h_mal.atlas_weather.mvvm.model.forecast.Forecast" />
app:argType="com.appttude.h_mal.atlas_weather.model.forecast.Forecast" />
</fragment>
<fragment
android:id="@+id/nav_world"
android:name="com.appttude.h_mal.atlas_weather.mvvm.ui.world.WorldFragment"
android:name="com.appttude.h_mal.atlas_weather.ui.world.WorldFragment"
android:label="World"
tools:layout="@layout/fragment__two">
<action
@@ -51,12 +51,12 @@
</fragment>
<fragment
android:id="@+id/addLocationFragment"
android:name="com.appttude.h_mal.atlas_weather.mvvm.ui.world.AddLocationFragment"
android:name="com.appttude.h_mal.atlas_weather.ui.world.AddLocationFragment"
android:label="Add Weather Location"
tools:layout="@layout/activity_add_forecast" />
<fragment
android:id="@+id/worldItemFragment"
android:name="com.appttude.h_mal.atlas_weather.mvvm.ui.WorldItemFragment"
android:name="com.appttude.h_mal.atlas_weather.ui.WorldItemFragment"
android:label="Overview"
tools:layout="@layout/fragment_home">
<action
@@ -68,7 +68,7 @@
app:popExitAnim="@anim/fragment_open_exit" />
<argument
android:name="weatherDisplay"
app:argType="com.appttude.h_mal.atlas_weather.mvvm.model.forecast.WeatherDisplay" />
app:argType="com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay" />
</fragment>
</navigation>

View File

@@ -45,4 +45,12 @@
<item name="android:textSize">32sp</item>
</style>
<style name="icon_style__further_deatils">
<item name="android:layout_width">64dp</item>
<item name="android:layout_height">64dp</item>
<item name="android:adjustViewBounds">true</item>
<item name="android:layout_gravity">center</item>
<item name="android:tint">@color/colour_five</item>
</style>
</resources>

View File

@@ -33,4 +33,10 @@
android:key="notif_boolean"
android:title="Notification" />
</PreferenceCategory>
<PreferenceCategory android:title="Widget Settings">
<SwitchPreference
android:defaultValue="false"
android:key="widget_black_background"
android:title="Set widget background black" />
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -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

View File

@@ -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