Improvements in GUI for google map in weather information app.
authorgu.martinm@gmail.com <gu.martinm@gmail.com>
Wed, 9 Apr 2014 07:21:51 +0000 (09:21 +0200)
committergu.martinm@gmail.com <gu.martinm@gmail.com>
Wed, 9 Apr 2014 07:23:11 +0000 (09:23 +0200)
13 files changed:
gen/.gitignore [new file with mode: 0644]
res/drawable-hdpi/ic_action_map.png [deleted file]
res/drawable-hdpi/ic_action_place.png [new file with mode: 0644]
res/drawable-mdpi/ic_action_map.png [deleted file]
res/drawable-mdpi/ic_action_place.png [new file with mode: 0644]
res/drawable-xhdpi/ic_action_map.png [deleted file]
res/drawable-xhdpi/ic_action_place.png [new file with mode: 0644]
res/drawable-xxhdpi/ic_action_map.png [deleted file]
res/drawable-xxhdpi/ic_action_place.png [new file with mode: 0644]
res/menu/weather_main_menu.xml
res/values/strings.xml
src/de/example/exampletdd/WeatherInformationMapActivity.java
src/de/example/exampletdd/fragment/WeatherInformationDataFragment.java

diff --git a/gen/.gitignore b/gen/.gitignore
new file mode 100644 (file)
index 0000000..d4ffb9e
--- /dev/null
@@ -0,0 +1,2 @@
+/com
+/de
diff --git a/res/drawable-hdpi/ic_action_map.png b/res/drawable-hdpi/ic_action_map.png
deleted file mode 100644 (file)
index 370cf5c..0000000
Binary files a/res/drawable-hdpi/ic_action_map.png and /dev/null differ
diff --git a/res/drawable-hdpi/ic_action_place.png b/res/drawable-hdpi/ic_action_place.png
new file mode 100644 (file)
index 0000000..dba994d
Binary files /dev/null and b/res/drawable-hdpi/ic_action_place.png differ
diff --git a/res/drawable-mdpi/ic_action_map.png b/res/drawable-mdpi/ic_action_map.png
deleted file mode 100644 (file)
index 50a9100..0000000
Binary files a/res/drawable-mdpi/ic_action_map.png and /dev/null differ
diff --git a/res/drawable-mdpi/ic_action_place.png b/res/drawable-mdpi/ic_action_place.png
new file mode 100644 (file)
index 0000000..ce055ca
Binary files /dev/null and b/res/drawable-mdpi/ic_action_place.png differ
diff --git a/res/drawable-xhdpi/ic_action_map.png b/res/drawable-xhdpi/ic_action_map.png
deleted file mode 100644 (file)
index 537c5a4..0000000
Binary files a/res/drawable-xhdpi/ic_action_map.png and /dev/null differ
diff --git a/res/drawable-xhdpi/ic_action_place.png b/res/drawable-xhdpi/ic_action_place.png
new file mode 100644 (file)
index 0000000..5e93aeb
Binary files /dev/null and b/res/drawable-xhdpi/ic_action_place.png differ
diff --git a/res/drawable-xxhdpi/ic_action_map.png b/res/drawable-xxhdpi/ic_action_map.png
deleted file mode 100644 (file)
index ed72ce9..0000000
Binary files a/res/drawable-xxhdpi/ic_action_map.png and /dev/null differ
diff --git a/res/drawable-xxhdpi/ic_action_place.png b/res/drawable-xxhdpi/ic_action_place.png
new file mode 100644 (file)
index 0000000..25623c7
Binary files /dev/null and b/res/drawable-xxhdpi/ic_action_place.png differ
index 33a8e65..a589c87 100644 (file)
@@ -28,7 +28,7 @@
     </item>
     <item
         android:id="@+id/weather_menu_map"
-        android:icon="@drawable/ic_action_map"
+        android:icon="@drawable/ic_action_place"
         android:showAsAction="ifRoom|withText"
         android:visible="true"
         android:checkable="false"
index 2307940..ad65976 100644 (file)
@@ -42,6 +42,7 @@
     <string name="weather_preferences_language">Language</string>
     <string name="city_not_found">city not found</string>
     <string name="country_not_found">country not found</string>
-    <string name="weather_progress_getdata">Downloading remote data</string>
+    <string name="progress_dialog_get_remote_data">Downloading remote data</string>
+    <string name="progress_dialog_generic_message">Please wait&#8230;</string>
 
 </resources>
index ad67b52..779a243 100644 (file)
@@ -20,9 +20,9 @@ import android.os.Bundle;
 import android.util.Log;
 import android.widget.TextView;
 
+import com.google.android.gms.maps.CameraUpdateFactory;
 import com.google.android.gms.maps.GoogleMap;
 import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener;
-import com.google.android.gms.maps.GoogleMap.OnMarkerClickListener;
 import com.google.android.gms.maps.MapFragment;
 import com.google.android.gms.maps.model.LatLng;
 import com.google.android.gms.maps.model.Marker;
