merge heads

This commit is contained in:
Jimmy Shih
2011-11-02 11:39:14 -07:00
25 changed files with 83 additions and 86 deletions
@@ -260,7 +260,6 @@ public class ChartActivity extends Activity implements TrackDataListener {
*
* @param location the location to get data for (this method takes ownership of that location)
* @param result the resulting point to fill out
* @return the previous location, now available for reuse
*/
private void fillDataPoint(Location location, double result[]) {
double timeOrDistance = Double.NaN,
@@ -20,8 +20,8 @@ import com.google.android.apps.mytracks.stats.ExtremityMonitor;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Paint.Style;
import android.graphics.Path;
import java.text.DecimalFormat;
@@ -133,9 +133,10 @@ public class ChartValueSeries {
*
* @param context The context for the chart
* @param formatString The format of the decimal format for this series
* @param fill The paint for filling the chart
* @param stroke The paint for stroking the outside the chart, optional
* @param fillColor The paint for filling the chart
* @param strokeColor The paint for stroking the outside the chart, optional
* @param zoomSettings The settings related to zooming
* @param titleId The title ID
*
* TODO: Get rid of Context and inject appropriate values instead.
*/
@@ -881,7 +881,6 @@ public class ChartView extends View {
*
* @param index the time series, one of {@link #ELEVATION_SERIES},
* {@link #SPEED_SERIES}, {@link #POWER_SERIES}, etc.
* @return true to be drawn, false otherwise
*/
public void setChartValueSeriesEnabled(int index, boolean enabled) {
series[index].setEnabled(enabled);
@@ -30,8 +30,8 @@ import android.view.WindowManager.BadTokenException;
public class DialogManager {
/**
* The equivalent of {@link #showDialogSafely(int)}, but for a specific
* dialog instance.
* The equivalent of {@link Dialog#show()}, but for a specific dialog
* instance.
*/
public static void showDialogSafely(Activity activity, final Dialog dialog) {
if (activity.isFinishing()) {
@@ -53,8 +53,8 @@ public class DialogManager {
}
/**
* The equivalent of {@link #dismissDialogSafely(int)}, but for a specific
* dialog instance.
* The equivalent of {@link Dialog#dismiss()}, but for a specific dialog
* instance.
*/
public static void dismissDialogSafely(Activity activity, final Dialog dialog) {
if (activity.isFinishing()) {
@@ -77,7 +77,6 @@ public class MapOverlay extends Overlay implements OnSharedPreferenceChangeListe
private GeoPoint lastReferencePoint;
private Rect lastViewRect;
private boolean lastPathExists;
private Location lastLocation;
private TrackPathPainter trackPathPainter;
/**
@@ -509,8 +509,7 @@ public class SettingsActivity extends PreferenceActivity {
* Saves the given edit text preference value.
* If the units are not metric convert the value before saving.
*/
private void validateTrackColorModeSettings(EditTextPreference preference,
String newValue, int id) {
private void validateTrackColorModeSettings(String newValue, int id) {
CheckBoxPreference metricUnitsPreference = (CheckBoxPreference) findPreference(
getString(R.string.metric_units_key));
String metricspeed;
@@ -549,7 +548,7 @@ public class SettingsActivity extends PreferenceActivity {
@Override
public boolean onPreferenceChange(Preference preference,
Object newValue) {
validateTrackColorModeSettings((EditTextPreference) preference, (String) newValue, metricKey);
validateTrackColorModeSettings((String) newValue, metricKey);
return true;
}
});
@@ -84,7 +84,7 @@ public class TrackDataHub {
/**
* Listen to sampled-out points.
* Listening to this without listening to {@link #SAMPLED_POINT_UPDATES}
* Listening to this without listening to {@link #POINT_UPDATES}
* makes no sense and may yield unexpected results.
*/
SAMPLED_OUT_POINT_UPDATES,
@@ -385,8 +385,8 @@ public class TrackDataHub {
/**
* Loads the given track and makes it the currently-selected one.
* It is ok to call this method before {@link start}, and in that case
* the data will only be passed to listeners when {@link start} is called.
* It is ok to call this method before {@link #start}, and in that case
* the data will only be passed to listeners when {@link #start} is called.
*
* @param trackId the ID of the track to load
*/
@@ -801,7 +801,7 @@ public class TrackDataHub {
/**
* Notifies that a new track has been selected..
*
* @param track the new selected track
* @param trackId the new selected track
* @param listeners the listeners to notify
*/
private void notifySelectedTrackChanged(long trackId,
@@ -97,8 +97,8 @@ class TrackDataListeners {
/**
* Registers a listener to send data to.
* It is ok to call this method before {@link start}, and in that case
* the data will only be passed to listeners when {@link start} is called.
* It is ok to call this method before {@link TrackDataHub#start}, and in that case
* the data will only be passed to listeners when {@link TrackDataHub#start} is called.
*
* @param listener the listener to register
* @param dataTypes the type of data that the listener is interested in
@@ -135,9 +135,6 @@ public class ModernAuthManager implements AuthManager {
* {@link Activity#onActivityResult} function
* @param results The data passed in to the {@link Activity}'s
* {@link Activity#onActivityResult} function
* @return True if the auth token was fetched or we aren't done fetching
* the auth token, or False if there was an error or the request was
* canceled
*/
public void authResult(int resultCode, Intent results) {
boolean retry = false;
@@ -169,12 +166,11 @@ public class ModernAuthManager implements AuthManager {
}
/**
* Invalidates the existing auth token and request a new one. The
* {@link Runnable} provided will be executed when the new auth token is
* successfully fetched.
* Invalidates the existing auth token and request a new one. The callback
* provided will be executed when the new auth token is successfully fetched.
*
* @param runnable A {@link Runnable} to execute when a new auth token
* is successfully fetched
* @param callback A callback to execute when a new auth token is successfully
* fetched
*/
public void invalidateAndRefresh(final AuthCallback callback) {
this.authCallback = callback;
@@ -358,7 +358,7 @@ public class SendToMyMaps implements Runnable {
* Prepares a buffer of locations for transmission to google maps.
*
* @param track the original track with meta data
* @param buffer a buffer of locations on the track
* @param locations a buffer of locations on the track
* @return an array of tracks each with a sub section of the points in the
* original buffer
*/
@@ -15,8 +15,8 @@
*/
package com.google.android.apps.mytracks.io.backup;
import com.google.android.apps.mytracks.MyTracks;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracks;
import com.google.android.apps.mytracks.util.FileUtils;
import com.google.android.maps.mytracks.R;
@@ -148,7 +148,6 @@ public class BackupActivityHelper {
/**
* Shows a backup list for the user to pick, then restores it.
*
* @param backupDir the backup directory
* @param backupDates the list of available backup files
*/
private void pickBackupForRestore(final Date[] backupDates) {
@@ -179,9 +178,9 @@ public class BackupActivityHelper {
}
/**
* Shows a progress dialog, then starts restoring the backup osynchronously.
* Shows a progress dialog, then starts restoring the backup asynchronously.
*
* @param inputFile the file to restore from
* @param date the date
*/
private void restoreFromDateAsync(final Date date) {
// Show a progress dialog
@@ -23,9 +23,17 @@ import com.google.wireless.gdata.parser.ParseException;
import com.google.wireless.gdata.serializer.GDataSerializer;
import android.text.TextUtils;
import android.util.Config;
import android.util.Log;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.zip.GZIPInputStream;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@@ -39,15 +47,6 @@ import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.zip.GZIPInputStream;
/**
* Implementation of a GDataClient using GoogleHttpClient to make HTTP requests.
* Always issues GETs and POSTs, using the X-HTTP-Method-Override header when a
@@ -58,8 +57,7 @@ public class AndroidGDataClient implements GDataClient {
private static final String TAG = "GDataClient";
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = DEBUG ? Config.LOGD : Config.LOGV;
private static final String X_HTTP_METHOD_OVERRIDE = "X-HTTP-Method-Override";
private static final int MAX_REDIRECTS = 10;
@@ -196,7 +194,7 @@ public class AndroidGDataClient implements GDataClient {
if (!TextUtils.isEmpty(authToken)) {
request.addHeader("Authorization", "GoogleLogin auth=" + authToken);
}
if (LOCAL_LOGV) {
if (DEBUG) {
for (Header h : request.getAllHeaders()) {
Log.v(TAG, h.getName() + ": " + h.getValue());
}
@@ -36,7 +36,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
* handling. After a query is run, the wrapper can be queried about the error
* that occurred.
*
* @param C the GData service client
* @param <C> the GData service client
* @author Sandor Dornbush
*/
public class GDataWrapper<C> {
@@ -138,7 +138,7 @@ public class MapsFacade {
* @param mapId ID of the map to upload to
* @param trackName name of the track being started/ended
* @param trackDescription description of the track being started/ended
* @param location the location of the marker
* @param loc the location of the marker
* @param isStart true to add a start marker, false to add an end marker
* @return true on success, false otherwise
*/
@@ -185,7 +185,9 @@ public class MapsFacade {
/**
* Builds a placemark MyMapsFeature from a track.
*
* @param track the track
* @param trackName the track
* @param trackDescription the track description
* @param geoPoint the geo point
* @param isStart true if it's the start of the track, or false for end
* @return a MyMapsFeature
*/
@@ -206,9 +208,12 @@ public class MapsFacade {
}
/**
* Builds a MyMapsFeature from a track.
*
* @param wpt the waypoint
* Builds a MyMapsFeature from a waypoint.
*
* @param title the title
* @param description the description
* @param iconUrl the icon url
* @param geoPoint the waypoint
* @return a MyMapsFeature
*/
private static MyMapsFeature buildMyMapsPlacemarkFeature(
@@ -336,7 +341,8 @@ public class MapsFacade {
/**
* Builds a MyMapsFeature from a track.
*
* @param track the track
* @param trackName the track name
* @param locations locations on the track
* @return a MyMapsFeature
*/
private static MyMapsFeature buildMyMapsLineFeature(String trackName,
@@ -12,12 +12,12 @@ import com.google.wireless.gdata.serializer.xml.XmlEntryGDataSerializer;
import android.util.Log;
import org.xmlpull.v1.XmlPullParserException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.xmlpull.v1.XmlPullParserException;
/**
* Factory of Xml parsers for gdata maps data.
*/
@@ -39,7 +39,7 @@ class XmlMapsGDataParserFactory implements GDataParserFactory {
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings("unchecked")
@Override
public GDataParser createParser(Class cls, InputStream is)
throws ParseException {
@@ -60,7 +60,11 @@ class XmlMapsGDataSerializer extends XmlEntryGDataSerializer {
declareEntryNamespaces(serializer);
serializer.startTag(XmlGDataParser.NAMESPACE_ATOM_URI, "entry");
stream = MapsClient.LOG_COMMUNICATION ? printStream : out;
if (MapsClient.LOG_COMMUNICATION) {
stream = printStream;
} else {
stream = out;
}
serializeEntryContents(serializer, format);
serializer.endTag(XmlGDataParser.NAMESPACE_ATOM_URI, "entry");
@@ -69,8 +69,8 @@ public class BluetoothConnectionManager {
/**
* Constructor. Prepares a new BluetoothSensor session.
*
* @param context The UI Activity Context
* @param handler A Handler to send messages back to the UI Activity
* @param parser A message parser
*/
public BluetoothConnectionManager(Handler handler, MessageParser parser) {
this.adapter = BluetoothAdapter.getDefaultAdapter();
@@ -48,8 +48,8 @@ public class PolarMessageParser implements MessageParser {
* offset 2 = check byte, 255 - packet length.
* offset 3 = sequence byte, range from 0 to 15.
*
* @param an array of bytes to parse
* @param buffer offset to beginning of packet.
* @param buffer an array of bytes to parse
* @param i buffer offset to beginning of packet.
* @return whether buffer has a valid packet at offset i
*/
private boolean packetValid (byte[] buffer, int i) {
@@ -100,7 +100,7 @@ public class PolarMessageParser implements MessageParser {
/**
* Applies packet validation rules to buffer
*
* @param an array of bytes to parse
* @param buffer an array of bytes to parse
* @return whether buffer has a valid packet starting at index zero
*/
@Override
@@ -124,7 +124,7 @@ public class PolarMessageParser implements MessageParser {
/**
* Searches buffer for the beginning of a valid packet.
*
* @param an array of bytes to parse
* @param buffer an array of bytes to parse
* @return index to beginning of good packet, or -1 if none found.
*/
@Override
@@ -58,12 +58,12 @@ public class SensorUtils {
}
/**
* Returns CRC8 (polynomial 0x8C) from byte array buffer[start] until
* (including) buffer[end]
* Returns CRC8 (polynomial 0x8C) from byte array buffer[start] to
* (excluding) buffer[start + length]
*
* @param buffer the byte array of data (payload)
* @param start the position in the byte array where the payload begins
* @param end the position in the byte array where the payload ends
* @param length the length
* @return CRC8 value
*/
public static byte getCrc8(byte[] buffer, int start, int length) {
@@ -85,11 +85,11 @@ public class TrackWidgetProvider
selectedTrackId = -1;
}
private void initialize(Context context) {
private void initialize(Context aContext) {
if (this.context != null) {
return;
}
this.context = context;
this.context = aContext;
trackObserver = new TrackObserver();
providerUtils = MyTracksProviderUtils.Factory.get(context);
unknown = context.getString(R.string.unknown);
@@ -105,9 +105,9 @@ public class TrackWidgetProvider
}
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
initialize(context);
public void onReceive(Context aContext, Intent intent) {
super.onReceive(aContext, intent);
initialize(aContext);
selectedTrackId = intent.getLongExtra(
context.getString(R.string.track_id_broadcast_extra), selectedTrackId);
@@ -124,9 +124,9 @@ public class TrackWidgetProvider
}
@Override
public void onDisabled(Context context) {
public void onDisabled(Context aContext) {
if (trackObserver != null) {
context.getContentResolver().unregisterContentObserver(trackObserver);
aContext.getContentResolver().unregisterContentObserver(trackObserver);
}
if (sharedPreferences != null) {
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
@@ -154,7 +154,7 @@ public class TrackWidgetProvider
views.setOnClickPendingIntent(R.id.appwidget_track_statistics, pendingIntent);
if (action != null) {
updateViewButton(views, context, action);
updateViewButton(views, action);
}
updateViewTrackStatistics(views, track);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(widget);
@@ -167,20 +167,19 @@ public class TrackWidgetProvider
* Update the widget's button with the appropriate intent and icon.
*
* @param views The RemoteViews containing the button
* @param context The Context of the AppWidget
* @param action The action broadcast from the track service
*/
private void updateViewButton(RemoteViews views, Context context, String action) {
private void updateViewButton(RemoteViews views, String action) {
if (TRACK_STARTED_ACTION.equals(action)) {
// If a new track is started by this appwidget or elsewhere,
// toggle the button to active and have it disable the track if pressed.
setButtonIntent(
views, context, R.string.end_current_track_action, R.drawable.appwidget_button_enabled);
views, R.string.end_current_track_action, R.drawable.appwidget_button_enabled);
} else {
// If a track is stopped by this appwidget or elsewhere,
// toggle the button to inactive and have it start a new track if pressed.
setButtonIntent(
views, context, R.string.start_new_track_action, R.drawable.appwidget_button_disabled);
views, R.string.start_new_track_action, R.drawable.appwidget_button_disabled);
}
}
@@ -188,12 +187,10 @@ public class TrackWidgetProvider
* Set up the main widget button.
*
* @param views The widget views
* @param context The widget context
* @param action The resource id of the action to fire when the button is pressed
* @param icon The resource id of the icon to show for the button
*/
private void setButtonIntent(
RemoteViews views, Context context, int action, int icon) {
private void setButtonIntent(RemoteViews views, int action, int icon) {
Intent intent = new Intent(context, ControlRecordingService.class);
intent.setAction(context.getString(action));
PendingIntent pendingIntent = PendingIntent.getService(context, 0,
@@ -153,7 +153,7 @@ public class SpreadsheetsClient extends GDataServiceClient {
* @return a parser for the indicated feed
* @throws ParseException if the response from the server could not be parsed
*/
@SuppressWarnings("rawtypes")
@SuppressWarnings("unchecked")
@Override
public GDataParser getParserForFeed(
Class feedEntryClass, String feedUri, String authToken)
@@ -227,7 +227,7 @@ public class SpreadsheetsClient extends GDataServiceClient {
* Converts an HTTP exception which happened while writing to the equivalent
* local exception.
*/
@SuppressWarnings("rawtypes")
@SuppressWarnings("unchecked")
private void convertHttpExceptionForWrites(
Class entryClass, String message, HttpException cause)
throws ParseException, IOException {
@@ -253,7 +253,7 @@ public class SpreadsheetsClient extends GDataServiceClient {
/**
* Parses one entry from the input stream.
*/
@SuppressWarnings("rawtypes")
@SuppressWarnings("unchecked")
private Entry parseEntry(Class entryClass, InputStream is)
throws ParseException, IOException {
GDataParser parser = null;
@@ -48,7 +48,7 @@ public class XmlDocsGDataParserFactory implements GDataParserFactory {
}
}
@SuppressWarnings("rawtypes")
@SuppressWarnings("unchecked")
@Override
public GDataParser createParser(Class cls, InputStream is)
throws ParseException {
+1 -1
View File
@@ -3,7 +3,7 @@
package="com.google.android.apps.mytracks.samples.api"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<uses-sdk android:minSdkVersion="3"/>
<application android:icon="@drawable/icon"
android:label="@string/app_name">
@@ -20,7 +20,7 @@ import android.os.Parcelable;
/**
* Statistical data about a trip.
* The data in this class should be filled out by {@link TripStatisticsBuilder}.
* The data in this class should be filled out by TripStatisticsBuilder.
*
* TODO: hashCode and equals
*
@@ -215,7 +215,7 @@ public class MyTracksTest extends ActivityInstrumentationTestCase2<MyTracks>{
}
/**
* Clears {selected,recording}TrackId in the {@link getSharedPreferences()}.
* Clears {selected,recording}TrackId in the {@link #getSharedPreferences()}.
*/
private void clearSelectedAndRecordingTracks() {
Editor editor = getSharedPreferences().edit();