Skip to content

Commit

Permalink
Added IT Translations
Browse files Browse the repository at this point in the history
  • Loading branch information
evilbunny2008 committed Apr 17, 2021
1 parent 1040ab1 commit d993f16
Show file tree
Hide file tree
Showing 10 changed files with 247 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
minSdkVersion 19
//noinspection OldTargetApi
targetSdkVersion 29
versionCode 9002
versionName "0.9.2"
versionCode 9004
versionName "0.9.4"
}
buildTypes {
release {
Expand Down
75 changes: 74 additions & 1 deletion app/src/main/assets/weathericons.css
Original file line number Diff line number Diff line change
Expand Up @@ -3568,4 +3568,77 @@
}
.wi-met-ie-52n:before {
content: "\f024";
}
}
.wi-ilmeteo-ss1:before {
content: "\f00d";
}
.wi-ilmeteo-ss2:before {
content: "\f00d";
}
.wi-ilmeteo-ss3:before {
content: "\f00c";
}
.wi-ilmeteo-ss4:before {
content: "\f002";
}
.wi-ilmeteo-ss5:before {
content: "\f00b";
}
.wi-ilmeteo-ss6:before {
content: "\f004";
}
.wi-ilmeteo-ss7:before {
content: "\f00a";
}
.wi-ilmeteo-ss8:before {
content: "\f013";
}
.wi-ilmeteo-ss9:before {
content: "\f01c";
}
.wi-ilmeteo-ss10:before {
content: "\f01a";
}
.wi-ilmeteo-ss11:before {
content: "\f0ab";
}
.wi-ilmeteo-ss12:before {
content: "\f018";
}
.wi-ilmeteo-ss13:before {
content: "\f01d";
}
.wi-ilmeteo-ss14:before {
content: "\f014";
}
.wi-ilmeteo-ss15:before {
content: "\f003";
}
.wi-ilmeteo-ss16:before {
content: "\f00e";
}
.wi-ilmeteo-ss17:before {
content: "\f01c";
}
.wi-ilmeteo-ss18:before {
content: "\f01b";
}
.wi-ilmeteo-ss19:before {
content: "\f00e";
}
.wi-ilmeteo-ss20:before {
content: "\f068";
}
.wi-ilmeteo-ss21:before {
content: "\f00c";
}
.wi-ilmeteo-ss22:before {
content: "\f072";
}
.wi-ilmeteo-ss23:before {
content: "\f002";
}
.wi-ilmeteo-ss24:before {
content: "\f072";
}

85 changes: 79 additions & 6 deletions app/src/main/java/com/odiousapps/weewxweather/Common.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.odiousapps.weewxweather;

import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
Expand Down Expand Up @@ -218,12 +217,11 @@ void RemovePref(String name)
LogMessage("Removing '" + name + "'");
}

@SuppressLint("ApplySharedPref")
void commit()
{
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.commit();
editor.apply();
}

String GetStringPref(String name, String defval)
Expand Down Expand Up @@ -1634,6 +1632,81 @@ String[] processDWD(String data, boolean showHeader)
return new String[]{generateForecast(days, timestamp, showHeader), desc};
}

String[] processILMETEO(String data)
{
return processILMETEO(data, false);
}

