android:parentActivityName="de.example.exampletdd.WeatherTabsActivity" >
<intent-filter>
<action android:name="android.intent.action.WEATHERINFORMATIONSETTINGS" />
-
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
</activity>
<activity android:name="de.example.exampletdd.MapActivity"
android:parentActivityName="de.example.exampletdd.WeatherTabsActivity" >
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string-array name="weather_preferences_units_value">
- <item>ºC</item>
- <item>ºF</item>
- <item>K</item>
- </string-array>
- <string-array name="weather_preferences_units_human_value">
- <item>celsius</item>
- <item>fahrenheit</item>
- <item>kelvin</item>
- </string-array>
- <string-array name="weather_preferences_language_value">
- <item>ar</item>
- <item>bg</item>
- <item>zh_cn</item>
- <item>zh_tw</item>
- <item>cz</item>
- <item>nl</item>
- <item>en</item>
- <item>fi</item>
- <item>fr</item>
- <item>gl</item>
- <item>de</item>
- <item>it</item>
- <item>mk</item>
- <item>pl</item>
- <item>pt</item>
- <item>ro</item>
- <item>ru</item>
- <item>sk</item>
- <item>sp</item>
- <item>se</item>
- <item>tr</item>
- <item>ua</item>
- <item>vi</item>
- </string-array>
- <string-array name="weather_preferences_language_human_value">
- <item>Arabic</item>
- <item>Bulgarian</item>
- <item>Chinese Simplified</item>
- <item>Chinese Traditional</item>
- <item>Czech</item>
- <item>Dutch</item>
- <item>English</item>
- <item>Finnish</item>
- <item>French</item>
- <item>Galician</item>
- <item>German</item>
- <item>Italian</item>
- <item>Macedonian</item>
- <item>Polish</item>
- <item>Portuguese</item>
- <item>Romanian</item>
- <item>Russian</item>
- <item>Slovak</item>
- <item>Spanish</item>
- <item>Swedish</item>
- <item>Turkish</item>
- <item>Ukrainian</item>
- <item>Vietnamese</item>
- </string-array>
<string-array name="weather_preferences_day_forecast">
<item>5</item>
<item>10</item>
<item>half day</item>
<item>one day</item>
</string-array>
+ <string-array name="weather_preferences_units_value">
+ <item>@string/weather_preferences_temperature_celsius</item>
+ <item>@string/weather_preferences_temperature_fahrenheit</item>
+ <item>@string/weather_preferences_temperature_kelvin</item>
+ </string-array>
+ <string-array name="weather_preferences_units_human_value">
+ <item>@string/weather_preferences_temperature_celsius_human_value</item>
+ <item>@string/weather_preferences_temperature_fahrenheit_human_value</item>
+ <item>@string/weather_preferences_temperature_kelvin_human_value</item>
+ </string-array>
<string-array name="weather_preferences_wind">
- <item>m/s</item>
- <item>mph</item>
+ <item>@string/weather_preferences_wind_meters</item>
+ <item>@string/weather_preferences_wind_miles</item>
</string-array>
<string-array name="weather_preferences_wind_human_value">
- <item>meter per second</item>
- <item>miles per hour</item>
+ <item>@string/weather_preferences_wind_human_value_meters</item>
+ <item>@string/weather_preferences_wind_human_value_miles</item>
+ </string-array>
+ <string-array name="weather_preferences_pressure">
+ <item>@string/weather_preferences_pressure_pascal</item>
+ <item>@string/weather_preferences_pressure_standard_atm</item>
+ </string-array>
+ <string-array name="weather_preferences_pressure_human_value">
+ <item>@string/weather_preferences_pressure_human_value_pascal</item>
+ <item>@string/weather_preferences_pressure_human_value_standard_atm</item>
</string-array>
</resources>
<string name="icon_weather_description">Icon weather</string>
<string name="weather_preferences_actionbar_title">Settings</string>
<string name="weather_preferences_units">Units</string>
- <string name="weather_preferences_units_key">weather_preferences_units</string>
- <string name="weather_preferences_temperature_units">Temperature</string>
+ <string name="weather_preferences_temperature_key">weather_preferences_temperature</string>
+ <string name="weather_preferences_temperature">Temperature</string>
+ <string name="weather_preferences_temperature_celsius">ºC</string>
+ <string name="weather_preferences_temperature_fahrenheit">ºF</string>
+ <string name="weather_preferences_temperature_kelvin">K</string>
+ <string name="weather_preferences_temperature_celsius_human_value">celsius</string>
+ <string name="weather_preferences_temperature_fahrenheit_human_value">fahrenheit</string>
+ <string name="weather_preferences_temperature_kelvin_human_value">kelvin</string>
<string name="weather_preferences_notifications">Notifications</string>
<string name="weather_preferences_notifications_switch_off_summary">Disabled</string>
<string name="weather_preferences_notifications_switch_on_summary">Enabled</string>
<string name="weather_preferences_refresh_interval">Refresh interval</string>
<string name="weather_preferences_wind_key">weather_preferences_wind</string>
<string name="weather_preferences_wind">Wind</string>
- <string name="weather_preferences_wind_summary">meter per second</string>
+ <string name="weather_preferences_wind_meters">m/s</string>
+ <string name="weather_preferences_wind_miles">mph</string>
+ <string name="weather_preferences_wind_human_value_meters">meter per second</string>
+ <string name="weather_preferences_wind_human_value_miles">miles per hour</string>
+ <string name="weather_preferences_pressure_key">weather_preferences_pressure</string>
+ <string name="weather_preferences_pressure">Pressure</string>
+ <string name="weather_preferences_pressure_pascal">hpa</string>
+ <string name="weather_preferences_pressure_standard_atm">atm</string>
+ <string name="weather_preferences_pressure_human_value_pascal">pascal</string>
+ <string name="weather_preferences_pressure_human_value_standard_atm">standard atmosphere</string>
<string name="widget_preferences_units">Units</string>
<string name="widget_preferences_units_key">widget_preferences_units</string>
<string name="widget_preferences_refresh_interval_key">widget_preferences_refresh_interval</string>
<string name="weather_map_button_getlocation">Get Location</string>
<string name="text_units_mm3h">mm 3h</string>
<string name="text_units_percent">%</string>
- <string name="text_units_hpa">hpa</string>
<string name="text_field_remote_error">No data available</string>
</resources>
android:summary="five minutes" />
<PreferenceCategory android:title="@string/widget_preferences_units">
<ListPreference android:key="@string/widget_preferences_units_key"
- android:title="@string/weather_preferences_temperature_units"
+ android:title="@string/weather_preferences_temperature"
android:summary="celsius"
android:entries="@array/weather_preferences_units_human_value"
android:entryValues="@array/weather_preferences_units_value"
android:defaultValue="300000"
android:summary="five minutes" />
<PreferenceCategory android:title="@string/weather_preferences_units">
- <ListPreference android:key="@string/weather_preferences_units_key"
- android:title="@string/weather_preferences_temperature_units"
- android:summary="celsius"
+ <ListPreference android:key="@string/weather_preferences_temperature_key"
+ android:title="@string/weather_preferences_temperature"
+ android:summary="@string/weather_preferences_temperature_celsius_human_value"
android:entries="@array/weather_preferences_units_human_value"
android:entryValues="@array/weather_preferences_units_value"
android:selectable="true"
android:persistent="true"
- android:defaultValue="ºC" />
+ android:defaultValue="@string/weather_preferences_temperature_celsius" />
<ListPreference android:key="@string/weather_preferences_wind_key"
android:entryValues="@array/weather_preferences_wind"
android:entries="@array/weather_preferences_wind_human_value"
- android:summary="@string/weather_preferences_wind_summary"
+ android:summary="@string/weather_preferences_wind_human_value_meters"
android:selectable="true"
android:persistent="true"
- android:defaultValue="m/s"
+ android:defaultValue="@string/weather_preferences_wind_meters"
android:title="@string/weather_preferences_wind"/>
+ <ListPreference android:key="@string/weather_preferences_pressure_key"
+ android:entryValues="@array/weather_preferences_pressure"
+ android:entries="@array/weather_preferences_pressure_human_value"
+ android:summary="@string/weather_preferences_pressure_human_value_pascal"
+ android:selectable="true"
+ android:persistent="true"
+ android:defaultValue="@string/weather_preferences_pressure_pascal"
+ android:title="@string/weather_preferences_pressure"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/weather_preferences_notifications">
<SwitchPreference android:key="@string/weather_preferences_notifications_switch_key"
// 1.1 Temperature
String tempSymbol;
UnitsConversor tempUnitsConversor;
- String keyPreference = this.getResources().getString(R.string.weather_preferences_units_key);
+ String keyPreference = this.getResources().getString(R.string.weather_preferences_temperature_key);
String unitsPreferenceValue = sharedPreferences.getString(keyPreference, "");
String[] values = this.getResources().getStringArray(R.array.weather_preferences_units_value);
if (unitsPreferenceValue.equals(values[0])) {
// 1.1 Temperature
String tempSymbol;
UnitsConversor tempUnitsConversor;
- String keyPreference = this.getResources().getString(R.string.weather_preferences_units_key);
+ String keyPreference = this.getResources().getString(R.string.weather_preferences_temperature_key);
String unitsPreferenceValue = sharedPreferences.getString(keyPreference, "");
String[] values = this.getResources().getStringArray(R.array.weather_preferences_units_value);
if (unitsPreferenceValue.equals(values[0])) {
super.onPause();
}
- private interface TempUnitsConversor {
-
- public double doConversion(final double value);
- }
-
- private interface WindUnitsConversor {
+ private interface UnitsConversor {
public double doConversion(final double value);
}
// 1. Update units of measurement.
// 1.1 Temperature
String tempSymbol;
- TempUnitsConversor tempUnitsConversor;
- String keyPreference = this.getResources().getString(R.string.weather_preferences_units_key);
+ UnitsConversor tempUnitsConversor;
+ String keyPreference = this.getResources().getString(R.string.weather_preferences_temperature_key);
String unitsPreferenceValue = sharedPreferences.getString(keyPreference, "");
String[] values = this.getResources().getStringArray(R.array.weather_preferences_units_value);
if (unitsPreferenceValue.equals(values[0])) {
tempSymbol = values[0];
- tempUnitsConversor = new TempUnitsConversor(){
+ tempUnitsConversor = new UnitsConversor(){
@Override
public double doConversion(final double value) {
};
} else if (unitsPreferenceValue.equals(values[1])) {
tempSymbol = values[1];
- tempUnitsConversor = new TempUnitsConversor(){
+ tempUnitsConversor = new UnitsConversor(){
@Override
public double doConversion(final double value) {
};
} else {
tempSymbol = values[2];
- tempUnitsConversor = new TempUnitsConversor(){
+ tempUnitsConversor = new UnitsConversor(){
@Override
public double doConversion(final double value) {
// 1.2 Wind
String windSymbol;
- WindUnitsConversor windUnitsConversor;
+ UnitsConversor windUnitsConversor;
keyPreference = this.getResources().getString(R.string.weather_preferences_wind_key);
unitsPreferenceValue = sharedPreferences.getString(keyPreference, "");
values = this.getResources().getStringArray(R.array.weather_preferences_wind);
if (unitsPreferenceValue.equals(values[0])) {
windSymbol = values[0];
- windUnitsConversor = new WindUnitsConversor(){
+ windUnitsConversor = new UnitsConversor(){
@Override
public double doConversion(double value) {
};
} else {
windSymbol = values[1];
- windUnitsConversor = new WindUnitsConversor(){
+ windUnitsConversor = new UnitsConversor(){
@Override
public double doConversion(double value) {
};
}
+ // 1.3 Pressure
+ String pressureSymbol;
+ UnitsConversor pressureUnitsConversor;
+ keyPreference = this.getResources().getString(R.string.weather_preferences_pressure_key);
+ unitsPreferenceValue = sharedPreferences.getString(keyPreference, "");
+ values = this.getResources().getStringArray(R.array.weather_preferences_pressure);
+ if (unitsPreferenceValue.equals(values[0])) {
+ pressureSymbol = values[0];
+ pressureUnitsConversor = new UnitsConversor(){
+
+ @Override
+ public double doConversion(double value) {
+ return value;
+ }
+ };
+ } else {
+ pressureSymbol = values[1];
+ pressureUnitsConversor = new UnitsConversor(){
+
+ @Override
+ public double doConversion(double value) {
+ return value / 113.25d;
+ }
+ };
+ }
+
// 2. Formatters
final DecimalFormat tempFormatter = (DecimalFormat) NumberFormat.getNumberInstance(Locale.US);
String pressureValue = "";
if ((current.getMain() != null)
&& (current.getMain().getPressure() != null)) {
- final double conversion = (Double) current.getMain().getPressure();
+ double conversion = (Double) current.getMain().getPressure();
+ conversion = pressureUnitsConversor.doConversion(conversion);
pressureValue = tempFormatter.format(conversion);
}
String windValue = "";
this.getActivity().getApplicationContext().getString(R.string.text_units_percent));
((TextView) getActivity().findViewById(R.id.weather_current_pressure_value)).setText(pressureValue);
- ((TextView) getActivity().findViewById(R.id.weather_current_pressure_units)).setText(
- this.getActivity().getApplicationContext().getString(R.string.text_units_hpa));
+ ((TextView) getActivity().findViewById(R.id.weather_current_pressure_units)).setText(pressureSymbol);
((TextView) getActivity().findViewById(R.id.weather_current_wind_value)).setText(windValue);
((TextView) getActivity().findViewById(R.id.weather_current_wind_units)).setText(windSymbol);
String symbol;
UnitsConversor unitsConversor;
String keyPreference = this.getResources().getString(
- R.string.weather_preferences_units_key);
+ R.string.weather_preferences_temperature_key);
final String unitsPreferenceValue = sharedPreferences.getString(keyPreference, "");
String[] values = this.getResources().getStringArray(R.array.weather_preferences_units_value);
if (unitsPreferenceValue.equals(values[0])) {
String[] values = this.getResources().getStringArray(R.array.weather_preferences_units_value);
String[] humanValues = this.getResources().getStringArray(R.array.weather_preferences_units_human_value);
String keyPreference = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_units_key);
+ R.string.weather_preferences_temperature_key);
Preference connectionPref = this.findPreference(keyPreference);
String value = this.getPreferenceManager().getSharedPreferences()
.getString(keyPreference, "");
humanValue = humanValues[1];
}
connectionPref.setSummary(humanValue);
-
+
+ // Pressure
+ values = this.getResources().getStringArray(R.array.weather_preferences_pressure);
+ humanValues = this.getResources().getStringArray(R.array.weather_preferences_pressure_human_value);
+ keyPreference = this.getString(R.string.weather_preferences_pressure_key);
+ connectionPref = this.findPreference(keyPreference);
+ value = this.getPreferenceManager().getSharedPreferences().getString(keyPreference, "");
+ humanValue = "";
+ if (value.equals(values[0])) {
+ humanValue = humanValues[0];
+ } else if (value.equals(values[1])) {
+ humanValue = humanValues[1];
+ }
+ connectionPref.setSummary(humanValue);
+
// Forecast days number
values = this.getResources().getStringArray(R.array.weather_preferences_day_forecast);
humanValues = this.getResources().getStringArray(R.array.weather_preferences_day_forecast_human_value);
String[] values = this.getResources().getStringArray(R.array.weather_preferences_units_value);
String[] humanValues = this.getResources().getStringArray(R.array.weather_preferences_units_human_value);
String keyValue = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_units_key);
+ R.string.weather_preferences_temperature_key);
if (key.equals(keyValue)) {
final Preference connectionPref = this.findPreference(key);
final String value = sharedPreferences.getString(key, "");
connectionPref.setSummary(humanValue);
return;
}
+
+ // Pressure
+ values = this.getResources().getStringArray(R.array.weather_preferences_pressure);
+ humanValues = this.getResources().getStringArray(R.array.weather_preferences_pressure_human_value);
+ keyValue = this.getString(R.string.weather_preferences_pressure_key);
+ if (key.equals(keyValue)) {
+ final Preference connectionPref = this.findPreference(key);
+ final String value = sharedPreferences.getString(key, "");
+ String humanValue = "";
+ if (value.equals(values[0])) {
+ humanValue = humanValues[0];
+ } else if (value.equals(values[1])) {
+ humanValue = humanValues[1];
+ }
+ connectionPref.setSummary(humanValue);
+ return;
+ }
+
// Forecast days number
values = this.getResources().getStringArray(R.array.weather_preferences_day_forecast);
humanValues = this.getResources().getStringArray(R.array.weather_preferences_day_forecast_human_value);
import de.example.exampletdd.service.IconsList;
import de.example.exampletdd.service.PermanentStorage;
+
public class SpecificFragment extends Fragment {
private int mChosenDay;
}
}
- private interface TempUnitsConversor {
-
- public double doConversion(final double value);
- }
-
- private interface WindUnitsConversor {
+ private interface UnitsConversor {
public double doConversion(final double value);
}
// 1. Update units of measurement.
// 1.1 Temperature
String tempSymbol;
- TempUnitsConversor tempUnitsConversor;
+ UnitsConversor tempUnitsConversor;
String keyPreference = this.getResources().getString(
- R.string.weather_preferences_units_key);
+ R.string.weather_preferences_temperature_key);
String unitsPreferenceValue = sharedPreferences.getString(keyPreference, "");
String[] values = this.getResources().getStringArray(R.array.weather_preferences_units_value);
if (unitsPreferenceValue.equals(values[0])) {
tempSymbol = values[0];
- tempUnitsConversor = new TempUnitsConversor(){
+ tempUnitsConversor = new UnitsConversor(){
@Override
public double doConversion(final double value) {
};
} else if (unitsPreferenceValue.equals(values[1])) {
tempSymbol = values[1];
- tempUnitsConversor = new TempUnitsConversor(){
+ tempUnitsConversor = new UnitsConversor(){
@Override
public double doConversion(final double value) {
};
} else {
tempSymbol = values[2];
- tempUnitsConversor = new TempUnitsConversor(){
+ tempUnitsConversor = new UnitsConversor(){
@Override
public double doConversion(final double value) {
// 1.2 Wind
String windSymbol;
- WindUnitsConversor windUnitsConversor;
+ UnitsConversor windUnitsConversor;
keyPreference = this.getResources().getString(R.string.weather_preferences_wind_key);
unitsPreferenceValue = sharedPreferences.getString(keyPreference, "");
values = this.getResources().getStringArray(R.array.weather_preferences_wind);
if (unitsPreferenceValue.equals(values[0])) {
windSymbol = values[0];
- windUnitsConversor = new WindUnitsConversor(){
+ windUnitsConversor = new UnitsConversor(){
@Override
public double doConversion(double value) {
};
} else {
windSymbol = values[1];
- windUnitsConversor = new WindUnitsConversor(){
+ windUnitsConversor = new UnitsConversor(){
@Override
public double doConversion(double value) {
};
}
+ // 1.3 Pressure
+ String pressureSymbol;
+ UnitsConversor pressureUnitsConversor;
+ keyPreference = this.getResources().getString(R.string.weather_preferences_pressure_key);
+ unitsPreferenceValue = sharedPreferences.getString(keyPreference, "");
+ values = this.getResources().getStringArray(R.array.weather_preferences_pressure);
+ if (unitsPreferenceValue.equals(values[0])) {
+ pressureSymbol = values[0];
+ pressureUnitsConversor = new UnitsConversor(){
+
+ @Override
+ public double doConversion(double value) {
+ return value;
+ }
+ };
+ } else {
+ pressureSymbol = values[1];
+ pressureUnitsConversor = new UnitsConversor(){
+
+ @Override
+ public double doConversion(double value) {
+ return value / 113.25d;
+ }
+ };
+ }
+
// 2. Formatters
final DecimalFormat tempFormatter = (DecimalFormat) NumberFormat.getNumberInstance(Locale.US);
}
String pressureValue = "";
if (forecast.getPressure() != null) {
- final double conversion = (Double) forecast.getPressure();
+ double conversion = (Double) forecast.getPressure();
+ conversion = pressureUnitsConversor.doConversion(conversion);
pressureValue = tempFormatter.format(conversion);
}
String windValue = "";
final TextView humidityValueView = (TextView) getActivity().findViewById(R.id.weather_specific_humidity_value);
humidityValueView.setText(humidityValue);
- final TextView pressureValueView = (TextView) getActivity().findViewById(R.id.weather_specific_pressure_value);
- pressureValueView.setText(pressureValue);
+ ((TextView) getActivity().findViewById(R.id.weather_specific_pressure_value)).setText(pressureValue);
+ ((TextView) getActivity().findViewById(R.id.weather_specific_pressure_units)).setText(pressureSymbol);
((TextView) getActivity().findViewById(R.id.weather_specific_wind_value)).setText(windValue);;
((TextView) getActivity().findViewById(R.id.weather_specific_wind_units)).setText(windSymbol);
final TextView rainValueView = (TextView) getActivity().findViewById(R.id.weather_specific_rain_value);
import android.os.Bundle;
import android.view.View;
import de.example.exampletdd.R;
-import de.example.exampletdd.fragment.map.MapProgressFragment;
public class WidgetConfigure extends Activity {
private int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
String[] values = this.getResources().getStringArray(R.array.weather_preferences_units_value);
String[] humanValues = this.getResources().getStringArray(R.array.weather_preferences_units_human_value);
String keyPreference = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_units_key);
+ R.string.weather_preferences_temperature_key);
Preference connectionPref = this.findPreference(keyPreference);
String value = this.getPreferenceManager().getSharedPreferences()
.getString(keyPreference, "");
String[] values = this.getResources().getStringArray(R.array.weather_preferences_units_value);
String[] humanValues = this.getResources().getStringArray(R.array.weather_preferences_units_human_value);
String keyValue = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_units_key);
+ R.string.weather_preferences_temperature_key);
if (key.equals(keyValue)) {
final Preference connectionPref = this.findPreference(key);
final String value = sharedPreferences.getString(key, "");