Merge heads

This commit is contained in:
youtaol
2013-01-21 16:21:11 +08:00
17 changed files with 547 additions and 544 deletions
+1 -1
View File
@@ -208,7 +208,7 @@ limitations under the License.
<activity android:name="com.google.android.apps.mytracks.io.sendtogoogle.AccountChooserActivity" /> <activity android:name="com.google.android.apps.mytracks.io.sendtogoogle.AccountChooserActivity" />
<activity android:name="com.google.android.apps.mytracks.io.sendtogoogle.ConfirmSharingActivity" /> <activity android:name="com.google.android.apps.mytracks.io.sendtogoogle.ConfirmSharingActivity" />
<activity android:name="com.google.android.apps.mytracks.io.sendtogoogle.UploadResultActivity" /> <activity android:name="com.google.android.apps.mytracks.io.sendtogoogle.UploadResultActivity" />
<activity android:name="com.google.android.apps.mytracks.settings.BackupSettingsActivity" /> <activity android:name="com.google.android.apps.mytracks.settings.BackupResetSettingsActivity" />
<activity android:name="com.google.android.apps.mytracks.settings.ChartSettingsActivity" /> <activity android:name="com.google.android.apps.mytracks.settings.ChartSettingsActivity" />
<activity android:name="com.google.android.apps.mytracks.settings.GoogleSettingsActivity" /> <activity android:name="com.google.android.apps.mytracks.settings.GoogleSettingsActivity" />
<activity android:name="com.google.android.apps.mytracks.settings.MapSettingsActivity" /> <activity android:name="com.google.android.apps.mytracks.settings.MapSettingsActivity" />
@@ -15,6 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<resources> <resources>
<!-- Do not translate any arrays in this file. --> <!-- Do not translate any arrays in this file. -->
<string-array name="activity_types"> <string-array name="activity_types">
<item>@string/activity_type_airplane</item> <item>@string/activity_type_airplane</item>
@@ -160,32 +161,37 @@ limitations under the License.
<item>5000</item> <item>5000</item>
</string-array> </string-array>
<string-array name="sensor_type_all_options"> <string-array name="sensor_type_all_options">
<item>@string/value_none</item>
<item>@string/settings_sensor_type_ant</item>
<item>@string/settings_sensor_type_polar</item> <item>@string/settings_sensor_type_polar</item>
<item>@string/settings_sensor_type_zephyr</item> <item>@string/settings_sensor_type_zephyr</item>
<item>@string/settings_sensor_type_ant</item>
<item>@string/value_none</item>
</string-array> </string-array>
<string-array name="sensor_type_all_values"> <string-array name="sensor_type_all_values">
<item>@string/sensor_type_value_none</item>
<item>@string/sensor_type_value_ant</item>
<item>@string/sensor_type_value_polar</item> <item>@string/sensor_type_value_polar</item>
<item>@string/sensor_type_value_zephyr</item> <item>@string/sensor_type_value_zephyr</item>
<item>@string/sensor_type_value_ant</item>
<item>@string/sensor_type_value_none</item>
</string-array> </string-array>
<string-array name="sensor_type_bluetooth_options"> <string-array name="sensor_type_bluetooth_options">
<item>@string/value_none</item>
<item>@string/settings_sensor_type_polar</item> <item>@string/settings_sensor_type_polar</item>
<item>@string/settings_sensor_type_zephyr</item> <item>@string/settings_sensor_type_zephyr</item>
<item>@string/value_none</item>
</string-array> </string-array>
<string-array name="sensor_type_bluetooth_values"> <string-array name="sensor_type_bluetooth_values">
<item>@string/sensor_type_value_none</item>
<item>@string/sensor_type_value_polar</item> <item>@string/sensor_type_value_polar</item>
<item>@string/sensor_type_value_zephyr</item> <item>@string/sensor_type_value_zephyr</item>
<item>@string/sensor_type_value_none</item>
</string-array> </string-array>
<string-array name="track_color_mode_options"> <string-array name="track_color_mode_options">
<item>@string/settings_map_track_color_mode_single</item> <item>@string/settings_map_track_color_mode_single</item>
<item>@string/settings_map_track_color_mode_fixed</item> <item>@string/settings_map_track_color_mode_fixed</item>
<item>@string/settings_map_track_color_mode_dynamic</item> <item>@string/settings_map_track_color_mode_dynamic</item>
</string-array> </string-array>
<string-array name="track_color_mode_summary">
<item>@string/settings_map_track_color_mode_single</item>
<item>@string/settings_map_track_color_mode_fixed_summary</item>
<item>@string/settings_map_track_color_mode_dynamic_summary</item>
</string-array>
<string-array name="track_color_mode_values"> <string-array name="track_color_mode_values">
<item>@string/settings_map_track_color_mode_single_value</item> <item>@string/settings_map_track_color_mode_single_value</item>
<item>@string/settings_map_track_color_mode_fixed_value</item> <item>@string/settings_map_track_color_mode_fixed_value</item>
@@ -256,4 +262,5 @@ limitations under the License.
<item>@string/waypoint_type_water_fountain</item> <item>@string/waypoint_type_water_fountain</item>
<item>@string/waypoint_type_waypoint</item> <item>@string/waypoint_type_waypoint</item>
</string-array> </string-array>
</resources> </resources>
+2 -2
View File
@@ -71,8 +71,7 @@ limitations under the License.
<!-- Keys for non-persisted preferences. Sorted alphabetically. DO NOT TRANSLATE. --> <!-- Keys for non-persisted preferences. Sorted alphabetically. DO NOT TRANSLATE. -->
<string name="settings_backup_key">settingsBackup</string> <string name="settings_backup_key">settingsBackup</string>
<string name="settings_backup_now_key">settingsBackupNow</string> <string name="settings_backup_reset_key">settingsBackupReset</string>
<string name="settings_backup_restore_key">settingsBackupRestore</string>
<string name="settings_chart_key">settingsChart</string> <string name="settings_chart_key">settingsChart</string>
<string name="settings_google_key">settingsGoogle</string> <string name="settings_google_key">settingsGoogle</string>
<string name="settings_map_key">settingsMap</string> <string name="settings_map_key">settingsMap</string>
@@ -81,6 +80,7 @@ limitations under the License.
<string name="settings_map_slow_display_key">settingsMapSlowDisplay</string> <string name="settings_map_slow_display_key">settingsMapSlowDisplay</string>
<string name="settings_recording_key">settingsRecording</string> <string name="settings_recording_key">settingsRecording</string>
<string name="settings_reset_key">settingsReset</string> <string name="settings_reset_key">settingsReset</string>
<string name="settings_restore_key">settingsRestore</string>
<string name="settings_sensor_key">settingsSensor</string> <string name="settings_sensor_key">settingsSensor</string>
<string name="settings_sensor_ant_key">settingsSensorAnt</string> <string name="settings_sensor_ant_key">settingsSensorAnt</string>
<string name="settings_sensor_ant_reset_bike_cadence_sensor_key">settingsSensorAntResetBikeCadenceSensor</string> <string name="settings_sensor_ant_reset_bike_cadence_sensor_key">settingsSensorAntResetBikeCadenceSensor</string>
+139 -162
View File
@@ -1585,7 +1585,7 @@ limitations under the License.
<string name="settings_not_while_recording" <string name="settings_not_while_recording"
translation_description="In settings, the summary for an option that is not available during a translation_description="In settings, the summary for an option that is not available during a
track recording."> track recording.">
Not available while recording a track. Not available while recording a track
</string> </string>
<string name="settings_show" <string name="settings_show"
translation_description="In settings, the section label to show additional values. translation_description="In settings, the section label to show additional values.
@@ -1594,19 +1594,18 @@ limitations under the License.
Show Show
</string> </string>
<!-- Settings Backup --> <!-- Settings Backup Reset -->
<string name="settings_backup" <string name="settings_backup_reset"
translation_description="In the 'Settings' page, the option to change the data backup related translation_description="In the 'Settings' page, the option backup and reset.
settings.
Character limit: ~26 (1 line)"> Character limit: ~26 (1 line)">
Backup Backup &amp; reset
</string> </string>
<!-- Settings Backup Now --> <!-- Settings Backup Now -->
<string name="settings_backup_now" <string name="settings_backup_now"
translation_description="In the 'Backup' settings, the option to backup to the external storage translation_description="In the 'Backup and reset' settings, the option to backup to the
now. external storage now.
Character limit: ~26 (1 line)"> Character limit: ~26 (1 line)">
Backup now Backup now
@@ -1616,15 +1615,15 @@ limitations under the License.
Unable to backup. Unable to backup.
</string> </string>
<string name="settings_backup_now_progress_message" <string name="settings_backup_now_progress_message"
translation_description="In the 'Backup' settings, after pressing the 'Backup now' option, the translation_description="In the 'Backup and reset' settings, after pressing the 'Backup now'
progress message telling the user that it is writing all tracks and settings to the external option, the progress message telling the user that it is writing all tracks and settings to
storage."> the external storage.">
Writing all tracks and settings&#8230; Writing all tracks and settings&#8230;
</string> </string>
<string name="settings_backup_now_summary" <string name="settings_backup_now_summary"
translation_description="In the 'Backup' settings, the summary for the 'Backup now' option translation_description="In the 'Backup and reset' settings, the summary for the 'Backup now'
explaining that all tracks and settings will be written to the external storage."> option explaining that all tracks and settings will be written to the external storage.">
Write a full copy of all your tracks and settings to the external storage. Write a full copy of all your tracks and settings to the external storage
</string> </string>
<string name="settings_backup_now_success" <string name="settings_backup_now_success"
translation_description="When backing up to the external storage, the success message"> translation_description="When backing up to the external storage, the success message">
@@ -1633,16 +1632,16 @@ limitations under the License.
<!-- Settings Backup Restore --> <!-- Settings Backup Restore -->
<string name="settings_backup_restore" <string name="settings_backup_restore"
translation_description="In the 'Backup' settings, the option to restore from the external translation_description="In the 'Backup and reset' settings, the option to restore from the
storage. external storage.
Character limit: ~26 (1 line)"> Character limit: ~26 (1 line)">
Restore now Restore now
</string> </string>
<string name="settings_backup_restore_confirm_message" <string name="settings_backup_restore_confirm_message"
translation_description="In the 'Backup' settings, after pressing the 'Restore now' option, the translation_description="In the 'Backup and reset' settings, after pressing the 'Restore now'
message in the alert dialog asking the user to confirm that he wants to restore from a backup option, the message in the alert dialog asking the user to confirm that he wants to restore
and it will overwrite all the current tracks and settings."> from a backup and it will overwrite all the current tracks and settings.">
Restoring a backup from the external storage will overwrite all your current tracks and Restoring a backup from the external storage will overwrite all your current tracks and
settings. settings.
</string> </string>
@@ -1651,25 +1650,26 @@ limitations under the License.
Unable to restore from backup. Unable to restore from backup.
</string> </string>
<string name="settings_backup_restore_no_backup" <string name="settings_backup_restore_no_backup"
translation_description="In the 'Backup' settings, after pressing the 'Restore now' option, the translation_description="In the 'Backup and reset' settings, after pressing the 'Restore now'
message in the alert dialog informing the user that there is no backup to restore from."> option, the message in the alert dialog informing the user that there is no backup to restore
from.">
No backup found. No backup found.
</string> </string>
<string name="settings_backup_restore_progress_message" <string name="settings_backup_restore_progress_message"
translation_description="In the 'Backup' settings, after pressing the 'Restore now' option, the translation_description="In the 'Backup and reset' settings, after pressing the 'Restore now'
progress message informing that My Tracks is reading all tracks and settings from the backup option, the progress message informing that My Tracks is reading all tracks and settings from
on the external storage."> the backup on the external storage.">
Reading all tracks and settings&#8230; Reading all tracks and settings&#8230;
</string> </string>
<string name="settings_backup_restore_select_title" <string name="settings_backup_restore_select_title"
translation_description="In the 'Backup' settings, after pressing the 'Restore now' option, the translation_description="In the 'Backup and reset' settings, after pressing the 'Restore now'
title in the picker dialog asking the user to select a backup."> option, the title in the picker dialog asking the user to select a backup.">
Select a backup to restore Select a backup to restore
</string> </string>
<string name="settings_backup_restore_summary" <string name="settings_backup_restore_summary"
translation_description="In the 'Backup' settings, the summary for the 'Restore now' option translation_description="In the 'Backup and reset' settings, the summary for the 'Restore now'
explaining that it restores all tracks and settings from the external storage."> option explaining that it restores all tracks and settings from the external storage.">
Restore all tracks and settings from the external storage. Restore all tracks and settings from the external storage
</string> </string>
<string name="settings_backup_restore_success" <string name="settings_backup_restore_success"
translation_description="When restoring from backup, the success message."> translation_description="When restoring from backup, the success message.">
@@ -1820,73 +1820,84 @@ limitations under the License.
<!-- Settings Recording --> <!-- Settings Recording -->
<string name="settings_recording" <string name="settings_recording"
translation_description="In the 'Settings' page, the option to change the track recording translation_description="In the 'Settings' page, the option to change the recording settings.
settings.
Character limit: ~26 (1 line)"> Character limit: ~26 (1 line)">
Recording Recording
</string> </string>
<string name="settings_recording_auto_resume_track_timeout_always_summary"
translation_description="In the 'Recording' settings, the summary for the 'Auto-resume' setting
when 'Always' is selected.">
Always resume a recording after reboot
</string>
<string name="settings_recording_auto_resume_track_timeout_never_summary"
translation_description="In the 'Recording' settings, the summary for the 'Auto-resume' setting
when 'Never' is selected.">
Never resume a recording after reboot
</string>
<string name="settings_recording_auto_resume_track_timeout_summary"
translation_description="In the 'Recording' settings, the summary for the 'Auto-resume' setting
when a time value is selected.
%1$s time value. E.g., '5 min'.">
Resume a recording after reboot if the last recorded loation was within the last %1$s
</string>
<string name="settings_recording_auto_resume_track_timeout_title" <string name="settings_recording_auto_resume_track_timeout_title"
translation_description="In the 'Recording' settings, the title to configure resuming a translation_description="In the 'Recording' settings, the title to configure automatically
recording track after reboot. resuming a recording after reboot.
Character limit: ~23 (1 line)"> Character limit: ~23 (1 line)">
Auto-resume Auto-resume
</string> </string>
<string name="settings_recording_auto_resume_track_timeout_summary"
translation_description="In the 'Recording' settings, the summary for the 'Auto-resume' setting.
Occasionaly, phones will reboot due to crashes or users would need to change battery during a
long recording. My Tracks will resume a recording after reboot if it was recording beforehand
and that the last recorded time is recent, within certain minutes.">
Recording is resumed after reboot if the last recorded time is within this.
</string>
<string name="settings_recording_default_activity_title" <string name="settings_recording_default_activity_title"
translation_description="In the 'Recording' settings, the title to configure the default translation_description="In the 'Recording' settings, the title to configure the default
activity type for a new track. activity type for a new track. E.g., 'hiking'.
Character limit: ~23 (1 line)"> Character limit: ~23 (1 line)">
Default activity Default activity type
</string> </string>
<string name="settings_recording_default_activity_summary" <string name="settings_recording_location_frequency_summary"
translation_description="In the 'Recording' settings, the summary for the 'Default activity' translation_description="In the 'Recording' settings, the summary for how frequent a location
setting."> should be recorded.
Default activity type for a new track.
%1$s distance or time. E.g., '5 m' or '1 s'.">
%1$s between recorded locations
</string>
<string name="settings_recording_max_recording_distance_summary"
translation_description="In the 'Recording' settings, the summary for the 'Max distance'
setting.
%1$s distance value. E.g., '5 m'.">
A new segment is created if the distance between two locations is greater than %1$s
</string> </string>
<string name="settings_recording_max_recording_distance_title" <string name="settings_recording_max_recording_distance_title"
translation_description="In the 'Recording' settings, the title to configure the maximum translation_description="In the 'Recording' settings, the title to configure the maximum
distance. distance between 2 locations in a segment. A new segment is created if the distance between 2
locations is greater than this value.
Character limit: ~23 (1 line)"> Character limit: ~23 (1 line)">
Max distance Max distance
</string> </string>
<string name="settings_recording_max_recording_distance_summary"
translation_description="In the 'Recording' settings, the summary for the 'Max distance'
setting.">
Maximum distance between locations in the same segment.
</string>
<string name="settings_recording_min_recording_distance_title" <string name="settings_recording_min_recording_distance_title"
translation_description="In the 'Recording' settings, the title to configure the minimum translation_description="In the 'Recording' settings, the title to configure the distance
distance. between two recorded locations.
Character limit: ~23 (1 line)"> Character limit: ~23 (1 line)">
Min distance Recording distance interval
</string>
<string name="settings_recording_min_recording_distance_summary"
translation_description="In the 'Recording' settings, the summary for the 'Min distance'
setting.">
Minimum distance between recorded locations.
</string> </string>
<string name="settings_recording_min_recording_interval_title" <string name="settings_recording_min_recording_interval_title"
translation_description="In the 'Recording' settings, the title to configure the time between translation_description="In the 'Recording' settings, the title to configure the time between
two GPS locations. two recorded locations.
Character limit: ~23 (1 line)"> Character limit: ~23 (1 line)">
Location frequency Recording time interval
</string> </string>
<string name="settings_recording_min_recording_interval_summary" <string name="settings_recording_min_required_accuracy_summary"
translation_description="In the 'Recording' settings, the summary for the 'Location frequency' translation_description="In the 'Recording' settings, the summary for the 'GPS accuracy'
setting."> setting.
Time between two GPS locations.
%1$s distance value. E.g., '10 m'.">
Location is ignored if its accuracy is less than %1$s
</string> </string>
<string name="settings_recording_min_required_accuracy_title" <string name="settings_recording_min_required_accuracy_title"
translation_description="In the 'Recording' settings, the title to configure the GPS accuracy. translation_description="In the 'Recording' settings, the title to configure the GPS accuracy.
@@ -1894,211 +1905,173 @@ limitations under the License.
Character limit: ~23 (1 line)"> Character limit: ~23 (1 line)">
GPS accuracy GPS accuracy
</string> </string>
<string name="settings_recording_min_required_accuracy_summary"
translation_description="In the 'Recording' settings, the summary for the 'GPS accuracy'
setting..">
GPS location is ignored if it is not this accurate.
</string>
<string name="settings_recording_split_frequency_summary"
translation_description="In the 'Recording' settings, the summary for the 'Split frequency'
setting.">
Time/distance between two split markers.
</string>
<string name="settings_recording_track_name_date_iso_8601_option" <string name="settings_recording_track_name_date_iso_8601_option"
translation_description="In the 'Recording' settings, the option in the 'Track name' setting translation_description="In the 'Recording' settings, the option in the 'Default track name'
to use the track starting time in the ISO-8601 format as the track name. setting to use the track starting time in the ISO-8601 format as the default track name.
Character limit: ~20 (1 line)"> Character limit: ~20 (1 line)">
Date (ISO 8601) Date (ISO 8601)
</string> </string>
<string name="settings_recording_track_name_date_local_option" <string name="settings_recording_track_name_date_local_option"
translation_description="In the 'Recording' settings, the option in the 'Track name' setting to translation_description="In the 'Recording' settings, the option in the 'Defaul track name'
use the track starting time in the local default format as the track name. setting to use the track starting time in the local format as the default track name.
Character limit: ~20 (1 line)"> Character limit: ~20 (1 line)">
Date (local) Date (local)
</string> </string>
<string name="settings_recording_track_name_location_option" <string name="settings_recording_track_name_location_option"
translation_description="In the 'Recording' settings, the option in the 'Track name' setting to translation_description="In the 'Recording' settings, the option in the 'Defaul track name'
use the track location as the track name. setting to use the track starting location as the default track name.
Character limit: ~20 (1 line)"> Character limit: ~20 (1 line)">
Location Location
</string> </string>
<string name="settings_recording_track_name_number_option" <string name="settings_recording_track_name_number_option"
translation_description="In the 'Recording' settings, the option in the 'Track name' setting to translation_description="In the 'Recording' settings, the option in the 'Default track name'
use a number as the track name. setting to use number as the default track name.
Character limit: ~20 (1 line)"> Character limit: ~20 (1 line)">
Number Number
</string> </string>
<string name="settings_recording_track_name_title" <string name="settings_recording_track_name_title"
translation_description="In the 'Recording' settings, the title to configure the way to name a translation_description="In the 'Recording' settings, the option to configure how the default
new track. track name is named.
Character limit: ~23 (1 line)"> Character limit: ~23 (1 line)">
Track name Default track name
</string>
<string name="settings_recording_track_name_summary"
translation_description="In the 'Recording' settings, the summary for the 'Track name'
setting.">
Way to name a new track.
</string>
<string name="settings_recording_voice_frequency_summary"
translation_description="In the 'Recording' settings, the summary for the 'Voice frequency'
setting.">
Time/distance between two voice announcements.
</string> </string>
<!-- Settings Reset --> <!-- Settings Reset -->
<string name="settings_reset" <string name="settings_reset"
translation_description="In the 'Settings' page, the option to reset everything to the defaults. translation_description="In the 'Backup and reset' settings, the option to reset all settings to
the default values.
Character limit: ~26 (1 line)"> Character limit: ~26 (1 line)">
Reset Reset
</string> </string>
<string name="settings_reset_confirm_message" <string name="settings_reset_confirm_message"
translation_description="In the 'Settings' page, after pressing the 'Reset' option, the translation_description="In the 'Backup and reset' settings, after pressing the 'Reset' option,
confirmation dialog message informing the user that all settings will be reverted."> the confirmation dialog message informing the user that all settings will be reverted.">
All your settings will be erased and reverted to the default values. Saved tracks will be All settings will be erased and reverted to the default values. Saved tracks will be preserved.
preserved.
</string> </string>
<string name="settings_reset_done" <string name="settings_reset_done"
translation_description="In the 'Settings' page, after pressing the 'Reset' option, the translation_description="In the 'Backup and reset' settings, after pressing the 'Reset' option,
confirmation dialog informing the user that all settings have been reverted to their the confirmation dialog informing the user that all settings have been reverted to the default
defaults."> values.">
All settings have been reverted to their defaults. All settings have been reverted to the default values.
</string> </string>
<string name="settings_reset_summary" <string name="settings_reset_summary"
translation_description="In the 'Settings' page, the summary for the 'Reset' option explaining translation_description="In the 'Backup and reset' settings, the summary for the 'Reset' option
reverting all the settings to the default values."> explaining it will revert all settings to the default values.">
Revert all your settings to the default values. Revert all your settings to the default values
</string> </string>
<!-- Settings Sensor --> <!-- Settings Sensor -->
<string name="settings_sensor" <string name="settings_sensor"
translation_description="In the 'Settings' page, the option to change the sensor related translation_description="In the 'Settings' page, the option to change the sensor settings.
settings.
Character limit: ~26 (1 line)"> Character limit: ~26 (1 line)">
Sensor Sensor
</string> </string>
<string name="settings_sensor_ant_options" <string name="settings_sensor_ant_not_connected"
translation_description="In the 'Sensor' settings, the section header to configure the ANT+ translation_description="In the 'Sensor' settings, the summary to indicate that an ANT+ sensor
options. Note that ANT+ is a radio standard. is not connected.">
Not connected
Character limit: ~26 (1 line)">
ANT+ options
</string> </string>
<string name="settings_sensor_ant_paired" <string name="settings_sensor_ant_paired"
translation_description="In the 'Sensor' settings, the summary to indicate the paired ANT+ translation_description="In the 'Sensor' settings, the summary to indicate that an ANT+ sensor
device. Note that ANT+ is a radio standard. is paired. Note that ANT+ is a radio standard.
%1$d: device id number. E.g., '1'."> %1$d: device id number. E.g., '1'.">
Paired with: %1$d Paired with %1$d
</string> </string>
<string name="settings_sensor_ant_reset_bike_cadence_sensor" <string name="settings_sensor_ant_reset_bike_cadence_sensor"
translation_description="In the 'Sensor' settings, under the 'ANT+ options', the option to reset translation_description="In the 'Sensor' settings, under the 'ANT+' section, the option to reset
an ANT+ bike cadence sensor. Note that ANT+ is a radio standard. an ANT+ bike cadence sensor. Note that ANT+ is a radio standard.
Character limit: ~26 (1 line)"> Character limit: ~26 (1 line)">
Reset bike cadence Reset bike cadence
</string> </string>
<string name="settings_sensor_ant_reset_combined_bike_sensor" <string name="settings_sensor_ant_reset_combined_bike_sensor"
translation_description="In the 'Sensor' settings, under the 'ANT+ options', the option to reset translation_description="In the 'Sensor' settings, under the 'ANT+' section, the option to reset
an ANT+ combined bike cadence and speed sensor. Note that ANT+ is a radio standard. an ANT+ combined bike cadence and speed sensor. Note that ANT+ is a radio standard.
Character limit: ~26 (1 line)"> Character limit: ~26 (1 line)">
Reset combined bike Reset combined bike
</string> </string>
<string name="settings_sensor_ant_reset_heart_rate_monitor" <string name="settings_sensor_ant_reset_heart_rate_monitor"
translation_description="In the 'Sensor' settings, under the 'ANT+ options', the option to reset translation_description="In the 'Sensor' settings, under the 'ANT+' section, the option to reset
an ANT+ heart rate monitor. Note that ANT+ is a radio standard. an ANT+ heart rate monitor. Note that ANT+ is a radio standard.
Character limit: ~26 (1 line)"> Character limit: ~26 (1 line)">
Reset heart rate Reset heart rate
</string> </string>
<string name="settings_sensor_ant_reset_speed_distance_monitor" <string name="settings_sensor_ant_reset_speed_distance_monitor"
translation_description="In the 'Sensor' settings, under the 'ANT+ options', the option to reset translation_description="In the 'Sensor' settings, under the 'ANT+' section, the option to reset
an ANT+ stride based speed distance monitor, also known as foot pod. Note that ANT+ is a radio an ANT+ stride based speed distance monitor, also known as foot pod. Note that ANT+ is a radio
standard. standard.
Character limit: ~26 (1 line)"> Character limit: ~26 (1 line)">
Reset foot pod Reset foot pod
</string> </string>
<string name="settings_sensor_bluetooth_options" <string name="settings_sensor_bluetooth"
translation_description="In the 'Sensor' settings, the section header to configure the Bluetooth translation_description="In the 'Sensor' settings, the section to configure the Bluetooth
options. settings.
Character limit: ~26 (1 line)"> Character limit: ~26 (1 line)">
Bluetooth options Bluetooth
</string> </string>
<string name="settings_sensor_bluetooth_pairing" <string name="settings_sensor_bluetooth_pairing"
translation_description="In the 'Sensor' settings, under the 'Bluetooth options' configurations, translation_description="In the 'Sensor' settings, under the 'Bluetooth' section, the option to
the option to pair with a Bluetooth device. pair with a Bluetooth sensor.
Character limit: ~26 (1 line)"> Character limit: ~26 (1 line)">
Bluetooth pairing Bluetooth pairing
</string> </string>
<string name="settings_sensor_bluetooth_pairing_summary" <string name="settings_sensor_bluetooth_pairing_summary"
translation_description="In the 'Sensor' settings, under the 'Bluetooth options' configurations, translation_description="In the 'Sensor' settings, under the 'Bluetooth' section, the summary
the summary for the 'Bluetooth pairing' option explaining that it will open the Android's for the 'Bluetooth pairing' option explaining that it will open the Android's Bluetooth
Bluetooth settings to pair a device."> settings to pair a sensor.">
Open Android\'s Bluetooth settings to pair a device. Open Android\'s Bluetooth settings to pair a sensor
</string> </string>
<string name="settings_sensor_bluetooth_sensor" <string name="settings_sensor_bluetooth_sensor"
translation_description="In the 'Sensor' settings, under the 'Bluetooth options' configurations, translation_description="In the 'Sensor' settings, under the 'Bluetooth' section, the picker to
the dropdown option to pick a Bluetooth sensor. choose a Bluetooth sensor.
Character limit: ~23 (1 line)"> Character limit: ~23 (1 line)">
Bluetooth sensor Bluetooth sensor
</string> </string>
<string name="settings_sensor_bluetooth_sensor_summary"
translation_description="In the 'Sensor' settings, under the 'Bluetooth options' configurations,
the summary for the 'Bluetooth sensor' dropdown option explaining it is to pick a Bluetooth
sensor to connect to.">
The Bluetooth sensor to connect to.
</string>
<string name="settings_sensor_connected" <string name="settings_sensor_connected"
translation_description="The message when connected to a sensor. translation_description="A message when a sensor is connected.
%1$s: sensor name. E.g., 'polar bluetooth'."> %1$s: sensor name. E.g., 'Polar Bluetooth'.">
Connected to %1$s Connected to %1$s
</string> </string>
<string name="settings_sensor_not_connected"
translation_description="The message when not connected to a sensor.">
Not connected.
</string>
<string name="settings_sensor_type" <string name="settings_sensor_type"
translation_description="In the 'Sensor' settings, the dropdown option to choose a sensor type. translation_description="In the 'Sensor' settings, the picker to choose a sensor type.
Character limit: ~23 (1 line)"> Character limit: ~23 (1 line)">
Sensor type Sensor type
</string> </string>
<string name="settings_sensor_type_ant" <string name="settings_sensor_type_ant"
translation_description="In the 'Sensor' settings, for the 'Sensor type' dropdown, the option to translation_description="In the 'Sensor' settings, the option in the 'Sensor type' picker to
connect to an ANT+ sensor. Note that ANT+ is a radio standard. choose an ANT+ sensor. Note that ANT+ is a radio standard.
Character limit: ~20 (1 line)"> Character limit: ~20 (1 line)">
ANT+ ANT+
</string> </string>
<string name="settings_sensor_type_polar" <string name="settings_sensor_type_polar"
translation_description="In the 'Sensor' settings, for the 'Sensor type' dropdown, the option to translation_description="In the 'Sensor' settings, the option in the 'Sensor type' picker to
connect to a Polar bluetooth sensor. Do not translate Polar, the company name, but can choose a Polar bluetooth sensor. Do not translate Polar, the company name, but can translate
translate Bluetooth, the radio standard. Bluetooth, the radio standard.
Character limit: ~20 (1 line)"> Character limit: ~20 (1 line)">
Polar Bluetooth Polar Bluetooth
</string> </string>
<string name="settings_sensor_type_summary"
translation_description="In the 'Sensor' settings, the summary for the 'Sensor type' option
explaining that it is to configure the type of sensor to connect to.">
The type of sensor to connect to.
</string>
<string name="settings_sensor_type_zephyr" <string name="settings_sensor_type_zephyr"
translation_description="In the 'Sensor' settings, for the 'Sensor type' dropdown, the option to translation_description="In the 'Sensor' settings, the option in the 'Sensor type' picker to
connect to a Zephyr bluetooth sensor. Do not translate Zephyr, the company name, but can choose a Zephyr bluetooth sensor. Do not translate Zephyr, the company name, but can translate
translate Bluetooth, the radio standard. Bluetooth, the radio standard.
Character limit: ~20 (1 line)"> Character limit: ~20 (1 line)">
Zephyr Bluetooth Zephyr Bluetooth
@@ -2660,6 +2633,10 @@ limitations under the License.
translation_description="In a setting picker, the value to turn off the feature."> translation_description="In a setting picker, the value to turn off the feature.">
Off Off
</string> </string>
<string name="value_smallest"
translation_description="In a setting picker, the value to use the smallest value.">
Smallest
</string>
<string name="value_smallest_recommended" <string name="value_smallest_recommended"
translation_description="In a setting picker, the value to use the smallest value, also the translation_description="In a setting picker, the value to use the smallest value, also the
recommended value."> recommended value.">
@@ -15,13 +15,17 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/settings_backup" > android:title="@string/settings_backup_reset" >
<Preference <Preference
android:key="@string/settings_backup_now_key" android:key="@string/settings_backup_key"
android:persistent="false" android:persistent="false"
android:title="@string/settings_backup_now" /> android:title="@string/settings_backup_now" />
<Preference <Preference
android:key="@string/settings_backup_restore_key" android:key="@string/settings_restore_key"
android:persistent="false" android:persistent="false"
android:title="@string/settings_backup_restore" /> android:title="@string/settings_backup_restore" />
<Preference
android:key="@string/settings_reset_key"
android:persistent="false"
android:title="@string/settings_reset" />
</PreferenceScreen> </PreferenceScreen>
+2 -2
View File
@@ -23,7 +23,7 @@ limitations under the License.
android:title="@string/settings_sensor_type" /> android:title="@string/settings_sensor_type" />
<PreferenceCategory <PreferenceCategory
android:key="@string/settings_sensor_bluetooth_key" android:key="@string/settings_sensor_bluetooth_key"
android:title="@string/settings_sensor_bluetooth_options" > android:title="@string/settings_sensor_bluetooth" >
<Preference <Preference
android:key="@string/settings_sensor_bluetooth_pairing_key" android:key="@string/settings_sensor_bluetooth_pairing_key"
android:persistent="false" android:persistent="false"
@@ -36,7 +36,7 @@ limitations under the License.
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:key="@string/settings_sensor_ant_key" android:key="@string/settings_sensor_ant_key"
android:title="@string/settings_sensor_ant_options" > android:title="@string/settings_sensor_type_ant" >
<Preference <Preference
android:key="@string/settings_sensor_ant_reset_heart_rate_monitor_key" android:key="@string/settings_sensor_ant_reset_heart_rate_monitor_key"
android:persistent="false" android:persistent="false"
+2 -6
View File
@@ -45,11 +45,7 @@ limitations under the License.
android:persistent="false" android:persistent="false"
android:title="@string/settings_sensor" /> android:title="@string/settings_sensor" />
<Preference <Preference
android:key="@string/settings_backup_key" android:key="@string/settings_backup_reset_key"
android:persistent="false" android:persistent="false"
android:title="@string/settings_backup" /> android:title="@string/settings_backup_reset" />
<Preference
android:key="@string/settings_reset_key"
android:persistent="false"
android:title="@string/settings_reset" />
</PreferenceScreen> </PreferenceScreen>
@@ -124,7 +124,7 @@ public class TrackEditActivity extends AbstractMyTracksActivity {
Button cancel = (Button) findViewById(R.id.track_edit_cancel); Button cancel = (Button) findViewById(R.id.track_edit_cancel);
if (getIntent().getBooleanExtra(EXTRA_NEW_TRACK, false)) { if (getIntent().getBooleanExtra(EXTRA_NEW_TRACK, false)) {
String trackName = TrackNameUtils.getTrackName( String trackName = TrackNameUtils.getTrackName(
this, -1L, -1L, myTracksProviderUtils.getLastValidTrackPoint(trackId)); this, -1L, -1L, myTracksProviderUtils.getFirstValidTrackPoint(trackId));
if (trackName != null) { if (trackName != null) {
name.setText(trackName); name.setText(trackName);
} }
@@ -52,7 +52,7 @@ public class AbstractSettingsActivity extends PreferenceActivity {
preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE); preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE);
// Set up automatic preferences backup // Set up automatic preferences backup
backupPreferencesListener = new BackupPreferencesListener(this); backupPreferencesListener = new BackupPreferencesListener(this);
preferenceManager.getSharedPreferences() preferenceManager.getSharedPreferences()
.registerOnSharedPreferenceChangeListener(backupPreferencesListener); .registerOnSharedPreferenceChangeListener(backupPreferencesListener);
@@ -77,114 +77,66 @@ public class AbstractSettingsActivity extends PreferenceActivity {
} }
/** /**
* Configures a preference. * Configures a list preference.
* *
* @param preference the preference * @param listPreference the list preference
* @param options the list of displayed options * @param summary the summary array
* @param values the list of stored values * @param options the options array
* @param summaryId the summary id * @param values the values array
* @param value the stored value * @param value the value
* @param listener optional listener
*/ */
protected void configurePreference(final Preference preference, final String[] options, protected void configureListPreference(ListPreference listPreference, final String[] summary,
final String[] values, final int summaryId, String value) { final String[] options, final String[] values, String value,
configurePreference(preference, options, values, summaryId, value, null);
}
/**
* Configures a preference.
*
* @param preference the preference
* @param options the list of displayed options
* @param values the list of stored values
* @param summaryId the summary id
* @param value the stored value
* @param listener listener to invoke
*/
protected void configurePreference(final Preference preference, final String[] options,
final String[] values, final int summaryId, String value,
final OnPreferenceChangeListener listener) { final OnPreferenceChangeListener listener) {
if (options != null) { listPreference.setEntryValues(values);
((ListPreference) preference).setEntries(options); listPreference.setEntries(options);
} listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
if (values != null) {
((ListPreference) preference).setEntryValues(values);
}
preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference pref, Object newValue) { public boolean onPreferenceChange(Preference pref, Object newValue) {
updatePreferenceSummary(pref, options, values, summaryId, (String) newValue); updatePreferenceSummary(pref, summary, values, (String) newValue);
if (listener != null) { if (listener != null) {
listener.onPreferenceChange(pref, newValue); listener.onPreferenceChange(pref, newValue);
} }
return true; return true;
} }
}); });
updatePreferenceSummary(preference, options, values, summaryId, value); updatePreferenceSummary(listPreference, summary, values, value);
if (listener != null) { if (listener != null) {
listener.onPreferenceChange(preference, value); listener.onPreferenceChange(listPreference, value);
} }
} }
protected void configurePreference(final Preference preference, final String[] options,
final String[] values, String value, final OnPreferenceChangeListener listener) {
if (options != null) {
((ListPreference) preference).setEntries(options);
}
if (values != null) {
((ListPreference) preference).setEntryValues(values);
}
preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference pref, Object newValue) {
if (listener != null) {
listener.onPreferenceChange(pref, newValue);
}
return true;
}
});
if (listener != null) {
listener.onPreferenceChange(preference, value);
}
}
/** /**
* Updates a preference when a stored value changes. * Update the preference summary.
* *
* @param preference the preference * @param preference the preference
* @param options the list of displayed options * @param summary the summary array
* @param values the list of stored values * @param values the values array
* @param summaryId the summary id * @param value the value
* @param value the stored value
*/ */
private void updatePreferenceSummary( private void updatePreferenceSummary(
Preference preference, String[] options, String[] values, int summaryId, String value) { Preference preference, String[] summary, String[] values, String value) {
String summary = getString(summaryId); int index = getIndex(values, value);
String option; if (index == -1) {
if (options != null && values != null) { preference.setSummary(R.string.value_unknown);
option = getOption(options, values, value);
if (option == null) {
option = getString(R.string.value_unknown);
}
} else { } else {
option = value != null && value.length() != 0 ? value : getString(R.string.value_unknown); preference.setSummary(summary[index]);
} }
summary += "\n" + option;
preference.setSummary(summary);
} }
/** /**
* Gets the display option for a stored value. * Get the array index for a value.
* *
* @param options the list of the display options * @param values the array
* @param values the list of the stored values * @param value the value
* @param value the store value
*/ */
private String getOption(String[] options, String[] values, String value) { private int getIndex(String[] values, String value) {
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
if (value.equals(values[i])) { if (value.equals(values[i])) {
return options[i]; return i;
} }
} }
return null; return -1;
} }
} }
@@ -33,19 +33,24 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener; import android.preference.Preference.OnPreferenceClickListener;
import android.util.Log;
import android.widget.Toast;
/** /**
* An activity for accessing the backup settings. * An activity for accessing the backup and reset settings.
* *
* @author Jimmy Shih * @author Jimmy Shih
*/ */
public class BackupSettingsActivity extends AbstractSettingsActivity { public class BackupResetSettingsActivity extends AbstractSettingsActivity {
private static final String TAG = BackupResetSettingsActivity.class.getSimpleName();
private static final int DIALOG_CONFIRM_RESTORE_ID = 0; private static final int DIALOG_CONFIRM_RESTORE_ID = 0;
private static final int DIALOG_CONFIRM_RESET_ID = 1;
private SharedPreferences sharedPreferences; private SharedPreferences sharedPreferences;
private Preference backupPreference; private Preference backupPreference;
private Preference restorePreference; private Preference restoreNowPreference;
private Preference resetPreference;
private long recordingTrackId = PreferencesUtils.RECORDING_TRACK_ID_DEFAULT; private long recordingTrackId = PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
@@ -57,12 +62,10 @@ public class BackupSettingsActivity extends AbstractSettingsActivity {
sharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() { sharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) { public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
if (key == null || key.equals(PreferencesUtils.getKey( if (key != null && key.equals(PreferencesUtils.getKey(
BackupSettingsActivity.this, R.string.recording_track_id_key))) { BackupResetSettingsActivity.this, R.string.recording_track_id_key))) {
recordingTrackId = PreferencesUtils.getLong( recordingTrackId = PreferencesUtils.getLong(
BackupSettingsActivity.this, R.string.recording_track_id_key); BackupResetSettingsActivity.this, R.string.recording_track_id_key);
}
if (key != null) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -77,60 +80,81 @@ public class BackupSettingsActivity extends AbstractSettingsActivity {
@Override @Override
protected void onCreate(Bundle bundle) { protected void onCreate(Bundle bundle) {
super.onCreate(bundle); super.onCreate(bundle);
addPreferencesFromResource(R.xml.backup_reset_settings);
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE); sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
addPreferencesFromResource(R.xml.backup_settings); backupPreference = findPreference(getString(R.string.settings_backup_key));
backupPreference = findPreference(getString(R.string.settings_backup_now_key));
backupPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() { backupPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
Intent intent = IntentUtils.newIntent(BackupSettingsActivity.this, BackupActivity.class); Intent intent = IntentUtils.newIntent(
BackupResetSettingsActivity.this, BackupActivity.class);
startActivity(intent); startActivity(intent);
return true; return true;
} }
}); });
restorePreference = findPreference(getString(R.string.settings_backup_restore_key)); restoreNowPreference = findPreference(getString(R.string.settings_restore_key));
restorePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() { restoreNowPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
showDialog(DIALOG_CONFIRM_RESTORE_ID); showDialog(DIALOG_CONFIRM_RESTORE_ID);
return true; return true;
} }
}); });
resetPreference = findPreference(getString(R.string.settings_reset_key));
resetPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
showDialog(DIALOG_CONFIRM_RESET_ID);
return true;
}
});
} }
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
if (id != DIALOG_CONFIRM_RESTORE_ID) { Dialog dialog;
return null; switch (id) {
case DIALOG_CONFIRM_RESTORE_ID:
dialog = DialogUtils.createConfirmationDialog(this,
R.string.settings_backup_restore_confirm_message,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int which) {
Intent intent = IntentUtils.newIntent(
BackupResetSettingsActivity.this, RestoreChooserActivity.class);
startActivity(intent);
}
});
break;
case DIALOG_CONFIRM_RESET_ID:
dialog = DialogUtils.createConfirmationDialog(
this, R.string.settings_reset_confirm_message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int button) {
onResetPreferencesConfirmed();
}
});
break;
default:
dialog = null;
} }
return DialogUtils.createConfirmationDialog(this, return dialog;
R.string.settings_backup_restore_confirm_message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = IntentUtils.newIntent(
BackupSettingsActivity.this, RestoreChooserActivity.class);
startActivity(intent);
}
});
}
@Override
protected void onStart() {
super.onStart();
sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
sharedPreferenceChangeListener.onSharedPreferenceChanged(null, null);
} }
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
recordingTrackId = PreferencesUtils.getLong(this, R.string.recording_track_id_key);
updateUi(); updateUi();
} }
@Override @Override
protected void onStop() { protected void onPause() {
super.onStop(); super.onPause();
sharedPreferences.unregisterOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); sharedPreferences.unregisterOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
} }
@@ -140,10 +164,45 @@ public class BackupSettingsActivity extends AbstractSettingsActivity {
private void updateUi() { private void updateUi() {
boolean isRecording = recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT; boolean isRecording = recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
backupPreference.setEnabled(!isRecording); backupPreference.setEnabled(!isRecording);
restorePreference.setEnabled(!isRecording);
backupPreference.setSummary( backupPreference.setSummary(
isRecording ? R.string.settings_not_while_recording : R.string.settings_backup_now_summary); isRecording ? R.string.settings_not_while_recording : R.string.settings_backup_now_summary);
restorePreference.setSummary(isRecording ? R.string.settings_not_while_recording
restoreNowPreference.setEnabled(!isRecording);
restoreNowPreference.setSummary(isRecording ? R.string.settings_not_while_recording
: R.string.settings_backup_restore_summary); : R.string.settings_backup_restore_summary);
resetPreference.setEnabled(!isRecording);
resetPreference.setSummary(
isRecording ? R.string.settings_not_while_recording : R.string.settings_reset_summary);
}
/**
* Callback when the user confirms resetting all settings.
*/
private void onResetPreferencesConfirmed() {
// Change preferences in a separate thread
new Thread() {
@Override
public void run() {
Log.i(TAG, "Resetting all settings");
// Actually wipe preferences and save synchronously
sharedPreferences.edit().clear().commit();
// Give UI feedback in the UI thread
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(
BackupResetSettingsActivity.this, R.string.settings_reset_done, Toast.LENGTH_SHORT)
.show();
// Restart the settings activity so all changes are loaded
Intent intent = getIntent()
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
});
}
}.start();
} }
} }
@@ -41,7 +41,6 @@ public class MapSettingsActivity extends AbstractSettingsActivity {
private static final String TAG = MapSettingsActivity.class.getSimpleName(); private static final String TAG = MapSettingsActivity.class.getSimpleName();
private ListPreference trackColorModePreference;
private EditTextPreference slowPreference; private EditTextPreference slowPreference;
private EditTextPreference mediumPreference; private EditTextPreference mediumPreference;
private EditTextPreference percentagePreference; private EditTextPreference percentagePreference;
@@ -52,8 +51,6 @@ public class MapSettingsActivity extends AbstractSettingsActivity {
super.onCreate(bundle); super.onCreate(bundle);
addPreferencesFromResource(R.xml.map_settings); addPreferencesFromResource(R.xml.map_settings);
trackColorModePreference = (ListPreference) findPreference(
getString(R.string.track_color_mode_key));
slowPreference = (EditTextPreference) findPreference( slowPreference = (EditTextPreference) findPreference(
getString(R.string.settings_map_slow_display_key)); getString(R.string.settings_map_slow_display_key));
mediumPreference = (EditTextPreference) findPreference( mediumPreference = (EditTextPreference) findPreference(
@@ -79,6 +76,8 @@ public class MapSettingsActivity extends AbstractSettingsActivity {
* Configures the track color mode preference. * Configures the track color mode preference.
*/ */
private void configTrackColorModePerference() { private void configTrackColorModePerference() {
ListPreference preference = (ListPreference) findPreference(
getString(R.string.track_color_mode_key));
OnPreferenceChangeListener listener = new OnPreferenceChangeListener() { OnPreferenceChangeListener listener = new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
@@ -86,11 +85,12 @@ public class MapSettingsActivity extends AbstractSettingsActivity {
return true; return true;
} }
}; };
String trackColorMode = PreferencesUtils.getString( String value = PreferencesUtils.getString(
this, R.string.track_color_mode_key, PreferencesUtils.TRACK_COLOR_MODE_DEFAULT); this, R.string.track_color_mode_key, PreferencesUtils.TRACK_COLOR_MODE_DEFAULT);
configurePreference(trackColorModePreference, String[] values = getResources().getStringArray(R.array.track_color_mode_values);
getResources().getStringArray(R.array.track_color_mode_options), String[] options = getResources().getStringArray(R.array.track_color_mode_options);
getResources().getStringArray(R.array.track_color_mode_values), trackColorMode, listener); String[] summary = getResources().getStringArray(R.array.track_color_mode_summary);
configureListPreference(preference, summary, options, values, value, listener);
} }
/** /**
@@ -204,13 +204,6 @@ public class MapSettingsActivity extends AbstractSettingsActivity {
getString(R.string.settings_map_track_color_mode_fixed_value)); getString(R.string.settings_map_track_color_mode_fixed_value));
boolean isDynamicValue = trackColorMode.equals( boolean isDynamicValue = trackColorMode.equals(
getString(R.string.settings_map_track_color_mode_dynamic_value)); getString(R.string.settings_map_track_color_mode_dynamic_value));
if (isDynamicValue) {
trackColorModePreference.setSummary(R.string.settings_map_track_color_mode_dynamic_summary);
} else if (isFixedValue) {
trackColorModePreference.setSummary(R.string.settings_map_track_color_mode_fixed_summary);
} else {
trackColorModePreference.setSummary(R.string.settings_map_track_color_mode_single);
}
slowPreference.setEnabled(isFixedValue); slowPreference.setEnabled(isFixedValue);
mediumPreference.setEnabled(isFixedValue); mediumPreference.setEnabled(isFixedValue);
percentagePreference.setEnabled(isDynamicValue); percentagePreference.setEnabled(isDynamicValue);
@@ -41,178 +41,224 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity {
boolean metricUnits = PreferencesUtils.getBoolean( boolean metricUnits = PreferencesUtils.getBoolean(
this, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT); this, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT);
int voiceFrequencyValue = PreferencesUtils.getInt( configFrequencyPreference(R.string.voice_frequency_key,
this, R.string.voice_frequency_key, PreferencesUtils.VOICE_FREQUENCY_DEFAULT); PreferencesUtils.VOICE_FREQUENCY_DEFAULT, R.array.frequency_values, metricUnits);
ListPreference voiceFrequencyListPreference = (ListPreference) findPreference( configFrequencyPreference(R.string.split_frequency_key,
getString(R.string.voice_frequency_key)); PreferencesUtils.SPLIT_FREQUENCY_DEFAULT, R.array.frequency_values, metricUnits);
configurePreference(voiceFrequencyListPreference, configTrackName();
StringUtils.getFrequencyOptions(this, metricUnits), configDefaultActivity();
getResources().getStringArray(R.array.frequency_values), configListPreference(R.string.min_recording_interval_key,
R.string.settings_recording_voice_frequency_summary, String.valueOf(voiceFrequencyValue)); PreferencesUtils.MIN_RECORDING_INTERVAL_DEFAULT, R.array.min_recording_interval_values,
metricUnits);
configListPreference(R.string.min_recording_distance_key,
PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT, R.array.min_recording_distance_values,
metricUnits);
configListPreference(R.string.max_recording_distance_key,
PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT, R.array.max_recording_distance_values,
metricUnits);
configListPreference(R.string.min_required_accuracy_key,
PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT, R.array.min_required_accuracy_values,
metricUnits);
configListPreference(R.string.auto_resume_track_timeout_key,
PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT,
R.array.auto_resume_track_timeout_values, metricUnits);
}
int splitFrequencyValue = PreferencesUtils.getInt( private void configFrequencyPreference(
this, R.string.split_frequency_key, PreferencesUtils.SPLIT_FREQUENCY_DEFAULT); int key, int defaultValue, int valueArray, boolean metricUnits) {
ListPreference splitFrequencyListPreference = (ListPreference) findPreference( ListPreference preference = (ListPreference) findPreference(getString(key));
getString(R.string.split_frequency_key)); int value = PreferencesUtils.getInt(this, key, defaultValue);
configurePreference(splitFrequencyListPreference, String[] values = getResources().getStringArray(valueArray);
StringUtils.getFrequencyOptions(this, metricUnits), String[] options = StringUtils.getFrequencyOptions(this, metricUnits);
getResources().getStringArray(R.array.frequency_values), configureListPreference(preference, options, options, values, String.valueOf(value), null);
R.string.settings_recording_split_frequency_summary, String.valueOf(splitFrequencyValue)); }
String trackNameValue = PreferencesUtils.getString( private void configTrackName() {
ListPreference preference = (ListPreference) findPreference(getString(R.string.track_name_key));
String value = PreferencesUtils.getString(
this, R.string.track_name_key, PreferencesUtils.TRACK_NAME_DEFAULT); this, R.string.track_name_key, PreferencesUtils.TRACK_NAME_DEFAULT);
ListPreference trackNameListPreference = (ListPreference) findPreference( String[] values = getResources().getStringArray(R.array.track_name_values);
getString(R.string.track_name_key)); String[] options = getResources().getStringArray(R.array.track_name_options);
configurePreference(trackNameListPreference, configureListPreference(preference, options, options, values, value, null);
getResources().getStringArray(R.array.track_name_options), }
getResources().getStringArray(R.array.track_name_values),
R.string.settings_recording_track_name_summary, trackNameValue);
String defaultActivityValue = PreferencesUtils.getString( private void configDefaultActivity() {
Preference preference = findPreference(getString(R.string.default_activity_key));
String value = PreferencesUtils.getString(
this, R.string.default_activity_key, PreferencesUtils.DEFAULT_ACTIVITY_DEFAULT); this, R.string.default_activity_key, PreferencesUtils.DEFAULT_ACTIVITY_DEFAULT);
Preference defaultActivityPreference = findPreference(getString(R.string.default_activity_key)); preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
configurePreference(defaultActivityPreference, null, null, @Override
R.string.settings_recording_default_activity_summary, defaultActivityValue); public boolean onPreferenceChange(Preference pref, Object newValue) {
String stringValue = (String) newValue;
pref.setSummary(stringValue != null
&& !stringValue.equals(PreferencesUtils.DEFAULT_ACTIVITY_DEFAULT) ? stringValue
: getString(R.string.value_unknown));
return true;
}
});
preference.setSummary(
value != null && !value.equals(PreferencesUtils.DEFAULT_ACTIVITY_DEFAULT) ? value
: getString(R.string.value_unknown));
}
int minRecordingIntervalValue = PreferencesUtils.getInt( private void configListPreference(
this, R.string.min_recording_interval_key, PreferencesUtils.MIN_RECORDING_INTERVAL_DEFAULT); int key, int defaultValue, int valueArray, boolean metricUnits) {
ListPreference minRecordingIntervalListPreference = (ListPreference) findPreference( ListPreference preference = (ListPreference) findPreference(getString(key));
getString(R.string.min_recording_interval_key)); int value = PreferencesUtils.getInt(this, key, defaultValue);
configurePreference(minRecordingIntervalListPreference, getMinRecordingIntervalOptions(), String[] values = getResources().getStringArray(valueArray);
getResources().getStringArray(R.array.min_recording_interval_values), String[] options = new String[values.length];
R.string.settings_recording_min_recording_interval_summary, String[] summary = new String[values.length];
String.valueOf(minRecordingIntervalValue)); switch (key) {
case R.string.min_recording_interval_key:
int minRecordingDistanceValue = PreferencesUtils.getInt( setMinRecordingIntervalSummaryAndOptions(summary, options, values);
this, R.string.min_recording_distance_key, PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT); break;
ListPreference minRecordingDistanceListPreference = (ListPreference) findPreference( case R.string.min_recording_distance_key:
getString(R.string.min_recording_distance_key)); setMinRecordingDistanceSummaryAndOptions(summary, options, values, metricUnits);
configurePreference(minRecordingDistanceListPreference, break;
getMinRecordingDistanceOptions(metricUnits), case R.string.max_recording_distance_key:
getResources().getStringArray(R.array.min_recording_distance_values), setMaxRecordingDistanceSummaryAndOptions(summary, options, values, metricUnits);
R.string.settings_recording_min_recording_distance_summary, break;
String.valueOf(minRecordingDistanceValue)); case R.string.min_required_accuracy_key:
setMinRequiredAccuracySummaryAndOptions(summary, options, values, metricUnits);
int maxRecordingDistanceValue = PreferencesUtils.getInt( break;
this, R.string.max_recording_distance_key, PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT); case R.string.auto_resume_track_timeout_key:
ListPreference maxRecordingDistanceListPreference = (ListPreference) findPreference( setAutoResumeTrackTimeoutSummaryAndOptions(summary, options, values);
getString(R.string.max_recording_distance_key)); break;
configurePreference(maxRecordingDistanceListPreference, default:
getMaxRecordingDistanceOptions(metricUnits), return;
getResources().getStringArray(R.array.max_recording_distance_values), }
R.string.settings_recording_max_recording_distance_summary, configureListPreference(preference, summary, options, values, String.valueOf(value), null);
String.valueOf(maxRecordingDistanceValue));
int minRequiredAcuracyValue = PreferencesUtils.getInt(
this, R.string.min_required_accuracy_key, PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT);
ListPreference minRequiredAccuracyListPreference = (ListPreference) findPreference(
getString(R.string.min_required_accuracy_key));
configurePreference(minRequiredAccuracyListPreference,
getMinRequiredAccuracyOptions(metricUnits),
getResources().getStringArray(R.array.min_required_accuracy_values),
R.string.settings_recording_min_required_accuracy_summary,
String.valueOf(minRequiredAcuracyValue));
int autoResumeTrackTimeoutValue = PreferencesUtils.getInt(this,
R.string.auto_resume_track_timeout_key, PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT);
ListPreference autoResumeTrackTimeoutListPreference = (ListPreference) findPreference(
getString(R.string.auto_resume_track_timeout_key));
configurePreference(autoResumeTrackTimeoutListPreference, getAutoResumeTrackTimeoutOptions(),
getResources().getStringArray(R.array.auto_resume_track_timeout_values),
R.string.settings_recording_auto_resume_track_timeout_summary,
String.valueOf(autoResumeTrackTimeoutValue));
} }
/** /**
* Gets the min recording interval display options. * Sets the min recording interval summary and options.
*
* @param summary the summary
* @param options the options
* @param values the values
*/ */
private String[] getMinRecordingIntervalOptions() { private void setMinRecordingIntervalSummaryAndOptions(
String[] values = getResources().getStringArray(R.array.min_recording_interval_values); String[] summary, String[] options, String[] values) {
String[] options = new String[values.length];
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
int value = Integer.parseInt(values[i]); int value = Integer.parseInt(values[i]);
switch (value) { switch (value) {
case PreferencesUtils.MIN_RECORDING_INTERVAL_ADAPT_BATTERY_LIFE: case PreferencesUtils.MIN_RECORDING_INTERVAL_ADAPT_BATTERY_LIFE:
options[i] = getString(R.string.value_adapt_battery_life); options[i] = getString(R.string.value_adapt_battery_life);
summary[i] = options[i];
break; break;
case PreferencesUtils.MIN_RECORDING_INTERVAL_ADAPT_ACCURACY: case PreferencesUtils.MIN_RECORDING_INTERVAL_ADAPT_ACCURACY:
options[i] = getString(R.string.value_adapt_accuracy); options[i] = getString(R.string.value_adapt_accuracy);
summary[i] = options[i];
break; break;
case PreferencesUtils.MIN_RECORDING_INTERVAL_DEFAULT: case PreferencesUtils.MIN_RECORDING_INTERVAL_DEFAULT:
options[i] = getString(R.string.value_smallest_recommended); options[i] = getString(R.string.value_smallest_recommended);
summary[i] = getString(R.string.value_smallest);
break; break;
default: default:
options[i] = value < 60 ? getString(R.string.value_integer_second, value) options[i] = value < 60 ? getString(R.string.value_integer_second, value)
: getString(R.string.value_integer_minute, value / 60); : getString(R.string.value_integer_minute, value / 60);
summary[i] = getString(
R.string.settings_recording_location_frequency_summary, options[i]);
} }
} }
return options;
} }
/** /**
* Gets the min recording distance display options. * Sets the min recording distance summary and options.
* *
* @param metricUnits true to display metric units * @param summary the summary
* @param options the options
* @param values the values
* @param metricUnits true for metric units
*/ */
private String[] getMinRecordingDistanceOptions(boolean metricUnits) { private void setMinRecordingDistanceSummaryAndOptions(
String[] values = getResources().getStringArray(R.array.min_recording_distance_values); String[] summary, String[] options, String[] values, boolean metricUnits) {
String[] options = new String[values.length];
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
int value = Integer.parseInt(values[i]); int value = Integer.parseInt(values[i]);
String displayValue;
if (metricUnits) { if (metricUnits) {
options[i] = getString( displayValue = getString(R.string.value_integer_meter, value);
value == PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT ? R.string.value_integer_meter_recommended switch (value) {
: R.string.value_integer_meter, value); case PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT:
options[i] = getString(R.string.value_integer_meter_recommended, value);
break;
default:
options[i] = displayValue;
}
} else { } else {
int feet = (int) (value * UnitConversions.M_TO_FT); int feet = (int) (value * UnitConversions.M_TO_FT);
options[i] = getString( displayValue = getString(R.string.value_integer_feet, feet);
value == PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT ? R.string.value_integer_feet_recommended switch (value) {
: R.string.value_integer_feet, feet); case PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT:
options[i] = getString(R.string.value_integer_feet_recommended, feet);
break;
default:
options[i] = displayValue;
}
} }
summary[i] = getString(R.string.settings_recording_location_frequency_summary, displayValue);
} }
return options;
} }
/** /**
* Gets the max recording distance display options. * Sets the max recording distance summary and options.
* *
* @param metricUnits true to display metric units * @param summary the summary
* @param options the options
* @param values the values
* @param metricUnits true for metric units
*/ */
private String[] getMaxRecordingDistanceOptions(boolean metricUnits) { private void setMaxRecordingDistanceSummaryAndOptions(
String[] values = getResources().getStringArray(R.array.max_recording_distance_values); String[] summary, String[] options, String[] values, boolean metricUnits) {
String[] options = new String[values.length];
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
int value = Integer.parseInt(values[i]); int value = Integer.parseInt(values[i]);
String displayValue;
if (metricUnits) { if (metricUnits) {
options[i] = getString( displayValue = getString(R.string.value_integer_meter, value);
value == PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT ? R.string.value_integer_meter_recommended switch (value) {
: R.string.value_integer_meter, value); case PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT:
options[i] = getString(R.string.value_integer_meter_recommended, value);
break;
default:
options[i] = displayValue;
}
} else { } else {
int feet = (int) (value * UnitConversions.M_TO_FT); int feet = (int) (value * UnitConversions.M_TO_FT);
if (feet < 2000) { if (feet < 2000) {
options[i] = getString( displayValue = getString(R.string.value_integer_feet, feet);
value == PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT ? R.string.value_integer_feet_recommended switch (value) {
: R.string.value_integer_feet, feet); case PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT:
options[i] = getString(R.string.value_integer_feet_recommended, feet);
break;
default:
options[i] = displayValue;
}
} else { } else {
double mile = feet * UnitConversions.FT_TO_MI; double mile = feet * UnitConversions.FT_TO_MI;
options[i] = getString(R.string.value_float_mile, mile); displayValue = getString(R.string.value_float_mile, mile);
options[i] = displayValue;
} }
} }
summary[i] = getString(
R.string.settings_recording_max_recording_distance_summary, displayValue);
} }
return options;
} }
/** /**
* Gets the min required accuracy display options. * Sets the min required accuracy summary and options.
* *
* @param metricUnits true to display metric units * @param summary the summary
* @param options the options
* @param values the values
* @param metricUnits true for metric units
*/ */
private String[] getMinRequiredAccuracyOptions(boolean metricUnits) { private void setMinRequiredAccuracySummaryAndOptions(
String[] values = getResources().getStringArray(R.array.min_required_accuracy_values); String[] summary, String[] options, String[] values, boolean metricUnits) {
String[] options = new String[values.length];
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
int value = Integer.parseInt(values[i]); int value = Integer.parseInt(values[i]);
String displayValue;
if (metricUnits) { if (metricUnits) {
displayValue = getString(R.string.value_integer_meter, value);
switch (value) { switch (value) {
case PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT: case PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT:
options[i] = getString(R.string.value_integer_meter_recommended, value); options[i] = getString(R.string.value_integer_meter_recommended, value);
@@ -224,11 +270,12 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity {
options[i] = getString(R.string.value_integer_meter_poor_gps, value); options[i] = getString(R.string.value_integer_meter_poor_gps, value);
break; break;
default: default:
options[i] = getString(R.string.value_integer_meter, value); options[i] = displayValue;
} }
} else { } else {
int feet = (int) (value * UnitConversions.M_TO_FT); int feet = (int) (value * UnitConversions.M_TO_FT);
if (feet < 2000) { if (feet < 2000) {
displayValue = getString(R.string.value_integer_feet, feet);
switch (value) { switch (value) {
case PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT: case PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT:
options[i] = getString(R.string.value_integer_feet_recommended, feet); options[i] = getString(R.string.value_integer_feet_recommended, feet);
@@ -237,38 +284,52 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity {
options[i] = getString(R.string.value_integer_feet_excellent_gps, feet); options[i] = getString(R.string.value_integer_feet_excellent_gps, feet);
break; break;
default: default:
options[i] = getString(R.string.value_integer_feet, feet); options[i] = displayValue;
} }
} else { } else {
double mile = feet * UnitConversions.FT_TO_MI; double mile = feet * UnitConversions.FT_TO_MI;
options[i] = getString( displayValue = getString(R.string.value_float_mile, mile);
value == PreferencesUtils.MIN_REQUIRED_ACCURACY_POOR ? R.string.value_float_mile_poor_gps switch (value) {
: R.string.value_float_mile, mile); case PreferencesUtils.MIN_REQUIRED_ACCURACY_POOR:
options[i] = getString(R.string.value_float_mile_poor_gps, mile);
break;
default:
options[i] = displayValue;
}
} }
} }
summary[i] = getString(
R.string.settings_recording_min_required_accuracy_summary, displayValue);
} }
return options;
} }
/** /**
* Gets the auto resume track timeout display options. * Sets the auto resume track timeout summary and options.
*
* @param summary the summary
* @param options the options
* @param values the values
*/ */
private String[] getAutoResumeTrackTimeoutOptions() { private void setAutoResumeTrackTimeoutSummaryAndOptions(
String[] values = getResources().getStringArray(R.array.auto_resume_track_timeout_values); String[] summary, String[] options, String[] values) {
String[] options = new String[values.length];
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
int value = Integer.parseInt(values[i]); int value = Integer.parseInt(values[i]);
switch (value) { switch (value) {
case PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_NEVER: case PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_NEVER:
options[i] = getString(R.string.value_never); options[i] = getString(R.string.value_never);
summary[i] = getString(
R.string.settings_recording_auto_resume_track_timeout_never_summary);
break; break;
case PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_ALWAYS: case PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_ALWAYS:
options[i] = getString(R.string.value_always); options[i] = getString(R.string.value_always);
summary[i] = getString(
R.string.settings_recording_auto_resume_track_timeout_always_summary);
break; break;
default: default:
options[i] = getString(R.string.value_integer_minute, value); options[i] = getString(R.string.value_integer_minute, value);
summary[i] = getString(
R.string.settings_recording_auto_resume_track_timeout_summary, options[i]);
} }
} }
return options;
} }
} }
@@ -49,23 +49,8 @@ public class SensorSettingsActivity extends AbstractSettingsActivity {
addPreferencesFromResource(R.xml.sensor_settings); addPreferencesFromResource(R.xml.sensor_settings);
boolean hasAntSupport = AntInterface.hasAntSupport(this); boolean hasAntSupport = AntInterface.hasAntSupport(this);
ListPreference sensorTypeListPreference = (ListPreference) findPreference(
getString(R.string.sensor_type_key)); configSensorType(hasAntSupport);
String[] sensorTypeOptions = getResources().getStringArray(
hasAntSupport ? R.array.sensor_type_all_options : R.array.sensor_type_bluetooth_options);
String[] sensorTypeValues = getResources().getStringArray(
hasAntSupport ? R.array.sensor_type_all_values : R.array.sensor_type_bluetooth_values);
String sensorTypeValue = PreferencesUtils.getString(
this, R.string.sensor_type_key, PreferencesUtils.SENSOR_TYPE_DEFAULT);
OnPreferenceChangeListener listener = new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
updateUiBySensorType((String) newValue);
return true;
}
};
configurePreference(sensorTypeListPreference, sensorTypeOptions, sensorTypeValues,
R.string.settings_sensor_type_summary, sensorTypeValue, listener);
findPreference(getString(R.string.settings_sensor_bluetooth_pairing_key)) findPreference(getString(R.string.settings_sensor_bluetooth_pairing_key))
.setOnPreferenceClickListener(new OnPreferenceClickListener() { .setOnPreferenceClickListener(new OnPreferenceClickListener() {
@@ -84,6 +69,31 @@ public class SensorSettingsActivity extends AbstractSettingsActivity {
} }
} }
private void configSensorType(boolean hasAntSupport) {
ListPreference preference = (ListPreference) findPreference(
getString(R.string.sensor_type_key));
String value = PreferencesUtils.getString(
this, R.string.sensor_type_key, PreferencesUtils.SENSOR_TYPE_DEFAULT);
String[] options = getResources().getStringArray(
hasAntSupport ? R.array.sensor_type_all_options : R.array.sensor_type_bluetooth_options);
String[] values = getResources().getStringArray(
hasAntSupport ? R.array.sensor_type_all_values : R.array.sensor_type_bluetooth_values);
if (!hasAntSupport && value.equals(R.string.sensor_type_value_ant)) {
value = PreferencesUtils.SENSOR_TYPE_DEFAULT;
PreferencesUtils.setString(this, R.string.sensor_type_key, value);
}
OnPreferenceChangeListener listener = new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference pref, Object newValue) {
updateUiBySensorType((String) newValue);
return true;
}
};
configureListPreference(preference, options, options, values, value, listener);
}
/** /**
* Updates the UI based on the sensor type. * Updates the UI based on the sensor type.
* *
@@ -120,7 +130,7 @@ public class SensorSettingsActivity extends AbstractSettingsActivity {
preference.setEnabled(enabled); preference.setEnabled(enabled);
int deviceId = PreferencesUtils.getInt(this, valueKey, AntSensorManager.WILDCARD); int deviceId = PreferencesUtils.getInt(this, valueKey, AntSensorManager.WILDCARD);
if (deviceId == AntSensorManager.WILDCARD) { if (deviceId == AntSensorManager.WILDCARD) {
preference.setSummary(R.string.settings_sensor_not_connected); preference.setSummary(R.string.settings_sensor_ant_not_connected);
} else { } else {
preference.setSummary(getString(R.string.settings_sensor_ant_paired, deviceId)); preference.setSummary(getString(R.string.settings_sensor_ant_paired, deviceId));
} }
@@ -128,7 +138,7 @@ public class SensorSettingsActivity extends AbstractSettingsActivity {
@Override @Override
public boolean onPreferenceClick(Preference pref) { public boolean onPreferenceClick(Preference pref) {
PreferencesUtils.setInt(SensorSettingsActivity.this, valueKey, AntSensorManager.WILDCARD); PreferencesUtils.setInt(SensorSettingsActivity.this, valueKey, AntSensorManager.WILDCARD);
pref.setSummary(R.string.settings_sensor_not_connected); pref.setSummary(R.string.settings_sensor_ant_not_connected);
return true; return true;
} }
}); });
@@ -138,14 +148,20 @@ public class SensorSettingsActivity extends AbstractSettingsActivity {
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
updateBluetoothSensorListPreference();
// Update each time in case the list of bluetooth sensors has changed
configBluetoothSensor();
} }
/** /**
* Updates the bluetooth sensor list preference. * Configures the bluetooth sensor.
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void updateBluetoothSensorListPreference() { private void configBluetoothSensor() {
ListPreference preference = (ListPreference) findPreference(
getString(R.string.bluetooth_sensor_key));
String value = PreferencesUtils.getString(
this, R.string.bluetooth_sensor_key, PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT);
List<String> optionsList = new ArrayList<String>(); List<String> optionsList = new ArrayList<String>();
List<String> valuesList = new ArrayList<String>(); List<String> valuesList = new ArrayList<String>();
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
@@ -155,22 +171,17 @@ public class SensorSettingsActivity extends AbstractSettingsActivity {
String[] options = optionsList.toArray(new String[optionsList.size()]); String[] options = optionsList.toArray(new String[optionsList.size()]);
String[] values = valuesList.toArray(new String[valuesList.size()]); String[] values = valuesList.toArray(new String[valuesList.size()]);
String bluetoothSensorValue = PreferencesUtils.getString(
this, R.string.bluetooth_sensor_key, PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT);
ListPreference bluetoothSensorListPreference = (ListPreference) findPreference(
getString(R.string.bluetooth_sensor_key));
if (valuesList.size() == 1) { if (valuesList.size() == 1) {
if (!valuesList.get(0).equals(bluetoothSensorValue)) { if (!valuesList.get(0).equals(value)) {
bluetoothSensorValue = valuesList.get(0); value = valuesList.get(0);
PreferencesUtils.setString(this, R.string.bluetooth_sensor_key, bluetoothSensorValue); PreferencesUtils.setString(this, R.string.bluetooth_sensor_key, value);
} }
} else { } else {
if (!valuesList.contains(bluetoothSensorValue)) { if (!valuesList.contains(value)) {
bluetoothSensorValue = PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT; value = PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT;
PreferencesUtils.setString(this, R.string.bluetooth_sensor_key, bluetoothSensorValue); PreferencesUtils.setString(this, R.string.bluetooth_sensor_key, value);
} }
} }
configurePreference(bluetoothSensorListPreference, options, values, configureListPreference(preference, options, options, values, value, null);
R.string.settings_sensor_bluetooth_sensor_summary, bluetoothSensorValue);
} }
} }
@@ -16,22 +16,13 @@
package com.google.android.apps.mytracks.settings; package com.google.android.apps.mytracks.settings;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.apps.mytracks.util.IntentUtils; import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener; import android.preference.Preference.OnPreferenceClickListener;
import android.util.Log;
import android.widget.Toast;
/** /**
* An activity for accessing settings. * An activity for accessing settings.
@@ -41,11 +32,6 @@ import android.widget.Toast;
*/ */
public class SettingsActivity extends AbstractSettingsActivity { public class SettingsActivity extends AbstractSettingsActivity {
private static final String TAG = SettingsActivity.class.getSimpleName();
private static final int DIALOG_CONFIRM_RESET_ID = 0;
private Preference resetPreference;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected void onCreate(Bundle bundle) { protected void onCreate(Bundle bundle) {
@@ -59,16 +45,7 @@ public class SettingsActivity extends AbstractSettingsActivity {
configPreference(R.string.settings_recording_key, RecordingSettingsActivity.class); configPreference(R.string.settings_recording_key, RecordingSettingsActivity.class);
configPreference(R.string.settings_sharing_key, SharingSettingsActivity.class); configPreference(R.string.settings_sharing_key, SharingSettingsActivity.class);
configPreference(R.string.settings_sensor_key, SensorSettingsActivity.class); configPreference(R.string.settings_sensor_key, SensorSettingsActivity.class);
configPreference(R.string.settings_backup_key, BackupSettingsActivity.class); configPreference(R.string.settings_backup_reset_key, BackupResetSettingsActivity.class);
resetPreference = findPreference(getString(R.string.settings_reset_key));
resetPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
showDialog(DIALOG_CONFIRM_RESET_ID);
return true;
}
});
} }
/** /**
@@ -88,58 +65,4 @@ public class SettingsActivity extends AbstractSettingsActivity {
} }
}); });
} }
@Override
protected void onResume() {
super.onResume();
boolean isRecording = PreferencesUtils.getLong(this, R.string.recording_track_id_key)
!= PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
resetPreference.setEnabled(!isRecording);
resetPreference.setSummary(isRecording ? R.string.settings_not_while_recording
: R.string.settings_reset_summary);
}
@Override
protected Dialog onCreateDialog(int id) {
if (id != DIALOG_CONFIRM_RESET_ID) {
return null;
}
return DialogUtils.createConfirmationDialog(
this, R.string.settings_reset_confirm_message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int button) {
onResetPreferencesConfirmed();
}
});
}
/**
* Callback when the user confirms resetting all settings.
*/
private void onResetPreferencesConfirmed() {
// Change preferences in a separate thread
new Thread() {
@Override
public void run() {
Log.i(TAG, "Resetting all settings");
SharedPreferences sharedPreferences = getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
// Actually wipe preferences and save synchronously
sharedPreferences.edit().clear().commit();
// Give UI feedback in the UI thread
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(SettingsActivity.this, R.string.settings_reset_done, Toast.LENGTH_SHORT)
.show();
// Restart the settings activity so all changes are loaded
Intent intent = getIntent()
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
});
}
}.start();
}
} }
@@ -27,6 +27,7 @@ import android.location.Location;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.List; import java.util.List;
import java.util.Locale;
/** /**
* Utilities for track name. * Utilities for track name.
@@ -65,7 +66,7 @@ public class TrackNameUtils {
if (startTime == -1L) { if (startTime == -1L) {
return null; return null;
} }
SimpleDateFormat dateFormat = new SimpleDateFormat(ISO_8601_FORMAT); SimpleDateFormat dateFormat = new SimpleDateFormat(ISO_8601_FORMAT, Locale.US);
return dateFormat.format(startTime); return dateFormat.format(startTime);
} else if (trackName.equals( } else if (trackName.equals(
context.getString(R.string.settings_recording_track_name_number_value))) { context.getString(R.string.settings_recording_track_name_number_value))) {
@@ -227,6 +227,13 @@ public interface MyTracksProviderUtils {
*/ */
public long getLastTrackPointId(long trackId); public long getLastTrackPointId(long trackId);
/**
* Gets the first valid location for a track. Returns null if it doesn't exist.
*
* @param trackId the track id
*/
public Location getFirstValidTrackPoint(long trackId);
/** /**
* Gets the last valid location for a track. Returns null if it doesn't exist. * Gets the last valid location for a track. Returns null if it doesn't exist.
* *
@@ -748,6 +748,18 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
return -1L; return -1L;
} }
@Override
public Location getFirstValidTrackPoint(long trackId) {
if (trackId < 0) {
return null;
}
String selection = TrackPointsColumns._ID + "=(select min(" + TrackPointsColumns._ID + ") from "
+ TrackPointsColumns.TABLE_NAME + " WHERE " + TrackPointsColumns.TRACKID + "=? AND "
+ TrackPointsColumns.LATITUDE + "<=" + MAX_LATITUDE + ")";
String[] selectionArgs = new String[] { Long.toString(trackId) };
return findTrackPointBy(selection, selectionArgs);
}
@Override @Override
public Location getLastValidTrackPoint(long trackId) { public Location getLastValidTrackPoint(long trackId) {
if (trackId < 0) { if (trackId < 0) {