Skip to content

Commit

Permalink
add m/s and kn as wind speed units #90
Browse files Browse the repository at this point in the history
  • Loading branch information
woheller69 committed Aug 24, 2024
1 parent b296d9f commit 87a66a9
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,37 +89,47 @@ public static String formatDate(long time) {

public static String formatWindSpeed(Context context, float wind_speed) {
SharedPreferences sharedPreferences= PreferenceManager.getDefaultSharedPreferences(context);
if (sharedPreferences.getString("speedUnit", "3").equals("3")) {
if (wind_speed < 0.3) {
return formatInt(0, context.getString(R.string.units_Bft)); // Calm
} else if (wind_speed < 1.5) {
return formatInt(1, context.getString(R.string.units_Bft)); // Light air
} else if (wind_speed < 3.3) {
return formatInt(2, context.getString(R.string.units_Bft)); // Light breeze
} else if (wind_speed < 5.5) {
return formatInt(3, context.getString(R.string.units_Bft)); // Gentle breeze
} else if (wind_speed < 7.9) {
return formatInt(4, context.getString(R.string.units_Bft)); // Moderate breeze
} else if (wind_speed < 10.7) {
return formatInt(5, context.getString(R.string.units_Bft)); // Fresh breeze
} else if (wind_speed < 13.8) {
return formatInt(6, context.getString(R.string.units_Bft)); // Strong breeze
} else if (wind_speed < 17.1) {
return formatInt(7, context.getString(R.string.units_Bft)); // High wind
} else if (wind_speed < 20.7) {
return formatInt(8, context.getString(R.string.units_Bft)); // Gale
} else if (wind_speed < 24.4) {
return formatInt(9, context.getString(R.string.units_Bft)); // Strong gale
} else if (wind_speed < 28.4) {
return formatInt(10, context.getString(R.string.units_Bft)); // Storm
} else if (wind_speed < 32.6) {
return formatInt(11, context.getString(R.string.units_Bft)); // Violent storm
} else {
return formatInt(12, context.getString(R.string.units_Bft)); // Hurricane
}
} else if (sharedPreferences.getString("speedUnit", "3").equals("1")) {
return formatInt((float) (wind_speed*3.6),context.getString(R.string.units_km_h));
} else return formatInt((float) (wind_speed*2.236),context.getString(R.string.units_mph));
String unitPref = sharedPreferences.getString("speedUnit", "3");
switch (unitPref) {
case "1":
return formatInt((float) (wind_speed * 3.6), context.getString(R.string.units_km_h));
case "2":
return formatInt((float) (wind_speed * 2.236), context.getString(R.string.units_mph));
case "3":
if (wind_speed < 0.3) {
return formatInt(0, context.getString(R.string.units_Bft)); // Calm
} else if (wind_speed < 1.5) {
return formatInt(1, context.getString(R.string.units_Bft)); // Light air
} else if (wind_speed < 3.3) {
return formatInt(2, context.getString(R.string.units_Bft)); // Light breeze
} else if (wind_speed < 5.5) {
return formatInt(3, context.getString(R.string.units_Bft)); // Gentle breeze
} else if (wind_speed < 7.9) {
return formatInt(4, context.getString(R.string.units_Bft)); // Moderate breeze
} else if (wind_speed < 10.7) {
return formatInt(5, context.getString(R.string.units_Bft)); // Fresh breeze
} else if (wind_speed < 13.8) {
return formatInt(6, context.getString(R.string.units_Bft)); // Strong breeze
} else if (wind_speed < 17.1) {
return formatInt(7, context.getString(R.string.units_Bft)); // High wind
} else if (wind_speed < 20.7) {
return formatInt(8, context.getString(R.string.units_Bft)); // Gale
} else if (wind_speed < 24.4) {
return formatInt(9, context.getString(R.string.units_Bft)); // Strong gale
} else if (wind_speed < 28.4) {
return formatInt(10, context.getString(R.string.units_Bft)); // Storm
} else if (wind_speed < 32.6) {
return formatInt(11, context.getString(R.string.units_Bft)); // Violent storm
} else {
return formatInt(12, context.getString(R.string.units_Bft)); // Hurricane
}
case "4":
return formatInt((float) (wind_speed), context.getString(R.string.units_m_s));
case "5":
return formatInt((float) (wind_speed * 0.51444), context.getString(R.string.units_kn));
default:
return formatInt((float) (wind_speed * 2.236), context.getString(R.string.units_mph));
}

}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,7 @@
<string name="units_hours">h</string>
<string name="settings_title_precipitation">Precipitació</string>
<string name="about_license_intro">Aquesta aplicació té llicència GPLv3. Utilitza codi de:</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
<string name="units_hours">h</string>
<string name="settings_title_precipitation">Nedbør</string>
<string name="about_license_intro">Denne app er licenseret under GPLv3. Den bruger kode fra:</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>
<!-- Generated by Automatic String Resource Translation -->
<!-- https://asrt.gluege.boerde.de -->
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,7 @@
<string name="units_hours">h</string>
<string name="settings_title_precipitation">Niederschlag</string>
<string name="about_license_intro">Diese App ist unter GPLv3 lizenziert. Sie verwendet Code von:</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,7 @@
<string name="units_hours">h</string>
<string name="settings_title_precipitation">Precipitación</string>
<string name="about_license_intro">Esta aplicación tiene licencia GPLv3. Utiliza código de:</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,7 @@
<string name="units_hours">h</string>
<string name="settings_title_precipitation">Précipitation</string>
<string name="about_license_intro">Cette application est sous licence GPLv3. Il utilise le code de :</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,6 @@
<string name="units_hours">h</string>
<string name="settings_title_precipitation">Precipitazione</string>
<string name="about_license_intro">Questa app è concessa in licenza con GPLv3. Utilizza il codice da:</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
<string name="units_hours">h</string>
<string name="settings_title_precipitation">Neerslag</string>
<string name="about_license_intro">Deze app is gelicentieerd onder GPLv3. Het gebruikt code van:</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>

<!-- Generated by Automatic String Resource Translation -->
<!-- https://asrt.gluege.boerde.de -->
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,7 @@
<string name="units_hours">h</string>
<string name="settings_title_precipitation">Opad atmosferyczny</string>
<string name="about_license_intro">Ta aplikacja jest objęta licencją GPLv3. Wykorzystuje kod z:</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>
</resources>

2 changes: 2 additions & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,6 @@
<string name="units_hours">h</string>
<string name="settings_title_precipitation">Precipitação</string>
<string name="about_license_intro">Esta aplicação está licenciada sob GPLv3. Utiliza código de:</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-sk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,6 @@
<string name="units_hours">h</string>
<string name="settings_title_precipitation">Zrážky</string>
<string name="about_license_intro">Táto aplikácia je licencovaná pod GPLv3. Využíva zdrojové kódy týchto projektov:</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
<string name="units_hours">h</string>
<string name="settings_title_precipitation">Nederbörd</string>
<string name="about_license_intro">Denna app är licensierad under GPLv3. Den använder kod från:</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>
<!-- Generated by Automatic String Resource Translation -->
<!-- https://asrt.gluege.boerde.de -->
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,6 @@
<string name="units_hours">s</string>
<string name="settings_title_precipitation">Yağış</string>
<string name="about_license_intro">Bu uygulama GPLv3 kapsamında lisanslıdır. Şu kaynaktan gelen kodu kullanır:</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,6 @@
<string name="units_hours">год</string>
<string name="settings_title_precipitation">Опади</string>
<string name="about_license_intro">Ця програма ліцензована згідно з GPLv3. Він використовує код із:</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
<item>@string/units_km_h</item>
<item>@string/units_mph</item>
<item>@string/units_Bft</item>
<item>@string/units_m_s</item>
<item>@string/units_kn</item>
</string-array>
<string-array name="speedUnitsValues">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
</string-array>

<string-array name="preciptiationUnitsArray">
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,6 @@
<string name="units_hours">h</string>
<string name="settings_title_precipitation">Precipitation</string>
<string name="about_license_intro">This app is licensed under GPLv3. It uses code from:</string>
<string name="units_m_s">m/s</string>
<string name="units_kn">kn</string>
</resources>

0 comments on commit 87a66a9

Please sign in to comment.