diff --git a/MyTracks/.settings/org.eclipse.jdt.core.prefs b/MyTracks/.settings/org.eclipse.jdt.core.prefs
index dec15e80b..65082d868 100644
--- a/MyTracks/.settings/org.eclipse.jdt.core.prefs
+++ b/MyTracks/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Thu Aug 12 18:54:52 BRT 2010
+#Wed Sep 29 18:44:16 BRT 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
diff --git a/MyTracks/AndroidManifest.xml b/MyTracks/AndroidManifest.xml
index b4f5aeca7..71e892c9d 100755
--- a/MyTracks/AndroidManifest.xml
+++ b/MyTracks/AndroidManifest.xml
@@ -56,8 +56,11 @@
+
+
+ android:label="@string/statistics" />
diff --git a/MyTracks/res/menu/main.xml b/MyTracks/res/menu/main.xml
index 23053e2d5..9acffc9b3 100644
--- a/MyTracks/res/menu/main.xml
+++ b/MyTracks/res/menu/main.xml
@@ -20,10 +20,15 @@
android:icon="@android:drawable/ic_menu_preferences"
android:orderInCategory="1001"
android:title="@string/settings"/>
+
+
diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml
index a4c5c6a8a..cb5ba7b48 100644
--- a/MyTracks/res/values/strings.xml
+++ b/MyTracks/res/values/strings.xml
@@ -32,6 +32,7 @@ limitations under the License.
Please select the track to view
Current track
Last segment
+ Aggregated Statistics
No location manager was found on this device!
diff --git a/MyTracks/src/com/google/android/apps/mymaps/MyMapsConstants.java b/MyTracks/src/com/google/android/apps/mymaps/MyMapsConstants.java
index 8fa70a9c2..d88a2ff5a 100644
--- a/MyTracks/src/com/google/android/apps/mymaps/MyMapsConstants.java
+++ b/MyTracks/src/com/google/android/apps/mymaps/MyMapsConstants.java
@@ -25,5 +25,8 @@ public class MyMapsConstants {
"http://maps.google.com/maps/ms";
public static final String MAPSHOP_SERVICE = MapsClient.SERVICE;
+ /**
+ * Private constructor to prevent instantiation.
+ */
private MyMapsConstants() { }
}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/AggregatedStatsActivity.java b/MyTracks/src/com/google/android/apps/mytracks/AggregatedStatsActivity.java
new file mode 100644
index 000000000..c0f95242a
--- /dev/null
+++ b/MyTracks/src/com/google/android/apps/mytracks/AggregatedStatsActivity.java
@@ -0,0 +1,114 @@
+package com.google.android.apps.mytracks;
+
+import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
+import com.google.android.apps.mytracks.content.Track;
+import com.google.android.apps.mytracks.stats.TripStatistics;
+import com.google.android.maps.mytracks.R;
+
+import android.app.Activity;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
+import android.os.Bundle;
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.view.Window;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import java.util.List;
+
+/**
+ * Activity for viewing the combined statistics for all the recorded tracks.
+ *
+ * Other features to add - menu items to change setings.
+ *
+ * @author Fergus Nelson
+ */
+public class AggregatedStatsActivity extends Activity implements
+ OnSharedPreferenceChangeListener {
+
+ private final StatsUtilities utils;
+
+ private MyTracksProviderUtils tracksProvider;
+
+ private boolean metricUnits = true;
+
+ public AggregatedStatsActivity() {
+ this.utils = new StatsUtilities(this);
+ this.tracksProvider = MyTracksProviderUtils.Factory.get(this);
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
+ String key) {
+ Log.d(MyTracksConstants.TAG, "StatsActivity: onSharedPreferences changed "
+ + key);
+ if (key != null) {
+ if (key.equals(R.string.metric_units_key)) {
+ metricUnits = sharedPreferences.getBoolean(
+ getString(R.string.metric_units_key), true);
+ utils.setMetricUnits(metricUnits);
+ utils.updateUnits();
+ loadAggregatedStats();
+ }
+ }
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // We don't need a window title bar:
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ setContentView(R.layout.stats);
+
+ ScrollView sv = ((ScrollView) findViewById(R.id.scrolly));
+ sv.setScrollBarStyle(ScrollView.SCROLLBARS_OUTSIDE_INSET);
+
+ SharedPreferences preferences = getSharedPreferences(
+ MyTracksSettings.SETTINGS_NAME, 0);
+ if (preferences != null) {
+ metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true);
+ preferences.registerOnSharedPreferenceChangeListener(this);
+ }
+ utils.setMetricUnits(metricUnits);
+ utils.updateUnits();
+ utils.setSpeedLabel(R.id.speed_label, R.string.speed, R.string.pace_label);
+ utils.setSpeedLabels();
+
+ DisplayMetrics metrics = new DisplayMetrics();
+ getWindowManager().getDefaultDisplay().getMetrics(metrics);
+ if (metrics.heightPixels > 600) {
+ ((TextView) findViewById(R.id.speed_register)).setTextSize(80.0f);
+ }
+ loadAggregatedStats();
+ }
+
+ /**
+ * 1. Reads tracks from the db
+ * 2. Merges the trip stats from the tracks
+ * 3. Updates the view
+ */
+ private void loadAggregatedStats() {
+ List