Fixed startup crash when internet is off and weather enabled. Updated accessibility service settings location.

This commit is contained in:
ottoptj 2024-08-22 19:11:21 +03:00
commit 6282b83897
3 changed files with 53 additions and 39 deletions

View file

@ -92,10 +92,12 @@ class WeatherSystem(private val context: Context) {
if (location != null) { if (location != null) {
if (location.isNotEmpty()) { if (location.isNotEmpty()) {
val url = URL("https://api.open-meteo.com/v1/forecast?$location&temperature_unit=${tempUnits}&current=temperature_2m,weather_code") val url =
URL("https://api.open-meteo.com/v1/forecast?$location&temperature_unit=${tempUnits}&current=temperature_2m,weather_code")
with(url.openConnection() as HttpURLConnection) { with(url.openConnection() as HttpURLConnection) {
requestMethod = "GET" requestMethod = "GET"
try {
inputStream.bufferedReader().use { inputStream.bufferedReader().use {
val response = it.readText() val response = it.readText()
@ -109,15 +111,19 @@ class WeatherSystem(private val context: Context) {
0, 1 -> { 0, 1 -> {
weatherType = "\uFE0E" // Sunny weatherType = "\uFE0E" // Sunny
} }
2, 3, 45, 48 -> { 2, 3, 45, 48 -> {
weatherType = "\uFE0E" // Sunny weatherType = "\uFE0E" // Sunny
} }
51, 53, 55, 56, 57, 61, 63, 65, 67, 80, 81, 82 -> { 51, 53, 55, 56, 57, 61, 63, 65, 67, 80, 81, 82 -> {
weatherType = "\uFE0E" // Rain weatherType = "\uFE0E" // Rain
} }
71, 73, 75, 77, 85, 86 -> { 71, 73, 75, 77, 85, 86 -> {
weatherType = "\uFE0E" // Snow weatherType = "\uFE0E" // Snow
} }
95, 96, 99 -> { 95, 96, 99 -> {
weatherType = "\uFE0E" // Thunder weatherType = "\uFE0E" // Thunder
} }
@ -127,8 +133,9 @@ class WeatherSystem(private val context: Context) {
currentWeather = "$weatherType ${currentData.getInt("temperature_2m")}" currentWeather = "$weatherType ${currentData.getInt("temperature_2m")}"
} }
}
} } catch(_: Exception) {}
}}
} }
return when (tempUnits) { return when (tempUnits) {

View file

@ -14,9 +14,16 @@
</style> </style>
<style name="SettingsTheme" parent="Base.Theme.YamLauncher"> <style name="SettingsTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@color/settings_bg</item> <item name="android:windowBackground">@color/settings_bg</item>
<item name="android:windowShowWallpaper">false</item> <item name="android:windowShowWallpaper">false</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:enforceNavigationBarContrast">false</item>
<item name="android:enforceStatusBarContrast">false</item>
</style> </style>
<style name="AppSearchView" parent="Widget.AppCompat.SearchView" > <style name="AppSearchView" parent="Widget.AppCompat.SearchView" >

View file

@ -5,4 +5,4 @@
android:accessibilityEventTypes="typeViewClicked" android:accessibilityEventTypes="typeViewClicked"
android:accessibilityFeedbackType="feedbackGeneric" android:accessibilityFeedbackType="feedbackGeneric"
android:notificationTimeout="100" android:notificationTimeout="100"
android:settingsActivity="eu.ottop.yamlauncher.SettingsActivity"/> android:settingsActivity="eu.ottop.yamlauncher.settings.SettingsActivity"/>