diff --git a/MyTracks/proguard.cfg b/MyTracks/proguard.cfg
index 17ce7b54e..8a6a82b85 100644
--- a/MyTracks/proguard.cfg
+++ b/MyTracks/proguard.cfg
@@ -67,3 +67,9 @@
# Needed by Guava
-dontwarn sun.misc.Unsafe
+
+# Keep services needed by ANT+ protocol
+-keep public class com.dsi.ant.IAnt_6
+-keep public class com.dsi.ant.IAnt
+-keep public class com.dsi.ant.IServiceSettings
+
diff --git a/MyTracks/src/com/google/android/apps/mytracks/CheckUnits.java b/MyTracks/src/com/google/android/apps/mytracks/CheckUnits.java
index f466cb322..355418599 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/CheckUnits.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/CheckUnits.java
@@ -86,7 +86,7 @@ class CheckUnits {
}
private static void recordCheckPerformed(SharedPreferences preferences) {
- ApiFeatures.getInstance().getApiPlatformAdapter().applyPreferenceChanges(
+ ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(
preferences.edit().putBoolean(PREFERENCE_UNITS_CHECKED, true));
}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/DeleteAllTracks.java b/MyTracks/src/com/google/android/apps/mytracks/DeleteAllTracks.java
index 55516eb36..2338b5b39 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/DeleteAllTracks.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/DeleteAllTracks.java
@@ -65,7 +65,7 @@ public class DeleteAllTracks extends Handler {
SharedPreferences.Editor editor = prefs.edit();
// TODO: Go through data manager
editor.putLong(context.getString(R.string.selected_track_key), -1);
- ApiFeatures.getInstance().getApiPlatformAdapter().applyPreferenceChanges(editor);
+ ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(editor);
if (done != null) {
Handler h = new Handler();
h.post(done);
diff --git a/MyTracks/src/com/google/android/apps/mytracks/DeleteTrack.java b/MyTracks/src/com/google/android/apps/mytracks/DeleteTrack.java
index 1b73e8f68..bc53c8fed 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/DeleteTrack.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/DeleteTrack.java
@@ -108,7 +108,7 @@ public class DeleteTrack extends Activity
SharedPreferences preferences = getSharedPreferences(Constants.SETTINGS_NAME, 0);
if (preferences.getLong(selectedKey, -1) == deleteTrackId) {
Editor editor = preferences.edit().putLong(selectedKey, -1);
- ApiFeatures.getInstance().getApiPlatformAdapter().applyPreferenceChanges(editor);
+ ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(editor);
}
}
}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/Eula.java b/MyTracks/src/com/google/android/apps/mytracks/Eula.java
index c54926795..59936ce80 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/Eula.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/Eula.java
@@ -95,7 +95,7 @@ class Eula {
}
private static void accept(Activity activity, SharedPreferences preferences) {
- ApiFeatures.getInstance().getApiPlatformAdapter().applyPreferenceChanges(
+ ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(
preferences.edit().putBoolean(PREFERENCE_EULA_ACCEPTED, true));
Intent startIntent = new Intent(activity, WelcomeActivity.class);
activity.startActivityForResult(startIntent, Constants.WELCOME);
diff --git a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java
index 2071bf948..6da1bb12b 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java
@@ -134,7 +134,7 @@ public class MyTracks extends TabActivity implements OnTouchListener {
super.onCreate(savedInstanceState);
ApiFeatures apiFeatures = ApiFeatures.getInstance();
if (!SystemUtils.isRelease(this)) {
- apiFeatures.getApiPlatformAdapter().enableStrictMode();
+ apiFeatures.getApiAdapter().enableStrictMode();
}
tracker = GoogleAnalyticsTracker.getInstance();
diff --git a/MyTracks/src/com/google/android/apps/mytracks/SettingsActivity.java b/MyTracks/src/com/google/android/apps/mytracks/SettingsActivity.java
index 27b19779e..b4e2ffd62 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/SettingsActivity.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/SettingsActivity.java
@@ -93,7 +93,7 @@ public class SettingsActivity extends PreferenceActivity {
preferenceManager.setSharedPreferencesMode(0);
// Set up automatic preferences backup
- backupListener = BackupPreferencesListener.create(this, apiFeatures);
+ backupListener = apiFeatures.getApiAdapter().getBackupPreferencesListener(this);
preferences = preferenceManager.getSharedPreferences();
preferences.registerOnSharedPreferenceChangeListener(backupListener);
diff --git a/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java b/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java
index 3bdd31b0c..c375f15bf 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java
@@ -397,7 +397,7 @@ public class TrackDataHub {
// Save the selection to memory and flush.
selectedTrackId = trackId;
- ApiFeatures.getInstance().getApiPlatformAdapter().applyPreferenceChanges(
+ ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(
preferences.edit().putLong(SELECTED_TRACK_KEY, trackId));
// Force it to reload data from the beginning.
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java b/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java
index f8b7e1f69..d7f35df06 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java
@@ -41,8 +41,6 @@ import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpResponseException;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.InputStreamContent;
-import com.google.api.client.http.apache.ApacheHttpTransport;
-import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.util.Strings;
import android.app.Activity;
@@ -140,8 +138,7 @@ public class SendToFusionTables implements Runnable {
this.stringUtils = new StringUtils(context);
this.providerUtils = MyTracksProviderUtils.Factory.get(context);
- HttpTransport transport = ApiFeatures.getInstance().useNetHttpTransport()
- ? new NetHttpTransport() : new ApacheHttpTransport();
+ HttpTransport transport = ApiFeatures.getInstance().getApiAdapter().getHttpTransport();
httpRequestFactory = transport.createRequestFactory(new MethodOverride());
}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupPreferencesListener.java b/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupPreferencesListener.java
index 51e9439ea..3162c4779 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupPreferencesListener.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupPreferencesListener.java
@@ -15,63 +15,13 @@
*/
package com.google.android.apps.mytracks.io.backup;
-import com.google.android.apps.mytracks.util.ApiFeatures;
-
-import android.app.backup.BackupManager;
-import android.content.Context;
-import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
/**
* Shared preferences listener which notifies the backup system about new data
* being available for backup.
- * This class is API-version-safe and will provide a dummy implementation if
- * the device doesn't support backup services.
*
* @author Rodrigo Damazio
*/
-public abstract class BackupPreferencesListener
- implements OnSharedPreferenceChangeListener {
-
- /**
- * Real implementation of the listener, which calls the {@link BackupManager}.
- */
- private static class BackupPreferencesListenerImpl
- extends BackupPreferencesListener {
- private final BackupManager backupManager;
-
- public BackupPreferencesListenerImpl(Context context) {
- this.backupManager = new BackupManager(context);
- }
-
- @Override
- public void onSharedPreferenceChanged(
- SharedPreferences sharedPreferences, String key) {
- backupManager.dataChanged();
- }
- }
-
- /**
- * Dummy implementation of the listener which does nothing.
- */
- private static class DummyBackupPreferencesListener
- extends BackupPreferencesListener {
- @Override
- public void onSharedPreferenceChanged(
- SharedPreferences sharedPreferences, String key) {
- // Do nothing
- }
- }
-
- /**
- * Creates and returns a proper instance of the listener for this device.
- */
- public static BackupPreferencesListener create(
- Context context, ApiFeatures apiFeatures) {
- if (apiFeatures.hasBackup()) {
- return new BackupPreferencesListenerImpl(context);
- } else {
- return new DummyBackupPreferencesListener();
- }
- }
+public interface BackupPreferencesListener extends OnSharedPreferenceChangeListener {
}
\ No newline at end of file
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupPreferencesListenerImpl.java b/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupPreferencesListenerImpl.java
new file mode 100644
index 000000000..5f11b2876
--- /dev/null
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupPreferencesListenerImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.android.apps.mytracks.io.backup;
+
+import android.app.backup.BackupManager;
+import android.content.Context;
+import android.content.SharedPreferences;
+
+/**
+ * Implementation of {@link BackupPreferencesListener} that calls the
+ * {@link BackupManager}.
+ *
+ * @author Jimmy Shih
+ */
+public class BackupPreferencesListenerImpl implements BackupPreferencesListener {
+
+ private final BackupManager backupManager;
+
+ public BackupPreferencesListenerImpl(Context context) {
+ this.backupManager = new BackupManager(context);
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ backupManager.dataChanged();
+ }
+}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/docs/DocsTagBuilder.java b/MyTracks/src/com/google/android/apps/mytracks/io/docs/DocsTagBuilder.java
index 26351d508..f0cf5180f 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/docs/DocsTagBuilder.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/docs/DocsTagBuilder.java
@@ -48,7 +48,7 @@ import java.util.Locale;
class DocsTagBuilder {
private static final DecimalFormatSymbols FORMAT_SYMBOLS =
- ApiFeatures.getInstance().getApiPlatformAdapter().getDecimalFormatSymbols(Locale.ENGLISH);
+ ApiFeatures.getInstance().getApiAdapter().getDecimalFormatSymbols(Locale.ENGLISH);
private static final NumberFormat LARGE_UNIT_FORMAT =
new DecimalFormat("#,###,###.00", FORMAT_SYMBOLS);
private static final NumberFormat SMALL_UNIT_FORMAT =
diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java b/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java
index b9d31a681..c32f88c10 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java
@@ -37,7 +37,7 @@ import com.google.android.apps.mytracks.services.tasks.StatusAnnouncerFactory;
import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.stats.TripStatisticsBuilder;
import com.google.android.apps.mytracks.util.ApiFeatures;
-import com.google.android.apps.mytracks.util.ApiPlatformAdapter;
+import com.google.android.apps.mytracks.util.ApiLevelAdapter;
import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.maps.mytracks.R;
@@ -485,8 +485,8 @@ public class TrackRecordingService extends Service {
* Shows the notification message and icon in the notification bar.
*/
private void showNotification() {
- final ApiPlatformAdapter apiPlatformAdapter =
- ApiFeatures.getInstance().getApiPlatformAdapter();
+ final ApiLevelAdapter apiLevelAdapter =
+ ApiFeatures.getInstance().getApiAdapter();
if (isRecording) {
Notification notification = new Notification(
R.drawable.arrow_320, null /* tickerText */,
@@ -497,10 +497,10 @@ public class TrackRecordingService extends Service {
notification.setLatestEventInfo(this, getString(R.string.app_name),
getString(R.string.recording_your_track), contentIntent);
notification.flags += Notification.FLAG_NO_CLEAR;
- apiPlatformAdapter.startForeground(this, notificationManager, 1,
+ apiLevelAdapter.startForeground(this, notificationManager, 1,
notification);
} else {
- apiPlatformAdapter.stopForeground(this, notificationManager, 1);
+ apiLevelAdapter.stopForeground(this, notificationManager, 1);
}
}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/ZephyrMessageParser.java b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/ZephyrMessageParser.java
index aa96f2e48..b70e0fddf 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/ZephyrMessageParser.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/ZephyrMessageParser.java
@@ -62,7 +62,7 @@ public class ZephyrMessageParser implements MessageParser {
// 0x1A00316550003162 produces erroneous values for Cadence and needs
// a workaround based on the stride counter.
// Firmware values range from field 3 to 10 (inclusive) of the byte buffer.
- byte[] hardwareFirmwareId = ApiFeatures.getInstance().getApiPlatformAdapter()
+ byte[] hardwareFirmwareId = ApiFeatures.getInstance().getApiAdapter()
.copyByteArray(buffer, 3, 11);
Sensor.SensorData.Builder cadence = Sensor.SensorData.newBuilder();
diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/ant/AntSensorManager.java b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/ant/AntSensorManager.java
index d8a37a55d..096943abd 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/ant/AntSensorManager.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/ant/AntSensorManager.java
@@ -22,6 +22,7 @@ import com.dsi.ant.AntInterface;
import com.dsi.ant.AntInterfaceIntent;
import com.dsi.ant.AntMesg;
import com.dsi.ant.exception.AntInterfaceException;
+import com.dsi.ant.exception.AntServiceNotConnectedException;
import com.google.android.apps.mytracks.content.Sensor;
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
import com.google.android.apps.mytracks.services.sensors.SensorManager;
@@ -142,13 +143,16 @@ public abstract class AntSensorManager extends SensorManager {
Log.w(TAG, "Failed to unregister ANT data receiver", e);
}
- try {
- antReceiver.releaseInterface();
- } catch (AntInterfaceException e) {
- Log.e(TAG, "failed to release ANT interface", e);
+ if (antReceiver != null) {
+ try {
+ antReceiver.releaseInterface();
+ } catch (AntServiceNotConnectedException e) {
+ Log.i(TAG, "ANT service not connected", e);
+ } catch (AntInterfaceException e) {
+ Log.e(TAG, "failed to release ANT interface", e);
+ }
+ antReceiver.destroy();
}
-
- antReceiver.destroy();
}
@Override
@@ -236,7 +240,7 @@ public abstract class AntSensorManager extends SensorManager {
/**
* Process a raw ANT message.
* @param antMessage the ANT message, including the size and message ID bytes
- * @deprecated Use {@link #handleMessage(int, byte[])} instead.
+ * @deprecated Use {@link #handleMessage(byte, byte[])} instead.
*/
protected void handleMessage(byte[] antMessage) {
int len = antMessage[0];
diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/tasks/StatusAnnouncerFactory.java b/MyTracks/src/com/google/android/apps/mytracks/services/tasks/StatusAnnouncerFactory.java
index 30c87d781..739b81cb3 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/services/tasks/StatusAnnouncerFactory.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/services/tasks/StatusAnnouncerFactory.java
@@ -37,11 +37,7 @@ public class StatusAnnouncerFactory implements PeriodicTaskFactory {
@Override
public PeriodicTask create(Context context) {
if (hasTts) {
- if (ApiFeatures.getInstance().isAudioFocusSupported()) {
- return new FroyoStatusAnnouncerTask(context);
- } else {
- return new StatusAnnouncerTask(context);
- }
+ return ApiFeatures.getInstance().getApiAdapter().getStatusAnnouncerTask(context);
} else {
return null;
}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/ApiFeatures.java b/MyTracks/src/com/google/android/apps/mytracks/util/ApiFeatures.java
index ad87ac45a..700b5a2a6 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/util/ApiFeatures.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/util/ApiFeatures.java
@@ -16,11 +16,7 @@
package com.google.android.apps.mytracks.util;
import com.google.android.apps.mytracks.Constants;
-import com.google.api.client.http.HttpTransport;
-import com.google.api.client.http.apache.ApacheHttpTransport;
-import com.google.api.client.http.javanet.NetHttpTransport;
-import android.bluetooth.BluetoothDevice;
import android.os.Build;
import android.util.Log;
@@ -33,7 +29,7 @@ import android.util.Log;
public class ApiFeatures {
/**
- * The API level of the Android version we're being run under.
+ * The API level of the Android version we are being run under.
*/
private static final int ANDROID_API_LEVEL = Integer.parseInt(
Build.VERSION.SDK);
@@ -41,9 +37,9 @@ public class ApiFeatures {
private static ApiFeatures instance;
/**
- * The API platform adapter supported by this system.
+ * The API level adapter for the Android version we are being run under.
*/
- private ApiPlatformAdapter apiPlatformAdapter;
+ private ApiLevelAdapter apiLevelAdapter;
/**
* Returns the singleton instance of this class.
@@ -70,18 +66,20 @@ public class ApiFeatures {
// It is safe to import unsupported classes as long as we only actually
// load the class when supported.
if (getApiLevel() >= 9) {
- apiPlatformAdapter = new GingerbreadPlatformAdapter();
+ apiLevelAdapter = new ApiLevel9Adapter();
+ } else if (getApiLevel() >= 8) {
+ apiLevelAdapter = new ApiLevel8Adapter();
} else if (getApiLevel() >= 5) {
- apiPlatformAdapter = new EclairPlatformAdapter();
+ apiLevelAdapter = new ApiLevel5Adapter();
} else {
- apiPlatformAdapter = new CupcakePlatformAdapter();
+ apiLevelAdapter = new ApiLevel3Adapter();
}
- Log.i(Constants.TAG, "Using platform adapter " + apiPlatformAdapter.getClass());
+ Log.i(Constants.TAG, "Using API level adapter " + apiLevelAdapter.getClass());
}
- public ApiPlatformAdapter getApiPlatformAdapter() {
- return apiPlatformAdapter;
+ public ApiLevelAdapter getApiAdapter() {
+ return apiLevelAdapter;
}
// API Level 4 Changes
@@ -107,35 +105,11 @@ public class ApiFeatures {
return getApiLevel() >= 5;
}
- // API Level 8 Changes
-
- public boolean isAudioFocusSupported() {
- return getApiLevel() >= 8;
- }
-
- /**
- * Returns whether cloud backup (a.k.a. Froyo backup) is available.
- */
- public boolean hasBackup() {
- return getApiLevel() >= 8;
- }
-
- // API Level 9 Changes
-
- /**
- * Returns true if {@link NetHttpTransport} should be used rather than
- * {@link ApacheHttpTransport}. See {@link HttpTransport} for more info.
- */
- public boolean useNetHttpTransport() {
- return getApiLevel() >= 9;
- }
-
// API Level 10 changes
/**
- * Returns true if
- * {@link BluetoothDevice#createInsecureRfcommSocketToServiceRecord} is
- * available.
+ * Returns true if BluetoothDevice.createInsecureRfcommSocketToServiceRecord
+ * is available.
*/
public boolean hasBluetoothDeviceCreateInsecureRfcommSocketToServiceRecord() {
return getApiLevel() >= 10;
diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/CupcakePlatformAdapter.java b/MyTracks/src/com/google/android/apps/mytracks/util/ApiLevel3Adapter.java
similarity index 73%
rename from MyTracks/src/com/google/android/apps/mytracks/util/CupcakePlatformAdapter.java
rename to MyTracks/src/com/google/android/apps/mytracks/util/ApiLevel3Adapter.java
index 835d095ab..c93b3dda3 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/util/CupcakePlatformAdapter.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/util/ApiLevel3Adapter.java
@@ -17,9 +17,17 @@ package com.google.android.apps.mytracks.util;
import static com.google.android.apps.mytracks.Constants.TAG;
+import com.google.android.apps.mytracks.io.backup.BackupPreferencesListener;
+import com.google.android.apps.mytracks.services.tasks.PeriodicTask;
+import com.google.android.apps.mytracks.services.tasks.StatusAnnouncerTask;
+import com.google.api.client.http.HttpTransport;
+import com.google.api.client.http.apache.ApacheHttpTransport;
+
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
+import android.content.Context;
+import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.util.Log;
@@ -29,12 +37,11 @@ import java.text.DecimalFormatSymbols;
import java.util.Locale;
/**
- * The Cupcake (API level 3) specific implementation of the
- * {@link ApiPlatformAdapter}.
- *
+ * API level 3 specific implementation of the {@link ApiLevelAdapter}.
+ *
* @author Bartlomiej Niechwiej
*/
-public class CupcakePlatformAdapter implements ApiPlatformAdapter {
+public class ApiLevel3Adapter implements ApiLevelAdapter {
@Override
public void startForeground(Service service,
@@ -53,6 +60,21 @@ public class CupcakePlatformAdapter implements ApiPlatformAdapter {
notificationManager.cancel(id);
}
}
+
+ @Override
+ public PeriodicTask getStatusAnnouncerTask(Context context) {
+ return new StatusAnnouncerTask(context);
+ }
+
+ @Override
+ public BackupPreferencesListener getBackupPreferencesListener(Context context) {
+ return new BackupPreferencesListener() {
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ // Do nothing
+ }
+ };
+ }
private void setServiceForeground(Service service, boolean foreground) {
// setForeground has been completely removed in API level 11, so we use reflection.
@@ -94,4 +116,9 @@ public class CupcakePlatformAdapter implements ApiPlatformAdapter {
public DecimalFormatSymbols getDecimalFormatSymbols(Locale locale) {
return new DecimalFormatSymbols(locale);
}
+
+ @Override
+ public HttpTransport getHttpTransport() {
+ return new ApacheHttpTransport();
+ }
}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/EclairPlatformAdapter.java b/MyTracks/src/com/google/android/apps/mytracks/util/ApiLevel5Adapter.java
similarity index 87%
rename from MyTracks/src/com/google/android/apps/mytracks/util/EclairPlatformAdapter.java
rename to MyTracks/src/com/google/android/apps/mytracks/util/ApiLevel5Adapter.java
index dcb005eb6..0f963f70f 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/util/EclairPlatformAdapter.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/util/ApiLevel5Adapter.java
@@ -20,12 +20,11 @@ import android.app.NotificationManager;
import android.app.Service;
/**
- * The Eclair (API level 5) specific implementation of the
- * {@link ApiPlatformAdapter}.
- *
+ * API level 5 specific implementation of the {@link ApiLevelAdapter}.
+ *
* @author Bartlomiej Niechwiej
*/
-public class EclairPlatformAdapter extends CupcakePlatformAdapter {
+public class ApiLevel5Adapter extends ApiLevel3Adapter {
@Override
public void startForeground(Service service,
diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/ApiLevel8Adapter.java b/MyTracks/src/com/google/android/apps/mytracks/util/ApiLevel8Adapter.java
new file mode 100644
index 000000000..35696189d
--- /dev/null
+++ b/MyTracks/src/com/google/android/apps/mytracks/util/ApiLevel8Adapter.java
@@ -0,0 +1,26 @@
+package com.google.android.apps.mytracks.util;
+
+import com.google.android.apps.mytracks.io.backup.BackupPreferencesListener;
+import com.google.android.apps.mytracks.io.backup.BackupPreferencesListenerImpl;
+import com.google.android.apps.mytracks.services.tasks.FroyoStatusAnnouncerTask;
+import com.google.android.apps.mytracks.services.tasks.PeriodicTask;
+
+import android.content.Context;
+
+/**
+ * API level 8 specific implementation of the {@link ApiLevelAdapter}.
+ *
+ * @author Jimmy Shih
+ */
+public class ApiLevel8Adapter extends ApiLevel5Adapter {
+
+ @Override
+ public PeriodicTask getStatusAnnouncerTask(Context context) {
+ return new FroyoStatusAnnouncerTask(context);
+ }
+
+ @Override
+ public BackupPreferencesListener getBackupPreferencesListener(Context context) {
+ return new BackupPreferencesListenerImpl(context);
+ }
+}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/GingerbreadPlatformAdapter.java b/MyTracks/src/com/google/android/apps/mytracks/util/ApiLevel9Adapter.java
similarity index 77%
rename from MyTracks/src/com/google/android/apps/mytracks/util/GingerbreadPlatformAdapter.java
rename to MyTracks/src/com/google/android/apps/mytracks/util/ApiLevel9Adapter.java
index 648a4cc72..011d7d74a 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/util/GingerbreadPlatformAdapter.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/util/ApiLevel9Adapter.java
@@ -1,6 +1,8 @@
package com.google.android.apps.mytracks.util;
import com.google.android.apps.mytracks.Constants;
+import com.google.api.client.http.HttpTransport;
+import com.google.api.client.http.javanet.NetHttpTransport;
import android.content.SharedPreferences.Editor;
import android.os.StrictMode;
@@ -11,12 +13,11 @@ import java.util.Arrays;
import java.util.Locale;
/**
- * The Gingerbread (API level 9) specific implememntation of the
- * {@link ApiPlatformAdapter}.
+ * API level 9 specific implementation of the {@link ApiLevelAdapter}.
*
* @author Rodrigo Damazio
*/
-public class GingerbreadPlatformAdapter extends EclairPlatformAdapter {
+public class ApiLevel9Adapter extends ApiLevel8Adapter {
@Override
public void applyPreferenceChanges(Editor editor) {
@@ -47,4 +48,9 @@ public class GingerbreadPlatformAdapter extends EclairPlatformAdapter {
public DecimalFormatSymbols getDecimalFormatSymbols(Locale locale) {
return DecimalFormatSymbols.getInstance(locale);
}
+
+ @Override
+ public HttpTransport getHttpTransport() {
+ return new NetHttpTransport();
+ }
}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/ApiPlatformAdapter.java b/MyTracks/src/com/google/android/apps/mytracks/util/ApiLevelAdapter.java
similarity index 72%
rename from MyTracks/src/com/google/android/apps/mytracks/util/ApiPlatformAdapter.java
rename to MyTracks/src/com/google/android/apps/mytracks/util/ApiLevelAdapter.java
index 02a225dd5..932601e76 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/util/ApiPlatformAdapter.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/util/ApiLevelAdapter.java
@@ -15,24 +15,31 @@
*/
package com.google.android.apps.mytracks.util;
+import com.google.android.apps.mytracks.io.backup.BackupPreferencesListener;
+import com.google.android.apps.mytracks.services.tasks.PeriodicTask;
+import com.google.api.client.http.HttpTransport;
+
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
+import android.content.Context;
import android.content.SharedPreferences;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
/**
- * A set of methods that may be implemented in a platform specific way.
+ * A set of methods that may be implemented differently depending on the Android API level.
*
* @author Bartlomiej Niechwiej
*/
-public interface ApiPlatformAdapter {
+public interface ApiLevelAdapter {
/**
* Puts the specified service into foreground.
*
+ * Due to changes in API level 5.
+ *
* @param service the service to be put in foreground.
* @param notificationManager the notification manager used to post the given
* notification.
@@ -44,6 +51,9 @@ public interface ApiPlatformAdapter {
/**
* Puts the given service into background.
+ *
+ * Due to changes in API level 5.
+ *
* @param service the service to put into background.
* @param notificationManager the notification manager to user when removing
* notifications.
@@ -53,14 +63,32 @@ public interface ApiPlatformAdapter {
void stopForeground(Service service, NotificationManager notificationManager,
int id);
+ /**
+ * Gets a status announcer task.
+ *
+ * Due to changes in API level 8.
+ */
+ PeriodicTask getStatusAnnouncerTask(Context context);
+
+ /**
+ * Gets a {@link BackupPreferencesListener}.
+ *
+ * Due to changes in API level 8.
+ */
+ BackupPreferencesListener getBackupPreferencesListener(Context context);
+
/**
* Applies all changes done to the given preferences editor.
* Changes may or may not be applied immediately.
+ *
+ * Due to changes in API level 9.
*/
void applyPreferenceChanges(SharedPreferences.Editor editor);
/**
* Enables strict mode where supported, only if this is a development build.
+ *
+ * Due to changes in API level 9.
*/
void enableStrictMode();
@@ -69,6 +97,8 @@ public interface ApiPlatformAdapter {
* indexes start (inclusive) to end (exclusive). The end index must be less
* than or equal to input.length.
*
+ * Due to changes in API level 9.
+ *
* @param input the input byte array
* @param start the start index
* @param end the end index
@@ -80,8 +110,17 @@ public interface ApiPlatformAdapter {
/**
* Gets an instance of {@link DecimalFormatSymbols} for a locale.
*
+ * Due to changes in API level 9.
+ *
* @param locale the locale
* @return a new instance of {@link DecimalFormatSymbols}
*/
DecimalFormatSymbols getDecimalFormatSymbols(Locale locale);
+
+ /**
+ * Gets a {@link HttpTransport}.
+ *
+ * Due to changes in API level 9.
+ */
+ HttpTransport getHttpTransport();
}
diff --git a/MyTracksApiSample/.classpath b/MyTracksApiSample/.classpath
new file mode 100644
index 000000000..d98e37d5d
--- /dev/null
+++ b/MyTracksApiSample/.classpath
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/MyTracksApiSample/.project b/MyTracksApiSample/.project
new file mode 100644
index 000000000..f7a2037ed
--- /dev/null
+++ b/MyTracksApiSample/.project
@@ -0,0 +1,40 @@
+
+
+ MyTracksApiSample
+
+
+
+
+
+ com.android.ide.eclipse.adt.ResourceManagerBuilder
+
+
+
+
+ com.android.ide.eclipse.adt.PreCompilerBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ com.android.ide.eclipse.adt.ApkBuilder
+
+
+
+
+
+ com.android.ide.eclipse.adt.AndroidNature
+ org.eclipse.jdt.core.javanature
+
+
+
+ MyTracksLib_src
+ 2
+ _android_MyTracksLib_e2802071/src
+
+
+
diff --git a/MyTracksApiSample/.settings/org.eclipse.jdt.core.prefs b/MyTracksApiSample/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..a1c77fa36
--- /dev/null
+++ b/MyTracksApiSample/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,282 @@
+#Thu Oct 13 15:26:00 PDT 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=569
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_member=569
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package_declaration=569
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=24
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type_declaration=569
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_field_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_for_statement=16
+org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments=16
+org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class=0
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.comment_new_line_at_start_of_html_paragraph=true
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.force_if_else_statement_brace=false
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=80
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.sort_local_variable_annotations=false
+org.eclipse.jdt.core.formatter.sort_member_annotations=false
+org.eclipse.jdt.core.formatter.sort_package_annotations=false
+org.eclipse.jdt.core.formatter.sort_parameter_annotations=false
+org.eclipse.jdt.core.formatter.sort_type_annotations=false
+org.eclipse.jdt.core.formatter.tabulation.char=mixed
+org.eclipse.jdt.core.formatter.tabulation.size=8
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_comment_inline_tags=false
+org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation=true
+org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation=true
+org.eclipse.jdt.core.formatter.wrap_non_simple_package_annotation=true
+org.eclipse.jdt.core.formatter.wrap_non_simple_parameter_annotation=false
+org.eclipse.jdt.core.formatter.wrap_non_simple_type_annotation=true
+org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments=false
diff --git a/MyTracksApiSample/.settings/org.eclipse.jdt.ui.prefs b/MyTracksApiSample/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 000000000..57a8a95d5
--- /dev/null
+++ b/MyTracksApiSample/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,4 @@
+#Thu Oct 13 15:26:00 PDT 2011
+eclipse.preferences.version=1
+formatter_profile=org.eclipse.jdt.ui.default.sun_profile
+formatter_settings_version=11
diff --git a/MyTracksApiSample/AndroidManifest.xml b/MyTracksApiSample/AndroidManifest.xml
new file mode 100644
index 000000000..1c09cf1f9
--- /dev/null
+++ b/MyTracksApiSample/AndroidManifest.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MyTracksApiSample/default.properties b/MyTracksApiSample/default.properties
new file mode 100644
index 000000000..2a471ddd6
--- /dev/null
+++ b/MyTracksApiSample/default.properties
@@ -0,0 +1,12 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=Google Inc.:Google APIs:10
+android.library.reference.1=../MyTracksLib
diff --git a/MyTracksApiSample/proguard.cfg b/MyTracksApiSample/proguard.cfg
new file mode 100644
index 000000000..b1cdf17b5
--- /dev/null
+++ b/MyTracksApiSample/proguard.cfg
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native ;
+}
+
+-keepclasseswithmembers class * {
+ public (android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public (android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
diff --git a/MyTracksApiSample/res/drawable-hdpi/icon.png b/MyTracksApiSample/res/drawable-hdpi/icon.png
new file mode 100644
index 000000000..8074c4c57
Binary files /dev/null and b/MyTracksApiSample/res/drawable-hdpi/icon.png differ
diff --git a/MyTracksApiSample/res/drawable-ldpi/icon.png b/MyTracksApiSample/res/drawable-ldpi/icon.png
new file mode 100644
index 000000000..1095584ec
Binary files /dev/null and b/MyTracksApiSample/res/drawable-ldpi/icon.png differ
diff --git a/MyTracksApiSample/res/drawable-mdpi/icon.png b/MyTracksApiSample/res/drawable-mdpi/icon.png
new file mode 100644
index 000000000..a07c69fa5
Binary files /dev/null and b/MyTracksApiSample/res/drawable-mdpi/icon.png differ
diff --git a/MyTracksApiSample/res/layout/main.xml b/MyTracksApiSample/res/layout/main.xml
new file mode 100644
index 000000000..cad11badf
--- /dev/null
+++ b/MyTracksApiSample/res/layout/main.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
diff --git a/MyTracksApiSample/res/values/strings.xml b/MyTracksApiSample/res/values/strings.xml
new file mode 100644
index 000000000..cb332de6c
--- /dev/null
+++ b/MyTracksApiSample/res/values/strings.xml
@@ -0,0 +1,7 @@
+
+
+ Add a waypoint to all the tracks
+ MyTracksApiSample
+ Start recording
+ Stop recording
+
diff --git a/MyTracksApiSample/src/com/google/android/apps/mytracks/samples/api/MainActivity.java b/MyTracksApiSample/src/com/google/android/apps/mytracks/samples/api/MainActivity.java
new file mode 100644
index 000000000..319b0f848
--- /dev/null
+++ b/MyTracksApiSample/src/com/google/android/apps/mytracks/samples/api/MainActivity.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.android.apps.mytracks.samples.api;
+
+import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
+import com.google.android.apps.mytracks.content.Track;
+import com.google.android.apps.mytracks.content.Waypoint;
+import com.google.android.apps.mytracks.services.ITrackRecordingService;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * An activity to access MyTracks content provider and service.
+ *
+ * Note you must first install MyTracks before installing this app.
+ *
+ * You also need to enable third party application access inside MyTracks
+ * MyTracks -> menu -> Settings -> Sharing -> Allow access
+ *
+ * @author Jimmy Shih
+ */
+public class MainActivity extends Activity {
+
+ private static final String TAG = MainActivity.class.getSimpleName();
+
+ // utils to access the MyTracks content provider
+ private MyTracksProviderUtils myTracksProviderUtils;
+
+ // display output from the MyTracks content provider
+ private TextView outputTextView;
+
+ // MyTracks service
+ private ITrackRecordingService myTracksService;
+
+ // intent to access the MyTracks service
+ private Intent intent;
+
+ // connection to the MyTracks service
+ private ServiceConnection serviceConnection = new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName className, IBinder service) {
+ myTracksService = ITrackRecordingService.Stub.asInterface(service);
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName className) {
+ myTracksService = null;
+ }
+ };
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ // for the MyTracks content provider
+ myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
+ outputTextView = (TextView) findViewById(R.id.output);
+
+ Button addWaypointsButton = (Button) findViewById(R.id.add_waypoints_button);
+ addWaypointsButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ List