Merge branch 'develop' of github.com:tommasoberlose/another-widget into design-update
This commit is contained in:
commit
2aed9e3b25
@ -2,7 +2,10 @@ package com.tommasoberlose.anotherwidget.global
|
|||||||
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.appcompat.app.AppCompatDelegate.*
|
import androidx.appcompat.app.AppCompatDelegate.*
|
||||||
|
import androidx.core.os.ConfigurationCompat
|
||||||
import com.chibatching.kotpref.KotprefModel
|
import com.chibatching.kotpref.KotprefModel
|
||||||
|
import com.tommasoberlose.anotherwidget.utils.isMetric
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
object Preferences : KotprefModel() {
|
object Preferences : KotprefModel() {
|
||||||
override val commitAllPropertiesByDefault: Boolean = true
|
override val commitAllPropertiesByDefault: Boolean = true
|
||||||
@ -14,8 +17,8 @@ object Preferences : KotprefModel() {
|
|||||||
var showWeather by booleanPref(key = "PREF_SHOW_WEATHER", default = false)
|
var showWeather by booleanPref(key = "PREF_SHOW_WEATHER", default = false)
|
||||||
var weatherIcon by stringPref(key = "PREF_WEATHER_ICON", default = "")
|
var weatherIcon by stringPref(key = "PREF_WEATHER_ICON", default = "")
|
||||||
var weatherTemp by floatPref(key = "PREF_WEATHER_TEMP", default = 0f)
|
var weatherTemp by floatPref(key = "PREF_WEATHER_TEMP", default = 0f)
|
||||||
var weatherTempUnit by stringPref(key = "PREF_WEATHER_TEMP_UNIT", default = "F")
|
var weatherTempUnit by stringPref(key = "PREF_WEATHER_TEMP_UNIT", default = if (ConfigurationCompat.getLocales(context.resources.configuration)[0].isMetric()) "C" else "F")
|
||||||
var weatherRealTempUnit by stringPref(key = "PREF_WEATHER_REAL_TEMP_UNIT", default = "F")
|
var weatherRealTempUnit by stringPref(key = "PREF_WEATHER_REAL_TEMP_UNIT", default = if (ConfigurationCompat.getLocales(context.resources.configuration)[0].isMetric()) "C" else "F")
|
||||||
var calendarAllDay by booleanPref(key = "PREF_CALENDAR_ALL_DAY", default = true)
|
var calendarAllDay by booleanPref(key = "PREF_CALENDAR_ALL_DAY", default = true)
|
||||||
var calendarFilter by stringPref(key = "PREF_CALENDAR_FILTER", default = "")
|
var calendarFilter by stringPref(key = "PREF_CALENDAR_FILTER", default = "")
|
||||||
|
|
||||||
@ -43,7 +46,7 @@ object Preferences : KotprefModel() {
|
|||||||
var weatherProviderApiWeatherApi by stringPref(default = "")
|
var weatherProviderApiWeatherApi by stringPref(default = "")
|
||||||
var weatherProviderApiWeatherBit by stringPref(default = "")
|
var weatherProviderApiWeatherBit by stringPref(default = "")
|
||||||
var weatherProviderApiAccuweather by stringPref(default = "")
|
var weatherProviderApiAccuweather by stringPref(default = "")
|
||||||
var weatherProvider by intPref(default = Constants.WeatherProvider.OPEN_WEATHER.value)
|
var weatherProvider by intPref(default = if (ConfigurationCompat.getLocales(context.resources.configuration)[0].isMetric()) Constants.WeatherProvider.YR.value else Constants.WeatherProvider.WEATHER_GOV.value)
|
||||||
var weatherProviderError by stringPref(default = "")
|
var weatherProviderError by stringPref(default = "")
|
||||||
var weatherProviderLocationError by stringPref(default = "")
|
var weatherProviderLocationError by stringPref(default = "")
|
||||||
var eventAppName by stringPref(key = "PREF_EVENT_APP_NAME", default = "")
|
var eventAppName by stringPref(key = "PREF_EVENT_APP_NAME", default = "")
|
||||||
|
@ -258,3 +258,10 @@ fun Intent.isDefaultSet(context: Context): Boolean {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Locale.isMetric(): Boolean {
|
||||||
|
return when (country.toUpperCase(this)) {
|
||||||
|
"US", "LR", "MM", "GB" -> false
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
}
|
@ -164,7 +164,7 @@
|
|||||||
<string name="location_access_notification_channel_id" translatable="false">location-access</string>
|
<string name="location_access_notification_channel_id" translatable="false">location-access</string>
|
||||||
<string name="location_access_notification_channel_name">Background service</string>
|
<string name="location_access_notification_channel_name">Background service</string>
|
||||||
<string name="location_access_notification_channel_description">Service used to update the weather based on the current location of the user.</string>
|
<string name="location_access_notification_channel_description">Service used to update the weather based on the current location of the user.</string>
|
||||||
<string name="location_access_notification_title">Weather update</string>
|
<string name="location_access_notification_title">Updating the weather…</string>
|
||||||
<string name="location_access_notification_subtitle">We\'re updating the weather based on your current location.</string>
|
<string name="location_access_notification_subtitle">We\'re updating the weather based on your current location.</string>
|
||||||
|
|
||||||
<!-- Clock -->
|
<!-- Clock -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user