forked from upstream-mirrors/OpenTracks
Tidy up to adhere to style guidlines
This commit is contained in:
@@ -56,17 +56,17 @@
|
|||||||
<activity android:name="com.google.android.apps.mytracks.MyTracksSettings"
|
<activity android:name="com.google.android.apps.mytracks.MyTracksSettings"
|
||||||
android:label="@string/mytracks_settings" />
|
android:label="@string/mytracks_settings" />
|
||||||
|
|
||||||
<activity android:name="com.google.android.apps.mytracks.AggregatedStatsActivity"
|
<activity android:name="com.google.android.apps.mytracks.AggregatedStatsActivity"
|
||||||
android:label="@string/aggregated_stats" />
|
android:label="@string/aggregated_stats" />
|
||||||
|
|
||||||
<activity android:name="com.google.android.apps.mytracks.StatsActivity"
|
<activity android:name="com.google.android.apps.mytracks.StatsActivity"
|
||||||
android:label="@string/statistics" />
|
android:label="@string/statistics" />
|
||||||
|
|
||||||
<activity android:name="com.google.android.apps.mytracks.ChartActivity"
|
<activity android:name="com.google.android.apps.mytracks.ChartActivity"
|
||||||
android:label="@string/elevation_label"/>
|
android:label="@string/elevation_label"/>
|
||||||
|
|
||||||
<activity android:name="com.google.android.apps.mytracks.WelcomeActivity"
|
<activity android:name="com.google.android.apps.mytracks.WelcomeActivity"
|
||||||
android:label="@string/welcome"/>
|
android:label="@string/welcome"/>
|
||||||
|
|
||||||
<service android:name="com.google.android.apps.mytracks.services.TrackRecordingService"
|
<service android:name="com.google.android.apps.mytracks.services.TrackRecordingService"
|
||||||
android:process=":trackrecord"
|
android:process=":trackrecord"
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.google.android.apps.mytracks;
|
package com.google.android.apps.mytracks;
|
||||||
|
|
||||||
import java.util.List;
|
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.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@@ -12,10 +15,7 @@ import android.view.Window;
|
|||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
import java.util.List;
|
||||||
import com.google.android.apps.mytracks.content.Track;
|
|
||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
|
||||||
import com.google.android.maps.mytracks.R;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity for viewing the combined statistics for all the recorded tracks.
|
* Activity for viewing the combined statistics for all the recorded tracks.
|
||||||
@@ -24,38 +24,39 @@ import com.google.android.maps.mytracks.R;
|
|||||||
*
|
*
|
||||||
* @author Fergus Nelson
|
* @author Fergus Nelson
|
||||||
*/
|
*/
|
||||||
public class AggregatedStatsActivity extends Activity
|
public class AggregatedStatsActivity extends Activity implements
|
||||||
implements OnSharedPreferenceChangeListener {
|
OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
private final StatsUtilities utils;
|
private final StatsUtilities utils;
|
||||||
|
|
||||||
private MyTracksProviderUtils tracksProvider;
|
private MyTracksProviderUtils tracksProvider;
|
||||||
|
|
||||||
private boolean metricUnits = true;
|
private boolean metricUnits = true;
|
||||||
|
|
||||||
public AggregatedStatsActivity() {
|
public AggregatedStatsActivity() {
|
||||||
this.utils = new StatsUtilities(this);
|
this.utils = new StatsUtilities(this);
|
||||||
this.tracksProvider = MyTracksProviderUtils.Factory.get(this);
|
this.tracksProvider = MyTracksProviderUtils.Factory.get(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
|
||||||
Log.d(MyTracksConstants.TAG, "StatsActivity: onSharedPreferences changed "
|
String key) {
|
||||||
+ key);
|
Log.d(MyTracksConstants.TAG, "StatsActivity: onSharedPreferences changed "
|
||||||
if (key != null) {
|
+ key);
|
||||||
if (key.equals(MyTracksSettings.METRIC_UNITS)) {
|
if (key != null) {
|
||||||
metricUnits = sharedPreferences.getBoolean(
|
if (key.equals(MyTracksSettings.METRIC_UNITS)) {
|
||||||
MyTracksSettings.METRIC_UNITS, true);
|
metricUnits = sharedPreferences.getBoolean(
|
||||||
utils.setMetricUnits(metricUnits);
|
MyTracksSettings.METRIC_UNITS, true);
|
||||||
utils.updateUnits();
|
utils.setMetricUnits(metricUnits);
|
||||||
loadAggregatedStats();
|
utils.updateUnits();
|
||||||
}
|
loadAggregatedStats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// We don't need a window title bar:
|
// We don't need a window title bar:
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
@@ -64,11 +65,10 @@ public class AggregatedStatsActivity extends Activity
|
|||||||
ScrollView sv = ((ScrollView) findViewById(R.id.scrolly));
|
ScrollView sv = ((ScrollView) findViewById(R.id.scrolly));
|
||||||
sv.setScrollBarStyle(ScrollView.SCROLLBARS_OUTSIDE_INSET);
|
sv.setScrollBarStyle(ScrollView.SCROLLBARS_OUTSIDE_INSET);
|
||||||
|
|
||||||
SharedPreferences preferences =
|
SharedPreferences preferences = getSharedPreferences(
|
||||||
getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0);
|
MyTracksSettings.SETTINGS_NAME, 0);
|
||||||
if (preferences != null) {
|
if (preferences != null) {
|
||||||
metricUnits = preferences.getBoolean(MyTracksSettings.METRIC_UNITS,
|
metricUnits = preferences.getBoolean(MyTracksSettings.METRIC_UNITS, true);
|
||||||
true);
|
|
||||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
utils.setMetricUnits(metricUnits);
|
utils.setMetricUnits(metricUnits);
|
||||||
@@ -82,33 +82,32 @@ public class AggregatedStatsActivity extends Activity
|
|||||||
((TextView) findViewById(R.id.speed_register)).setTextSize(80.0f);
|
((TextView) findViewById(R.id.speed_register)).setTextSize(80.0f);
|
||||||
}
|
}
|
||||||
loadAggregatedStats();
|
loadAggregatedStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. Reads tracks from the db
|
* 1. Reads tracks from the db 2. Merges the trip stats from the tracks 3.
|
||||||
* 2. Merges the trip stats from the tracks
|
* Updates the view
|
||||||
* 3. Updates the view
|
*/
|
||||||
*/
|
private void loadAggregatedStats() {
|
||||||
private void loadAggregatedStats() {
|
List<Track> tracks = retrieveTracks();
|
||||||
List<Track> tracks = retrieveTracks();
|
TripStatistics rollingStats = null;
|
||||||
TripStatistics rollingStats = null;
|
if (!tracks.isEmpty()) {
|
||||||
if (!tracks.isEmpty()) {
|
rollingStats = new TripStatistics(tracks.iterator().next()
|
||||||
rollingStats = new TripStatistics(tracks.iterator().next()
|
.getStatistics());
|
||||||
.getStatistics());
|
for (int i = 1; i < tracks.size(); i++) {
|
||||||
for (int i = 1; i < tracks.size(); i++) {
|
rollingStats.merge(tracks.get(i).getStatistics());
|
||||||
rollingStats.merge(tracks.get(i).getStatistics());
|
}
|
||||||
}
|
}
|
||||||
}
|
updateView(rollingStats);
|
||||||
updateView(rollingStats);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private List<Track> retrieveTracks() {
|
private List<Track> retrieveTracks() {
|
||||||
return tracksProvider.retrieveAllTracks();
|
return tracksProvider.retrieveAllTracks();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateView(TripStatistics aggStats) {
|
private void updateView(TripStatistics aggStats) {
|
||||||
if (aggStats != null) {
|
if (aggStats != null) {
|
||||||
utils.setAllStats(aggStats);
|
utils.setAllStats(aggStats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,8 +70,6 @@ import android.widget.RelativeLayout;
|
|||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -80,6 +78,8 @@ import java.util.Random;
|
|||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The super activity that embeds our sub activities.
|
* The super activity that embeds our sub activities.
|
||||||
*
|
*
|
||||||
@@ -434,7 +434,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
|||||||
help = menu.add(0, MyTracksConstants.MENU_HELP, 10002, R.string.help);
|
help = menu.add(0, MyTracksConstants.MENU_HELP, 10002, R.string.help);
|
||||||
help.setIcon(android.R.drawable.ic_menu_info_details);
|
help.setIcon(android.R.drawable.ic_menu_info_details);
|
||||||
aggregatedStats = menu.add(0, MyTracksConstants.MENU_AGGREGATED_STATS,
|
aggregatedStats = menu.add(0, MyTracksConstants.MENU_AGGREGATED_STATS,
|
||||||
10003, R.string.aggregated_stats);
|
10003, R.string.aggregated_stats);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,7 +492,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case MyTracksConstants.MENU_AGGREGATED_STATS: {
|
case MyTracksConstants.MENU_AGGREGATED_STATS: {
|
||||||
Intent startIntent = new Intent(this, AggregatedStatsActivity.class);
|
Intent startIntent = new Intent(this, AggregatedStatsActivity.class);
|
||||||
startActivity(startIntent);
|
startActivity(startIntent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.content;
|
package com.google.android.apps.mytracks.content;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility to access data from the mytracks content provider.
|
* Utility to access data from the mytracks content provider.
|
||||||
*
|
*
|
||||||
@@ -186,14 +186,14 @@ public interface MyTracksProviderUtils {
|
|||||||
*/
|
*/
|
||||||
Track getTrack(long id);
|
Track getTrack(long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all tracks without track points. If no tracks exist an empty
|
* Retrieves all tracks without track points. If no tracks exist an empty
|
||||||
* list will be returned. Use {@link #getTrackPoints(Track, int)} to load
|
* list will be returned. Use {@link #getTrackPoints(Track, int)} to load
|
||||||
* the track points.
|
* the track points.
|
||||||
*
|
*
|
||||||
* @return a list of all the recorded tracks
|
* @return a list of all the recorded tracks
|
||||||
*/
|
*/
|
||||||
List<Track> retrieveAllTracks();
|
List<Track> retrieveAllTracks();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the track points for a given track.
|
* Loads the track points for a given track.
|
||||||
|
|||||||
+11
-11
@@ -15,8 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.content;
|
package com.google.android.apps.mytracks.content;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -25,7 +24,8 @@ import android.location.Location;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class providing easy access to locations and tracks in the
|
* Helper class providing easy access to locations and tracks in the
|
||||||
@@ -808,14 +808,14 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Track> retrieveAllTracks() {
|
public List<Track> retrieveAllTracks() {
|
||||||
List<Track> tracks = new LinkedList<Track>();
|
List<Track> tracks = new LinkedList<Track>();
|
||||||
Cursor cursor = getTracksCursor(null);
|
Cursor cursor = getTracksCursor(null);
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
tracks.add(createTrack(cursor));
|
tracks.add(createTrack(cursor));
|
||||||
} while(cursor.moveToNext());
|
} while(cursor.moveToNext());
|
||||||
}
|
}
|
||||||
return tracks;
|
return tracks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user