String[] processILMETEO(String data, boolean showHeader)
{
if (data == null || data.equals(""))
return null;

boolean metric = GetBoolPref("metric", true);
boolean use_icons = GetBoolPref("use_icons", false);
List<Day> days = new ArrayList<>();
String desc = "";
long timestamp, lastTS;

try
{
String[] bits = data.split("<title>");
if (bits.length >= 2)
desc = bits[1].split(" &#9655; ")[0];
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
String ftime = sdf.format(System.currentTimeMillis());
ftime = ftime + " " + data.split("<b>Aggiornamento delle ore</b> ", 2)[1].split(" - ", 2)[0].trim();
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault());
lastTS = timestamp = sdf.parse(ftime).getTime();

data = data.split("<li class=\"tabnav\">")[0].trim();
bits = data.split("<span style=\"display:block\">");
for(int i = 1; i < bits.length; i++)
{
Day day = new Day();
String bit = bits[i].split("</li>")[0].trim();
String icon, temp;
day.day = bit.split("</span>", 2)[0].trim();

day.timestamp = convertDaytoTS(day.day, new Locale("it", "IT"), lastTS);
if(day.timestamp != 0)
{
sdf = new SimpleDateFormat("EEE dd", Locale.getDefault());
day.day = sdf.format(day.timestamp) + " " + day.day.substring(day.day.lastIndexOf(" ") + 1);
}

icon = bit.split("<span class=\"s ", 2)[1].split("\"></span>",2)[0].trim();
day.max = bit.split("<span class=\"tmax\">", 2)[1].split("&deg;</span>", 2)[0].trim();
day.min = bit.split("<span class=\"tmin\">", 2)[1].split("&deg;</span>", 2)[0].trim();

if(use_icons)
{
String fileName = "ilmeteo_" + icon + ".png";
day.icon = "file://" + checkImage(fileName, null);
} else {
day.icon = "wi wi-ilmeteo-" + icon;
}

if(metric)
{
day.max += "&deg;C";
day.min += "&deg;C";
} else {
day.max = round((Double.parseDouble(day.max) * 9.0 / 5.0) + 32.0) + "&deg;F";
day.min = round((Double.parseDouble(day.min) * 9.0 / 5.0) + 32.0) + "&deg;F";
}

days.add(day);
lastTS = day.timestamp;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}

return new String[]{generateForecast(days, timestamp, showHeader), desc};
}

String[] processAEMET(String data)
{
return processAEMET(data, false);
Expand Down Expand Up @@ -2418,7 +2491,7 @@ void reallyGetWeather(String fromURL) throws Exception
if(!line.equals(""))
{
String[] bits = line.split("\\|");
if (Double.valueOf(bits[0]) < inigo_version)
if (Double.parseDouble(bits[0]) < inigo_version)
{
if(GetLongPref("inigo_version", 0) < Common.inigo_version)
{
Expand All @@ -2427,7 +2500,7 @@ void reallyGetWeather(String fromURL) throws Exception
}
}

if (Double.valueOf(bits[0]) >= 4000)
if (Double.parseDouble(bits[0]) >= 4000)
{
StringBuilder sb = new StringBuilder();
for (int i = 1; i < bits.length; i++)
Expand Down Expand Up @@ -3292,7 +3365,7 @@ boolean checkForImages()
return false;

String[] files = new String[]{"aemet_11_g.png", "apixu_113.png", "bom1.png", "bom2clear.png", "dwd_pic_0_8.png",
"i1.png", "met0.png", "mf_j_w1_0_n_2.png", "ms_cloudy.png",
"i1.png", "ilmeteo_ss1.png", "met0.png", "mf_j_w1_0_n_2.png", "ms_cloudy.png",
"wca00.png", "wgovbkn.jpg", "wzclear.png", "y01d.png", "yahoo0.gif", "yrno01d.png"};
for(String file : files)
{
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/odiousapps/weewxweather/Custom.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.view.ViewTreeObserver;
import android.webkit.ConsoleMessage;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

Expand Down Expand Up @@ -50,6 +51,9 @@ public boolean onLongClick(View v)
}
});

WebSettings settings = wv.getSettings();
settings.setDomStorageEnabled(true);

swipeLayout = rootView.findViewById(R.id.swipeToRefresh);
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener()
{
Expand Down
16 changes: 14 additions & 2 deletions app/src/main/java/com/odiousapps/weewxweather/Forecast.java
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,13 @@ public void run()
updateForecast(content[0], content[1]);
break;
}
case "ilmeteo.it":
{
String[] content = common.processILMETEO(data, true);
if(content != null && content.length >= 2)
updateForecast(content[0], content[1]);
break;
}
}

mHandler.post(new Runnable()
Expand Down Expand Up @@ -763,9 +770,11 @@ public void run()
case "bom2":
im.setImageResource(R.drawable.bom);
if(dark_theme)
{
im.setColorFilter(new ColorMatrixColorFilter(Common.NEGATIVE));
else
im.setColorFilter(null);
} else {
im.setColorFilter(null);
}
break;
case "aemet.es":
im.setImageResource(R.drawable.aemet);
Expand Down Expand Up @@ -810,6 +819,9 @@ public void run()
else
im.setColorFilter(null);
break;
case "ilmeteo.it":
im.setImageResource(R.drawable.ilmeteo_it);
break;
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,10 @@ public void run()
Common.LogMessage("fctype=" + fctype);
Common.LogMessage("metierev=" + metierev);
break;
case "ilmeteo.it":
Common.LogMessage("forecast=" + forecast);
Common.LogMessage("fctype=" + fctype);
break;
default:
common.SetStringPref("lastError", "forecast type " + fctype + " is invalid, check your settings file and try again.");
handlerForecast.sendEmptyMessage(0);
Expand All @@ -735,7 +739,7 @@ public void run()
}
}

