diff --git a/MyTracks/AndroidManifest.xml b/MyTracks/AndroidManifest.xml index 351598e86..001979cb0 100755 --- a/MyTracks/AndroidManifest.xml +++ b/MyTracks/AndroidManifest.xml @@ -102,7 +102,7 @@ limitations under the License. + android:label="@string/settings_title" > diff --git a/MyTracks/res/values-ca/strings.xml b/MyTracks/res/values-ca/strings.xml index 5ee06afaa..51fb413f7 100644 --- a/MyTracks/res/values-ca/strings.xml +++ b/MyTracks/res/values-ca/strings.xml @@ -165,12 +165,12 @@ limitations under the License. Tipus de marcador - Paràmetres de My Tracks + Paràmetres de My Tracks Visualització Enregistrament Compartició - No es troba disponible a la vostra versió de l\'Android + No es troba disponible a la vostra versió de l\'Android Freqüència d\'avís Temps mínim entre dos avisos de veu @@ -391,7 +391,7 @@ limitations under the License. Associació de dispositius Obriu els paràmetres de bluetooth de l\'Android per associar un dispositiu bluetoothSensorsEnabled - Opcions del sensor + Opcions del sensor Connectat a %s diff --git a/MyTracks/res/values-de/strings.xml b/MyTracks/res/values-de/strings.xml index efa613187..651355bbc 100644 --- a/MyTracks/res/values-de/strings.xml +++ b/MyTracks/res/values-de/strings.xml @@ -168,12 +168,12 @@ limitations under the License. Art des Wegpunktes - Einstellungen für My Tracks + Einstellungen für My Tracks Anzeige Aufzeichnung Mit Freunden teilen - In dieser Android-Version nicht verfügbar + In dieser Android-Version nicht verfügbar Dauer zwischen Ansagen Kürzeste Zeit zwischen zwei Ansagen @@ -424,7 +424,7 @@ limitations under the License. Geräteverbindung Öffnet Androids Bluetooth-Einstellungen, um Geräte zu verbinden. - Sensor-Einstellungen + Sensor-Einstellungen Verbunden mit %s diff --git a/MyTracks/res/values-es-rES/strings.xml b/MyTracks/res/values-es-rES/strings.xml index da765295d..f1f0aa237 100644 --- a/MyTracks/res/values-es-rES/strings.xml +++ b/MyTracks/res/values-es-rES/strings.xml @@ -55,7 +55,7 @@ limitations under the License. - No está disponible en su versión de Android + No está disponible en su versión de Android Mostrar velocidad diff --git a/MyTracks/res/values-es/strings.xml b/MyTracks/res/values-es/strings.xml index 2c7f1c63a..6778d2007 100644 --- a/MyTracks/res/values-es/strings.xml +++ b/MyTracks/res/values-es/strings.xml @@ -197,12 +197,12 @@ limitations under the License. Tipo de señal - Configuraciones de My Tracks + Configuraciones de My Tracks Visualizador Grabando Compartiendo - No disponible para tu versión de Android + No disponible para tu versión de Android No disponible mientras se graba el recorrido Permitir acceso @@ -480,7 +480,7 @@ limitations under the License. Abrir la configuración Bluetooth de Android para conectar un dispositivo Sensor Bluetooth activado Optiones ANT - Opciones del sensor + Opciones del sensor Modo de Recorrido Coloreado Opciones de velocidad fija Opciones de velocidad dinámica diff --git a/MyTracks/res/values-fi/strings.xml b/MyTracks/res/values-fi/strings.xml index 56117930a..cdec1f2ba 100644 --- a/MyTracks/res/values-fi/strings.xml +++ b/MyTracks/res/values-fi/strings.xml @@ -197,12 +197,12 @@ limitations under the License. Merkinnän tyyppi - My Tracks Asetukset + My Tracks Asetukset Näyttö Tallennus Jakaminen - Ei tuettu tässä Android-versiossa + Ei tuettu tässä Android-versiossa Ei saatavilla reittiä tallennettaessa. Äänimerkki @@ -477,7 +477,7 @@ limitations under the License. Avaa Androidin bluetooth-asetukset luodaksesi laitepareja bluetoothSensorsEnabled ANT asetukset - Sensorien asetukset + Sensorien asetukset Yhdistetty %s diff --git a/MyTracks/res/values-fr/strings.xml b/MyTracks/res/values-fr/strings.xml index d12903a88..63b2ebdb9 100644 --- a/MyTracks/res/values-fr/strings.xml +++ b/MyTracks/res/values-fr/strings.xml @@ -158,7 +158,7 @@ limitations under the License. Nom de balise - Paramètres My Tracks + Paramètres My Tracks Affichage Enregistrement Partage @@ -380,7 +380,7 @@ limitations under the License. Association d\'un appareil Visitez les paramètres Bluetooth d\'Android pour associer un nouvel appareil bluetoothSensorsEnabled - Options du capteur + Options du capteur Connecté à %s diff --git a/MyTracks/res/values-it/strings.xml b/MyTracks/res/values-it/strings.xml index d4af3ea86..2c9fb29e0 100644 --- a/MyTracks/res/values-it/strings.xml +++ b/MyTracks/res/values-it/strings.xml @@ -161,7 +161,7 @@ limitations under the License. Tipo di segnaposto - Impostazioni di My Tracks + Impostazioni di My Tracks Visualizzazione Registrazione Condivisione diff --git a/MyTracks/res/values-ja/strings.xml b/MyTracks/res/values-ja/strings.xml index 56231e598..d502df530 100644 --- a/MyTracks/res/values-ja/strings.xml +++ b/MyTracks/res/values-ja/strings.xml @@ -190,12 +190,12 @@ limitations under the License. マーカータイプ - My Tracks設定 + My Tracks設定 表示 記録 共有 - このAndroidバージョンでは使用できません + このAndroidバージョンでは使用できません 定期通知 音声通知間隔の最小時間 @@ -446,7 +446,7 @@ limitations under the License. ペアリングを行うには「Bluetooth設定」を開いて下さい bluetoothSensorsEnabled ANTオプション - センサーオプション + センサーオプション %sに接続しました diff --git a/MyTracks/res/values-pl/strings.xml b/MyTracks/res/values-pl/strings.xml index 0b70afa7a..cfd8d37fa 100644 --- a/MyTracks/res/values-pl/strings.xml +++ b/MyTracks/res/values-pl/strings.xml @@ -163,7 +163,7 @@ limitations under the License. Typ znacznika - Ustawienia My Tracks + Ustawienia My Tracks Wyświetlanie Rejestrowanie Dzielenie @@ -395,7 +395,7 @@ limitations under the License. Przejdź do ustawień Bluetooth Androida aby sparować urządzenie bluetoothSensorsEnabled Opce ANT - Opcje Czujników + Opcje Czujników Połączony z %s diff --git a/MyTracks/res/values-pt-rBR/strings.xml b/MyTracks/res/values-pt-rBR/strings.xml index ddf6e74ee..a7b1e4a4e 100644 --- a/MyTracks/res/values-pt-rBR/strings.xml +++ b/MyTracks/res/values-pt-rBR/strings.xml @@ -158,11 +158,11 @@ limitations under the License. Tipo do Marcador - Configurações do My Tracks + Configurações do My Tracks Exibição Gravação Compartilhamento - Não disponível na sua versão do Android + Não disponível na sua versão do Android Não disponível durante a gravação de uma trilha Tempo entre anúncios Tempo mínimo entre dois anúncios de voz diff --git a/MyTracks/res/values-ru/strings.xml b/MyTracks/res/values-ru/strings.xml index c3f70190a..3e8ac0c08 100644 --- a/MyTracks/res/values-ru/strings.xml +++ b/MyTracks/res/values-ru/strings.xml @@ -193,12 +193,12 @@ limitations under the License. Тип маркера - Настройки My Tracks + Настройки My Tracks Отображение Запись Обмен - Не доступен в вашем версии Android + Не доступен в вашем версии Android Не доступно во время записи трека Частота объявлений @@ -473,7 +473,7 @@ limitations under the License. Открыть настройки Android по bluetooth для подключения устройства bluetoothSensorsEnabled Параметры ANT - Параметры датчика + Параметры датчика Подключен к %s diff --git a/MyTracks/res/values-sv/strings.xml b/MyTracks/res/values-sv/strings.xml index c7376b2cc..0853acb77 100644 --- a/MyTracks/res/values-sv/strings.xml +++ b/MyTracks/res/values-sv/strings.xml @@ -163,7 +163,7 @@ limitations under the License. Markörtyp - My Tracks inställningar + My Tracks inställningar Visning Inspelning Delning diff --git a/MyTracks/res/values-zh-rCN/strings.xml b/MyTracks/res/values-zh-rCN/strings.xml index faac28912..ee16d60d6 100644 --- a/MyTracks/res/values-zh-rCN/strings.xml +++ b/MyTracks/res/values-zh-rCN/strings.xml @@ -194,12 +194,12 @@ limitations under the License. 标记类型 - My Tracks 设置 + My Tracks 设置 显示 记录 分享 - 不支持当前使用的 Android 版本 + 不支持当前使用的 Android 版本 在记录轨迹时不可用 通知频度 @@ -453,7 +453,7 @@ limitations under the License. 蓝牙设置 设备关联 打开 Android 的蓝牙设置关联设备 - 感应器选项 + 感应器选项 连接到 %s diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml index 2c343e868..798c69f83 100644 --- a/MyTracks/res/values/strings.xml +++ b/MyTracks/res/values/strings.xml @@ -660,110 +660,427 @@ limitations under the License. Marker Description - - My Tracks Settings - Display - Recording - Sharing - - Not available in your version of Android - Not available while recording a track - - Allow access - Other apps can read, write, start/stop recording - MyTracks data. - Other apps cannot read, write, start/stop - recording MyTracks data. - Are you sure you want to allow other apps, - including future apps, to control and access MyTracks data? There will be no further - notification. - - Announcement frequency - Minimum time between two voice announcements - - Min distance between points - Smallest distance between two recordings of your position - - Max distance between points - If two points are further than this, the track will be split - - Min time between points - Smallest time interval between two recordings of your position - - Minimum accuracy - Recording will be paused if your position is not at least this accurate - - Use metric units - All distances will be displayed in metric units - All distances will be displayed in imperial units - - Make maps public - Uploaded maps will be visible to anyone on maps.google.com - Uploaded maps will not be listed publicly on maps.google.com - - Display speed - Speed will be displayed - Pace will be displayed - - Share only URL - Only the URL of the map will be sent when sharing - The contents of the track will also be included when sharing - - Split frequency - Maximum time or distance after which a new split marker will be inserted - - Auto-resume track timeout - Maximum time in minutes after which a previously recording track will not be resumed on phone reboot - - Timestamp as track name - The default track name will be the date and time at the start of the track - Track names will have numbers which increment for each new track. - - Reset to defaults - Revert all your settings to the default values - All your settings will be erased and reverted to the default values. Saved tracks will be preserved. Are you sure? - All settings have been reverted to their defaults. - - Only supported in Android 2.0 or above - Sensor Type - The type of sensor to connect to - Clear ANT heart rate sensor pairing - Clear ANT power sensor pairing - Clear ANT SRM bridge sensor pairing - ANT sensor not paired - ANT sensor paired with: %d - Bluetooth sensor - The bluetooth sensor to connect to - Modular Stats Display - - Track Color Mode - The way to color the track - Fixed - Dynamic - Fixed Speed Slow - Slow speed top value - Fixed Speed Medium - Medium speed top value - Dynamic Speed Variation - % Margin from average speed to consider medium speed + + + My Tracks Settings + + + Display + + + Recording + + + Sensor + + + Sharing + + + Backup + + + Reset to defaults + + + Revert all your settings to the default values + - - Backup (BETA) - SD Card Backup - Backup now - Write a full copy of all your tracks and settings to the SD card - Restore now - Restore all tracks and settings from the SD card - - Restoring a backup from the SD card will OVERWRITE all your current tracks and settings. Are you sure? - Select the backup to restore - No backups found. - Writing all tracks and settings to the SD card. This may take a while... - Reading all tracks and settings from the SD card. This may take a while... - - - GPS Satellites - + + + Use metric units + + + Use metrics units to display distances + + + Use imperial units to display distances + + + Display speed + + + Display speed (e.g., miles/hour) + + + Display pace (e.g., hours/mile) + + + Track color mode + + + The way to color a track based on speed + + + Slow speed threshold + + + Slow speed top value + + + Medium speed threshold + + + Medium speed top value + + + Medium speed range + + + Percentage from the average speed for the medium speed + + + + + + Voice frequency + + + Time/distance between two voice announcements + + + Voice announcement is not available on your Android phone + + + Marker frequency + + + Time/distance after which a new marker will be inserted + + + Time between points + + + Smallest time interval between two recordings of your position + + + Distance between points + + + Smallest distance between two recordings of your position + + + Distance between tracks + + + Track will be split if two recordings of your position are further than this + + + GPS accuracy + + + GPS position will be ignored if it is not this accurate + + + Auto-resume timeout + + + Maximum time after which a previously recording track will not be resumed on phone reboot + + + Use time for track name + + + Use the track\'s start time as the default track name + + + Use a number as the default track name + + + + + Sensor Type + + + The type of sensor to connect to + + + Bluetooth Options + + + Bluetooth sensor + + + The Bluetooth sensor to connect to + + + Bluetooth pairing + + + Open Android\'s Bluetooth settings to pair a device + + + ANT+ Options + + + Unpair ANT+ heart rate sensor + + + Unpair SRM ANT+ bridge + + + Not paired + + + Paired with: %d + + + + + Make new maps public + + + Make new maps created in Google My Maps public + + + Make new maps created in Goolge My Maps unlisted + + + Share only URL link + + + Only the URL link will be sent when sharing a link with friends + + + Some text and the URL link will be sent when sharing a link with friends + + + Allow access + + + Other apps can read, write, start/stop recording My Tracks data. + + + Other apps cannot read, write, start/stop recording My Tracks data. + + + Are you sure you want to allow other apps, including future apps, to control and access My + Tracks data? There will be no further notification. + + + + + SD Card Backup + + + Backup now + + + Write a full copy of all your tracks and settings to the SD card + + + Restore now + + + Restore all tracks and settings from the SD card + + + + + All your settings will be erased and reverted to the default values. Saved tracks will be + preserved. Are you sure? + + + All settings have been reverted to their defaults. + + + + + Not available while recording a track + + + + + Writing all tracks and settings to the SD card. This may take a while... + + + + + Restoring a backup from the SD card will OVERWRITE all your current tracks and settings. Are you + sure? + + + Select the backup to restore + + + No backup found. + + + Reading all tracks and settings from the SD card. This may take a while... + + Time SD Unavailable + Pace You must start a trip. Distance Power @@ -1028,23 +1346,6 @@ limitations under the License. Units of Measure Notice Do you want to use metrics as your default units? - - Bluetooth - Bluetooth options - Device pairing - Open Android\'s bluetooth settings to pair a device - bluetoothSensorsEnabled - ANT options - Sensor Options - Track Color Mode - Fixed Speed Options - Dynamic Speed Options - - - Connected to %s - Bluetooth sensor connecting ... - Bluetooth sensor not connected - Sensor Data Time Power meter enabled diff --git a/MyTracks/res/xml/preferences.xml b/MyTracks/res/xml/preferences.xml index d27a968a9..754d709f5 100644 --- a/MyTracks/res/xml/preferences.xml +++ b/MyTracks/res/xml/preferences.xml @@ -41,7 +41,7 @@ limitations under the License. android:entryValues="@array/track_color_mode_values" android:defaultValue="@string/track_color_mode_value_none"/> - - + - the GData service client * @author Sandor Dornbush */ public class GDataWrapper { diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsFacade.java b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsFacade.java index 07acfb5e6..a5b817dc1 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsFacade.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/MapsFacade.java @@ -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, diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/XmlMapsGDataParserFactory.java b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/XmlMapsGDataParserFactory.java index 3bba20e56..9ee4818d0 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/XmlMapsGDataParserFactory.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/XmlMapsGDataParserFactory.java @@ -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 { diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/XmlMapsGDataSerializer.java b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/XmlMapsGDataSerializer.java index 3251f2624..ba23ca512 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/XmlMapsGDataSerializer.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/mymaps/XmlMapsGDataSerializer.java @@ -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"); diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/BluetoothConnectionManager.java b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/BluetoothConnectionManager.java index 9e1f59fe9..4a3bc512b 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/BluetoothConnectionManager.java +++ b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/BluetoothConnectionManager.java @@ -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(); diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/PolarMessageParser.java b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/PolarMessageParser.java index d8876587d..53a4e1613 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/PolarMessageParser.java +++ b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/PolarMessageParser.java @@ -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 diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/SensorUtils.java b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/SensorUtils.java index c4b23a206..6c1d99f71 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/SensorUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/SensorUtils.java @@ -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) { 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 096943abd..7b5d896e3 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 @@ -67,10 +67,6 @@ public abstract class AntSensorManager extends SensorManager { private AntInterface antReceiver; - // Flag to know if the ANT App was interrupted - // TODO: This code path is not used but probably should be. - private boolean antInterrupted; - /** * The data from the sensors. */ @@ -126,33 +122,19 @@ public abstract class AntSensorManager extends SensorManager { public AntSensorManager(Context context) { this.context = context; + + // We register for ANT intents early because we want to have a record of + // the status intents in the log as we start up. + registerForAntIntents(); + } @Override public void onDestroy() { Log.i(TAG, "destroying AntSensorManager"); - try { - context.unregisterReceiver(statusReceiver); - } catch (IllegalArgumentException e) { - Log.w(TAG, "Failed to unregister ANT status receiver", e); - } - - try { - context.unregisterReceiver(dataReceiver); - } catch (IllegalArgumentException e) { - Log.w(TAG, "Failed to unregister ANT data receiver", 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(); - } + + cleanAntInterface(); + unregisterForAntIntents(); } @Override @@ -177,16 +159,18 @@ public abstract class AntSensorManager extends SensorManager { */ @Override protected final void setupChannel() { + setup(); + } + + private synchronized void setup() { // We handle this unpleasantly because the UI should've checked for ANT // support before it even instantiated this class. if (!AntInterface.hasAntSupport(context)) { throw new IllegalStateException("device does not have ANT support"); } - - // We register for ANT intents early because we want to have a record of - // the status intents in the log as we start up. - registerForAntIntents(); - + + cleanAntInterface(); + antReceiver = AntInterface.getInstance(context, antServiceListener); if (antReceiver == null) { @@ -197,6 +181,29 @@ public abstract class AntSensorManager extends SensorManager { setSensorState(Sensor.SensorState.CONNECTING); } + /** + * Cleans up the ANT+ receiver interface, by releasing the interface + * and destroying it. + */ + private void cleanAntInterface() + { + Log.i(TAG, "Destroying AntSensorManager"); + + 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 = null; + } + } + /** * This method is invoked via the ServiceListener when we're connected to * the ANT service. If we're just starting up, this is our first opportunity @@ -214,10 +221,8 @@ public abstract class AntSensorManager extends SensorManager { if (!antReceiver.isEnabled()) { // Make sure not to call AntInterface.enable() again, if it has been // already called before - if (antInterrupted == false) { - Log.i(TAG, "Powering on Radio"); - antReceiver.enable(); - } + Log.i(TAG, "Powering on Radio"); + antReceiver.enable(); } else { Log.i(TAG, "Radio already enabled"); } @@ -337,6 +342,23 @@ public abstract class AntSensorManager extends SensorManager { dataIntentFilter.addAction(AntInterfaceIntent.ANT_RX_MESSAGE_ACTION); context.registerReceiver(dataReceiver, dataIntentFilter); } + + private void unregisterForAntIntents() + { + Log.i(TAG, "Unregistering ANT Intents."); + + try { + context.unregisterReceiver(statusReceiver); + } catch (IllegalArgumentException e) { + Log.w(TAG, "Failed to unregister ANT status receiver", e); + } + + try { + context.unregisterReceiver(dataReceiver); + } catch (IllegalArgumentException e) { + Log.w(TAG, "Failed to unregister ANT data receiver", e); + } + } private String messageToString(byte[] message) { StringBuilder out = new StringBuilder(); diff --git a/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java b/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java index e62a05a26..ff7959365 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java +++ b/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java @@ -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, diff --git a/MyTracks/src/com/google/wireless/gdata/docs/SpreadsheetsClient.java b/MyTracks/src/com/google/wireless/gdata/docs/SpreadsheetsClient.java index 59e675f24..803c5bf70 100755 --- a/MyTracks/src/com/google/wireless/gdata/docs/SpreadsheetsClient.java +++ b/MyTracks/src/com/google/wireless/gdata/docs/SpreadsheetsClient.java @@ -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; diff --git a/MyTracks/src/com/google/wireless/gdata/docs/XmlDocsGDataParserFactory.java b/MyTracks/src/com/google/wireless/gdata/docs/XmlDocsGDataParserFactory.java index 5e9a7d913..f9337f934 100644 --- a/MyTracks/src/com/google/wireless/gdata/docs/XmlDocsGDataParserFactory.java +++ b/MyTracks/src/com/google/wireless/gdata/docs/XmlDocsGDataParserFactory.java @@ -48,7 +48,7 @@ public class XmlDocsGDataParserFactory implements GDataParserFactory { } } - @SuppressWarnings("rawtypes") + @SuppressWarnings("unchecked") @Override public GDataParser createParser(Class cls, InputStream is) throws ParseException { diff --git a/MyTracksApiSample/AndroidManifest.xml b/MyTracksApiSample/AndroidManifest.xml index 1c09cf1f9..56dd998b4 100644 --- a/MyTracksApiSample/AndroidManifest.xml +++ b/MyTracksApiSample/AndroidManifest.xml @@ -3,7 +3,7 @@ package="com.google.android.apps.mytracks.samples.api" android:versionCode="1" android:versionName="1.0"> - + diff --git a/MyTracksLib/src/com/google/android/apps/mytracks/stats/TripStatistics.java b/MyTracksLib/src/com/google/android/apps/mytracks/stats/TripStatistics.java index e0a7dac76..09508bf41 100644 --- a/MyTracksLib/src/com/google/android/apps/mytracks/stats/TripStatistics.java +++ b/MyTracksLib/src/com/google/android/apps/mytracks/stats/TripStatistics.java @@ -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 * diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/MyTracksTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/MyTracksTest.java index a82c4aa12..1b7a04837 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/MyTracksTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/MyTracksTest.java @@ -215,7 +215,7 @@ public class MyTracksTest extends ActivityInstrumentationTestCase2{ } /** - * Clears {selected,recording}TrackId in the {@link getSharedPreferences()}. + * Clears {selected,recording}TrackId in the {@link #getSharedPreferences()}. */ private void clearSelectedAndRecordingTracks() { Editor editor = getSharedPreferences().edit();