@@ -50,13 +50,6 @@ public class WeatherInformationMapActivity extends Activity {
         this.mMap.setMyLocationEnabled(true);
         this.mMap.getUiSettings().setCompassEnabled(false);
         this.mMap.setOnMapLongClickListener(new LongClickListener());
-        this.mMap.setOnMarkerClickListener(new MarkerClickListener());
-
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
 
         GeocodingData geocodingData = null;
         try {
@@ -75,9 +68,11 @@ public class WeatherInformationMapActivity extends Activity {
             final LatLng point = new LatLng(
                     geocodingData.getLatitude(), geocodingData.getLongitude());
             this.mMap.clear();
-            this.mMarker = this.mMap.addMarker(new MarkerOptions().position(
-                    point).draggable(
-                            true));
+            this.mMarker = this.mMap.addMarker(new MarkerOptions().position(point).draggable(true));
+
+            this.mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(point,15));
+            this.mMap.animateCamera(CameraUpdateFactory.zoomIn());
+            this.mMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);
 
             final TextView cityCountry = (TextView) WeatherInformationMapActivity.this
                     .findViewById(R.id.weather_map_citycountry_data);
@@ -128,16 +123,7 @@ public class WeatherInformationMapActivity extends Activity {
 
         @Override
         public void onMapLongClick(final LatLng point) {
-            if (WeatherInformationMapActivity.this.mMarker == null) {
-                WeatherInformationMapActivity.this.mMarker = WeatherInformationMapActivity.this.mMap
-                        .addMarker(new MarkerOptions().position(point).draggable(
-                                true));
-            } else {
-                WeatherInformationMapActivity.this.mMarker.setPosition(point);
-            }
-
             final GeocoderAsyncTask geocoderAsyncTask = new GeocoderAsyncTask();
-          
             geocoderAsyncTask.execute(point.latitude, point.longitude);
         }
     }
@@ -148,7 +134,8 @@ public class WeatherInformationMapActivity extends Activity {
 
         public GeocoderAsyncTask() {
             this.newFragment = ProgressDialogFragment
-                    .newInstance(R.string.weather_progress_getdata);
+                    .newInstance(R.string.progress_dialog_get_remote_data,
+                            WeatherInformationMapActivity.this.getString(R.string.progress_dialog_generic_message));
         }
 
         @Override
@@ -198,6 +185,7 @@ public class WeatherInformationMapActivity extends Activity {
 
         private void onPostExecuteThrowable(final GeocodingData geocodingData)
                 throws FileNotFoundException, IOException {
+
             WeatherInformationMapActivity.this.storeGeocodingDataToFile(geocodingData);
 
             final String city = (geocodingData.getCity() == null) ?
@@ -206,11 +194,18 @@ public class WeatherInformationMapActivity extends Activity {
             final String country = (geocodingData.getCountry() == null) ?
                     WeatherInformationMapActivity.this.getString(R.string.country_not_found)
                     : geocodingData.getCountry();
-
             final TextView cityCountry = (TextView) WeatherInformationMapActivity.this
-                    .findViewById(R.id.weather_map_citycountry_data);
-
+                                    .findViewById(R.id.weather_map_citycountry_data);
             cityCountry.setText(city + "," + country);
+
+            final LatLng point = new LatLng(geocodingData.getLatitude(), geocodingData.getLongitude());
+            if (WeatherInformationMapActivity.this.mMarker == null) {
+                WeatherInformationMapActivity.this.mMarker =
+                        WeatherInformationMapActivity.this.mMap.addMarker
+                            (new MarkerOptions().position(point).draggable(true));
+            } else {
+                WeatherInformationMapActivity.this.mMarker.setPosition(point);
+            }
         }
 
         private GeocodingData getGeocodingData(final double latitude, final double longitude) throws IOException {
@@ -234,14 +229,4 @@ public class WeatherInformationMapActivity extends Activity {
         }
 
     }
-
-    private class MarkerClickListener implements OnMarkerClickListener {
-
-        @Override
-        public boolean onMarkerClick(final Marker marker) {
-            marker.getPosition();
-            return false;
-        }
-
-    }
 }
index efc8657..5d60ecf 100644 (file)
@@ -210,11 +210,12 @@ public class WeatherInformationDataFragment extends Fragment implements GetWeath
             entries.set(6, new WeatherDataEntry(this.getString(R.string.text_field_cloudiness), tempFormatter.format(cloudiness)));
         }
 
-        if (weatherData.getIconData() != null) {
+        if (weatherData.getWeather().getIcon() != null) {
             final Bitmap icon = BitmapFactory.decodeByteArray(
                     weatherData.getIconData(), 0,
                     weatherData.getIconData().length);
-            final ImageView imageIcon = (ImageView) this.getActivity().findViewById(R.id.weather_picture);
+            final ImageView imageIcon = (ImageView) this.getActivity()
+                    .findViewById(R.id.weather_picture);
             imageIcon.setImageBitmap(icon);
         }
 
@@ -285,8 +286,10 @@ public class WeatherInformationDataFragment extends Fragment implements GetWeath
                 final WeatherService weatherService) {
             this.weatherHTTPClient = weatherHTTPClient;
             this.weatherService = weatherService;
-            this.newFragment = ProgressDialogFragment
-                    .newInstance(R.string.weather_progress_getdata);
+            this.newFragment = ProgressDialogFragment.newInstance(
+                    R.string.progress_dialog_get_remote_data,
+                    WeatherInformationDataFragment.this
+                    .getString(R.string.progress_dialog_generic_message));
         }
 
         @Override