Common.LogMessage("line 780");
Common.LogMessage("line 742");

if((fctype.equals("weather.gov") || fctype.equals("yahoo")) && !common.checkForImages() && !use_icons.isChecked())
{
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/com/odiousapps/weewxweather/Weather.java
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,24 @@ public void run()
tmp = "<head>" + Common.ssheader + "</head>";
sb.append(tmp);

tmp = "<body style='text-align:center'>" + logo + content[0] + "</body></html>";
sb.append(tmp);
break;
}
case "ilmeteo.it":
{
String[] content = common.processILMETEO(data);
if (content == null || content.length <= 0)
return;

String logo = "<img src='ilmeteo_it.png' height='29px'/><br/>";
sb.append("<html>");
if(dark_theme)
tmp = "<head><style>body{color: #fff; background-color: #000;}</style>" + Common.ssheader + "</head>";
else
tmp = "<head>" + Common.ssheader + "</head>";
sb.append(tmp);

tmp = "<body style='text-align:center'>" + logo + content[0] + "</body></html>";
sb.append(tmp);
break;
Expand Down
Binary file added app/src/main/res/drawable/ilmeteo_it.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">weeWX Weather App</string>
<string name="action_settings">Impostazioni</string>
<string name="section_format">Ciao Mondo dalla sezio: %1$d</string>
<string name="settings">Pagina delle impostazioni</string>
<string name="fileURL">Inserisci l\'URL del tuo settings.txt</string>
<string name="refresh_time">Aggiorna</string>
<string name="save_settings">Salva</string>
<string name="empty">Vuoto</string>
<string name="today">Statistiche odierne</string>
<string name="radarURL">Inserisci l\'indirizzo radar.html (facoltativo)</string>
<string name="stats">Statistiche meteo</string>
<string name="todayStats">Statistiche di oggi</string>
<string name="yesterdayStats">Statistiche di ieri</string>
<string name="monthlyStats">Statistiche mensili</string>
<string name="updateBG">Aggiornamento in background?</string>
<string name="yes">Si</string>
<string name="forecast">Previsioni Meteo</string>
<string name="mainmenu">Pagina Meteo</string>
<string name="metric">Utilizzare la metrica nelle previsioni?</string>
<string name="webcam">Webcam</string>
<string name="custom">Personalizza Schermo</string>
<string name="about">Info weeWX Weather App</string>
<string name="weather2">Meteo</string>
<string name="stats2">Statistiche</string>
<string name="forecast2">Previsioni</string>
<string name="webcam2">Webcam</string>
<string name="custom2">Custom</string>
<string name="settings2">Impostazioni</string>
<string name="about2">Info</string>
<string name="delete_all_data">Elimina tutti i dati e arresta</string>
<string name="show_radar">Mostra radar</string>
<string name="show_forecast">Mostra previsione</string>
<string name="radarforecast">Radar o previsione sulla schermata principale</string>
<string name="navigation_drawer_open">Apri il riquadro a scomparsa di navigazione</string>
<string name="navigation_drawer_close">Chiudi il riquadro a scomparsa di navigazione</string>
<string name="nav_header_title">weeWX Weather App</string>
<string name="demo_min_label">Min</string>
<string name="demo_max_label">Max</string>
<string name="radar">Radar</string>
<string name="custom_url">Inserisci il tuo URL personalizzato (opzionale)</string>
<string name="fgColour">Colore in primo piano del widget</string>
<string name="bgColour">Colore di sfondo del widget</string>
<string name="indoor_readings">Mostra letture interne?</string>
<string name="update_over_wifi">Aggiornare solo tramite Wi-Fi?</string>
<string name="use_dark_theme">Usa tema scuro?</string>
<string name="rooster">Rooster</string>
<string name="use_icons">Usare le icone invece dei glifi?</string>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.android.tools.build:gradle:4.1.3'


// NOTE: Do not place your application dependencies here; they belong
Expand Down

0 comments on commit d993f16

Please sign in to comment.