Compare commits

..

9 Commits

Author SHA1 Message Date
Rodrigo Damazio 38de0e352f Releasing 1.1.5 2011-05-25 16:19:54 -03:00
Rodrigo Damazio 053fb403c5 Merging 2011-05-24 14:19:12 -03:00
Rodrigo Damazio 1d70d4bca0 Merging 2011-05-24 14:18:57 -03:00
Rodrigo Damazio bba04ba1bd If the only listener is a new one (and since for optimization we keep its state as the global state), we want to reset the global state before loading points onto it. 2011-05-24 13:53:26 -03:00
Rodrigo Damazio 1588c25fba Merging to head 2011-05-20 14:42:10 -03:00
Rodrigo Damazio da928fb549 Making data hub tests run considerably faster. 2011-05-19 21:42:40 -03:00
Rodrigo Damazio f657c2f1d1 Adding tests and making minor reorg changes. 2011-05-19 20:59:40 -03:00
Rodrigo Damazio d00c92ef99 Fixing incremental loading when there's only a single listener. 2011-05-18 17:55:39 -03:00
Rodrigo Damazio cb75c6fbe6 Fixing eclipse warnings all over the project. 2011-05-17 00:15:02 -03:00
20 changed files with 144 additions and 260 deletions
-1
View File
@@ -5,7 +5,6 @@
<classpathentry kind="lib" path="libs/google-common.jar"/>
<classpathentry kind="lib" path="libs/accounts.jar"/>
<classpathentry kind="lib" path="libs/google-api-client-1.2.2-alpha.jar"/>
<classpathentry kind="lib" path="libs/libGoogleAnalytics.jar"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry exported="true" kind="lib" path="/MyTracksLib/libs/protobuf-java-2.3.0-lite.jar"/>
+2 -3
View File
@@ -17,8 +17,8 @@ limitations under the License.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.maps.mytracks"
android:installLocation="auto"
android:versionCode="30"
android:versionName="1.1.7">
android:versionCode="28"
android:versionName="1.1.5">
<application android:icon="@drawable/arrow_icon"
android:label="@string/app_name"
android:backupAgent="com.google.android.apps.mytracks.io.backup.MyTracksBackupAgent">
@@ -114,7 +114,6 @@ limitations under the License.
<!-- Permissions for recording tracks and showing maps -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BLUETOOTH" />
Binary file not shown.
-5
View File
@@ -170,11 +170,6 @@ limitations under the License.
<item>inline skating</item>
<item>skate boarding</item>
<item>roller skiing (classic)</item>
<item>roller skiing (skate)</item>
<item>cross-country skiing (classic)</item>
<item>cross-country skiing (skate)</item>
<item>snow shoeing</item>
<item>skiing</item>
<item>snow boarding</item>
@@ -38,6 +38,16 @@ limitations under the License.
<item>100</item>
</string-array>
<string-array name="min_recording_distance_values">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>10</item>
<item>100</item>
</string-array>
<string-array name="max_recording_distance_values">
<item>50</item>
<item>100</item>
-3
View File
@@ -39,7 +39,4 @@ limitations under the License.
<string name="sendtogoogle_google_fusiontables_url">google.com/fusiontables</string>
<string name="sendtogoogle_google_mymaps_url">maps.google.com</string>
<string name="sendtogoogle_google_docs_url">docs.google.com</string>
<!-- ID for Google Analytics -->
<string name="google_analytics_id">UA-7222692-2</string>
</resources>
+1 -1
View File
@@ -42,7 +42,7 @@ limitations under the License.
android:summary="@string/settings_announcement_frequency_summary"
android:entries="@array/task_frequency_options"
android:entryValues="@array/task_frequency_values"
android:defaultValue="0" />
android:defaultValue="-1" />
<com.google.android.apps.mytracks.IntegerListPreference
android:key="@string/split_frequency_key"
@@ -144,7 +144,6 @@ public class ChartActivity extends Activity implements TrackDataListener {
dataHub.registerTrackDataListener(this, EnumSet.of(
ListenerDataType.SELECTED_TRACK_CHANGED,
ListenerDataType.TRACK_UPDATES,
ListenerDataType.POINT_UPDATES,
ListenerDataType.SAMPLED_OUT_POINT_UPDATES,
ListenerDataType.WAYPOINT_UPDATES,
@@ -133,7 +133,7 @@ public class ExportAllTracks {
Log.i(Constants.TAG, "ExportAllTracks: Releasing wake lock.");
}
Log.i(Constants.TAG, "ExportAllTracks: Done");
showToast(R.string.export_done, Toast.LENGTH_SHORT);
Toast.makeText(activity, R.string.export_done, Toast.LENGTH_SHORT).show();
}
private void makeProgressDialog(final int trackCount) {
@@ -189,16 +189,12 @@ public class ExportAllTracks {
Log.i(Constants.TAG, "ExportAllTracks: exporting: " + id);
TrackWriter writer =
TrackWriterFactory.newWriter(activity, providerUtils, id, format);
if (writer == null) {
showToast(R.string.error_track_does_not_exist, Toast.LENGTH_LONG);
return;
}
writer.writeTrack();
if (!writer.wasSuccess()) {
// Abort the whole export on the first error.
showToast(writer.getErrorMessage(), Toast.LENGTH_LONG);
int error = writer.getErrorMessage();
Toast.makeText(activity, error, Toast.LENGTH_LONG).show();
return;
}
}
@@ -214,13 +210,4 @@ public class ExportAllTracks {
}
}
}
private void showToast(final int messageId, final int length) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(activity, messageId, length).show();
}
});
}
}
@@ -51,7 +51,6 @@ import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.util.EnumSet;
@@ -465,21 +464,21 @@ public class MapActivity extends com.google.android.maps.MapActivity
@Override
public void onProviderStateChange(ProviderState state) {
final int messageId;
final boolean isGpsDisabled;
final boolean bindClick;
switch (state) {
case DISABLED:
messageId = R.string.status_enable_gps;
isGpsDisabled = true;
bindClick = true;
break;
case NO_FIX:
case BAD_FIX:
messageId = R.string.wait_for_fix;
isGpsDisabled = false;
bindClick = false;
break;
case GOOD_FIX:
// Nothing to show.
messageId = -1;
isGpsDisabled = false;
bindClick = false;
break;
default:
throw new IllegalArgumentException("Unexpected state: " + state);
@@ -492,13 +491,7 @@ public class MapActivity extends com.google.android.maps.MapActivity
messageText.setText(messageId);
messagePane.setVisibility(View.VISIBLE);
if (isGpsDisabled) {
// Give a warning about this state.
Toast.makeText(MapActivity.this,
R.string.error_no_gps_location_provider,
Toast.LENGTH_LONG).show();
// Make clicking take the user to the location settings.
if (bindClick) {
messagePane.setOnClickListener(MapActivity.this);
} else {
messagePane.setOnClickListener(null);
@@ -21,7 +21,6 @@ import static com.google.android.apps.mytracks.DialogManager.DIALOG_PROGRESS;
import static com.google.android.apps.mytracks.DialogManager.DIALOG_SEND_TO_GOOGLE;
import com.google.android.accounts.Account;
import com.google.android.apps.analytics.GoogleAnalyticsTracker;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.content.TrackDataHub;
@@ -160,11 +159,6 @@ public class MyTracks extends TabActivity implements OnTouchListener,
private SharedPreferences sharedPreferences;
/**
* Google Analytics tracker
*/
private GoogleAnalyticsTracker tracker;
/**
* The connection to the track recording service.
*/
@@ -256,13 +250,6 @@ public class MyTracks extends TabActivity implements OnTouchListener,
apiFeatures.getApiPlatformAdapter().enableStrictMode();
}
tracker = GoogleAnalyticsTracker.getInstance();
// Start the tracker in manual dispatch mode...
tracker.start(this.getString(R.string.google_analytics_id), this.getApplicationContext());
tracker.setProductVersion("android-mytracks", SystemUtils.getMyTracksVersion(this));
tracker.trackPageView("/appstart");
tracker.dispatch();
providerUtils = MyTracksProviderUtils.Factory.get(this);
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, 0);
dataHub = new TrackDataHub(this, sharedPreferences, providerUtils);
@@ -338,8 +325,6 @@ public class MyTracks extends TabActivity implements OnTouchListener,
dataHub.destroy();
tryUnbindTrackRecordingService();
tracker.dispatch();
tracker.stop();
super.onDestroy();
}
@@ -946,7 +931,6 @@ public class MyTracks extends TabActivity implements OnTouchListener,
}
private void sendToGoogleMapsOrPickMap(SendDialog sendToGoogleDialog) {
tracker.trackPageView("/send/maps");
if (!sendToGoogleDialog.getCreateNewMap()) {
// Ask the user to choose a map to upload into
Intent listIntent = new Intent(this, MyMapsList.class);
@@ -979,12 +963,8 @@ public class MyTracks extends TabActivity implements OnTouchListener,
// Update the map id for this track:
try {
Track track = providerUtils.getTrack(trackId);
if (track != null) {
track.setMapId(mapId);
providerUtils.updateTrack(track);
} else {
Log.w(TAG, "Updating map id failed.");
}
} catch (RuntimeException e) {
// If that fails whatever reasons we'll just log an error, but
// continue.
@@ -1026,7 +1006,6 @@ public class MyTracks extends TabActivity implements OnTouchListener,
}
private void sendToFusionTables(final long trackId) {
tracker.trackPageView("/send/fusion_tables");
OnSendCompletedListener onCompletion = new OnSendCompletedListener() {
@Override
public void onSendCompleted(String tableId, boolean success,
@@ -1038,12 +1017,8 @@ public class MyTracks extends TabActivity implements OnTouchListener,
// Update the table id for this track:
try {
Track track = providerUtils.getTrack(trackId);
if (track != null) {
track.setTableId(tableId);
providerUtils.updateTrack(track);
} else {
Log.w(TAG, "Updating table id failed.");
}
} catch (RuntimeException e) {
// If that fails whatever reasons we'll just log an error, but
// continue.
@@ -1095,7 +1070,6 @@ public class MyTracks extends TabActivity implements OnTouchListener,
private void sendToGoogleDocs(final long trackId) {
Log.d(TAG, "Sending to Docs....");
tracker.trackPageView("/send/docs");
setProgressValue(50);
setProgressMessage(R.string.progress_message_sending_docs);
final SendToDocs sender = new SendToDocs(this,
@@ -1121,7 +1095,6 @@ public class MyTracks extends TabActivity implements OnTouchListener,
}
private void onSendToGoogleDone() {
tracker.dispatch();
SendDialog sendToGoogleDialog = dialogManager.getSendToGoogleDialog();
final boolean sentToMyMaps = sendToGoogleDialog.getSendToMyMaps();
final boolean sentToFusionTables = sendToGoogleDialog.getSendToFusionTables();
@@ -1255,11 +1228,6 @@ public class MyTracks extends TabActivity implements OnTouchListener,
*/
public void saveTrack(long trackId, TrackFileFormat format) {
TrackWriter writer = TrackWriterFactory.newWriter(this, providerUtils, trackId, format);
if (writer == null) {
dialogManager.showMessageDialog(R.string.error_track_does_not_exist, false);
return;
}
WriteProgressController controller = new WriteProgressController(this, writer);
controller.setOnCompletionListener(new WriteProgressController.OnCompletionListener() {
@Override
@@ -1279,10 +1247,6 @@ public class MyTracks extends TabActivity implements OnTouchListener,
*/
public void sendTrack(long trackId, final TrackFileFormat format) {
TrackWriter writer = TrackWriterFactory.newWriter(this, providerUtils, trackId, format);
if (writer == null) {
dialogManager.showMessageDialog(R.string.error_track_does_not_exist, false);
return;
}
FileUtils fileUtils = new FileUtils();
String extension = format.getExtension();
@@ -73,9 +73,7 @@ public class WaypointsList extends ListActivity
contextPosition = info.position;
waypointId = WaypointsList.this.listView.getAdapter()
.getItemId(contextPosition);
Waypoint waypoint = providerUtils.getWaypoint(info.id);
if (waypoint != null) {
int type = waypoint.getType();
int type = providerUtils.getWaypoint(info.id).getType();
menu.add(0, Constants.MENU_SHOW, 0,
R.string.waypointslist_show_waypoint);
menu.add(0, Constants.MENU_EDIT, 0,
@@ -85,7 +83,6 @@ public class WaypointsList extends ListActivity
recordingTrackId < 0 || type == Waypoint.TYPE_WAYPOINT ||
info.id != providerUtils.getLastWaypointId(recordingTrackId));
}
}
};
@Override
@@ -17,10 +17,10 @@ package com.google.android.apps.mytracks.content;
import static com.google.android.apps.mytracks.Constants.DEFAULT_MIN_REQUIRED_ACCURACY;
import static com.google.android.apps.mytracks.Constants.MAX_DISPLAYED_WAYPOINTS_POINTS;
import static com.google.android.apps.mytracks.Constants.TARGET_DISPLAYED_TRACK_POINTS;
import static com.google.android.apps.mytracks.Constants.MAX_LOCATION_AGE_MS;
import static com.google.android.apps.mytracks.Constants.MAX_NETWORK_AGE_MS;
import static com.google.android.apps.mytracks.Constants.TAG;
import static com.google.android.apps.mytracks.Constants.TARGET_DISPLAYED_TRACK_POINTS;
import com.google.android.apps.mytracks.content.DataSourceManager.DataSourceListener;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.DoubleBufferedLocationFactory;
@@ -40,6 +40,7 @@ import android.location.LocationManager;
import android.os.Handler;
import android.os.HandlerThread;
import android.util.Log;
import android.widget.Toast;
import java.util.Collections;
import java.util.EnumSet;
@@ -653,6 +654,9 @@ public class TrackDataHub {
final TrackDataListener.ProviderState state;
if (!hasProviderEnabled) {
state = ProviderState.DISABLED;
// Give a global warning about this state.
Toast.makeText(context, R.string.error_no_gps_location_provider, Toast.LENGTH_LONG).show();
} else if (!hasFix) {
state = ProviderState.NO_FIX;
} else if (!hasGoodFix) {
@@ -790,6 +794,10 @@ public class TrackDataHub {
public void run() {
for (TrackDataListener listener : listeners) {
listener.onSelectedTrackChanged(track, isRecordingSelected());
if (track != null) {
listener.onTrackUpdated(track);
}
}
}
});
@@ -179,11 +179,6 @@ public class SendToFusionTables implements Runnable {
// Get the track meta-data
Track track = providerUtils.getTrack(trackId);
if (track == null) {
Log.w(Constants.TAG, "Cannot get track.");
return;
}
String originalDescription = track.getDescription();
// Create a new table:
@@ -212,6 +207,7 @@ public class SendToFusionTables implements Runnable {
Log.d(Constants.TAG, "SendToFusionTables: Done: " + success);
progressIndicator.setProgressValue(PROGRESS_COMPLETE);
} finally {
final boolean finalSuccess = success;
final int finalStatusMessageId = statusMessageId;
context.runOnUiThread(new Runnable() {
@@ -308,7 +304,7 @@ public class SendToFusionTables implements Runnable {
Cursor locationsCursor = providerUtils.getLocationsCursor(track.getId(), 0, -1, false);
try {
if (locationsCursor == null || !locationsCursor.moveToFirst()) {
if (!locationsCursor.moveToFirst()) {
Log.w(Constants.TAG, "Unable to get any points to upload");
return false;
}
@@ -395,11 +391,9 @@ public class SendToFusionTables implements Runnable {
return true;
} finally {
if (locationsCursor != null) {
locationsCursor.close();
}
}
}
/**
* Appends the given location to the string in the format:
@@ -106,11 +106,6 @@ public class SendToMyMaps implements Runnable {
// Get the track meta-data
Track track = providerUtils.getTrack(trackId);
if (track == null) {
Log.w(Constants.TAG, "Cannot get track.");
return;
}
String originalDescription = track.getDescription();
track.setDescription("<p>" + track.getDescription() + "</p><p>"
+ stringUtils.generateTrackDescription(track, null, null) + "</p>");
@@ -211,7 +206,7 @@ public class SendToMyMaps implements Runnable {
Cursor locationsCursor =
providerUtils.getLocationsCursor(track.getId(), 0, -1, false);
try {
if (locationsCursor == null || !locationsCursor.moveToFirst()) {
if (!locationsCursor.moveToFirst()) {
Log.w(TAG, "Unable to get any points to upload");
return false;
}
@@ -302,11 +297,9 @@ public class SendToMyMaps implements Runnable {
return true;
} finally {
if (locationsCursor != null) {
locationsCursor.close();
}
}
}
private boolean prepareAndUploadPoints(Track track, List<Location> locations) {
@@ -187,7 +187,7 @@ public class TcxTrackWriter implements TrackFormatWriter {
&& sensorData.getCadence().getState() == Sensor.SensorState.SENDING
&& sensorData.getCadence().hasValue()) {
pw.print(" <Cadence>");
pw.print(Math.min(254, sensorData.getCadence().getValue()));
pw.print(sensorData.getCadence().getValue());
pw.println("</Cadence>");
}
}
@@ -16,13 +16,10 @@
package com.google.android.apps.mytracks.io.file;
import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Track;
import android.content.Context;
import android.util.Log;
/**
* A factory to produce track writers for any format.
@@ -93,11 +90,6 @@ public class TrackWriterFactory {
MyTracksProviderUtils providerUtils,
long trackId, TrackFileFormat format) {
Track track = providerUtils.getTrack(trackId);
if (track == null) {
Log.w(TAG, "Trying to create a writer for an invalid track, id=" + trackId);
return null;
}
return newWriter(context, providerUtils, track, format);
}
@@ -660,10 +660,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
@Override
public Waypoint getFirstWaypoint(long trackId) {
if (trackId < 0) {
return null;
}
Cursor cursor = contentResolver.query(
WaypointsColumns.CONTENT_URI,
null /*projection*/,
@@ -686,10 +682,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
@Override
public Waypoint getWaypoint(long waypointId) {
if (waypointId < 0) {
return null;
}
Cursor cursor = contentResolver.query(
WaypointsColumns.CONTENT_URI,
null /*projection*/,
@@ -712,10 +704,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
@Override
public long getLastLocationId(long trackId) {
if (trackId < 0) {
return -1;
}
final String[] projection = {"_id"};
Cursor cursor = contentResolver.query(
TrackPointsColumns.CONTENT_URI,
@@ -740,10 +728,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
@Override
public long getFirstWaypointId(long trackId) {
if (trackId < 0) {
return -1;
}
final String[] projection = {"_id"};
Cursor cursor = contentResolver.query(
WaypointsColumns.CONTENT_URI,
@@ -768,10 +752,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
@Override
public long getLastWaypointId(long trackId) {
if (trackId < 0) {
return -1;
}
final String[] projection = {"_id"};
Cursor cursor = contentResolver.query(
WaypointsColumns.CONTENT_URI,
@@ -835,10 +815,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
@Override
public Location getLocation(long id) {
if (id < 0) {
return null;
}
String selection = TrackPointsColumns._ID + "=" + id;
return findLocationBy(selection);
}
@@ -846,10 +822,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
@Override
public Cursor getLocationsCursor(long trackId, long minTrackPointId,
int maxLocations, boolean descending) {
if (trackId < 0) {
return null;
}
String selection;
if (minTrackPointId >= 0) {
selection = String.format("%s=%d AND %s%s%d",
@@ -870,10 +842,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
@Override
public Cursor getWaypointsCursor(long trackId, long minWaypointId,
int maxWaypoints) {
if (trackId < 0) {
return null;
}
String selection;
if (minWaypointId > 0) {
selection = String.format("%s=%d AND %s>=%d",
@@ -895,10 +863,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
@Override
public Track getTrack(long id) {
if (id < 0) {
return null;
}
String select = TracksColumns._ID + "=" + id;
return findTrackBy(select);
}
@@ -965,10 +929,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
@Override
public boolean trackExists(long id) {
if (id < 0) {
return false;
}
Cursor cursor = null;
try {
final String[] projection = { TracksColumns._ID };
@@ -26,23 +26,20 @@ public class ZephyrMessageParserTest extends TestCase {
public void testParseBuffer() {
byte[] buf = new byte[60];
// Heartrate (-1 =^ 255 unsigned byte)
buf[12] = -1;
// Power
buf[12] = 50;
buf[11] = 51;
// Cadence (=^ 255*16 strides/min)
buf[56] = -1;
buf[57] = 15;
buf[56] = 32;
buf[57] = 0;
Sensor.SensorDataSet sds = parser.parseBuffer(buf);
assertTrue(sds.hasHeartRate());
assertTrue(sds.getHeartRate().getState() == Sensor.SensorState.SENDING);
assertEquals(255, sds.getHeartRate().getValue());
assertEquals(50, sds.getHeartRate().getValue());
assertTrue(sds.hasPower());
assertTrue(sds.getPower().getState() == Sensor.SensorState.SENDING);
assertEquals(51, sds.getPower().getValue());
assertTrue(sds.hasCadence());
assertTrue(sds.getCadence().getState() == Sensor.SensorState.SENDING);
assertEquals(255, sds.getCadence().getValue());
assertEquals(2, sds.getCadence().getValue());
}
public void testFindNextAlignment() {
@@ -15,10 +15,10 @@
*/
package com.google.android.apps.mytracks.signalstrength;
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.START_SAMPLING;
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.STOP_SAMPLING;
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.TAG;
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.*;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.MyTracksProviderUtilsImpl;
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
import com.google.android.apps.mytracks.services.ITrackRecordingService;
import com.google.android.apps.mytracks.signalstrength.SignalStrengthListener.SignalStrengthCallback;