WeatherInformation: pressure units configuration and access from Android's network...
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Mon, 13 Oct 2014 00:32:58 +0000 (02:32 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Mon, 13 Oct 2014 00:34:59 +0000 (02:34 +0200)
13 files changed:
Android/WeatherInformation/AndroidManifest.xml
Android/WeatherInformation/res/values/arrays.xml
Android/WeatherInformation/res/values/strings.xml
Android/WeatherInformation/res/xml/appwidget_preferences.xml
Android/WeatherInformation/res/xml/weather_preferences.xml
Android/WeatherInformation/src/de/example/exampletdd/NotificationIntentService.java
Android/WeatherInformation/src/de/example/exampletdd/WidgetIntentService.java
Android/WeatherInformation/src/de/example/exampletdd/fragment/current/CurrentFragment.java
Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/OverviewFragment.java
Android/WeatherInformation/src/de/example/exampletdd/fragment/preferences/WeatherInformationPreferencesFragment.java
Android/WeatherInformation/src/de/example/exampletdd/fragment/specific/SpecificFragment.java
Android/WeatherInformation/src/de/example/exampletdd/widget/WidgetConfigure.java
Android/WeatherInformation/src/de/example/exampletdd/widget/WidgetPreferences.java

index a626e9b..55771d1 100644 (file)
             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" >
index d306f8e..af804e7 100644 (file)
@@ -1,65 +1,5 @@
 <?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>
index 76158fa..53195da 100644 (file)
     <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>
@@ -51,6 +66,5 @@
        <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>
index 1445bae..4ab359e 100644 (file)
@@ -10,7 +10,7 @@
         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"
index 6bf3bb0..adf3d00 100644 (file)
         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"
index 608c4d7..1773b9c 100644 (file)
@@ -113,7 +113,7 @@ public class NotificationIntentService extends IntentService {
         // 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])) {
index 75ed893..91eedee 100644 (file)
@@ -157,7 +157,7 @@ public class WidgetIntentService extends IntentService {
         // 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])) {
index 901ecfa..0e7fb9b 100644 (file)
@@ -197,12 +197,7 @@ public class CurrentFragment extends Fragment {
         super.onPause();
     }
 
-    private interface TempUnitsConversor {
-       
-       public double doConversion(final double value);
-    }
-
-    private interface WindUnitsConversor {
+    private interface UnitsConversor {
        
        public double doConversion(final double value);
     }
@@ -216,13 +211,13 @@ public class CurrentFragment extends Fragment {
         // 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) {
@@ -232,7 +227,7 @@ public class CurrentFragment extends Fragment {
                };
         } else if (unitsPreferenceValue.equals(values[1])) {
                tempSymbol = values[1];
-               tempUnitsConversor = new TempUnitsConversor(){
+               tempUnitsConversor = new UnitsConversor(){
 
                                @Override
                                public double doConversion(final double value) {
@@ -242,7 +237,7 @@ public class CurrentFragment extends Fragment {
                };
         } else {
                tempSymbol = values[2];
-               tempUnitsConversor = new TempUnitsConversor(){
+               tempUnitsConversor = new UnitsConversor(){
 
                                @Override
                                public double doConversion(final double value) {
@@ -254,13 +249,13 @@ public class CurrentFragment extends Fragment {
 
         // 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) {
@@ -269,7 +264,7 @@ public class CurrentFragment extends Fragment {
                };
         } else {
                windSymbol = values[1];
-               windUnitsConversor = new WindUnitsConversor(){
+               windUnitsConversor = new UnitsConversor(){
 
                        @Override
                        public double doConversion(double value) {
@@ -278,6 +273,32 @@ public class CurrentFragment extends Fragment {
                };
         }
 
+        // 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);
@@ -326,7 +347,8 @@ public class CurrentFragment extends Fragment {
         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 = "";
@@ -390,8 +412,7 @@ public class CurrentFragment extends Fragment {
                        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);
index c8a5bf6..9d16694 100644 (file)
@@ -213,7 +213,7 @@ public class OverviewFragment extends ListFragment {
         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])) {
index ed0c662..aa1c8ac 100644 (file)
@@ -29,7 +29,7 @@ public class WeatherInformationPreferencesFragment extends PreferenceFragment
         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, "");
@@ -56,7 +56,21 @@ public class WeatherInformationPreferencesFragment extends PreferenceFragment
             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);
@@ -145,7 +159,7 @@ public class WeatherInformationPreferencesFragment extends PreferenceFragment
        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, "");
@@ -179,7 +193,25 @@ public class WeatherInformationPreferencesFragment extends PreferenceFragment
                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);
index 40f11d9..3497db4 100644 (file)
@@ -23,6 +23,7 @@ import de.example.exampletdd.model.forecastweather.Forecast;
 import de.example.exampletdd.service.IconsList;
 import de.example.exampletdd.service.PermanentStorage;
 
+
 public class SpecificFragment extends Fragment {
     private int mChosenDay;
 
@@ -103,12 +104,7 @@ public class SpecificFragment extends Fragment {
         }
     }
 
-    private interface TempUnitsConversor {
-       
-       public double doConversion(final double value);
-    }
-
-    private interface WindUnitsConversor {
+    private interface UnitsConversor {
        
        public double doConversion(final double value);
     }
@@ -122,14 +118,14 @@ public class SpecificFragment extends Fragment {
         // 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) {
@@ -139,7 +135,7 @@ public class SpecificFragment extends Fragment {
                };
         } else if (unitsPreferenceValue.equals(values[1])) {
                tempSymbol = values[1];
-               tempUnitsConversor = new TempUnitsConversor(){
+               tempUnitsConversor = new UnitsConversor(){
 
                                @Override
                                public double doConversion(final double value) {
@@ -149,7 +145,7 @@ public class SpecificFragment extends Fragment {
                };
         } else {
                tempSymbol = values[2];
-               tempUnitsConversor = new TempUnitsConversor(){
+               tempUnitsConversor = new UnitsConversor(){
 
                                @Override
                                public double doConversion(final double value) {
@@ -161,13 +157,13 @@ public class SpecificFragment extends Fragment {
 
         // 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) {
@@ -176,7 +172,7 @@ public class SpecificFragment extends Fragment {
                };
         } else {
                windSymbol = values[1];
-               windUnitsConversor = new WindUnitsConversor(){
+               windUnitsConversor = new UnitsConversor(){
 
                        @Override
                        public double doConversion(double value) {
@@ -185,6 +181,32 @@ public class SpecificFragment extends Fragment {
                };
         }
 
+        // 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);
@@ -238,7 +260,8 @@ public class SpecificFragment extends Fragment {
         }        
         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 = "";
@@ -299,8 +322,8 @@ public class SpecificFragment extends Fragment {
         
         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);
index 25ee849..6a89c70 100644 (file)
@@ -8,7 +8,6 @@ import android.content.Intent;
 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;
index 1fc7202..0edf6e2 100644 (file)
@@ -26,7 +26,7 @@ public class WidgetPreferences extends PreferenceFragment {
         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, "");
@@ -73,7 +73,7 @@ public class WidgetPreferences extends PreferenceFragment {
        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, "");