-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into droidcon-theme-changer
- Loading branch information
Showing
8 changed files
with
147 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ android { | |
"pl", | ||
"et", | ||
"ru", | ||
"hu", | ||
), | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
zeapp/android/src/main/java/de/berlindroid/zeapp/zeservices/ZeWeatherApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package de.berlindroid.zeapp.zeservices | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import retrofit2.http.GET | ||
|
||
interface ZeWeatherApi { | ||
|
||
@Serializable | ||
data class Weather( | ||
@SerialName(value = "hourly") | ||
val hourly: Hourly, | ||
) | ||
|
||
@Serializable | ||
data class Hourly( | ||
@SerialName(value = "time") | ||
val time: List<String>, | ||
|
||
@SerialName(value = "temperature_2m") | ||
val temperature: List<Double>, | ||
) | ||
|
||
@GET("v1/forecast?latitude=52.5244&longitude=13.4105&hourly=temperature_2m&forecast_days=16") | ||
suspend fun getWeather(): Weather | ||
} |
89 changes: 29 additions & 60 deletions
89
zeapp/android/src/main/java/de/berlindroid/zeapp/zeservices/ZeWeatherService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,38 @@ | ||
package de.berlindroid.zeapp.zeservices | ||
|
||
import de.berlindroid.zeapp.zemodels.WeatherData | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import retrofit2.http.GET | ||
|
||
internal suspend fun fetchWeather(date: String): WeatherData { | ||
try { | ||
val weather = weatherApiService.getWeather() | ||
|
||
val tempIndex = weather.hourly.time.indexOfFirst { | ||
it.contains("${date}T12:00") | ||
} | ||
if (tempIndex == -1) { | ||
import javax.inject.Inject | ||
|
||
|
||
/** | ||
* Service to fetch the weather data from the API by the provided date | ||
*/ | ||
class ZeWeatherService @Inject constructor(private val zeWeatherApi: ZeWeatherApi) { | ||
|
||
internal suspend fun fetchWeather(date: String): WeatherData { | ||
try { | ||
val weather = zeWeatherApi.getWeather() | ||
|
||
val tempIndex = weather.hourly.time.indexOfFirst { | ||
it.contains("${date}T12:00") | ||
} | ||
if (tempIndex == -1) { | ||
return WeatherData( | ||
day = null, | ||
temperature = -1.0, | ||
) | ||
} | ||
val temperature = weather.hourly.temperature[tempIndex] | ||
val day = weather.hourly.time[tempIndex] | ||
return WeatherData( | ||
day = day, | ||
temperature = temperature, | ||
) | ||
} catch (e: Exception) { | ||
return WeatherData( | ||
day = null, | ||
temperature = -1.0, | ||
temperature = -42.0, | ||
) | ||
} | ||
val temperature = weather.hourly.temperature[tempIndex] | ||
val day = weather.hourly.time[tempIndex] | ||
return WeatherData( | ||
day = day, | ||
temperature = temperature, | ||
) | ||
} catch (e: Exception) { | ||
return WeatherData( | ||
day = null, | ||
temperature = -42.0, | ||
) | ||
} | ||
} | ||
|
||
private val json = Json { | ||
ignoreUnknownKeys = true | ||
} | ||
|
||
private val retrofit = Retrofit.Builder() | ||
.baseUrl("https://api.open-meteo.com") | ||
.addConverterFactory(json.asConverterFactory("application/json".toMediaType())) | ||
.build() | ||
|
||
private val weatherApiService = retrofit.create(WeatherApi::class.java) | ||
|
||
private interface WeatherApi { | ||
|
||
@Serializable | ||
data class Weather( | ||
@SerialName(value = "hourly") | ||
val hourly: Hourly, | ||
) | ||
|
||
@Serializable | ||
data class Hourly( | ||
@SerialName(value = "time") | ||
val time: List<String>, | ||
|
||
@SerialName(value = "temperature_2m") | ||
val temperature: List<Double>, | ||
) | ||
|
||
@GET("v1/forecast?latitude=52.5244&longitude=13.4105&hourly=temperature_2m&forecast_days=16") | ||
suspend fun getWeather(): Weather | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<resources xmlns:tools="http://schemas.android.com/tools"> | ||
<string name="app_name" translatable="false">ZeApp</string> | ||
<string name="repo_url" translatable="false">https://github.com/gdg-berlin-android</string> | ||
|
||
<string name="black_and_white">B/W</string> | ||
<string name="reset">Alaphelyzet</string> | ||
<string name="ze_edit">Szerkesztés</string> | ||
<string name="floyd_steninberg_initials">FS</string> | ||
<string name="positional">Helyzeti</string> | ||
<string name="rotate">Forgatás</string> | ||
<string name="invert">Invertálás</string> | ||
<string name="static_tool">Statikus</string> | ||
<string name="ze_very_important" tools:ignore="MissingTranslation">Nagyon fontos</string> | ||
<string name="remind_binary_image" tools:ignore="MissingTranslation">(Ez nem egy fekete-fehér kép fájl. Válassz egy szín szűrőt az alábbiakból!)</string> | ||
|
||
<string name="generate">Generálás</string> | ||
<string name="not_binary_image">Nem fekete-fehér kép fájl. Minden pixelnek feketének vagy fehérnek kell lennie.</string> | ||
<string name="generate_image_page">Kép generálása</string> | ||
<string name="draw_image_page">Kép rajzolása</string> | ||
<string name="enter_prompt">Itt írd be a promptodat</string> | ||
<string name="could_not_generate_image">Nem sikerült legenerálni a képet</string> | ||
|
||
<string name="image_needed">Itt fekete-fehér képre van szükség. Nyomd meg az egyik gombot a kép alatt!</string> | ||
<string name="add_qr_url">Add meg a QR URL-t</string> | ||
<string name="qr_code_title">QR kód címe</string> | ||
<string name="qr_code_text">További szöveg</string> | ||
<string name="url">URL</string> | ||
<string name="add_barcode_url">Add meg a vonalkód URL-jét</string> | ||
<string name="bar_code_title">Vonalkód címe</string> | ||
<string name="qr_vcard">vCard</string> | ||
<string name="qr_code_email">Email</string> | ||
<string name="qr_code_phone">Telefon</string> | ||
<string name="your_name_here" tools:ignore="MissingTranslation">Neved</string> | ||
<string name="contact_me_here" tools:ignore="MissingTranslation">Elérhetőséged</string> | ||
<string name="binary_image_needed" tools:ignore="MissingTranslation">Bináris képre van szükség.</string> | ||
<string name="add_your_phrase_here" tools:ignore="MissingTranslation">Adj meg egy kifejezést</string> | ||
<string name="random_phrase" tools:ignore="MissingTranslation">Véletlenszerű kifejezés</string> | ||
<string name="unicorn_at_an_android_conference_in_isometric_view" tools:ignore="MissingTranslation">Unicorn at an android conference in isometric view.</string> | ||
<string name="name" tools:ignore="MissingTranslation">Név</string> | ||
<string name="contact" tools:ignore="MissingTranslation">Elérhetőség</string> | ||
<string name="clear" tools:ignore="MissingTranslation">Törlés</string> | ||
<string name="add_your_contact_details" tools:ignore="MissingTranslation">Add meg az elérhetőségedet</string> | ||
<string name="set_picture" tools:ignore="MissingTranslation">Kép beállítása</string> | ||
<string name="click_get_to_show_quote_of_the_day" tools:ignore="MissingTranslation">Kattints a Nap idézetére</string> | ||
<string name="get" tools:ignore="MissingTranslation">Beszerzés</string> | ||
<string name="decline" tools:ignore="MissingTranslation">Elutasítás</string> | ||
<string name="send" tools:ignore="MissingTranslation">Küldés</string> | ||
<string name="n_a" tools:ignore="MissingTranslation">N/A</string> | ||
<string name="load_weather" tools:ignore="MissingTranslation">Időjárás betöltése</string> | ||
<string name="hello_my_github_profile_is" tools:ignore="MissingTranslation">Hello, my github profile is</string> | ||
<string name="your_phrase_here" tools:ignore="MissingTranslation">A kifejezésed</string> | ||
<string name="hello_my_name_is" tools:ignore="MissingTranslation">Hello, my name is</string> | ||
<string name="upcoming_weather" tools:ignore="MissingTranslation">☀️Upcoming weather</string> | ||
<string name="quote_of_the_day" tools:ignore="MissingTranslation">Quote of The Day</string> | ||
<string name="send_icon_text" tools:ignore="MissingTranslation">Küldés</string> | ||
<string name="badge_config_editor_title">Badge összeállítás szerkesztése</string> | ||
|
||
<string name="ze_navdrawer_save_all_pages">Minden összeállítás mentése a badge-re</string> | ||
<string name="ze_navdrawer_update_config">Beállítások frissítése a badge-en</string> | ||
<string name="ze_navdrawer_send_random_page">Véletlenszerű összeállítás letöltése a badge-re</string> | ||
<string name="ze_navdrawer_new_release">✨ Új verzió elérhető: %d</string> | ||
<string name="ze_navdrawer_open_release_page">Kiadott verziók megtekintése</string> | ||
<string name="ze_navdrawer_contributors">Hozzájárulók</string> | ||
<string name="ze_navdrawer_open_source">Open Source</string> | ||
<string name="ze_select_content" tools:ignore="MissingTranslation">Tartalom kiválasztása</string> | ||
<string name="ze_not_added_yet_message" tools:ignore="MissingTranslation">Nem járultál még hozzá ezzel! Bármit hozzáadhatsz ehhez a szerkesztőhöz!</string> | ||
|
||
<string name="ze_sample_configuration_key" tools:ignore="MissingTranslation">minta összeállítás</string> | ||
<string name="ze_sample_configuration_value" tools:ignore="MissingTranslation">minta érték</string> | ||
<string name="ze_sample_int_key" tools:ignore="MissingTranslation">minta szám</string> | ||
<string name="ze_sample_another_configuration_key" tools:ignore="MissingTranslation">másik összeállítás</string> | ||
</resources> |