diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 005fbc3..570321e 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/app/build.gradle b/app/build.gradle index 43043a1..023be3a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,8 +23,8 @@ android { applicationId "com.tommasoberlose.anotherwidget" minSdkVersion 23 targetSdkVersion 29 - versionCode 105 - versionName "2.0.13" + versionCode 106 + versionName "2.0.14" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" buildConfigField("String", "GOOGLE_API_KEY", apikeyProperties['GOOGLE_API_KEY']) diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/components/BottomSheetWeatherProviderSettings.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/components/BottomSheetWeatherProviderSettings.kt new file mode 100644 index 0000000..334e8b5 --- /dev/null +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/components/BottomSheetWeatherProviderSettings.kt @@ -0,0 +1,64 @@ +package com.tommasoberlose.anotherwidget.components + +import android.content.Context +import android.view.View +import androidx.core.view.isVisible +import com.google.android.material.bottomsheet.BottomSheetDialog +import com.tommasoberlose.anotherwidget.R +import com.tommasoberlose.anotherwidget.global.Constants +import com.tommasoberlose.anotherwidget.global.Preferences +import com.tommasoberlose.anotherwidget.helpers.WeatherHelper +import com.tommasoberlose.anotherwidget.utils.openURI +import kotlinx.android.synthetic.main.weather_provider_settings_layout.view.* + +class BottomSheetWeatherProviderSettings(context: Context, callback: () -> Unit) : BottomSheetDialog(context, R.style.BottomSheetDialogTheme) { + + init { + val view = View.inflate(context, R.layout.weather_provider_settings_layout, null) + view.api_key_container.isVisible = WeatherHelper.isKeyRequired() + view.action_save_key.isVisible = WeatherHelper.isKeyRequired() + + WeatherHelper.getProviderInfoTitle(context).let { title -> + view.info_title.text = title + view.info_title.isVisible = title != "" + } + + WeatherHelper.getProviderInfoSubtitle(context).let { subtitle -> + view.info_subtitle.text = subtitle + view.info_subtitle.isVisible = subtitle != "" + } + + view.info_provider.text = WeatherHelper.getProviderName(context) + + view.api_key.editText?.setText(when (Constants.WeatherProvider.fromInt(Preferences.weatherProvider)) { + Constants.WeatherProvider.OPEN_WEATHER -> Preferences.weatherProviderApiOpen + Constants.WeatherProvider.WEATHER_BIT -> Preferences.weatherProviderApiWeatherBit + Constants.WeatherProvider.WEATHER_API -> Preferences.weatherProviderApiWeatherApi + Constants.WeatherProvider.HERE -> Preferences.weatherProviderApiHere + Constants.WeatherProvider.ACCUWEATHER -> Preferences.weatherProviderApiAccuweather + Constants.WeatherProvider.WEATHER_GOV, + Constants.WeatherProvider.YR, + null -> "" + }) + + view.action_open_provider.setOnClickListener { + context.openURI(WeatherHelper.getProviderLink()) + } + + view.action_save_key.setOnClickListener { + val key = view.api_key.editText?.text.toString() + when (Constants.WeatherProvider.fromInt(Preferences.weatherProvider)) { + Constants.WeatherProvider.OPEN_WEATHER -> Preferences.weatherProviderApiOpen = key + Constants.WeatherProvider.WEATHER_BIT -> Preferences.weatherProviderApiWeatherBit = key + Constants.WeatherProvider.WEATHER_API -> Preferences.weatherProviderApiWeatherApi = key + Constants.WeatherProvider.HERE -> Preferences.weatherProviderApiHere = key + Constants.WeatherProvider.ACCUWEATHER -> Preferences.weatherProviderApiAccuweather = key + else -> {} + } + callback.invoke() + dismiss() + } + + setContentView(view) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/WeatherHelper.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/WeatherHelper.kt index 1346167..29e906d 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/WeatherHelper.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/WeatherHelper.kt @@ -3,6 +3,7 @@ package com.tommasoberlose.anotherwidget.helpers import android.Manifest import android.content.Context import android.os.Build +import android.util.Log import com.google.android.gms.location.LocationServices import com.tommasoberlose.anotherwidget.R import com.tommasoberlose.anotherwidget.global.Constants @@ -12,6 +13,9 @@ import com.tommasoberlose.anotherwidget.ui.fragments.MainFragment import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission import com.tommasoberlose.anotherwidget.utils.isDarkTheme +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch import org.greenrobot.eventbus.EventBus @@ -21,7 +25,7 @@ import org.greenrobot.eventbus.EventBus object WeatherHelper { - fun updateWeather(context: Context) { + suspend fun updateWeather(context: Context) { val networkApi = WeatherNetworkApi(context) if (Preferences.customLocationAdd != "") { networkApi.updateWeather() @@ -32,10 +36,17 @@ object WeatherHelper { if (location != null) { Preferences.customLocationLat = location.latitude.toString() Preferences.customLocationLon = location.longitude.toString() - - networkApi.updateWeather() - EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } + + CoroutineScope(Dispatchers.IO).launch { + networkApi.updateWeather() + } + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) + } else { + CoroutineScope(Dispatchers.IO).launch { + networkApi.updateWeather() + } + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } } @@ -48,7 +59,7 @@ object WeatherHelper { MainWidget.updateWidget(context) } - fun getProviderName(context: Context, provider: Constants.WeatherProvider): String { + fun getProviderName(context: Context, provider: Constants.WeatherProvider = Constants.WeatherProvider.fromInt(Preferences.weatherProvider)!!): String { return context.getString(when(provider) { Constants.WeatherProvider.OPEN_WEATHER -> R.string.settings_weather_provider_open_weather Constants.WeatherProvider.WEATHER_BIT -> R.string.settings_weather_provider_weatherbit @@ -60,21 +71,8 @@ object WeatherHelper { }) } - fun getProviderLinkName(context: Context): String { - return context.getString(when(Constants.WeatherProvider.fromInt(Preferences.weatherProvider)) { - Constants.WeatherProvider.OPEN_WEATHER -> R.string.action_open_provider_open_weather - Constants.WeatherProvider.WEATHER_BIT -> R.string.action_open_provider_weatherbit - Constants.WeatherProvider.WEATHER_API -> R.string.action_open_provider_weatherapi - Constants.WeatherProvider.HERE -> R.string.action_open_provider_here - Constants.WeatherProvider.ACCUWEATHER -> R.string.action_open_provider_accuweather - Constants.WeatherProvider.WEATHER_GOV -> R.string.action_open_provider_weather_gov - Constants.WeatherProvider.YR -> R.string.action_open_provider_yr - else -> R.string.nothing - }) - } - - fun getProviderInfoTitle(context: Context): String { - return context.getString(when(Constants.WeatherProvider.fromInt(Preferences.weatherProvider)) { + fun getProviderInfoTitle(context: Context, provider: Constants.WeatherProvider? = Constants.WeatherProvider.fromInt(Preferences.weatherProvider)!!): String { + return context.getString(when(provider) { Constants.WeatherProvider.OPEN_WEATHER -> R.string.weather_provider_info_open_weather_title Constants.WeatherProvider.WEATHER_BIT -> R.string.weather_provider_info_weatherbit_title Constants.WeatherProvider.WEATHER_API -> R.string.weather_provider_info_weatherapi_title @@ -86,8 +84,8 @@ object WeatherHelper { }) } - fun getProviderInfoSubtitle(context: Context): String { - return context.getString(when(Constants.WeatherProvider.fromInt(Preferences.weatherProvider)) { + fun getProviderInfoSubtitle(context: Context, provider: Constants.WeatherProvider? = Constants.WeatherProvider.fromInt(Preferences.weatherProvider)!!): String { + return context.getString(when(provider) { Constants.WeatherProvider.OPEN_WEATHER -> R.string.weather_provider_info_open_weather_subtitle Constants.WeatherProvider.WEATHER_BIT -> R.string.weather_provider_info_weatherbit_subtitle Constants.WeatherProvider.WEATHER_API -> R.string.weather_provider_info_weatherapi_subtitle @@ -99,20 +97,20 @@ object WeatherHelper { }) } - fun getProviderLink(): String { - return when(Constants.WeatherProvider.fromInt(Preferences.weatherProvider)) { - Constants.WeatherProvider.OPEN_WEATHER -> "https://home.openweathermap.org/users/sign_up" - Constants.WeatherProvider.WEATHER_BIT -> "https://www.weatherbit.io/account/create" - Constants.WeatherProvider.WEATHER_API -> "https://www.weatherapi.com/signup.aspx" - Constants.WeatherProvider.HERE -> "https://developer.here.com/sign-up?create=Freemium-Basic&keepState=true&step=account" - Constants.WeatherProvider.ACCUWEATHER -> "https://developer.accuweather.com/user/register" + fun getProviderLink(provider: Constants.WeatherProvider? = Constants.WeatherProvider.fromInt(Preferences.weatherProvider)!!): String { + return when(provider) { + Constants.WeatherProvider.OPEN_WEATHER -> "https://home.openweathermap.org/users/sign_in" + Constants.WeatherProvider.WEATHER_BIT -> "https://www.weatherbit.io/account/login" + Constants.WeatherProvider.WEATHER_API -> "https://www.weatherapi.com/login.aspx" + Constants.WeatherProvider.HERE -> "https://developer.here.com/login" + Constants.WeatherProvider.ACCUWEATHER -> "https://developer.accuweather.com/user/login" Constants.WeatherProvider.WEATHER_GOV -> "http://www.weather.gov/" Constants.WeatherProvider.YR -> "https://www.yr.no/" else -> "" } } - fun isKeyRequired(): Boolean = when (Constants.WeatherProvider.fromInt(Preferences.weatherProvider)) { + fun isKeyRequired(provider: Constants.WeatherProvider? = Constants.WeatherProvider.fromInt(Preferences.weatherProvider)!!): Boolean = when (provider) { Constants.WeatherProvider.OPEN_WEATHER, Constants.WeatherProvider.WEATHER_BIT, Constants.WeatherProvider.WEATHER_API, @@ -124,6 +122,17 @@ object WeatherHelper { else -> true } + fun getApiKey(provider: Constants.WeatherProvider? = Constants.WeatherProvider.fromInt(Preferences.weatherProvider)!!): String = when (provider) { + Constants.WeatherProvider.OPEN_WEATHER -> Preferences.weatherProviderApiOpen + Constants.WeatherProvider.WEATHER_BIT -> Preferences.weatherProviderApiWeatherBit + Constants.WeatherProvider.WEATHER_API -> Preferences.weatherProviderApiWeatherApi + Constants.WeatherProvider.HERE -> Preferences.weatherProviderApiHere + Constants.WeatherProvider.ACCUWEATHER -> Preferences.weatherProviderApiAccuweather + Constants.WeatherProvider.WEATHER_GOV -> "" + Constants.WeatherProvider.YR -> "" + else -> "" + } + fun getWeatherIconResource(context: Context, icon: String, style: Int = Preferences.weatherIconPack): Int { return when (icon) { "01d" -> { @@ -451,4 +460,50 @@ object WeatherHelper { 1282 -> "13" else -> "" } + if (isDaytime) "d" else "n" + + fun getYRIcon(iconCode: String, isDaytime: Boolean): String = when { + iconCode.contains("clearsky") -> "01" + iconCode.contains("cloudy") -> "04" + iconCode.contains("fair") -> "02" + iconCode.contains("fog") -> "82" + iconCode.contains("heavyrain") -> "10" + iconCode.contains("heavyrainandthunder") -> "11" + iconCode.contains("heavyrainshowers") -> "10" + iconCode.contains("heavyrainshowersandthunder") -> "11" + iconCode.contains("heavysleet") -> "10" + iconCode.contains("heavysleetandthunder") -> "11" + iconCode.contains("heavysleetshowers") -> "10" + iconCode.contains("heavysleetshowersandthunder") -> "11" + iconCode.contains("heavysnow") -> "13" + iconCode.contains("heavysnowandthunder") -> "13" + iconCode.contains("heavysnowshowers") -> "13" + iconCode.contains("heavysnowshowersandthunder") -> "13" + iconCode.contains("lightrain") -> "10" + iconCode.contains("lightrainandthunder") -> "11" + iconCode.contains("lightrainshowers") -> "10" + iconCode.contains("lightrainshowersandthunder") -> "11" + iconCode.contains("lightsleet") -> "10" + iconCode.contains("lightsleetandthunder") -> "11" + iconCode.contains("lightsleetshowers") -> "10" + iconCode.contains("lightsnow") -> "13" + iconCode.contains("lightsnowandthunder") -> "13" + iconCode.contains("lightsnowshowers") -> "13" + iconCode.contains("lightssleetshowersandthunder") -> "81" + iconCode.contains("lightssnowshowersandthunder") -> "81" + iconCode.contains("partlycloudy") -> "03" + iconCode.contains("rain") -> "10" + iconCode.contains("rainandthunder") -> "11" + iconCode.contains("rainshowers") -> "10" + iconCode.contains("rainshowersandthunder") -> "11" + iconCode.contains("sleet") -> "10" + iconCode.contains("sleetandthunder") -> "11" + iconCode.contains("sleetshowers") -> "10" + iconCode.contains("sleetshowersandthunder") -> "11" + iconCode.contains("snow") -> "13" + iconCode.contains("snowandthunder") -> "13" + iconCode.contains("snowshowers") -> "13" + iconCode.contains("snowshowersandthunder") -> "13" + else -> "" + } + if (isDaytime) "d" else "n" + } \ No newline at end of file diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/network/WeatherNetworkApi.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/network/WeatherNetworkApi.kt index ead423d..59d30fc 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/network/WeatherNetworkApi.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/network/WeatherNetworkApi.kt @@ -21,10 +21,12 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import org.greenrobot.eventbus.EventBus import java.lang.Exception +import java.text.SimpleDateFormat +import java.util.* class WeatherNetworkApi(val context: Context) { - fun updateWeather() { - Preferences.weatherProviderError = "" + suspend fun updateWeather() { + Preferences.weatherProviderError = "-" Preferences.weatherProviderLocationError = "" if (Preferences.showWeather && Preferences.customLocationLat != "" && Preferences.customLocationLon != "") { @@ -41,11 +43,13 @@ class WeatherNetworkApi(val context: Context) { WeatherHelper.removeWeather( context ) + + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } private fun useOpenWeatherMap(context: Context) { - if (Preferences.weatherProviderApiOpen != "" ) { + if (Preferences.weatherProviderApiOpen != "") { val helper = OpenWeatherMapHelper(Preferences.weatherProviderApiOpen) helper.setUnits(if (Preferences.weatherTempUnit == "F") Units.IMPERIAL else Units.METRIC) helper.getCurrentWeatherByGeoCoordinates(Preferences.customLocationLat.toDouble(), Preferences.customLocationLon.toDouble(), object : @@ -56,14 +60,18 @@ class WeatherNetworkApi(val context: Context) { Preferences.weatherIcon = currentWeather.weather[0].icon Preferences.weatherRealTempUnit = Preferences.weatherTempUnit MainWidget.updateWidget(context) - - EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } + + Preferences.weatherProviderError = "" + Preferences.weatherProviderLocationError = "" + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } override fun onFailure(throwable: Throwable?) { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_generic) + Preferences.weatherProviderLocationError = "" + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } - }) } else { Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_missing_key) @@ -72,95 +80,137 @@ class WeatherNetworkApi(val context: Context) { WeatherHelper.removeWeather( context ) + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } - private fun useWeatherGov(context: Context) { - CoroutineScope(Dispatchers.IO).launch { - val repository = WeatherGovRepository() - val pointsResponse = executeWithRetry(times = 5) { - repository.getGridPoints( - Preferences.customLocationLat, - Preferences.customLocationLon - ) - } + private suspend fun useWeatherGov(context: Context) { + val repository = WeatherGovRepository() + val pointsResponse = executeWithRetry(times = 5) { + repository.getGridPoints( + Preferences.customLocationLat, + Preferences.customLocationLon + ) + } - when (pointsResponse) { - is NetworkResponse.Success -> { - try { - val pp = pointsResponse.body["properties"] as LinkedTreeMap<*, *> - val gridId = pp["gridId"] as String - val gridX = pp["gridX"] as Double - val gridY = pp["gridY"] as Double + when (pointsResponse) { + is NetworkResponse.Success -> { + try { + val pp = pointsResponse.body["properties"] as LinkedTreeMap<*, *> + val gridId = pp["gridId"] as String + val gridX = pp["gridX"] as Double + val gridY = pp["gridY"] as Double - when (val weatherResponse = repository.getWeather( - gridId, - gridX, - gridY, - if (Preferences.weatherTempUnit == "F") "us" else "si" - )) { - is NetworkResponse.Success -> { - try { - val props = - weatherResponse.body["properties"] as LinkedTreeMap<*, *> - val periods = props["periods"] as List<*> - val now = periods[0] as LinkedTreeMap<*, *> + when (val weatherResponse = repository.getWeather( + gridId, + gridX, + gridY, + if (Preferences.weatherTempUnit == "F") "us" else "si" + )) { + is NetworkResponse.Success -> { + try { + val props = + weatherResponse.body["properties"] as LinkedTreeMap<*, *> + val periods = props["periods"] as List<*> + val now = periods[0] as LinkedTreeMap<*, *> - val temp = now["temperature"] as Double - val fullIcon = now["icon"] as String - val isDaytime = now["isDaytime"] as Boolean + val temp = now["temperature"] as Double + val fullIcon = now["icon"] as String + val isDaytime = now["isDaytime"] as Boolean - Preferences.weatherTemp = temp.toFloat() - Preferences.weatherIcon = WeatherHelper.getWeatherGovIcon(fullIcon, isDaytime) - Preferences.weatherRealTempUnit = Preferences.weatherTempUnit + Preferences.weatherTemp = temp.toFloat() + Preferences.weatherIcon = WeatherHelper.getWeatherGovIcon(fullIcon, isDaytime) + Preferences.weatherRealTempUnit = Preferences.weatherTempUnit - MainWidget.updateWidget(context) + Preferences.weatherProviderError = "" + Preferences.weatherProviderLocationError = "" - EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) - } catch (ex: Exception) { - } + MainWidget.updateWidget(context) + } catch (ex: Exception) { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_generic) + Preferences.weatherProviderLocationError = "" + } finally { + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } - } catch(ex: Exception) { + else -> { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_connection) + Preferences.weatherProviderLocationError = "" + } } - } - is NetworkResponse.ServerError -> { - if (pointsResponse.body?.containsKey("status") == true && (pointsResponse.body?.get("status") as Double).toInt() == 404) { - Preferences.weatherProviderError = "" - Preferences.weatherProviderLocationError = context.getString(R.string.weather_provider_error_wrong_location) - } - - WeatherHelper.removeWeather( - context - ) + } catch(ex: Exception) { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_generic) + Preferences.weatherProviderLocationError = "" + } finally { + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } + is NetworkResponse.ServerError -> { + if (pointsResponse.body?.containsKey("status") == true && (pointsResponse.body?.get("status") as Double).toInt() == 404) { + Preferences.weatherProviderError = "" + Preferences.weatherProviderLocationError = context.getString(R.string.weather_provider_error_wrong_location) + } else { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_generic) + Preferences.weatherProviderLocationError = "" + } + WeatherHelper.removeWeather( + context + ) + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) + } + else -> { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_connection) + Preferences.weatherProviderLocationError = "" + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) + } } } - private fun useHereProvider(context: Context) { - CoroutineScope(Dispatchers.IO).launch { + private suspend fun useHereProvider(context: Context) { + if (Preferences.weatherProviderApiHere != "") { val repository = HereRepository() when (val response = repository.getWeather()) { is NetworkResponse.Success -> { try { Log.d("ciao - here", response.body.toString()) + Preferences.weatherProviderError = "" + Preferences.weatherProviderLocationError = "" } catch(ex: Exception) { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_generic) + Preferences.weatherProviderLocationError = "" + } finally { + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } is NetworkResponse.ServerError -> { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_generic) + Preferences.weatherProviderLocationError = "" WeatherHelper.removeWeather( context ) + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) + } + else -> { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_connection) + Preferences.weatherProviderLocationError = "" + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } + } else { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_missing_key) + Preferences.weatherProviderLocationError = "" + + WeatherHelper.removeWeather( + context + ) + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } - private fun useWeatherBitProvider(context: Context) { - CoroutineScope(Dispatchers.IO).launch { + private suspend fun useWeatherBitProvider(context: Context) { + if (Preferences.weatherProviderApiWeatherBit != "") { val repository = WeatherbitRepository() when (val response = repository.getWeather()) { @@ -177,27 +227,53 @@ class WeatherNetworkApi(val context: Context) { Preferences.weatherRealTempUnit = Preferences.weatherTempUnit MainWidget.updateWidget(context) + Preferences.weatherProviderError = "" + Preferences.weatherProviderLocationError = "" + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } catch(ex: Exception) { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_generic) + Preferences.weatherProviderLocationError = "" + } finally { + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } is NetworkResponse.ServerError -> { when (response.code) { 403 -> { Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_invalid_key) + Preferences.weatherProviderLocationError = "" + } + else -> { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_generic) + Preferences.weatherProviderLocationError = "" } } WeatherHelper.removeWeather( context ) + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) + } + else -> { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_connection) + Preferences.weatherProviderLocationError = "" + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } + } else { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_missing_key) + Preferences.weatherProviderLocationError = "" + + WeatherHelper.removeWeather( + context + ) + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } - private fun useWeatherApiProvider(context: Context) { - CoroutineScope(Dispatchers.IO).launch { + private suspend fun useWeatherApiProvider(context: Context) { + if (Preferences.weatherProviderApiWeatherApi != "") { val repository = WeatherApiRepository() when (val response = repository.getWeather()) { @@ -216,68 +292,150 @@ class WeatherNetworkApi(val context: Context) { Preferences.weatherRealTempUnit = Preferences.weatherTempUnit MainWidget.updateWidget(context) + Preferences.weatherProviderError = "" + Preferences.weatherProviderLocationError = "" + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } catch(ex: Exception) { - Log.d("ciao", ex.localizedMessage) + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_generic) + Preferences.weatherProviderLocationError = "" + } finally { + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } is NetworkResponse.ServerError -> { when (response.code) { 401 -> { Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_invalid_key) + Preferences.weatherProviderLocationError = "" } 403 -> { Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_expired_key) + Preferences.weatherProviderLocationError = "" + } + else -> { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_generic) + Preferences.weatherProviderLocationError = "" } } WeatherHelper.removeWeather( context ) + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) + } + else -> { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_connection) + Preferences.weatherProviderLocationError = "" + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } + } else { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_missing_key) + Preferences.weatherProviderLocationError = "" + + WeatherHelper.removeWeather( + context + ) + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } - private fun useAccuweatherProvider(context: Context) { - CoroutineScope(Dispatchers.IO).launch { - val repository = AccuweatherRepository() + private suspend fun useAccuweatherProvider(context: Context) { + if (Preferences.weatherProviderApiAccuweather != "") { + val repository = AccuweatherRepository() -// when (val response = repository.getWeather()) { -// is NetworkResponse.Success -> { -// try { -// Log.d("ciao", response.body.toString()) -// } catch(ex: Exception) { -// -// } -// } -// is NetworkResponse.ServerError -> { -// WeatherHelper.removeWeather( -// context -// ) -// } -// } + // when (val response = repository.getWeather()) { + // is NetworkResponse.Success -> { + // try { + // Log.d("ciao", response.body.toString()) + // } catch(ex: Exception) { + // +// Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_missing_key) +// Preferences.weatherProviderLocationError = "" + // } + // } + // is NetworkResponse.ServerError -> { + // WeatherHelper.removeWeather( + // context + // ) + // } +// Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_missing_key) +// Preferences.weatherProviderLocationError = "" + // EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) + // } + + } else { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_missing_key) + Preferences.weatherProviderLocationError = "" + + WeatherHelper.removeWeather( + context + ) + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } - private fun useYrProvider(context: Context) { - CoroutineScope(Dispatchers.IO).launch { - val repository = YrRepository() + private suspend fun useYrProvider(context: Context) { + val repository = YrRepository() - when (val response = repository.getWeather()) { - is NetworkResponse.Success -> { - try { - Log.d("ciao - yr", response.body.toString()) - } catch(ex: Exception) { + when (val response = repository.getWeather()) { + is NetworkResponse.Success -> { + try { + val pp = response.body["properties"] as LinkedTreeMap<*, *> + val data = pp["timeseries"] as List>? + data?.let { + val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") + for (item in data) { + val time = Calendar.getInstance().apply { time = format.parse(item["time"] as String)!! } + val now = Calendar.getInstance() + if (time.timeInMillis >= now.timeInMillis) { + val dd = item["data"] as LinkedTreeMap<*, *> + val instant = dd["instant"] as LinkedTreeMap<*, *> + val next = dd["next_1_hours"] as LinkedTreeMap<*, *> + val details = instant["details"] as LinkedTreeMap<*, *> + val temp = details["air_temperature"] as Double + + val summary = next["summary"] as LinkedTreeMap<*, *> + val iconCode = summary["symbol_code"] as String + + Preferences.weatherTemp = temp.toFloat() + Preferences.weatherIcon = WeatherHelper.getYRIcon(iconCode, now.get(Calendar.HOUR_OF_DAY) >= 22 || now.get(Calendar.HOUR_OF_DAY) <= 8) + Preferences.weatherTempUnit = "C" + Preferences.weatherRealTempUnit = Preferences.weatherTempUnit + MainWidget.updateWidget(context) + + Preferences.weatherProviderError = "" + Preferences.weatherProviderLocationError = "" + break + } + } } + + + + } catch(ex: Exception) { + ex.printStackTrace() + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_generic) + Preferences.weatherProviderLocationError = "" + } finally { + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } - is NetworkResponse.ServerError -> { - WeatherHelper.removeWeather( - context - ) - } + } + is NetworkResponse.ServerError -> { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_generic) + Preferences.weatherProviderLocationError = "" + WeatherHelper.removeWeather( + context + ) + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) + } + else -> { + Preferences.weatherProviderError = context.getString(R.string.weather_provider_error_connection) + Preferences.weatherProviderLocationError = "" + EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent()) } } } diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/WeatherReceiver.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/WeatherReceiver.kt index e0114fa..4b6f6eb 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/WeatherReceiver.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/WeatherReceiver.kt @@ -8,6 +8,9 @@ import android.content.Intent import com.tommasoberlose.anotherwidget.global.Actions import com.tommasoberlose.anotherwidget.global.Preferences import com.tommasoberlose.anotherwidget.helpers.WeatherHelper +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch import java.util.* @@ -22,7 +25,9 @@ class WeatherReceiver : BroadcastReceiver() { Intent.ACTION_TIME_CHANGED -> setUpdates(context) Actions.ACTION_WEATHER_UPDATE -> { - WeatherHelper.updateWeather(context) + GlobalScope.launch(Dispatchers.IO) { + WeatherHelper.updateWeather(context) + } } } } diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/WeatherProviderActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/WeatherProviderActivity.kt index 699d017..2052d51 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/WeatherProviderActivity.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activities/WeatherProviderActivity.kt @@ -4,8 +4,10 @@ import android.app.Activity import android.content.Intent import android.content.pm.ResolveInfo import android.os.Bundle +import android.util.Log import android.view.View import android.widget.ImageView +import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.core.view.isVisible @@ -15,37 +17,44 @@ import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager import com.bumptech.glide.Glide +import com.google.android.material.snackbar.Snackbar import com.tommasoberlose.anotherwidget.R import com.tommasoberlose.anotherwidget.components.BottomSheetMenu +import com.tommasoberlose.anotherwidget.components.BottomSheetWeatherProviderSettings import com.tommasoberlose.anotherwidget.databinding.ActivityChooseApplicationBinding import com.tommasoberlose.anotherwidget.databinding.ActivityWeatherProviderBinding import com.tommasoberlose.anotherwidget.global.Constants import com.tommasoberlose.anotherwidget.global.Preferences import com.tommasoberlose.anotherwidget.helpers.WeatherHelper +import com.tommasoberlose.anotherwidget.network.WeatherNetworkApi +import com.tommasoberlose.anotherwidget.ui.fragments.MainFragment import com.tommasoberlose.anotherwidget.ui.viewmodels.ChooseApplicationViewModel import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel +import com.tommasoberlose.anotherwidget.ui.viewmodels.WeatherProviderViewModel +import com.tommasoberlose.anotherwidget.utils.collapse +import com.tommasoberlose.anotherwidget.utils.expand import com.tommasoberlose.anotherwidget.utils.openURI -import kotlinx.android.synthetic.main.activity_choose_application.* +import com.tommasoberlose.anotherwidget.utils.reveal import kotlinx.android.synthetic.main.activity_weather_provider.* -import kotlinx.android.synthetic.main.activity_weather_provider.action_back -import kotlinx.android.synthetic.main.activity_weather_provider.list_view import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import net.idik.lib.slimadapter.SlimAdapter +import org.greenrobot.eventbus.EventBus +import org.greenrobot.eventbus.Subscribe +import org.greenrobot.eventbus.ThreadMode class WeatherProviderActivity : AppCompatActivity() { private lateinit var adapter: SlimAdapter - private lateinit var viewModel: MainViewModel + private lateinit var viewModel: WeatherProviderViewModel override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_weather_provider) - viewModel = ViewModelProvider(this).get(MainViewModel::class.java) - api_key.editText?.setText(Preferences.weatherProviderApiOpen) + viewModel = ViewModelProvider(this).get(WeatherProviderViewModel::class.java) list_view.setHasFixedSize(true) val mLayoutManager = LinearLayoutManager(this) @@ -53,91 +62,119 @@ class WeatherProviderActivity : AppCompatActivity() { adapter = SlimAdapter.create() adapter - .register(R.layout.list_item) { item, injector -> - val provider = Constants.WeatherProvider.fromInt(item)!! + .register(R.layout.weather_provider_list_item) { provider, injector -> injector .text(R.id.text, WeatherHelper.getProviderName(this, provider)) - .clicked(R.id.text) { - Preferences.weatherProvider = item + .clicked(R.id.item) { + val oldValue = Preferences.weatherProvider + Preferences.weatherProvider = provider.value + updateListItem(oldValue) + updateListItem() + loader.isVisible = true + + lifecycleScope.launch { + WeatherHelper.updateWeather(this@WeatherProviderActivity) + } } - } - .attachTo(list_view) + .clicked(R.id.radioButton) { + val oldValue = Preferences.weatherProvider + Preferences.weatherProvider = provider.value + updateListItem(oldValue) + updateListItem() + loader.isVisible = true + + lifecycleScope.launch { + WeatherHelper.updateWeather(this@WeatherProviderActivity) + } + } + .checked(R.id.radioButton, provider.value == Preferences.weatherProvider) + .with(R.id.text2) { + if (WeatherHelper.isKeyRequired(provider)) { + it.text = getString(R.string.api_key_required_message) + } + + if (provider == Constants.WeatherProvider.WEATHER_GOV) { + it.text = getString(R.string.us_only_message) + } + } + .clicked(R.id.action_configure) { + BottomSheetWeatherProviderSettings(this) { + lifecycleScope.launch { + loader.isVisible = true + WeatherHelper.updateWeather(this@WeatherProviderActivity) + } + }.show() + } + .visibility(R.id.action_configure, if (/*WeatherHelper.isKeyRequired(provider) && */provider.value == Preferences.weatherProvider) View.VISIBLE else View.GONE) + .visibility(R.id.info_container, if (WeatherHelper.isKeyRequired(provider) || provider == Constants.WeatherProvider.WEATHER_GOV) View.VISIBLE else View.GONE) + .with(R.id.provider_error) { + if (Preferences.weatherProviderError != "" && Preferences.weatherProviderError != "-") { + it.text = Preferences.weatherProviderError + it.isVisible = provider.value == Preferences.weatherProvider + } else if (Preferences.weatherProviderLocationError != "") { + it.text = Preferences.weatherProviderLocationError + it.isVisible = provider.value == Preferences.weatherProvider + } else { + it.isVisible = false + } + } + .image(R.id.action_configure, ContextCompat.getDrawable(this, if (WeatherHelper.isKeyRequired(provider)) R.drawable.round_settings else R.drawable.outline_info_white)) + }.attachTo(list_view) + + adapter.updateData( + Constants.WeatherProvider.values().asList() + .filter { it != Constants.WeatherProvider.HERE } + .filter { it != Constants.WeatherProvider.ACCUWEATHER } + ) setupListener() subscribeUi(viewModel) } - private fun subscribeUi(viewModel: MainViewModel) { - adapter.updateData(Constants.WeatherProvider.values().map { it.value }) + private fun subscribeUi(viewModel: WeatherProviderViewModel) { + viewModel.weatherProviderError.observe(this) { + updateListItem() + } -// viewModel.weatherProvider.observe(this, Observer { -// weather_provider.editText?.setText(WeatherHelper.getProviderName(this, Constants.WeatherProvider.fromInt(Preferences.weatherProvider)!!).split("\n").first()) -// -// api_key_container.isVisible = WeatherHelper.isKeyRequired() -// -// WeatherHelper.getProviderInfoTitle(this).let { -// info_title.text = it -// info_title.isVisible = it != "" -// } -// -// WeatherHelper.getProviderInfoSubtitle(this).let { -// info_subtitle.text = it -// info_subtitle.isVisible = it != "" -// } -// -// action_open_provider.text = WeatherHelper.getProviderLinkName(this) -// -// api_key.editText?.setText(when (Constants.WeatherProvider.fromInt(it)) { -// Constants.WeatherProvider.OPEN_WEATHER -> Preferences.weatherProviderApiOpen -// Constants.WeatherProvider.WEATHER_BIT -> Preferences.weatherProviderApiWeatherBit -// Constants.WeatherProvider.WEATHER_API -> Preferences.weatherProviderApiWeatherApi -// Constants.WeatherProvider.HERE -> Preferences.weatherProviderApiHere -// Constants.WeatherProvider.ACCUWEATHER -> Preferences.weatherProviderApiAccuweather -// Constants.WeatherProvider.WEATHER_GOV, -// Constants.WeatherProvider.YR, -// null -> "" -// }) -// }) + viewModel.weatherProviderLocationError.observe(this) { + updateListItem() + } + } + + private fun updateListItem(provider: Int = Preferences.weatherProvider) { + (adapter.data).forEachIndexed { index, item -> + if (item is Constants.WeatherProvider && item.value == provider) { + adapter.notifyItemChanged(index) + } + } } private fun setupListener() { action_back.setOnClickListener { onBackPressed() } - - action_open_provider.setOnClickListener { - openURI(WeatherHelper.getProviderLink()) - } - - weather_provider_inner.setOnClickListener { - if (Preferences.showWeather) { - val dialog = BottomSheetMenu(this, header = getString(R.string.settings_weather_provider_api)).setSelectedValue(Preferences.weatherProvider) - (0 until 7).forEach { - val item = Constants.WeatherProvider.fromInt(it) - dialog.addItem(WeatherHelper.getProviderName(this, item!!), it) - } - - dialog.addOnSelectItemListener { value -> - Preferences.weatherProvider = value - }.show() - } - } - - api_key.editText?.addTextChangedListener { - val key = it?.toString() ?: "" - when (Constants.WeatherProvider.fromInt(Preferences.weatherProvider)) { - Constants.WeatherProvider.OPEN_WEATHER -> Preferences.weatherProviderApiOpen = key - Constants.WeatherProvider.WEATHER_BIT -> Preferences.weatherProviderApiWeatherBit = key - Constants.WeatherProvider.WEATHER_API -> Preferences.weatherProviderApiWeatherApi = key - Constants.WeatherProvider.HERE -> Preferences.weatherProviderApiHere = key - Constants.WeatherProvider.ACCUWEATHER -> Preferences.weatherProviderApiAccuweather = key - else -> {} - } - } } override fun onBackPressed() { setResult(Activity.RESULT_OK) finish() } + + override fun onResume() { + super.onResume() + EventBus.getDefault().register(this) + } + + override fun onPause() { + EventBus.getDefault().unregister(this) + super.onPause() + } + + @Subscribe(threadMode = ThreadMode.MAIN) + fun onMessageEvent(ignore: MainFragment.UpdateUiMessageEvent?) { + loader.isVisible = Preferences.weatherProviderError == "-" + if (Preferences.weatherProviderError == "" && Preferences.weatherProviderLocationError == "") { + Snackbar.make(list_view, getString(R.string.settings_weather_provider_api_key_subtitle_all_set), Snackbar.LENGTH_LONG).show() + } + } } diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/MainFragment.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/MainFragment.kt index 9e806c1..53e98b7 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/MainFragment.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/MainFragment.kt @@ -39,10 +39,7 @@ import com.tommasoberlose.anotherwidget.ui.activities.MainActivity import com.tommasoberlose.anotherwidget.ui.adapters.ViewPagerAdapter import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget -import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission -import com.tommasoberlose.anotherwidget.utils.getCurrentWallpaper -import com.tommasoberlose.anotherwidget.utils.isDarkTheme -import com.tommasoberlose.anotherwidget.utils.toPixel +import com.tommasoberlose.anotherwidget.utils.* import kotlinx.android.synthetic.main.fragment_app_main.* import kotlinx.android.synthetic.main.the_widget_sans.* import kotlinx.coroutines.* @@ -76,6 +73,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) + subscribeUi(viewModel) // Viewpager @@ -352,11 +350,11 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList backgroundColor = ContextCompat.getColor(requireContext(), R.color.errorColorText) badgeGravity = BadgeDrawable.TOP_END }?.isVisible = if (Preferences.showWeather) { - (WeatherHelper.isKeyRequired() && Preferences.weatherProviderApiOpen == "") + (WeatherHelper.isKeyRequired() && WeatherHelper.getApiKey() == "") || (Preferences.customLocationAdd == "" && activity?.checkGrantedPermission( if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) Manifest.permission.ACCESS_BACKGROUND_LOCATION else Manifest.permission.ACCESS_FINE_LOCATION ) != true) - || (Preferences.weatherProviderError != "") + || (Preferences.weatherProviderError != "" && Preferences.weatherProviderError != "-") } else { false } diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/SettingsFragment.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/SettingsFragment.kt index e63af16..53ab98b 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/SettingsFragment.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/SettingsFragment.kt @@ -193,7 +193,9 @@ class SettingsFragment : Fragment() { } action_refresh_widget.setOnClickListener { - WeatherHelper.updateWeather(requireContext()) + viewLifecycleOwner.lifecycleScope.launch { + WeatherHelper.updateWeather(requireContext()) + } CalendarHelper.updateEventList(requireContext()) MediaPlayerHelper.updatePlayingMediaInfo(requireContext()) } diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/WeatherTabFragment.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/WeatherTabFragment.kt index 02d8a3c..0ab97d5 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/WeatherTabFragment.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/WeatherTabFragment.kt @@ -188,7 +188,7 @@ class WeatherTabFragment : Fragment() { } private fun checkWeatherProviderConfig() { - weather_provider_error.isVisible = Preferences.weatherProviderError != "" + weather_provider_error.isVisible = Preferences.weatherProviderError != "" && Preferences.weatherProviderError != "-" weather_provider_error?.text = Preferences.weatherProviderError weather_provider_location_error.isVisible = Preferences.weatherProviderLocationError != "" @@ -233,7 +233,9 @@ class WeatherTabFragment : Fragment() { .addItem(getString(R.string.celsius), "C") .addOnSelectItemListener { value -> if (value != Preferences.weatherTempUnit) { - WeatherHelper.updateWeather(requireContext()) + viewLifecycleOwner.lifecycleScope.launch { + WeatherHelper.updateWeather(requireContext()) + } } Preferences.weatherTempUnit = value }.show() diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/WeatherProviderViewModel.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/WeatherProviderViewModel.kt new file mode 100644 index 0000000..fd6ecc3 --- /dev/null +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/viewmodels/WeatherProviderViewModel.kt @@ -0,0 +1,19 @@ +package com.tommasoberlose.anotherwidget.ui.viewmodels + +import android.app.Application +import androidx.lifecycle.AndroidViewModel +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import com.chibatching.kotpref.livedata.asLiveData +import com.tommasoberlose.anotherwidget.R +import com.tommasoberlose.anotherwidget.global.Constants +import com.tommasoberlose.anotherwidget.global.Preferences + +class WeatherProviderViewModel(application: Application) : AndroidViewModel(application) { + + val weatherProvider = Preferences.asLiveData(Preferences::weatherProvider) + val weatherProviderError = Preferences.asLiveData(Preferences::weatherProviderError) + val weatherProviderLocationError = Preferences.asLiveData(Preferences::weatherProviderLocationError) + + +} \ No newline at end of file diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widgets/MainWidget.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widgets/MainWidget.kt index 5627144..96b7dd5 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widgets/MainWidget.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widgets/MainWidget.kt @@ -32,10 +32,7 @@ import com.tommasoberlose.anotherwidget.global.Preferences import com.tommasoberlose.anotherwidget.helpers.* import com.tommasoberlose.anotherwidget.helpers.ColorHelper.toIntValue import com.tommasoberlose.anotherwidget.receivers.* -import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission -import com.tommasoberlose.anotherwidget.utils.getCapWordString -import com.tommasoberlose.anotherwidget.utils.isDarkTheme -import com.tommasoberlose.anotherwidget.utils.toPixel +import com.tommasoberlose.anotherwidget.utils.* import kotlinx.android.synthetic.main.the_widget.view.* import java.lang.Exception import java.text.DateFormat @@ -661,14 +658,11 @@ class MainWidget : AppWidgetProvider() { if (Preferences.isCharging) { v.second_row_icon.isVisible = false val batteryLevel = BatteryHelper.getBatteryLevel(context) - if (batteryLevel == 100) { - v.next_event_date.text = "%s - %d%%".format( - context.getString(R.string.charging), - batteryLevel - ) + if (batteryLevel != 100) { + v.next_event_date.text = context.getString(R.string.charging) } else { v.next_event_date.text = - context.getString(R.string.charging) + context.getString(R.string.charged) } showSomething = true break@loop diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/utils/Extensions.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/utils/Extensions.kt index 7b71399..d6278cf 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/utils/Extensions.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/utils/Extensions.kt @@ -95,7 +95,7 @@ fun View.expand() { } } -fun View.collapse() { +fun View.collapse(duration: Long = 500L) { if (visibility != View.GONE) { val initialHeight = measuredHeight @@ -114,7 +114,7 @@ fun View.collapse() { } } - a.duration = 500L //(initialHeight / v.context.resources.displayMetrics.density).toLong() + a.duration = duration //(initialHeight / v.context.resources.displayMetrics.density).toLong() startAnimation(a) } } diff --git a/app/src/main/res/drawable-hdpi/round_call_made.png b/app/src/main/res/drawable-hdpi/round_call_made.png new file mode 100644 index 0000000..74fb74b Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_call_made.png differ diff --git a/app/src/main/res/drawable-hdpi/round_call_made_white_18.png b/app/src/main/res/drawable-hdpi/round_call_made_white_18.png new file mode 100644 index 0000000..9556f3c Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_call_made_white_18.png differ diff --git a/app/src/main/res/drawable-hdpi/round_call_made_white_24.png b/app/src/main/res/drawable-hdpi/round_call_made_white_24.png new file mode 100644 index 0000000..aca36b1 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_call_made_white_24.png differ diff --git a/app/src/main/res/drawable-hdpi/round_call_made_white_48.png b/app/src/main/res/drawable-hdpi/round_call_made_white_48.png new file mode 100644 index 0000000..3a06187 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_call_made_white_48.png differ diff --git a/app/src/main/res/drawable-hdpi/round_close_white_18.png b/app/src/main/res/drawable-hdpi/round_close_white_18.png new file mode 100644 index 0000000..272a726 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_close_white_18.png differ diff --git a/app/src/main/res/drawable-hdpi/round_close_white_24.png b/app/src/main/res/drawable-hdpi/round_close_white_24.png new file mode 100644 index 0000000..ee337f8 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_close_white_24.png differ diff --git a/app/src/main/res/drawable-hdpi/round_close_white_36.png b/app/src/main/res/drawable-hdpi/round_close_white_36.png new file mode 100644 index 0000000..e6360b4 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_close_white_36.png differ diff --git a/app/src/main/res/drawable-hdpi/round_close_white_48.png b/app/src/main/res/drawable-hdpi/round_close_white_48.png new file mode 100644 index 0000000..ad4be89 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_close_white_48.png differ diff --git a/app/src/main/res/drawable-hdpi/round_language.png b/app/src/main/res/drawable-hdpi/round_language.png new file mode 100644 index 0000000..073bf40 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_language.png differ diff --git a/app/src/main/res/drawable-hdpi/round_language_white_24.png b/app/src/main/res/drawable-hdpi/round_language_white_24.png new file mode 100644 index 0000000..0f6fc07 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_language_white_24.png differ diff --git a/app/src/main/res/drawable-hdpi/round_language_white_36.png b/app/src/main/res/drawable-hdpi/round_language_white_36.png new file mode 100644 index 0000000..5b67983 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_language_white_36.png differ diff --git a/app/src/main/res/drawable-hdpi/round_language_white_48.png b/app/src/main/res/drawable-hdpi/round_language_white_48.png new file mode 100644 index 0000000..7d8cdc1 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_language_white_48.png differ diff --git a/app/src/main/res/drawable-hdpi/round_pageview_white_18.png b/app/src/main/res/drawable-hdpi/round_pageview_white_18.png new file mode 100644 index 0000000..ae809cf Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_pageview_white_18.png differ diff --git a/app/src/main/res/drawable-hdpi/round_pageview_white_24.png b/app/src/main/res/drawable-hdpi/round_pageview_white_24.png new file mode 100644 index 0000000..56d83d8 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_pageview_white_24.png differ diff --git a/app/src/main/res/drawable-hdpi/round_pageview_white_36.png b/app/src/main/res/drawable-hdpi/round_pageview_white_36.png new file mode 100644 index 0000000..6ab4f4b Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_pageview_white_36.png differ diff --git a/app/src/main/res/drawable-hdpi/round_pageview_white_48.png b/app/src/main/res/drawable-hdpi/round_pageview_white_48.png new file mode 100644 index 0000000..9a46559 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_pageview_white_48.png differ diff --git a/app/src/main/res/drawable-hdpi/round_public.png b/app/src/main/res/drawable-hdpi/round_public.png new file mode 100644 index 0000000..41899cf Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_public.png differ diff --git a/app/src/main/res/drawable-hdpi/round_public_white_18.png b/app/src/main/res/drawable-hdpi/round_public_white_18.png new file mode 100644 index 0000000..c694829 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_public_white_18.png differ diff --git a/app/src/main/res/drawable-hdpi/round_public_white_24.png b/app/src/main/res/drawable-hdpi/round_public_white_24.png new file mode 100644 index 0000000..635d234 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_public_white_24.png differ diff --git a/app/src/main/res/drawable-hdpi/round_public_white_36.png b/app/src/main/res/drawable-hdpi/round_public_white_36.png new file mode 100644 index 0000000..1f12d40 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_public_white_36.png differ diff --git a/app/src/main/res/drawable-hdpi/round_search.png b/app/src/main/res/drawable-hdpi/round_search.png new file mode 100644 index 0000000..656911d Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_search.png differ diff --git a/app/src/main/res/drawable-hdpi/round_search_white_18.png b/app/src/main/res/drawable-hdpi/round_search_white_18.png new file mode 100644 index 0000000..8d68e36 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_search_white_18.png differ diff --git a/app/src/main/res/drawable-hdpi/round_search_white_24.png b/app/src/main/res/drawable-hdpi/round_search_white_24.png new file mode 100644 index 0000000..57fe552 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_search_white_24.png differ diff --git a/app/src/main/res/drawable-hdpi/round_search_white_36.png b/app/src/main/res/drawable-hdpi/round_search_white_36.png new file mode 100644 index 0000000..b96b48c Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_search_white_36.png differ diff --git a/app/src/main/res/drawable-mdpi/round_call_made.png b/app/src/main/res/drawable-mdpi/round_call_made.png new file mode 100644 index 0000000..aca36b1 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_call_made.png differ diff --git a/app/src/main/res/drawable-mdpi/round_call_made_white_18.png b/app/src/main/res/drawable-mdpi/round_call_made_white_18.png new file mode 100644 index 0000000..6d3f9c1 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_call_made_white_18.png differ diff --git a/app/src/main/res/drawable-mdpi/round_call_made_white_24.png b/app/src/main/res/drawable-mdpi/round_call_made_white_24.png new file mode 100644 index 0000000..0d64358 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_call_made_white_24.png differ diff --git a/app/src/main/res/drawable-mdpi/round_call_made_white_48.png b/app/src/main/res/drawable-mdpi/round_call_made_white_48.png new file mode 100644 index 0000000..7b9fb86 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_call_made_white_48.png differ diff --git a/app/src/main/res/drawable-mdpi/round_close_white_18.png b/app/src/main/res/drawable-mdpi/round_close_white_18.png new file mode 100644 index 0000000..0cf2410 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_close_white_18.png differ diff --git a/app/src/main/res/drawable-mdpi/round_close_white_24.png b/app/src/main/res/drawable-mdpi/round_close_white_24.png new file mode 100644 index 0000000..4d8be71 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_close_white_24.png differ diff --git a/app/src/main/res/drawable-mdpi/round_close_white_36.png b/app/src/main/res/drawable-mdpi/round_close_white_36.png new file mode 100644 index 0000000..ee337f8 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_close_white_36.png differ diff --git a/app/src/main/res/drawable-mdpi/round_close_white_48.png b/app/src/main/res/drawable-mdpi/round_close_white_48.png new file mode 100644 index 0000000..a6929bf Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_close_white_48.png differ diff --git a/app/src/main/res/drawable-mdpi/round_language.png b/app/src/main/res/drawable-mdpi/round_language.png new file mode 100644 index 0000000..9925e89 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_language.png differ diff --git a/app/src/main/res/drawable-mdpi/round_language_white_24.png b/app/src/main/res/drawable-mdpi/round_language_white_24.png new file mode 100644 index 0000000..efcea72 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_language_white_24.png differ diff --git a/app/src/main/res/drawable-mdpi/round_language_white_36.png b/app/src/main/res/drawable-mdpi/round_language_white_36.png new file mode 100644 index 0000000..0f6fc07 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_language_white_36.png differ diff --git a/app/src/main/res/drawable-mdpi/round_language_white_48.png b/app/src/main/res/drawable-mdpi/round_language_white_48.png new file mode 100644 index 0000000..8214b2d Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_language_white_48.png differ diff --git a/app/src/main/res/drawable-mdpi/round_pageview_white_18.png b/app/src/main/res/drawable-mdpi/round_pageview_white_18.png new file mode 100644 index 0000000..dcff9be Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_pageview_white_18.png differ diff --git a/app/src/main/res/drawable-mdpi/round_pageview_white_24.png b/app/src/main/res/drawable-mdpi/round_pageview_white_24.png new file mode 100644 index 0000000..2f27bd7 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_pageview_white_24.png differ diff --git a/app/src/main/res/drawable-mdpi/round_pageview_white_36.png b/app/src/main/res/drawable-mdpi/round_pageview_white_36.png new file mode 100644 index 0000000..56d83d8 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_pageview_white_36.png differ diff --git a/app/src/main/res/drawable-mdpi/round_pageview_white_48.png b/app/src/main/res/drawable-mdpi/round_pageview_white_48.png new file mode 100644 index 0000000..42aeea1 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_pageview_white_48.png differ diff --git a/app/src/main/res/drawable-mdpi/round_public.png b/app/src/main/res/drawable-mdpi/round_public.png new file mode 100644 index 0000000..d3ba554 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_public.png differ diff --git a/app/src/main/res/drawable-mdpi/round_public_white_18.png b/app/src/main/res/drawable-mdpi/round_public_white_18.png new file mode 100644 index 0000000..6b0cd50 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_public_white_18.png differ diff --git a/app/src/main/res/drawable-mdpi/round_public_white_24.png b/app/src/main/res/drawable-mdpi/round_public_white_24.png new file mode 100644 index 0000000..2146e2c Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_public_white_24.png differ diff --git a/app/src/main/res/drawable-mdpi/round_public_white_36.png b/app/src/main/res/drawable-mdpi/round_public_white_36.png new file mode 100644 index 0000000..635d234 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_public_white_36.png differ diff --git a/app/src/main/res/drawable-mdpi/round_search.png b/app/src/main/res/drawable-mdpi/round_search.png new file mode 100644 index 0000000..882aced Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_search.png differ diff --git a/app/src/main/res/drawable-mdpi/round_search_white_18.png b/app/src/main/res/drawable-mdpi/round_search_white_18.png new file mode 100644 index 0000000..7f630cb Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_search_white_18.png differ diff --git a/app/src/main/res/drawable-mdpi/round_search_white_24.png b/app/src/main/res/drawable-mdpi/round_search_white_24.png new file mode 100644 index 0000000..62ff549 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_search_white_24.png differ diff --git a/app/src/main/res/drawable-mdpi/round_search_white_36.png b/app/src/main/res/drawable-mdpi/round_search_white_36.png new file mode 100644 index 0000000..57fe552 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_search_white_36.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_call_made.png b/app/src/main/res/drawable-xhdpi/round_call_made.png new file mode 100644 index 0000000..3a06187 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_call_made.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_call_made_white_18.png b/app/src/main/res/drawable-xhdpi/round_call_made_white_18.png new file mode 100644 index 0000000..aca36b1 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_call_made_white_18.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_call_made_white_24.png b/app/src/main/res/drawable-xhdpi/round_call_made_white_24.png new file mode 100644 index 0000000..7b9fb86 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_call_made_white_24.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_call_made_white_48.png b/app/src/main/res/drawable-xhdpi/round_call_made_white_48.png new file mode 100644 index 0000000..6e5a123 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_call_made_white_48.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_close_white_18.png b/app/src/main/res/drawable-xhdpi/round_close_white_18.png new file mode 100644 index 0000000..ee337f8 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_close_white_18.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_close_white_24.png b/app/src/main/res/drawable-xhdpi/round_close_white_24.png new file mode 100644 index 0000000..a6929bf Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_close_white_24.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_close_white_36.png b/app/src/main/res/drawable-xhdpi/round_close_white_36.png new file mode 100644 index 0000000..ad4be89 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_close_white_36.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_close_white_48.png b/app/src/main/res/drawable-xhdpi/round_close_white_48.png new file mode 100644 index 0000000..2d8169e Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_close_white_48.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_language.png b/app/src/main/res/drawable-xhdpi/round_language.png new file mode 100644 index 0000000..0f6fc07 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_language.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_language_white_24.png b/app/src/main/res/drawable-xhdpi/round_language_white_24.png new file mode 100644 index 0000000..8214b2d Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_language_white_24.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_language_white_36.png b/app/src/main/res/drawable-xhdpi/round_language_white_36.png new file mode 100644 index 0000000..7d8cdc1 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_language_white_36.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_language_white_48.png b/app/src/main/res/drawable-xhdpi/round_language_white_48.png new file mode 100644 index 0000000..de3e03b Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_language_white_48.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_pageview_white_18.png b/app/src/main/res/drawable-xhdpi/round_pageview_white_18.png new file mode 100644 index 0000000..56d83d8 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_pageview_white_18.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_pageview_white_24.png b/app/src/main/res/drawable-xhdpi/round_pageview_white_24.png new file mode 100644 index 0000000..42aeea1 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_pageview_white_24.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_pageview_white_36.png b/app/src/main/res/drawable-xhdpi/round_pageview_white_36.png new file mode 100644 index 0000000..9a46559 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_pageview_white_36.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_pageview_white_48.png b/app/src/main/res/drawable-xhdpi/round_pageview_white_48.png new file mode 100644 index 0000000..0c378bf Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_pageview_white_48.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_public.png b/app/src/main/res/drawable-xhdpi/round_public.png new file mode 100644 index 0000000..386ab21 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_public.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_public_white_18.png b/app/src/main/res/drawable-xhdpi/round_public_white_18.png new file mode 100644 index 0000000..635d234 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_public_white_18.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_public_white_24.png b/app/src/main/res/drawable-xhdpi/round_public_white_24.png new file mode 100644 index 0000000..d3ba554 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_public_white_24.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_public_white_36.png b/app/src/main/res/drawable-xhdpi/round_public_white_36.png new file mode 100644 index 0000000..41899cf Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_public_white_36.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_search.png b/app/src/main/res/drawable-xhdpi/round_search.png new file mode 100644 index 0000000..89e3224 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_search.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_search_white_18.png b/app/src/main/res/drawable-xhdpi/round_search_white_18.png new file mode 100644 index 0000000..57fe552 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_search_white_18.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_search_white_24.png b/app/src/main/res/drawable-xhdpi/round_search_white_24.png new file mode 100644 index 0000000..882aced Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_search_white_24.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_search_white_36.png b/app/src/main/res/drawable-xhdpi/round_search_white_36.png new file mode 100644 index 0000000..656911d Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_search_white_36.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_call_made.png b/app/src/main/res/drawable-xxhdpi/round_call_made.png new file mode 100644 index 0000000..5cc48b6 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_call_made.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_call_made_white_18.png b/app/src/main/res/drawable-xxhdpi/round_call_made_white_18.png new file mode 100644 index 0000000..74fb74b Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_call_made_white_18.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_call_made_white_24.png b/app/src/main/res/drawable-xxhdpi/round_call_made_white_24.png new file mode 100644 index 0000000..3a06187 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_call_made_white_24.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_call_made_white_48.png b/app/src/main/res/drawable-xxhdpi/round_call_made_white_48.png new file mode 100644 index 0000000..86ce4e1 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_call_made_white_48.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_close_white_18.png b/app/src/main/res/drawable-xxhdpi/round_close_white_18.png new file mode 100644 index 0000000..e6360b4 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_close_white_18.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_close_white_24.png b/app/src/main/res/drawable-xxhdpi/round_close_white_24.png new file mode 100644 index 0000000..ad4be89 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_close_white_24.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_close_white_36.png b/app/src/main/res/drawable-xxhdpi/round_close_white_36.png new file mode 100644 index 0000000..76f1f4b Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_close_white_36.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_close_white_48.png b/app/src/main/res/drawable-xxhdpi/round_close_white_48.png new file mode 100644 index 0000000..252457b Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_close_white_48.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_language.png b/app/src/main/res/drawable-xxhdpi/round_language.png new file mode 100644 index 0000000..5b67983 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_language.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_language_white_24.png b/app/src/main/res/drawable-xxhdpi/round_language_white_24.png new file mode 100644 index 0000000..7d8cdc1 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_language_white_24.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_language_white_36.png b/app/src/main/res/drawable-xxhdpi/round_language_white_36.png new file mode 100644 index 0000000..cc1cc76 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_language_white_36.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_language_white_48.png b/app/src/main/res/drawable-xxhdpi/round_language_white_48.png new file mode 100644 index 0000000..c662d08 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_language_white_48.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_pageview_white_18.png b/app/src/main/res/drawable-xxhdpi/round_pageview_white_18.png new file mode 100644 index 0000000..6ab4f4b Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_pageview_white_18.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_pageview_white_24.png b/app/src/main/res/drawable-xxhdpi/round_pageview_white_24.png new file mode 100644 index 0000000..9a46559 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_pageview_white_24.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_pageview_white_36.png b/app/src/main/res/drawable-xxhdpi/round_pageview_white_36.png new file mode 100644 index 0000000..669d8f6 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_pageview_white_36.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_pageview_white_48.png b/app/src/main/res/drawable-xxhdpi/round_pageview_white_48.png new file mode 100644 index 0000000..0e9a226 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_pageview_white_48.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_public.png b/app/src/main/res/drawable-xxhdpi/round_public.png new file mode 100644 index 0000000..a52fa1e Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_public.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_public_white_18.png b/app/src/main/res/drawable-xxhdpi/round_public_white_18.png new file mode 100644 index 0000000..1f12d40 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_public_white_18.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_public_white_24.png b/app/src/main/res/drawable-xxhdpi/round_public_white_24.png new file mode 100644 index 0000000..41899cf Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_public_white_24.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_public_white_36.png b/app/src/main/res/drawable-xxhdpi/round_public_white_36.png new file mode 100644 index 0000000..b356849 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_public_white_36.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_search.png b/app/src/main/res/drawable-xxhdpi/round_search.png new file mode 100644 index 0000000..d9e35fe Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_search.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_search_white_18.png b/app/src/main/res/drawable-xxhdpi/round_search_white_18.png new file mode 100644 index 0000000..b96b48c Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_search_white_18.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_search_white_24.png b/app/src/main/res/drawable-xxhdpi/round_search_white_24.png new file mode 100644 index 0000000..656911d Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_search_white_24.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_search_white_36.png b/app/src/main/res/drawable-xxhdpi/round_search_white_36.png new file mode 100644 index 0000000..0504d20 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_search_white_36.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_call_made.png b/app/src/main/res/drawable-xxxhdpi/round_call_made.png new file mode 100644 index 0000000..86ce4e1 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_call_made.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_call_made_white_18.png b/app/src/main/res/drawable-xxxhdpi/round_call_made_white_18.png new file mode 100644 index 0000000..3a06187 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_call_made_white_18.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_call_made_white_24.png b/app/src/main/res/drawable-xxxhdpi/round_call_made_white_24.png new file mode 100644 index 0000000..6e5a123 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_call_made_white_24.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_call_made_white_48.png b/app/src/main/res/drawable-xxxhdpi/round_call_made_white_48.png new file mode 100644 index 0000000..991c16c Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_call_made_white_48.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_close_white_18.png b/app/src/main/res/drawable-xxxhdpi/round_close_white_18.png new file mode 100644 index 0000000..ad4be89 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_close_white_18.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_close_white_24.png b/app/src/main/res/drawable-xxxhdpi/round_close_white_24.png new file mode 100644 index 0000000..2d8169e Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_close_white_24.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_close_white_36.png b/app/src/main/res/drawable-xxxhdpi/round_close_white_36.png new file mode 100644 index 0000000..252457b Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_close_white_36.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_close_white_48.png b/app/src/main/res/drawable-xxxhdpi/round_close_white_48.png new file mode 100644 index 0000000..3c2bdf1 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_close_white_48.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_language.png b/app/src/main/res/drawable-xxxhdpi/round_language.png new file mode 100644 index 0000000..7d8cdc1 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_language.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_language_white_24.png b/app/src/main/res/drawable-xxxhdpi/round_language_white_24.png new file mode 100644 index 0000000..de3e03b Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_language_white_24.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_language_white_36.png b/app/src/main/res/drawable-xxxhdpi/round_language_white_36.png new file mode 100644 index 0000000..c662d08 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_language_white_36.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_language_white_48.png b/app/src/main/res/drawable-xxxhdpi/round_language_white_48.png new file mode 100644 index 0000000..b9992e6 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_language_white_48.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_pageview_white_18.png b/app/src/main/res/drawable-xxxhdpi/round_pageview_white_18.png new file mode 100644 index 0000000..9a46559 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_pageview_white_18.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_pageview_white_24.png b/app/src/main/res/drawable-xxxhdpi/round_pageview_white_24.png new file mode 100644 index 0000000..0c378bf Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_pageview_white_24.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_pageview_white_36.png b/app/src/main/res/drawable-xxxhdpi/round_pageview_white_36.png new file mode 100644 index 0000000..0e9a226 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_pageview_white_36.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_pageview_white_48.png b/app/src/main/res/drawable-xxxhdpi/round_pageview_white_48.png new file mode 100644 index 0000000..71bafcd Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_pageview_white_48.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_public.png b/app/src/main/res/drawable-xxxhdpi/round_public.png new file mode 100644 index 0000000..d241946 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_public.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_public_white_18.png b/app/src/main/res/drawable-xxxhdpi/round_public_white_18.png new file mode 100644 index 0000000..41899cf Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_public_white_18.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_public_white_24.png b/app/src/main/res/drawable-xxxhdpi/round_public_white_24.png new file mode 100644 index 0000000..386ab21 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_public_white_24.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_public_white_36.png b/app/src/main/res/drawable-xxxhdpi/round_public_white_36.png new file mode 100644 index 0000000..a52fa1e Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_public_white_36.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_search.png b/app/src/main/res/drawable-xxxhdpi/round_search.png new file mode 100644 index 0000000..3411b4d Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_search.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_search_white_18.png b/app/src/main/res/drawable-xxxhdpi/round_search_white_18.png new file mode 100644 index 0000000..656911d Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_search_white_18.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_search_white_24.png b/app/src/main/res/drawable-xxxhdpi/round_search_white_24.png new file mode 100644 index 0000000..89e3224 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_search_white_24.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_search_white_36.png b/app/src/main/res/drawable-xxxhdpi/round_search_white_36.png new file mode 100644 index 0000000..d9e35fe Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_search_white_36.png differ diff --git a/app/src/main/res/drawable/round_call_made_24.xml b/app/src/main/res/drawable/round_call_made_24.xml new file mode 100644 index 0000000..7dd1c62 --- /dev/null +++ b/app/src/main/res/drawable/round_call_made_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/round_close.xml b/app/src/main/res/drawable/round_close.xml new file mode 100644 index 0000000..57511cc --- /dev/null +++ b/app/src/main/res/drawable/round_close.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/round_language_24.xml b/app/src/main/res/drawable/round_language_24.xml new file mode 100644 index 0000000..e745325 --- /dev/null +++ b/app/src/main/res/drawable/round_language_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/round_pageview.xml b/app/src/main/res/drawable/round_pageview.xml new file mode 100644 index 0000000..6e39997 --- /dev/null +++ b/app/src/main/res/drawable/round_pageview.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/round_public_24.xml b/app/src/main/res/drawable/round_public_24.xml new file mode 100644 index 0000000..19fb425 --- /dev/null +++ b/app/src/main/res/drawable/round_public_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/round_search_24.xml b/app/src/main/res/drawable/round_search_24.xml new file mode 100644 index 0000000..c1818d5 --- /dev/null +++ b/app/src/main/res/drawable/round_search_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/activity_weather_provider.xml b/app/src/main/res/layout/activity_weather_provider.xml index d91ba84..2f01f41 100644 --- a/app/src/main/res/layout/activity_weather_provider.xml +++ b/app/src/main/res/layout/activity_weather_provider.xml @@ -1,5 +1,6 @@ - + android:src="@drawable/round_close" /> + + + + - + style="@style/AnotherWidget.Main.Subtitle"/> + - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_app_main.xml b/app/src/main/res/layout/fragment_app_main.xml index 28bbe62..ee129c1 100644 --- a/app/src/main/res/layout/fragment_app_main.xml +++ b/app/src/main/res/layout/fragment_app_main.xml @@ -129,7 +129,7 @@ app:tabTextAppearance="@style/AnotherWidget.Settings.Header" /> - - - + android:layout_height="match_parent" /> + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_glance_settings.xml b/app/src/main/res/layout/fragment_glance_settings.xml index b06f702..172cdb2 100644 --- a/app/src/main/res/layout/fragment_glance_settings.xml +++ b/app/src/main/res/layout/fragment_glance_settings.xml @@ -38,9 +38,9 @@ + android:src="@drawable/round_pageview"/> + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/weather_provider_settings_layout.xml b/app/src/main/res/layout/weather_provider_settings_layout.xml new file mode 100644 index 0000000..28273fa --- /dev/null +++ b/app/src/main/res/layout/weather_provider_settings_layout.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 8424050..1d9ad3d 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -126,6 +126,35 @@ Raccoglieremo i dati sulla posizione per attivare l\'aggiornamento del meteo anche quando l\'app è chiusa o non in uso.\nNon utilizzeremo i tuoi dati in nessun altro modo. Provider meteo + Questo provider meteo necessita di una chiave API\nper un corretto funzionamento. + Questo provider meteo necessita di una chiave API\nper un corretto funzionamento. + Questo provider meteo necessita di una chiave API\nper un corretto funzionamento. + Questo provider meteo necessita di una chiave API\nper un corretto funzionamento. + Questo provider meteo necessita di una chiave API\nper un corretto funzionamento. + Questo provider meteo funziona\nsolo negli Stati Uniti. + Questo provider meteo funziona unicamente in gradi Celsius. + + Apri il sito del provider, crea un account gratuito e personale.\nCerca la chiave API di default nelle impostazioni e copiala qui. + Apri il sito del provider, crea un account gratuito e personale.\nCerca la chiave API di default nelle impostazioni e copiala qui. + Apri il sito del provider, crea un account gratuito e personale.\nCerca la chiave API di default nelle impostazioni e copiala qui. + Apri il sito del provider, crea un account gratuito e personale.\nCerca la chiave API di default nelle impostazioni e copiala qui. + Apri il sito del provider, crea un account gratuito e personale.\nCerca la chiave API di default nelle impostazioni e copiala qui. + + + + Il provider meteo che hai selezionato\nnecessita di una chiave API. + La posizione attuale non è supportata da questo provider. + Seleziona una posizione valida. + Sembra che la tua chiave API sia scaduta. + La chiave API non è valida o deve ancora essere attivata. + Verifica la configurazione del provider meteo. + Errore di connessione. + Errore, verifica la configurazione del provider meteo. + Account richiesto + Solo US + Scegli provider + Scegli un provider meteo.\nAlcuni provider richiedono la creazione di un account personale, ma è grauito e permette di avere migliori prestazioni. + Orologio Tap sull\'orologio apre @@ -161,7 +190,8 @@ Passi fatti Livello batteria basso %d passi fatti finora - Carica + In carica + Carica completa Providers Glance info will show up only when there are no events displayed and only when a few conditions are verified. Player Musica diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4bdc3ae..8623436 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -112,8 +112,8 @@ Weather info is hidden Tap on weather opens Weather API key - The weather provider is configured correctly - The weather provider must be configured + The weather provider is configured correctly. + The weather provider must be configured. OpenWeather API Key Google Weather Google Awareness weather has been deprecated. It\'s now required an OpenWeather API key to show the weather in the widget. @@ -130,21 +130,13 @@ We will collect location data to update the weather information even when the app is closed or not in use.\nWe will not use these data otherwise. Weather provider - Open Weather Map - Weatherbit.io - Weatherapi.com - Here.com - Accuweather.com - Weather.gov (US)\nPowered by National Weather Services - YR.no/Met.no\nPowered by Meteorological Institute - - Open openweathermap.com - Open weatherbit.io - Open weatherapi.com - Open here.com - Open Accuweather.com - Open Weather.gov - Open yr.no + Open Weather Map + Weatherbit.io + Weatherapi.com + Here.com + Accuweather.com + Weather.gov (US)\nPowered by National Weather Services + YR.no/Met.no\nPowered by Meteorological Institute This weather provider needs\nan API key to work correctly. This weather provider needs\nan API key to work correctly. @@ -168,6 +160,12 @@ It seems that your API key has expired. API key not valid, or not yet activated. The weather provider is wrongly configured. + Connection error. + Something went wrong, check the weather provider config. + Account required + US Only + Select a provider + Select a weather provider from the list.\nA few providers need a free personal account,\nbut they\'re usually more accurate. Clock @@ -204,7 +202,8 @@ Daily steps Low battery level %d steps so far - Charged + Charging + Charged Providers Glance info will show up only when there are no events displayed and only when a few conditions are verified. Music Players diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 551dccf..99b870b 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -2,7 +2,6 @@