forked from upstream-mirrors/OpenTracks
Place map settings in MapSettingsActivity.
This commit is contained in:
@@ -208,6 +208,7 @@ limitations under the License.
|
|||||||
<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.io.sendtogoogle.UploadServiceChooserActivity" />
|
<activity android:name="com.google.android.apps.mytracks.io.sendtogoogle.UploadServiceChooserActivity" />
|
||||||
<activity android:name="com.google.android.apps.mytracks.settings.BackupSettingsActivity" />
|
<activity android:name="com.google.android.apps.mytracks.settings.BackupSettingsActivity" />
|
||||||
|
<activity android:name="com.google.android.apps.mytracks.settings.MapSettingsActivity" />
|
||||||
<activity android:name="com.google.android.apps.mytracks.settings.RecordingSettingsActivity" />
|
<activity android:name="com.google.android.apps.mytracks.settings.RecordingSettingsActivity" />
|
||||||
<activity android:name="com.google.android.apps.mytracks.settings.SensorSettingsActivity" />
|
<activity android:name="com.google.android.apps.mytracks.settings.SensorSettingsActivity" />
|
||||||
<activity android:name="com.google.android.apps.mytracks.settings.SettingsActivity" />
|
<activity android:name="com.google.android.apps.mytracks.settings.SettingsActivity" />
|
||||||
|
|||||||
@@ -90,16 +90,6 @@ limitations under the License.
|
|||||||
<item>15</item>
|
<item>15</item>
|
||||||
<item>-1</item>
|
<item>-1</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="display_track_color_options">
|
|
||||||
<item>@string/settings_display_track_color_single</item>
|
|
||||||
<item>@string/settings_display_track_color_fixed</item>
|
|
||||||
<item>@string/settings_display_track_color_dynamic</item>
|
|
||||||
</string-array>
|
|
||||||
<string-array name="display_track_color_values">
|
|
||||||
<item>@string/display_track_color_value_none</item>
|
|
||||||
<item>@string/display_track_color_value_fixed</item>
|
|
||||||
<item>@string/display_track_color_value_dynamic</item>
|
|
||||||
</string-array>
|
|
||||||
<string-array name="file_types">
|
<string-array name="file_types">
|
||||||
<item>GPX</item>
|
<item>GPX</item>
|
||||||
<item>KML</item>
|
<item>KML</item>
|
||||||
@@ -192,6 +182,16 @@ limitations under the License.
|
|||||||
<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>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
<string-array name="track_color_mode_options">
|
||||||
|
<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_dynamic</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="track_color_mode_values">
|
||||||
|
<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_dynamic_value</item>
|
||||||
|
</string-array>
|
||||||
<string-array name="track_name_options">
|
<string-array name="track_name_options">
|
||||||
<item>@string/settings_recording_track_name_date_local_option</item>
|
<item>@string/settings_recording_track_name_date_local_option</item>
|
||||||
<item>@string/settings_recording_track_name_date_iso_8601_option</item>
|
<item>@string/settings_recording_track_name_date_iso_8601_option</item>
|
||||||
|
|||||||
@@ -16,36 +16,25 @@ limitations under the License.
|
|||||||
-->
|
-->
|
||||||
<resources>
|
<resources>
|
||||||
<!-- DO NOT TRANSLATE ANY STRINGS IN THIS FILE. -->
|
<!-- DO NOT TRANSLATE ANY STRINGS IN THIS FILE. -->
|
||||||
<string name="color_mode_dynamic_percentage_default">25</string>
|
<string name="marker_statistics_icon_url">http://maps.google.com/mapfiles/ms/micons/ylw-pushpin.png</string>
|
||||||
<string name="color_mode_fixed_medium_default">15</string>
|
<string name="marker_waypoint_icon_url">http://maps.google.com/mapfiles/ms/micons/blue-pushpin.png</string>
|
||||||
<string name="color_mode_fixed_slow_default">9</string>
|
<string name="my_tracks_analytics_id">UA-7222692-2</string>
|
||||||
<string name="display_track_color_value_dynamic">DYNAMIC</string>
|
|
||||||
<string name="display_track_color_value_fixed">FIXED</string>
|
|
||||||
<string name="display_track_color_value_none">NONE</string>
|
|
||||||
<string name="marker_statistics_icon_url">
|
|
||||||
http://maps.google.com/mapfiles/ms/micons/ylw-pushpin.png
|
|
||||||
</string>
|
|
||||||
<string name="marker_waypoint_icon_url">
|
|
||||||
http://maps.google.com/mapfiles/ms/micons/blue-pushpin.png
|
|
||||||
</string>
|
|
||||||
<string name="my_tracks_analytics_id">UA-7222692-2</string>
|
|
||||||
<string name="my_tracks_privacy_url">www.google.com/policies/privacy/</string>
|
<string name="my_tracks_privacy_url">www.google.com/policies/privacy/</string>
|
||||||
<string name="my_tracks_recording_service_name">My Tracks Recording Service</string>
|
<string name="my_tracks_recording_service_name">My Tracks Recording Service</string>
|
||||||
<string name="my_tracks_support_url">
|
<string name="my_tracks_support_url">groups.google.com/a/googleproductforums.com/forum/#!categories/maps/mytracks</string>
|
||||||
groups.google.com/a/googleproductforums.com/forum/#!categories/maps/mytracks
|
|
||||||
</string>
|
|
||||||
<string name="my_tracks_web_url">www.google.com/mobile/mytracks</string>
|
<string name="my_tracks_web_url">www.google.com/mobile/mytracks</string>
|
||||||
<string name="permission_notification_value">
|
<string name="permission_notification_value">com.google.android.apps.mytracks.MYTRACKS_NOTIFICATIONS</string>
|
||||||
com.google.android.apps.mytracks.MYTRACKS_NOTIFICATIONS
|
|
||||||
</string>
|
|
||||||
<string name="send_google_docs_url">docs.google.com</string>
|
<string name="send_google_docs_url">docs.google.com</string>
|
||||||
<string name="send_google_fusion_tables_url">google.com/fusiontables</string>
|
<string name="send_google_fusion_tables_url">google.com/fusiontables</string>
|
||||||
<string name="send_google_maps_url">maps.google.com</string>
|
<string name="send_google_maps_url">maps.google.com</string>
|
||||||
<string name="sensor_type_value_ant">ANT</string>
|
<string name="sensor_type_value_ant">ANT</string>
|
||||||
<string name="sensor_type_value_none">NONE</string>
|
<string name="sensor_type_value_none">NONE</string>
|
||||||
<string name="sensor_type_value_polar">POLAR</string>
|
<string name="sensor_type_value_polar">POLAR</string>
|
||||||
<string name="sensor_type_value_srm_ant_bridge">SRM_ANT_BRIDGE</string>
|
<string name="sensor_type_value_srm_ant_bridge">SRM_ANT_BRIDGE</string>
|
||||||
<string name="sensor_type_value_zephyr">ZEPHYR</string>
|
<string name="sensor_type_value_zephyr">ZEPHYR</string>
|
||||||
|
<string name="settings_map_track_color_mode_dynamic_value">DYNAMIC</string>
|
||||||
|
<string name="settings_map_track_color_mode_fixed_value">FIXED</string>
|
||||||
|
<string name="settings_map_track_color_mode_single_value">SINGLE</string>
|
||||||
<string name="settings_recording_track_name_date_iso_8601_value">DATE_ISO_8601</string>
|
<string name="settings_recording_track_name_date_iso_8601_value">DATE_ISO_8601</string>
|
||||||
<string name="settings_recording_track_name_date_local_value">DATE_LOCAL</string>
|
<string name="settings_recording_track_name_date_local_value">DATE_LOCAL</string>
|
||||||
<string name="settings_recording_track_name_number_value">NUMBER</string>
|
<string name="settings_recording_track_name_number_value">NUMBER</string>
|
||||||
@@ -53,4 +42,4 @@ limitations under the License.
|
|||||||
<string name="track_action_save">android.intent.action.SAVE</string>
|
<string name="track_action_save">android.intent.action.SAVE</string>
|
||||||
<string name="track_action_start">com.google.android.apps.mytracks.START_NEW_TRACK</string>
|
<string name="track_action_start">com.google.android.apps.mytracks.START_NEW_TRACK</string>
|
||||||
<string name="value_unknown">-</string>
|
<string name="value_unknown">-</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -50,11 +50,9 @@ limitations under the License.
|
|||||||
<string name="stats_show_elevation_key">statsShowElevation</string>
|
<string name="stats_show_elevation_key">statsShowElevation</string>
|
||||||
<string name="stats_show_grade_key">statsShowGrade</string>
|
<string name="stats_show_grade_key">statsShowGrade</string>
|
||||||
<string name="stats_use_total_time_key">statsUseTotalTime</string>
|
<string name="stats_use_total_time_key">statsUseTotalTime</string>
|
||||||
<string name="track_color_mode_dynamic_speed_variation_key">trackColorModeDynamicVariation</string>
|
<string name="track_color_mode_medium_key">trackColorModeMedium</string>
|
||||||
<string name="track_color_mode_fixed_speed_medium_display_key">trackColorModeFixedMediumDisplay</string>
|
<string name="track_color_mode_percentage_key">trackColorModePercentage</string>
|
||||||
<string name="track_color_mode_fixed_speed_medium_key">trackColorModeFixedMedium</string>
|
<string name="track_color_mode_slow_key">trackColorModeSlow</string>
|
||||||
<string name="track_color_mode_fixed_speed_slow_display_key">trackColorModeFixedSlowDisplay</string>
|
|
||||||
<string name="track_color_mode_fixed_speed_slow_key">trackColorModeFixedSlow</string>
|
|
||||||
<string name="track_color_mode_key">trackColorMode</string>
|
<string name="track_color_mode_key">trackColorMode</string>
|
||||||
<string name="track_name_key">trackName</string>
|
<string name="track_name_key">trackName</string>
|
||||||
|
|
||||||
@@ -63,6 +61,10 @@ limitations under the License.
|
|||||||
<string name="reset_key">resetToDefaults</string>
|
<string name="reset_key">resetToDefaults</string>
|
||||||
<string name="restore_from_sd_key">restoreFromSd</string>
|
<string name="restore_from_sd_key">restoreFromSd</string>
|
||||||
<string name="settings_backup_key">settingsBackup</string>
|
<string name="settings_backup_key">settingsBackup</string>
|
||||||
|
<string name="settings_map_key">settingsMap</string>
|
||||||
|
<string name="settings_map_medium_display_key">settingsMapMediumDisplay</string>
|
||||||
|
<string name="settings_map_percentage_display_key">settingsMapPercentageDisplay</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_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>
|
||||||
@@ -71,5 +73,4 @@ limitations under the License.
|
|||||||
<string name="settings_sensor_root_key">settingsSensorRoot</string>
|
<string name="settings_sensor_root_key">settingsSensorRoot</string>
|
||||||
<string name="settings_sharing_key">settingsSharing</string>
|
<string name="settings_sharing_key">settingsSharing</string>
|
||||||
<string name="settings_stats_key">settingsStats</string>
|
<string name="settings_stats_key">settingsStats</string>
|
||||||
<string name="track_color_mode_fixed_speed_options_key">trackColorModeFixedOptions</string>
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1520,97 +1520,60 @@ limitations under the License.
|
|||||||
the SD card.">
|
the SD card.">
|
||||||
Restore all tracks and settings from the SD card.
|
Restore all tracks and settings from the SD card.
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
<!-- Settings Display -->
|
|
||||||
<string name="settings_display"
|
|
||||||
translation_description="In the 'Settings' page, the option to change the display related
|
|
||||||
settings.
|
|
||||||
|
|
||||||
Character limit: ~26 (1 line)">
|
<!-- Settings Map -->
|
||||||
Display
|
<string name="settings_map_medium"
|
||||||
|
translation_description="In the 'Map' settings, under the 'Fixed thresholds' configurations, the
|
||||||
|
option for configuring the top medium speed.">
|
||||||
|
Top medium speed
|
||||||
</string>
|
</string>
|
||||||
<string name="settings_display_track_color"
|
<string name="settings_map_percentage"
|
||||||
translation_description="In the 'Display' settings, the dropdown option to choose a track color
|
translation_description="In the 'Map' settings, under the 'Dynamic thresholds' configurations,
|
||||||
mode for how to use different colors to color a track based on slow, medium, and fast speed.
|
the option for configuring the percentage from the average speed for the medium speed range.">
|
||||||
|
Percentage from average
|
||||||
Character limit: ~23 (1 line)">
|
|
||||||
Color mode
|
|
||||||
</string>
|
</string>
|
||||||
<string name="settings_display_track_color_dynamic"
|
<string name="settings_map_percentage_summary"
|
||||||
translation_description="In the 'Display' settings, for the 'Color mode' dropdown, the
|
translation_description="In the 'Map' settings, under the 'Dynamic thresholds' configurations,
|
||||||
option to use different colors to color a track based on dynamically determined speed
|
the summary for the 'Percentage from average' option explaining that it sets the percentage
|
||||||
thresholds. E.g., use one color when the speed is below the slow speed threshold.
|
from the average speed for the medium speed range. The 'Dynamic thresholds' track color mode
|
||||||
|
uses different colors to color a track depending on whether the speed is above, in, or below
|
||||||
Character limit: ~21 (1 line)">
|
|
||||||
Dynamic thresholds
|
|
||||||
</string>
|
|
||||||
<string name="settings_display_track_color_dynamic_medium"
|
|
||||||
translation_description="In the 'Display' settings, under the 'Dynamic thresholds'
|
|
||||||
configurations, the option for configuring the percentage from the average speed for the
|
|
||||||
medium speed range. The color mode will use different colors to color a track depending
|
|
||||||
on whether the speed is above, in, or below the medium speed range.
|
|
||||||
|
|
||||||
Character limit: ~23 (1 line)">
|
|
||||||
Percentage
|
|
||||||
</string>
|
|
||||||
<string name="settings_display_track_color_dynamic_medium_summary"
|
|
||||||
translation_description="In the 'Display' settings, under the 'Dynamic thresholds'
|
|
||||||
configurations, the summary for the 'Percentage' option explaining that it sets
|
|
||||||
the percentage from the average speed for the medium speed range. The color mode will
|
|
||||||
use different colors to color a track depending on whether the speed is above, in, or below
|
|
||||||
the medium speed range.">
|
the medium speed range.">
|
||||||
Percentage from the average speed for the medium speed range.
|
Percentage from the average speed for the medium speed range.
|
||||||
</string>
|
</string>
|
||||||
<string name="settings_display_track_color_fixed"
|
<string name="settings_map_slow"
|
||||||
translation_description="In the 'Display' settings, for the 'Color mode' dropdown, the
|
translation_description="In the 'Map' settings, under the 'Fixed thresholds' configurations,
|
||||||
option to use different colors to color a track based on fixed speed thresholds. E.g., use
|
the option for configuring the top slow speed.">
|
||||||
one color when the speed is below the slow speed threshold.
|
Top slow speed
|
||||||
|
</string>
|
||||||
Character limit: ~21 (1 line)">
|
<string name="settings_map_track_color_mode"
|
||||||
|
translation_description="In the 'Map' settings, the option to select a track color mode for how
|
||||||
|
to use different colors to color a track based on slow, medium, and fast speed.">
|
||||||
|
Track color mode
|
||||||
|
</string>
|
||||||
|
<string name="settings_map_track_color_mode_dynamic"
|
||||||
|
translation_description="In the 'Map' settings, for the 'Track color mode' dropdown, the
|
||||||
|
option to use different colors to color a track based on dynamically determined speed
|
||||||
|
thresholds.">
|
||||||
|
Dynamic thresholds
|
||||||
|
</string>
|
||||||
|
<string name="settings_map_track_color_mode_fixed"
|
||||||
|
translation_description="In the 'Map' settings, for the 'Track color mode' dropdown, the
|
||||||
|
option to use different colors to color a track based on fixed speed thresholds.">
|
||||||
Fixed thresholds
|
Fixed thresholds
|
||||||
</string>
|
</string>
|
||||||
<string name="settings_display_track_color_fixed_medium"
|
<string name="settings_map_track_color_mode_single"
|
||||||
translation_description="In the 'Display' settings, under the 'Fixed thresholds' configurations,
|
translation_description="In the 'Map' settings, for the 'Track color mode' dropdown, the
|
||||||
the option for configuring the medium speed threshold. Thus any speed lower than the
|
option to use a single color for all speeds.">
|
||||||
threshold but greater than the slow speed threshold will be colored by the medium speed
|
|
||||||
color.
|
|
||||||
|
|
||||||
Character limit: ~23 (1 line)">
|
|
||||||
Medium speed
|
|
||||||
</string>
|
|
||||||
<string name="settings_display_track_color_fixed_medium_summary"
|
|
||||||
translation_description="In the 'Display' settings, under the 'Fixed thresholds' configurations,
|
|
||||||
the summary for the 'Medium speed' option explaining that it sets a cutoff speed
|
|
||||||
for the medium speed color.">
|
|
||||||
Medium speed top value.
|
|
||||||
</string>
|
|
||||||
<string name="settings_display_track_color_fixed_slow"
|
|
||||||
translation_description="In the 'Display' settings, under the 'Fixed thresholds' configurations,
|
|
||||||
the option for configuring the slow speed threshold. Thus any speed lower than the threshold
|
|
||||||
will be colored by the slow speed color.
|
|
||||||
|
|
||||||
Character limit: ~23 (1 line)">
|
|
||||||
Slow speed
|
|
||||||
</string>
|
|
||||||
<string name="settings_display_track_color_fixed_slow_summary"
|
|
||||||
translation_description="In the 'Display' settings, under the 'Fixed thresholds' configurations,
|
|
||||||
the summary for the 'Slow speed' option explaining that it sets a cutoff speed for
|
|
||||||
the slow speed color.">
|
|
||||||
Slow speed top value.
|
|
||||||
</string>
|
|
||||||
<string name="settings_display_track_color_single"
|
|
||||||
translation_description="In the 'Display' settings, for the 'Color mode' dropdown, the
|
|
||||||
option to use a single color for all speeds.
|
|
||||||
|
|
||||||
Character limit: ~21 (1 line)">
|
|
||||||
Single color
|
Single color
|
||||||
</string>
|
</string>
|
||||||
<string name="settings_display_track_color_summary"
|
<string name="settings_map_track_color_mode_summary"
|
||||||
translation_description="In the 'Display' settings, the summary for the 'Color mode'
|
translation_description="In the 'Map' settings, the summary for the 'Track color mode' option
|
||||||
dropdown explaining that it configures how colors are used to color a track based on
|
explaining that it configures how colors are used to color a track based on slow, medium, and
|
||||||
slow, medium, and fast speed.">
|
fast speed.">
|
||||||
The way to color a track based on slow, medium, and fast speed.
|
The way to color a track based on slow, medium, and fast speed.
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
|
<!-- Settings Others -->
|
||||||
<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.">
|
||||||
@@ -2281,7 +2244,7 @@ limitations under the License.
|
|||||||
%1$.2f: a float number. E.g., '2.22'">
|
%1$.2f: a float number. E.g., '2.22'">
|
||||||
%1$.2f km
|
%1$.2f km
|
||||||
</string>
|
</string>
|
||||||
<string name="value_float_kilometer_hour"
|
<string name="value_float_kilometer_hour"
|
||||||
translation_description="Display a float value in kilometers per hour (km/h).
|
translation_description="Display a float value in kilometers per hour (km/h).
|
||||||
|
|
||||||
%1$.2f: a float number. E.g., '2.22'">
|
%1$.2f: a float number. E.g., '2.22'">
|
||||||
@@ -2352,6 +2315,12 @@ limitations under the License.
|
|||||||
%1$d: an integer value. E.g., '2'">
|
%1$d: an integer value. E.g., '2'">
|
||||||
%1$d km
|
%1$d km
|
||||||
</string>
|
</string>
|
||||||
|
<string name="value_integer_kilometer_hour"
|
||||||
|
translation_description="Display an integer value in kilometers per hour (km/h).
|
||||||
|
|
||||||
|
%1$d: an integer value. E.g., '2'">
|
||||||
|
%1$d km/h
|
||||||
|
</string>
|
||||||
<string name="value_integer_meter"
|
<string name="value_integer_meter"
|
||||||
translation_description="In a setting picker, the string format to display an integer value in
|
translation_description="In a setting picker, the string format to display an integer value in
|
||||||
meters (m).
|
meters (m).
|
||||||
@@ -2387,6 +2356,12 @@ limitations under the License.
|
|||||||
%1$d: an integer value. E.g., '2'">
|
%1$d: an integer value. E.g., '2'">
|
||||||
%1$d mi
|
%1$d mi
|
||||||
</string>
|
</string>
|
||||||
|
<string name="value_integer_mile_hour"
|
||||||
|
translation_description="Display an integer value in miles per hour (mi/h).
|
||||||
|
|
||||||
|
%1$d: an integer value. E.g., '2'">
|
||||||
|
%1$d mi/h
|
||||||
|
</string>
|
||||||
<string name="value_integer_minute"
|
<string name="value_integer_minute"
|
||||||
translation_description="In a setting picker, the string format to display an integer value in
|
translation_description="In a setting picker, the string format to display an integer value in
|
||||||
minutes (min).
|
minutes (min).
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 2012 Google Inc.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:title="@string/track_detail_map_tab" >
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="@string/settings_map_track_color_mode_single_value"
|
||||||
|
android:entries="@array/track_color_mode_options"
|
||||||
|
android:entryValues="@array/track_color_mode_values"
|
||||||
|
android:key="@string/track_color_mode_key"
|
||||||
|
android:summary="@string/settings_map_track_color_mode_summary"
|
||||||
|
android:title="@string/settings_map_track_color_mode" />
|
||||||
|
<PreferenceCategory android:title="@string/settings_map_track_color_mode_fixed" >
|
||||||
|
<EditTextPreference
|
||||||
|
android:imeOptions="actionDone"
|
||||||
|
android:inputType="number"
|
||||||
|
android:key="@string/settings_map_slow_display_key"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/settings_map_slow" >
|
||||||
|
</EditTextPreference>
|
||||||
|
<EditTextPreference
|
||||||
|
android:imeOptions="actionDone"
|
||||||
|
android:inputType="number"
|
||||||
|
android:key="@string/settings_map_medium_display_key"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/settings_map_medium" >
|
||||||
|
</EditTextPreference>
|
||||||
|
</PreferenceCategory>
|
||||||
|
<PreferenceCategory android:title="@string/settings_map_track_color_mode_dynamic" >
|
||||||
|
<EditTextPreference
|
||||||
|
android:imeOptions="actionDone"
|
||||||
|
android:inputType="number"
|
||||||
|
android:key="@string/settings_map_percentage_display_key"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/settings_map_percentage" >
|
||||||
|
</EditTextPreference>
|
||||||
|
</PreferenceCategory>
|
||||||
|
</PreferenceScreen>
|
||||||
@@ -15,87 +15,35 @@ 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/menu_settings">
|
android:title="@string/menu_settings" >
|
||||||
|
<Preference
|
||||||
<!-- Display settings -->
|
android:key="@string/settings_map_key"
|
||||||
<PreferenceScreen android:title="@string/settings_display">
|
android:persistent="false"
|
||||||
<ListPreference android:key="@string/track_color_mode_key"
|
android:title="@string/track_detail_map_tab" />
|
||||||
android:title="@string/settings_display_track_color"
|
|
||||||
android:summary="@string/settings_display_track_color_summary"
|
|
||||||
android:entries="@array/display_track_color_options"
|
|
||||||
android:entryValues="@array/display_track_color_values"
|
|
||||||
android:defaultValue="@string/display_track_color_value_none"/>
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/settings_display_track_color_fixed"
|
|
||||||
android:key="@string/track_color_mode_fixed_speed_options_key">
|
|
||||||
<EditTextPreference android:key="@string/track_color_mode_fixed_speed_slow_key"
|
|
||||||
android:title="@string/settings_display_track_color_fixed_slow"
|
|
||||||
android:summary="@string/settings_display_track_color_fixed_slow_summary"
|
|
||||||
android:defaultValue="@string/color_mode_fixed_slow_default"
|
|
||||||
android:inputType="number"
|
|
||||||
android:maxLength="3">
|
|
||||||
</EditTextPreference>
|
|
||||||
|
|
||||||
<EditTextPreference android:key="@string/track_color_mode_fixed_speed_slow_display_key"
|
|
||||||
android:title="@string/settings_display_track_color_fixed_slow"
|
|
||||||
android:summary="@string/settings_display_track_color_fixed_slow_summary"
|
|
||||||
android:defaultValue="@string/color_mode_fixed_slow_default"
|
|
||||||
android:inputType="number"
|
|
||||||
android:maxLength="3">
|
|
||||||
</EditTextPreference>
|
|
||||||
|
|
||||||
<EditTextPreference android:key="@string/track_color_mode_fixed_speed_medium_key"
|
|
||||||
android:title="@string/settings_display_track_color_fixed_medium"
|
|
||||||
android:summary="@string/settings_display_track_color_fixed_medium_summary"
|
|
||||||
android:defaultValue="@string/color_mode_fixed_medium_default"
|
|
||||||
android:inputType="number"
|
|
||||||
android:maxLength="3">
|
|
||||||
</EditTextPreference>
|
|
||||||
|
|
||||||
<EditTextPreference android:key="@string/track_color_mode_fixed_speed_medium_display_key"
|
|
||||||
android:title="@string/settings_display_track_color_fixed_medium"
|
|
||||||
android:summary="@string/settings_display_track_color_fixed_medium_summary"
|
|
||||||
android:defaultValue="@string/color_mode_fixed_medium_default"
|
|
||||||
android:inputType="number"
|
|
||||||
android:maxLength="3">
|
|
||||||
</EditTextPreference>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/settings_display_track_color_dynamic">
|
|
||||||
<EditTextPreference android:key="@string/track_color_mode_dynamic_speed_variation_key"
|
|
||||||
android:title="@string/settings_display_track_color_dynamic_medium"
|
|
||||||
android:summary="@string/settings_display_track_color_dynamic_medium_summary"
|
|
||||||
android:defaultValue="@string/color_mode_dynamic_percentage_default"
|
|
||||||
android:inputType="number"
|
|
||||||
android:maxLength="2">
|
|
||||||
</EditTextPreference>
|
|
||||||
</PreferenceCategory>
|
|
||||||
</PreferenceScreen>
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="@string/settings_stats_key"
|
android:key="@string/settings_stats_key"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/track_detail_stats_tab" />
|
android:title="@string/track_detail_stats_tab" />
|
||||||
<Preference
|
<Preference
|
||||||
android:title="@string/settings_recording"
|
android:key="@string/settings_recording_key"
|
||||||
android:key="@string/settings_recording_key"
|
android:persistent="false"
|
||||||
android:persistent="false" />
|
android:title="@string/settings_recording" />
|
||||||
<Preference
|
<Preference
|
||||||
android:title="@string/settings_sharing"
|
android:key="@string/settings_sharing_key"
|
||||||
android:key="@string/settings_sharing_key"
|
android:persistent="false"
|
||||||
android:persistent="false" />
|
android:title="@string/settings_sharing" />
|
||||||
<Preference
|
|
||||||
android:title="@string/settings_sensor"
|
|
||||||
android:key="@string/settings_sensor_key"
|
|
||||||
android:persistent="false" />
|
|
||||||
<Preference
|
<Preference
|
||||||
android:title="@string/settings_backup"
|
android:key="@string/settings_sensor_key"
|
||||||
android:key="@string/settings_backup_key"
|
android:persistent="false"
|
||||||
android:persistent="false" />
|
android:title="@string/settings_sensor" />
|
||||||
|
<Preference
|
||||||
|
android:key="@string/settings_backup_key"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/settings_backup" />
|
||||||
<!-- Reset to defaults -->
|
<!-- Reset to defaults -->
|
||||||
<Preference
|
<Preference
|
||||||
android:title="@string/settings_reset"
|
android:key="@string/reset_key"
|
||||||
android:key="@string/reset_key"
|
android:persistent="false"
|
||||||
android:summary="@string/settings_reset_summary"
|
android:summary="@string/settings_reset_summary"
|
||||||
android:persistent="false" />
|
android:title="@string/settings_reset" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
@@ -23,6 +23,7 @@ import com.google.android.apps.mytracks.maps.TrackPathPainterFactory;
|
|||||||
import com.google.android.apps.mytracks.maps.TrackPathUtilities;
|
import com.google.android.apps.mytracks.maps.TrackPathUtilities;
|
||||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||||
import com.google.android.apps.mytracks.util.LocationUtils;
|
import com.google.android.apps.mytracks.util.LocationUtils;
|
||||||
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
import com.google.android.apps.mytracks.util.UnitConversions;
|
import com.google.android.apps.mytracks.util.UnitConversions;
|
||||||
import com.google.android.maps.GeoPoint;
|
import com.google.android.maps.GeoPoint;
|
||||||
import com.google.android.maps.MapView;
|
import com.google.android.maps.MapView;
|
||||||
@@ -462,10 +463,8 @@ public class MapOverlay extends Overlay implements OnSharedPreferenceChangeListe
|
|||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
Log.d(TAG, "MapOverlay: onSharedPreferences changed " + key);
|
Log.d(TAG, "MapOverlay: onSharedPreferences changed " + key);
|
||||||
if (key != null) {
|
if (PreferencesUtils.getKey(context, R.string.track_color_mode_key).equals(key)) {
|
||||||
if (key.equals(context.getString(R.string.track_color_mode_key))) {
|
trackPathPainter = TrackPathPainterFactory.getTrackPathPainter(context);
|
||||||
trackPathPainter = TrackPathPainterFactory.getTrackPathPainter(context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-30
@@ -42,7 +42,6 @@ public class DynamicSpeedTrackPathDescriptor implements TrackPathDescriptor,
|
|||||||
private int slowSpeed;
|
private int slowSpeed;
|
||||||
private int normalSpeed;
|
private int normalSpeed;
|
||||||
private int speedMargin;
|
private int speedMargin;
|
||||||
private final int speedMarginDefault;
|
|
||||||
private double averageMovingSpeed;
|
private double averageMovingSpeed;
|
||||||
private final Context context;
|
private final Context context;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -50,29 +49,12 @@ public class DynamicSpeedTrackPathDescriptor implements TrackPathDescriptor,
|
|||||||
|
|
||||||
public DynamicSpeedTrackPathDescriptor(Context context) {
|
public DynamicSpeedTrackPathDescriptor(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
speedMarginDefault = Integer.parseInt(context
|
|
||||||
.getString(R.string.color_mode_dynamic_percentage_default));
|
|
||||||
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME,
|
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME,
|
||||||
Context.MODE_PRIVATE);
|
Context.MODE_PRIVATE);
|
||||||
|
|
||||||
if (prefs == null) {
|
|
||||||
speedMargin = speedMarginDefault;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
speedMargin = getSpeedMargin(prefs);
|
speedMargin = PreferencesUtils.getInt(context, R.string.track_color_mode_percentage_key,
|
||||||
}
|
PreferencesUtils.TRACK_COLOR_MODE_PERCENTAGE_DEFAULT);
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
int getSpeedMargin(SharedPreferences sharedPreferences) {
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(sharedPreferences.getString(
|
|
||||||
context.getString(R.string.track_color_mode_dynamic_speed_variation_key),
|
|
||||||
Integer.toString(speedMarginDefault)));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return speedMarginDefault;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,17 +80,10 @@ public class DynamicSpeedTrackPathDescriptor implements TrackPathDescriptor,
|
|||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
Log.d(TAG, "DynamicSpeedTrackPathDescriptor: onSharedPreferences changed " + key);
|
Log.d(TAG, "DynamicSpeedTrackPathDescriptor: onSharedPreferences changed " + key);
|
||||||
if (key == null
|
if (PreferencesUtils.getKey(context, R.string.track_color_mode_percentage_key).equals(key)) {
|
||||||
|| !key.equals(context.getString(R.string.track_color_mode_dynamic_speed_variation_key))) { return; }
|
speedMargin = PreferencesUtils.getInt(context, R.string.track_color_mode_percentage_key,
|
||||||
SharedPreferences prefs = context.getSharedPreferences(Constants.SETTINGS_NAME,
|
PreferencesUtils.TRACK_COLOR_MODE_PERCENTAGE_DEFAULT);
|
||||||
Context.MODE_PRIVATE);
|
|
||||||
|
|
||||||
if (prefs == null) {
|
|
||||||
speedMargin = speedMarginDefault;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
speedMargin = getSpeedMargin(prefs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+25
-62
@@ -13,104 +13,67 @@
|
|||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.android.apps.mytracks.maps;
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
import static com.google.android.apps.mytracks.Constants.TAG;
|
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A fixed speed path descriptor.
|
* A fixed speed path descriptor.
|
||||||
*
|
*
|
||||||
* @author Vangelis S.
|
* @author Vangelis S.
|
||||||
*/
|
*/
|
||||||
public class FixedSpeedTrackPathDescriptor implements TrackPathDescriptor, OnSharedPreferenceChangeListener {
|
public class FixedSpeedTrackPathDescriptor
|
||||||
|
implements TrackPathDescriptor, OnSharedPreferenceChangeListener {
|
||||||
private int slowSpeed;
|
private int slowSpeed;
|
||||||
private int normalSpeed;
|
private int normalSpeed;
|
||||||
private final int slowDefault;
|
|
||||||
private final int normalDefault;
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
public FixedSpeedTrackPathDescriptor(Context context) {
|
public FixedSpeedTrackPathDescriptor(Context context) {
|
||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
slowDefault = Integer.parseInt(context.getString(R.string.color_mode_fixed_slow_default));
|
|
||||||
normalDefault = Integer.parseInt(context.getString(R.string.color_mode_fixed_medium_default));
|
SharedPreferences sharedPreferences = context.getSharedPreferences(
|
||||||
|
|
||||||
SharedPreferences prefs = context.getSharedPreferences(
|
|
||||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||||
if (prefs == null) {
|
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||||
slowSpeed = slowDefault;
|
|
||||||
normalSpeed = normalDefault;
|
slowSpeed = PreferencesUtils.getInt(context, R.string.track_color_mode_slow_key,
|
||||||
return;
|
PreferencesUtils.TRACK_COLOR_MODE_SLOW_DEFAULT);
|
||||||
}
|
normalSpeed = PreferencesUtils.getInt(context, R.string.track_color_mode_medium_key,
|
||||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
PreferencesUtils.TRACK_COLOR_MODE_MEDIUM_DEFAULT);
|
||||||
|
|
||||||
try {
|
|
||||||
slowSpeed = Integer.parseInt(prefs.getString(context.getString(
|
|
||||||
R.string.track_color_mode_fixed_speed_slow_key), Integer.toString(slowDefault)));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
slowSpeed = slowDefault;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
normalSpeed = Integer.parseInt(prefs.getString(context.getString(
|
|
||||||
R.string.track_color_mode_fixed_speed_medium_key), Integer.toString(normalDefault)));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
normalSpeed = normalDefault;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the slow speed for reference.
|
* Gets the slow speed for reference.
|
||||||
|
*
|
||||||
* @return The speed limit considered as slow.
|
* @return The speed limit considered as slow.
|
||||||
*/
|
*/
|
||||||
public int getSlowSpeed() {
|
public int getSlowSpeed() {
|
||||||
return slowSpeed;
|
return slowSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the normal speed for reference.
|
* Gets the normal speed for reference.
|
||||||
|
*
|
||||||
* @return The speed limit considered as normal.
|
* @return The speed limit considered as normal.
|
||||||
*/
|
*/
|
||||||
public int getNormalSpeed() {
|
public int getNormalSpeed() {
|
||||||
return normalSpeed;
|
return normalSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
Log.d(TAG, "FixedSpeedTrackPathDescriptor: onSharedPreferences changed " + key);
|
if (PreferencesUtils.getKey(context, R.string.track_color_mode_slow_key).equals(key)) {
|
||||||
if (key == null
|
slowSpeed = PreferencesUtils.getInt(context, R.string.track_color_mode_slow_key,
|
||||||
|| (!key.equals(context.getString(R.string.track_color_mode_fixed_speed_slow_key))
|
PreferencesUtils.TRACK_COLOR_MODE_SLOW_DEFAULT);
|
||||||
&& !key.equals(context.getString(R.string.track_color_mode_fixed_speed_medium_key)))) {
|
} else if (PreferencesUtils.getKey(context, R.string.track_color_mode_medium_key).equals(key)) {
|
||||||
return;
|
normalSpeed = PreferencesUtils.getInt(context, R.string.track_color_mode_medium_key,
|
||||||
}
|
PreferencesUtils.TRACK_COLOR_MODE_MEDIUM_DEFAULT);
|
||||||
SharedPreferences prefs = context.getSharedPreferences(
|
|
||||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
|
||||||
if (prefs == null) {
|
|
||||||
slowSpeed = slowDefault;
|
|
||||||
normalSpeed = normalDefault;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
slowSpeed = Integer.parseInt(prefs.getString(context.getString(
|
|
||||||
R.string.track_color_mode_fixed_speed_slow_key), Integer.toString(slowDefault)));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
slowSpeed = slowDefault;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
normalSpeed = Integer.parseInt(prefs.getString(context.getString(
|
|
||||||
R.string.track_color_mode_fixed_speed_medium_key), Integer.toString(normalDefault)));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
normalSpeed = normalDefault;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,10 @@ package com.google.android.apps.mytracks.maps;
|
|||||||
|
|
||||||
import static com.google.android.apps.mytracks.Constants.TAG;
|
import static com.google.android.apps.mytracks.Constants.TAG;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,26 +39,18 @@ public class TrackPathPainterFactory {
|
|||||||
* @return The TrackPathPainter that corresponds to the track color mode setting.
|
* @return The TrackPathPainter that corresponds to the track color mode setting.
|
||||||
*/
|
*/
|
||||||
public static TrackPathPainter getTrackPathPainter(Context context) {
|
public static TrackPathPainter getTrackPathPainter(Context context) {
|
||||||
SharedPreferences prefs = context.getSharedPreferences(
|
String trackColorMode = PreferencesUtils.getString(context, R.string.track_color_mode_key,
|
||||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
context.getString(R.string.settings_map_track_color_mode_single_value));
|
||||||
if (prefs == null) {
|
Log.i(TAG, "Creating track path painter of type: " + trackColorMode);
|
||||||
return new SingleColorTrackPathPainter(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
String colorMode = prefs.getString(context.getString(R.string.track_color_mode_key), null);
|
|
||||||
Log.i(TAG, "Creating track path painter of type: " + colorMode);
|
|
||||||
|
|
||||||
if (colorMode == null
|
if (context.getString(R.string.settings_map_track_color_mode_fixed_value)
|
||||||
|| colorMode.equals(context.getString(R.string.display_track_color_value_none))) {
|
.equals(trackColorMode)) {
|
||||||
return new SingleColorTrackPathPainter(context);
|
return new DynamicSpeedTrackPathPainter(context, new FixedSpeedTrackPathDescriptor(context));
|
||||||
} else if (colorMode.equals(context.getString(R.string.display_track_color_value_fixed))) {
|
} else if (context.getString(R.string.settings_map_track_color_mode_dynamic_value)
|
||||||
return new DynamicSpeedTrackPathPainter(context,
|
.equals(trackColorMode)) {
|
||||||
new FixedSpeedTrackPathDescriptor(context));
|
return new DynamicSpeedTrackPathPainter(context, new DynamicSpeedTrackPathDescriptor(
|
||||||
} else if (colorMode.equals(context.getString(R.string.display_track_color_value_dynamic))) {
|
context));
|
||||||
return new DynamicSpeedTrackPathPainter(context,
|
|
||||||
new DynamicSpeedTrackPathDescriptor(context));
|
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Using default track path painter. Unrecognized painter: " + colorMode);
|
|
||||||
return new SingleColorTrackPathPainter(context);
|
return new SingleColorTrackPathPainter(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,274 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012 Google Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.google.android.apps.mytracks.settings;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
|
import com.google.android.apps.mytracks.util.UnitConversions;
|
||||||
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.EditTextPreference;
|
||||||
|
import android.preference.ListPreference;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.preference.Preference.OnPreferenceChangeListener;
|
||||||
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An activity for accessing map settings.
|
||||||
|
*
|
||||||
|
* @author Jimmy Shih
|
||||||
|
*/
|
||||||
|
public class MapSettingsActivity extends AbstractSettingsActivity {
|
||||||
|
|
||||||
|
private static final String TAG = MapSettingsActivity.class.getSimpleName();
|
||||||
|
|
||||||
|
private EditTextPreference slowEditTextPreference;
|
||||||
|
private EditTextPreference mediumEditTextPreference;
|
||||||
|
private EditTextPreference percentageEditTextPreference;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle bundle) {
|
||||||
|
super.onCreate(bundle);
|
||||||
|
addPreferencesFromResource(R.xml.map_settings);
|
||||||
|
|
||||||
|
ListPreference trackColorModeListPreference = (ListPreference) findPreference(
|
||||||
|
getString(R.string.track_color_mode_key));
|
||||||
|
trackColorModeListPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
updateUiByTrackColorMode((String) newValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
updateUiByTrackColorMode(trackColorModeListPreference.getValue());
|
||||||
|
|
||||||
|
slowEditTextPreference = (EditTextPreference) findPreference(
|
||||||
|
getString(R.string.settings_map_slow_display_key));
|
||||||
|
configureSpeedEditTextPreference(R.string.track_color_mode_slow_key);
|
||||||
|
|
||||||
|
mediumEditTextPreference = (EditTextPreference) findPreference(
|
||||||
|
getString(R.string.settings_map_medium_display_key));
|
||||||
|
configureSpeedEditTextPreference(R.string.track_color_mode_medium_key);
|
||||||
|
|
||||||
|
percentageEditTextPreference = (EditTextPreference) findPreference(
|
||||||
|
getString(R.string.settings_map_percentage_display_key));
|
||||||
|
configurePercentageEditTextPreference();
|
||||||
|
updatePercentageSummary();
|
||||||
|
|
||||||
|
configureImeActionDone(slowEditTextPreference);
|
||||||
|
configureImeActionDone(mediumEditTextPreference);
|
||||||
|
configureImeActionDone(percentageEditTextPreference);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the speed edit text preference.
|
||||||
|
*
|
||||||
|
* @param keyId the key id
|
||||||
|
*/
|
||||||
|
private void configureSpeedEditTextPreference(final int keyId) {
|
||||||
|
final EditTextPreference editTextPreference = keyId == R.string.track_color_mode_slow_key ? slowEditTextPreference
|
||||||
|
: mediumEditTextPreference;
|
||||||
|
editTextPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
storeSpeedValue(keyId, (String) newValue);
|
||||||
|
updateSpeedSummary(keyId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
editTextPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
int value = getSpeedDisplayValue(keyId);
|
||||||
|
((EditTextPreference) preference).getEditText().setText(String.valueOf(value));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the percentage edit text preference.
|
||||||
|
*/
|
||||||
|
private void configurePercentageEditTextPreference() {
|
||||||
|
percentageEditTextPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
String displayValue = (String) newValue;
|
||||||
|
int value;
|
||||||
|
try {
|
||||||
|
value = Integer.parseInt(displayValue);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Log.e(TAG, "invalid value " + displayValue);
|
||||||
|
value = PreferencesUtils.TRACK_COLOR_MODE_PERCENTAGE_DEFAULT;
|
||||||
|
}
|
||||||
|
if (value < 0) {
|
||||||
|
value = PreferencesUtils.TRACK_COLOR_MODE_PERCENTAGE_DEFAULT;
|
||||||
|
}
|
||||||
|
PreferencesUtils.setInt(
|
||||||
|
MapSettingsActivity.this, R.string.track_color_mode_percentage_key, value);
|
||||||
|
updatePercentageSummary();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
percentageEditTextPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
int value = PreferencesUtils.getInt(
|
||||||
|
MapSettingsActivity.this, R.string.track_color_mode_percentage_key,
|
||||||
|
PreferencesUtils.TRACK_COLOR_MODE_PERCENTAGE_DEFAULT);
|
||||||
|
((EditTextPreference) preference).getEditText().setText(String.valueOf(value));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the IME action done.
|
||||||
|
*
|
||||||
|
* @param editTextPreference the edit text preference
|
||||||
|
*/
|
||||||
|
private void configureImeActionDone(final EditTextPreference editTextPreference) {
|
||||||
|
editTextPreference.getEditText()
|
||||||
|
.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||||
|
Dialog dialog = editTextPreference.getDialog();
|
||||||
|
editTextPreference.onClick(dialog, Dialog.BUTTON_POSITIVE);
|
||||||
|
dialog.dismiss();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
updateSpeedSummary(R.string.track_color_mode_slow_key);
|
||||||
|
updateSpeedSummary(R.string.track_color_mode_medium_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the UI by the track color mode.
|
||||||
|
*
|
||||||
|
* @param trackColorMode the track color mode
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
private void updateUiByTrackColorMode(String trackColorMode) {
|
||||||
|
boolean isFixedValue = trackColorMode.equals(
|
||||||
|
getString(R.string.settings_map_track_color_mode_fixed_value));
|
||||||
|
boolean isDynamicValue = trackColorMode.equals(
|
||||||
|
getString(R.string.settings_map_track_color_mode_dynamic_value));
|
||||||
|
findPreference(getString(R.string.settings_map_slow_display_key)).setEnabled(isFixedValue);
|
||||||
|
findPreference(getString(R.string.settings_map_medium_display_key)).setEnabled(isFixedValue);
|
||||||
|
findPreference(getString(R.string.settings_map_percentage_display_key))
|
||||||
|
.setEnabled(isDynamicValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the speed value, always in metric units.
|
||||||
|
*
|
||||||
|
* @param keyId the key id
|
||||||
|
* @param displayValue the display value
|
||||||
|
*/
|
||||||
|
private void storeSpeedValue(int keyId, String displayValue) {
|
||||||
|
int maxValue;
|
||||||
|
int minValue;
|
||||||
|
int defaultValue;
|
||||||
|
if (keyId == R.string.track_color_mode_slow_key) {
|
||||||
|
minValue = 0;
|
||||||
|
maxValue = PreferencesUtils.getInt(this, R.string.track_color_mode_medium_key,
|
||||||
|
PreferencesUtils.TRACK_COLOR_MODE_MEDIUM_DEFAULT);
|
||||||
|
defaultValue = PreferencesUtils.TRACK_COLOR_MODE_SLOW_DEFAULT;
|
||||||
|
} else {
|
||||||
|
minValue = PreferencesUtils.getInt(
|
||||||
|
this, R.string.track_color_mode_slow_key, PreferencesUtils.TRACK_COLOR_MODE_SLOW_DEFAULT);
|
||||||
|
maxValue = Integer.MAX_VALUE;
|
||||||
|
defaultValue = PreferencesUtils.TRACK_COLOR_MODE_MEDIUM_DEFAULT;
|
||||||
|
}
|
||||||
|
int value;
|
||||||
|
try {
|
||||||
|
value = Integer.parseInt(displayValue);
|
||||||
|
if (!PreferencesUtils.getBoolean(
|
||||||
|
this, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT)) {
|
||||||
|
value = (int) (value * UnitConversions.MI_TO_KM);
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Log.e(TAG, "invalid value " + displayValue);
|
||||||
|
value = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value > maxValue) {
|
||||||
|
value = maxValue;
|
||||||
|
}
|
||||||
|
if (value < minValue) {
|
||||||
|
value = minValue;
|
||||||
|
}
|
||||||
|
PreferencesUtils.setInt(this, keyId, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the speed display value, in metric or imperial depending on the preferred
|
||||||
|
* units.
|
||||||
|
*
|
||||||
|
* @param keyId the key id
|
||||||
|
*/
|
||||||
|
private int getSpeedDisplayValue(int keyId) {
|
||||||
|
int defaultValue = keyId == R.string.track_color_mode_slow_key ? PreferencesUtils.TRACK_COLOR_MODE_SLOW_DEFAULT
|
||||||
|
: PreferencesUtils.TRACK_COLOR_MODE_MEDIUM_DEFAULT;
|
||||||
|
int value = PreferencesUtils.getInt(this, keyId, defaultValue);
|
||||||
|
if (!PreferencesUtils.getBoolean(
|
||||||
|
this, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT)) {
|
||||||
|
value = (int) (value * UnitConversions.KM_TO_MI);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the speed summary.
|
||||||
|
*
|
||||||
|
* @param keyId the key id
|
||||||
|
*/
|
||||||
|
private void updateSpeedSummary(int keyId) {
|
||||||
|
EditTextPreference editTextPreference = keyId == R.string.track_color_mode_slow_key ? slowEditTextPreference
|
||||||
|
: mediumEditTextPreference;
|
||||||
|
boolean metric = PreferencesUtils.getBoolean(
|
||||||
|
this, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT);
|
||||||
|
int displayValue = getSpeedDisplayValue(keyId);
|
||||||
|
editTextPreference.setSummary(getString(metric ? R.string.value_integer_kilometer_hour
|
||||||
|
: R.string.value_integer_mile_hour, displayValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the percentage summary.
|
||||||
|
*/
|
||||||
|
private void updatePercentageSummary() {
|
||||||
|
int value = PreferencesUtils.getInt(
|
||||||
|
MapSettingsActivity.this, R.string.track_color_mode_percentage_key,
|
||||||
|
PreferencesUtils.TRACK_COLOR_MODE_PERCENTAGE_DEFAULT);
|
||||||
|
percentageEditTextPreference.setSummary(getString(R.string.settings_map_percentage_summary) + "\n"
|
||||||
|
+ getString(R.string.value_integer_percent, value));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,11 +19,9 @@ package com.google.android.apps.mytracks.settings;
|
|||||||
import static com.google.android.apps.mytracks.Constants.TAG;
|
import static com.google.android.apps.mytracks.Constants.TAG;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
|
||||||
import com.google.android.apps.mytracks.util.DialogUtils;
|
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.apps.mytracks.util.PreferencesUtils;
|
||||||
import com.google.android.apps.mytracks.util.UnitConversions;
|
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
@@ -31,14 +29,9 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.Editor;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.EditTextPreference;
|
|
||||||
import android.preference.ListPreference;
|
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceChangeListener;
|
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.preference.PreferenceCategory;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -58,19 +51,26 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
|||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
|
|
||||||
customizeTrackColorModePreferences();
|
Preference mapPreference = findPreference(getString(R.string.settings_map_key));
|
||||||
|
mapPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
Intent intent = IntentUtils.newIntent(SettingsActivity.this, MapSettingsActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Preference statsPreference = findPreference(getString(R.string.settings_stats_key));
|
Preference statsPreference = findPreference(getString(R.string.settings_stats_key));
|
||||||
statsPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
statsPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
Intent intent = IntentUtils.newIntent(
|
Intent intent = IntentUtils.newIntent(SettingsActivity.this, StatsSettingsActivity.class);
|
||||||
SettingsActivity.this, StatsSettingsActivity.class);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Preference recordingPreference = findPreference(getString(R.string.settings_recording_key));
|
Preference recordingPreference = findPreference(getString(R.string.settings_recording_key));
|
||||||
recordingPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
recordingPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -139,31 +139,6 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void customizeTrackColorModePreferences() {
|
|
||||||
ListPreference trackColorModePreference =
|
|
||||||
(ListPreference) findPreference(getString(R.string.track_color_mode_key));
|
|
||||||
trackColorModePreference.setOnPreferenceChangeListener(
|
|
||||||
new OnPreferenceChangeListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceChange(Preference preference,
|
|
||||||
Object newValue) {
|
|
||||||
updateTrackColorModeSettings((String) newValue);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
updateTrackColorModeSettings(trackColorModePreference.getValue());
|
|
||||||
|
|
||||||
setTrackColorModePreferenceListeners();
|
|
||||||
|
|
||||||
PreferenceCategory speedOptionsCategory = (PreferenceCategory) findPreference(
|
|
||||||
getString(R.string.track_color_mode_fixed_speed_options_key));
|
|
||||||
|
|
||||||
speedOptionsCategory.removePreference(
|
|
||||||
findPreference(getString(R.string.track_color_mode_fixed_speed_slow_key)));
|
|
||||||
speedOptionsCategory.removePreference(
|
|
||||||
findPreference(getString(R.string.track_color_mode_fixed_speed_medium_key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -175,20 +150,6 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
|||||||
: R.string.settings_reset_summary);
|
: R.string.settings_reset_summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTrackColorModeSettings(String trackColorMode) {
|
|
||||||
boolean usesFixedSpeed =
|
|
||||||
trackColorMode.equals(getString(R.string.display_track_color_value_fixed));
|
|
||||||
boolean usesDynamicSpeed =
|
|
||||||
trackColorMode.equals(getString(R.string.display_track_color_value_dynamic));
|
|
||||||
|
|
||||||
findPreference(getString(R.string.track_color_mode_fixed_speed_slow_display_key))
|
|
||||||
.setEnabled(usesFixedSpeed);
|
|
||||||
findPreference(getString(R.string.track_color_mode_fixed_speed_medium_display_key))
|
|
||||||
.setEnabled(usesFixedSpeed);
|
|
||||||
findPreference(getString(R.string.track_color_mode_dynamic_speed_variation_key))
|
|
||||||
.setEnabled(usesDynamicSpeed);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Callback for when user confirms resetting all settings. */
|
/** Callback for when user confirms resetting all settings. */
|
||||||
private void onResetPreferencesConfirmed() {
|
private void onResetPreferencesConfirmed() {
|
||||||
// Change preferences in a separate thread.
|
// Change preferences in a separate thread.
|
||||||
@@ -221,84 +182,4 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
|||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the given edit text preference text.
|
|
||||||
* If the units are not metric convert the value before displaying.
|
|
||||||
*/
|
|
||||||
private void viewTrackColorModeSettings(EditTextPreference preference, int id) {
|
|
||||||
if (PreferencesUtils.getBoolean(
|
|
||||||
this, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Convert miles/h to km/h
|
|
||||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
|
||||||
String metricspeed = prefs.getString(getString(id), null);
|
|
||||||
int englishspeed;
|
|
||||||
try {
|
|
||||||
englishspeed = (int) (Double.parseDouble(metricspeed) * UnitConversions.KM_TO_MI);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
englishspeed = 0;
|
|
||||||
}
|
|
||||||
preference.getEditText().setText(String.valueOf(englishspeed));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves the given edit text preference value.
|
|
||||||
* If the units are not metric convert the value before saving.
|
|
||||||
*/
|
|
||||||
private void validateTrackColorModeSettings(String newValue, int id) {
|
|
||||||
String metricspeed;
|
|
||||||
if (PreferencesUtils.getBoolean(
|
|
||||||
this, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT)) {
|
|
||||||
metricspeed = newValue;
|
|
||||||
} else {
|
|
||||||
// Convert miles/h to km/h
|
|
||||||
try {
|
|
||||||
metricspeed = String.valueOf(
|
|
||||||
(int) (Double.parseDouble(newValue) * UnitConversions.MI_TO_KM));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
metricspeed = "0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
|
||||||
Editor editor = prefs.edit();
|
|
||||||
editor.putString(getString(id), metricspeed);
|
|
||||||
ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(editor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the TrackColorMode preference listeners.
|
|
||||||
*/
|
|
||||||
private void setTrackColorModePreferenceListeners() {
|
|
||||||
setTrackColorModePreferenceListener(R.string.track_color_mode_fixed_speed_slow_display_key,
|
|
||||||
R.string.track_color_mode_fixed_speed_slow_key);
|
|
||||||
setTrackColorModePreferenceListener(R.string.track_color_mode_fixed_speed_medium_display_key,
|
|
||||||
R.string.track_color_mode_fixed_speed_medium_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a TrackColorMode preference listener.
|
|
||||||
*/
|
|
||||||
private void setTrackColorModePreferenceListener(int displayKey, final int metricKey) {
|
|
||||||
EditTextPreference trackColorModePreference =
|
|
||||||
(EditTextPreference) findPreference(getString(displayKey));
|
|
||||||
trackColorModePreference.setOnPreferenceChangeListener(
|
|
||||||
new OnPreferenceChangeListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceChange(Preference preference,
|
|
||||||
Object newValue) {
|
|
||||||
validateTrackColorModeSettings((String) newValue, metricKey);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
trackColorModePreference.setOnPreferenceClickListener(
|
|
||||||
new OnPreferenceClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
viewTrackColorModeSettings((EditTextPreference) preference, metricKey);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ public class PreferencesUtils {
|
|||||||
public static final boolean STATS_SHOW_GRADE_DEFAULT = false;
|
public static final boolean STATS_SHOW_GRADE_DEFAULT = false;
|
||||||
public static final boolean STATS_USE_TOTAL_TIME_DEFAULT = true;
|
public static final boolean STATS_USE_TOTAL_TIME_DEFAULT = true;
|
||||||
|
|
||||||
|
public static final int TRACK_COLOR_MODE_MEDIUM_DEFAULT = 15;
|
||||||
|
public static final int TRACK_COLOR_MODE_PERCENTAGE_DEFAULT = 25;
|
||||||
|
public static final int TRACK_COLOR_MODE_SLOW_DEFAULT = 9;
|
||||||
|
|
||||||
private PreferencesUtils() {}
|
private PreferencesUtils() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+26
-47
@@ -13,6 +13,7 @@
|
|||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.android.apps.mytracks.maps;
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
@@ -21,26 +22,23 @@ import com.google.android.maps.mytracks.R;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.Editor;
|
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the {@link DynamicSpeedTrackPathDescriptor}.
|
* Tests for the {@link DynamicSpeedTrackPathDescriptor}.
|
||||||
*
|
*
|
||||||
* @author Youtao Liu
|
* @author Youtao Liu
|
||||||
*/
|
*/
|
||||||
public class DynamicSpeedTrackPathDescriptorTest extends AndroidTestCase {
|
public class DynamicSpeedTrackPathDescriptorTest extends AndroidTestCase {
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private SharedPreferences sharedPreferences;
|
private SharedPreferences sharedPreferences;
|
||||||
private Editor sharedPreferencesEditor;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
context = getContext();
|
context = getContext();
|
||||||
sharedPreferences = context.getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
sharedPreferences = context.getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||||
sharedPreferencesEditor = sharedPreferences.edit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,96 +46,77 @@ public class DynamicSpeedTrackPathDescriptorTest extends AndroidTestCase {
|
|||||||
* with zero, normal and illegal value.
|
* with zero, normal and illegal value.
|
||||||
*/
|
*/
|
||||||
public void testGetSpeedMargin() {
|
public void testGetSpeedMargin() {
|
||||||
String[] actuals = { "0", "50", "99", "" };
|
|
||||||
// The default value of speedMargin is 25.
|
// The default value of speedMargin is 25.
|
||||||
int[] expectations = { 0, 50, 99, 25 };
|
int[] expectations = { 0, 50, 99, 25 };
|
||||||
// Test
|
// Test
|
||||||
for (int i = 0; i < expectations.length; i++) {
|
for (int i = 0; i < expectations.length; i++) {
|
||||||
sharedPreferencesEditor.putString(
|
PreferencesUtils.setInt(context, R.string.track_color_mode_percentage_key, expectations[i]);
|
||||||
context.getString(R.string.track_color_mode_dynamic_speed_variation_key), actuals[i]);
|
|
||||||
sharedPreferencesEditor.commit();
|
|
||||||
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
|
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
|
||||||
context);
|
context);
|
||||||
assertEquals(expectations[i],
|
assertEquals(expectations[i], dynamicSpeedTrackPathDescriptor.getSpeedMargin());
|
||||||
dynamicSpeedTrackPathDescriptor.getSpeedMargin(sharedPreferences));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link
|
* Tests {@link DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
||||||
* DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
|
||||||
* String)} when the key is null.
|
* String)} when the key is null.
|
||||||
*/
|
*/
|
||||||
public void testOnSharedPreferenceChanged_nullKey() {
|
public void testOnSharedPreferenceChanged_nullKey() {
|
||||||
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
|
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
|
||||||
context);
|
context);
|
||||||
int speedMargin = dynamicSpeedTrackPathDescriptor.getSpeedMargin(sharedPreferences);
|
int speedMargin = dynamicSpeedTrackPathDescriptor.getSpeedMargin();
|
||||||
// Change value in shared preferences.
|
// Change value in shared preferences.
|
||||||
sharedPreferencesEditor.putString(
|
PreferencesUtils.setInt(context, R.string.track_color_mode_percentage_key, speedMargin + 2);
|
||||||
context.getString(R.string.track_color_mode_dynamic_speed_variation_key),
|
|
||||||
Integer.toString(speedMargin + 2));
|
|
||||||
sharedPreferencesEditor.commit();
|
|
||||||
|
|
||||||
dynamicSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences, null);
|
dynamicSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences, null);
|
||||||
assertEquals(speedMargin, dynamicSpeedTrackPathDescriptor.getSpeedMargin());
|
assertEquals(speedMargin, dynamicSpeedTrackPathDescriptor.getSpeedMargin());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link
|
* Tests {@link DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
||||||
* DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
|
||||||
* String)} when the key is not null, and not trackColorModeDynamicVariation.
|
* String)} when the key is not null, and not trackColorModeDynamicVariation.
|
||||||
*/
|
*/
|
||||||
public void testOnSharedPreferenceChanged_otherKey() {
|
public void testOnSharedPreferenceChanged_otherKey() {
|
||||||
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
|
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
|
||||||
context);
|
context);
|
||||||
int speedMargin = dynamicSpeedTrackPathDescriptor.getSpeedMargin(sharedPreferences);
|
int speedMargin = dynamicSpeedTrackPathDescriptor.getSpeedMargin();
|
||||||
// Change value in shared preferences.
|
// Change value in shared preferences.
|
||||||
sharedPreferencesEditor.putString(
|
PreferencesUtils.setInt(context, R.string.track_color_mode_percentage_key, speedMargin + 2);
|
||||||
context.getString(R.string.track_color_mode_dynamic_speed_variation_key),
|
|
||||||
Integer.toString(speedMargin + 2));
|
|
||||||
sharedPreferencesEditor.commit();
|
|
||||||
|
|
||||||
dynamicSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences, "anyKey");
|
dynamicSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences, "anyKey");
|
||||||
assertEquals(speedMargin, dynamicSpeedTrackPathDescriptor.getSpeedMargin());
|
assertEquals(speedMargin, dynamicSpeedTrackPathDescriptor.getSpeedMargin());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link
|
* Tests {@link DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
||||||
* DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
|
||||||
* String)} when the key is trackColorModeDynamicVariation.
|
* String)} when the key is trackColorModeDynamicVariation.
|
||||||
*/
|
*/
|
||||||
public void testOnSharedPreferenceChanged_trackColorModeDynamicVariationKey() {
|
public void testOnSharedPreferenceChanged_trackColorModeDynamicVariationKey() {
|
||||||
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
|
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
|
||||||
context);
|
context);
|
||||||
int speedMargin = dynamicSpeedTrackPathDescriptor.getSpeedMargin(sharedPreferences);
|
int speedMargin = dynamicSpeedTrackPathDescriptor.getSpeedMargin();
|
||||||
// Change value in shared preferences.
|
// Change value in shared preferences.
|
||||||
sharedPreferencesEditor.putString(
|
PreferencesUtils.setInt(context, R.string.track_color_mode_percentage_key, speedMargin + 2);
|
||||||
"trackColorModeDynamicVariation",
|
|
||||||
Integer.toString(speedMargin + 2));
|
|
||||||
sharedPreferencesEditor.commit();
|
|
||||||
|
|
||||||
dynamicSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences,
|
dynamicSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences,
|
||||||
"trackColorModeDynamicVariation");
|
PreferencesUtils.getKey(context, R.string.track_color_mode_percentage_key));
|
||||||
assertEquals(speedMargin + 2, dynamicSpeedTrackPathDescriptor.getSpeedMargin());
|
assertEquals(speedMargin + 2, dynamicSpeedTrackPathDescriptor.getSpeedMargin());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link
|
* Tests {@link DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
||||||
* DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
* String)} when the values of speedMargin is the default value.
|
||||||
* String)} when the values of speedMargin is "".
|
|
||||||
*/
|
*/
|
||||||
public void testOnSharedPreferenceChanged_emptyValue() {
|
public void testOnSharedPreferenceChanged_defaultValue() {
|
||||||
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
|
DynamicSpeedTrackPathDescriptor dynamicSpeedTrackPathDescriptor = new DynamicSpeedTrackPathDescriptor(
|
||||||
context);
|
context);
|
||||||
// Change value in shared preferences
|
// Change value in shared preferences
|
||||||
sharedPreferencesEditor.putString(
|
PreferencesUtils.setInt(context, R.string.track_color_mode_percentage_key,
|
||||||
context.getString(R.string.track_color_mode_dynamic_speed_variation_key), "");
|
PreferencesUtils.TRACK_COLOR_MODE_PERCENTAGE_DEFAULT);
|
||||||
sharedPreferencesEditor.commit();
|
|
||||||
|
|
||||||
dynamicSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences,
|
dynamicSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences,
|
||||||
context.getString(R.string.track_color_mode_dynamic_speed_variation_key));
|
PreferencesUtils.getKey(context, R.string.track_color_mode_percentage_key));
|
||||||
// The default value of speedMargin is 25.
|
// The default value of speedMargin is 25.
|
||||||
assertEquals(25, dynamicSpeedTrackPathDescriptor.getSpeedMargin());
|
assertEquals(PreferencesUtils.TRACK_COLOR_MODE_PERCENTAGE_DEFAULT,
|
||||||
|
dynamicSpeedTrackPathDescriptor.getSpeedMargin());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,9 +139,9 @@ public class DynamicSpeedTrackPathDescriptorTest extends AndroidTestCase {
|
|||||||
context);
|
context);
|
||||||
double[] averageMovingSpeeds = { 0, 30, 30, 30 };
|
double[] averageMovingSpeeds = { 0, 30, 30, 30 };
|
||||||
double[] newAverageMovingSpeed = { 20, 30,
|
double[] newAverageMovingSpeed = { 20, 30,
|
||||||
// Difference is less than CRITICAL_DIFFERENCE_PERCENTAGE
|
// Difference is less than CRITICAL_DIFFERENCE_PERCENTAGE
|
||||||
30 * (1 + (DynamicSpeedTrackPathDescriptor.CRITICAL_DIFFERENCE_PERCENTAGE / 100) / 2),
|
30 * (1 + (DynamicSpeedTrackPathDescriptor.CRITICAL_DIFFERENCE_PERCENTAGE / 100) / 2),
|
||||||
// Difference is more than CRITICAL_DIFFERENCE_PERCENTAGE
|
// Difference is more than CRITICAL_DIFFERENCE_PERCENTAGE
|
||||||
30 * (1 + (DynamicSpeedTrackPathDescriptor.CRITICAL_DIFFERENCE_PERCENTAGE / 100.00) * 2) };
|
30 * (1 + (DynamicSpeedTrackPathDescriptor.CRITICAL_DIFFERENCE_PERCENTAGE / 100.00) * 2) };
|
||||||
boolean[] expectedValues = { true, false, false, true };
|
boolean[] expectedValues = { true, false, false, true };
|
||||||
double[] expectedAverageMovingSpeed = { 20, 30, 30,
|
double[] expectedAverageMovingSpeed = { 20, 30, 30,
|
||||||
@@ -172,8 +151,8 @@ public class DynamicSpeedTrackPathDescriptorTest extends AndroidTestCase {
|
|||||||
dynamicSpeedTrackPathDescriptor.setAverageMovingSpeed(averageMovingSpeeds[i]);
|
dynamicSpeedTrackPathDescriptor.setAverageMovingSpeed(averageMovingSpeeds[i]);
|
||||||
assertEquals(expectedValues[i], dynamicSpeedTrackPathDescriptor.isDifferenceSignificant(
|
assertEquals(expectedValues[i], dynamicSpeedTrackPathDescriptor.isDifferenceSignificant(
|
||||||
averageMovingSpeeds[i], newAverageMovingSpeed[i]));
|
averageMovingSpeeds[i], newAverageMovingSpeed[i]));
|
||||||
assertEquals(expectedAverageMovingSpeed[i],
|
assertEquals(
|
||||||
dynamicSpeedTrackPathDescriptor.getAverageMovingSpeed());
|
expectedAverageMovingSpeed[i], dynamicSpeedTrackPathDescriptor.getAverageMovingSpeed());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+39
-82
@@ -16,52 +16,42 @@
|
|||||||
package com.google.android.apps.mytracks.maps;
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.Editor;
|
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the {@link DynamicSpeedTrackPathDescriptor}.
|
* Tests for the {@link DynamicSpeedTrackPathDescriptor}.
|
||||||
*
|
*
|
||||||
* @author Youtao Liu
|
* @author Youtao Liu
|
||||||
*/
|
*/
|
||||||
public class FixedSpeedTrackPathDescriptorTest extends AndroidTestCase {
|
public class FixedSpeedTrackPathDescriptorTest extends AndroidTestCase {
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private SharedPreferences sharedPreferences;
|
private SharedPreferences sharedPreferences;
|
||||||
private Editor sharedPreferencesEditor;
|
|
||||||
private int slowDefault;
|
|
||||||
private int normalDefault;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
context = getContext();
|
context = getContext();
|
||||||
sharedPreferences = context.getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
sharedPreferences = context.getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||||
sharedPreferencesEditor = sharedPreferences.edit();
|
|
||||||
// Get the default value
|
|
||||||
slowDefault = 9;
|
|
||||||
normalDefault = 15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the initialization of slowSpeed and normalSpeed in {@link
|
* Tests the initialization of slowSpeed and normalSpeed in {@link DynamicSpeedTrackPathDescriptor#DynamicSpeedTrackPathDescriptor(Context)}
|
||||||
* DynamicSpeedTrackPathDescriptor#DynamicSpeedTrackPathDescriptor(Context)}.
|
* .
|
||||||
*/
|
*/
|
||||||
public void testConstructor() {
|
public void testConstructor() {
|
||||||
String[] slowSpeedsInShPre = { "0", "1", "99", "" };
|
int[] slowSpeedExpectations = { 0, 1, 99, PreferencesUtils.TRACK_COLOR_MODE_SLOW_DEFAULT };
|
||||||
int[] slowSpeedExpectations = { 0, 1, 99, slowDefault };
|
int[] normalSpeedExpectations = { 0, 1, 99, PreferencesUtils.TRACK_COLOR_MODE_MEDIUM_DEFAULT };
|
||||||
String[] normalSpeedsInShPre = { "0", "1", "99", "" };
|
for (int i = 0; i < slowSpeedExpectations.length; i++) {
|
||||||
int[] normalSpeedExpectations = { 0, 1, 99, normalDefault };
|
PreferencesUtils.setInt(
|
||||||
for (int i = 0; i < slowSpeedsInShPre.length; i++) {
|
context, R.string.track_color_mode_slow_key, slowSpeedExpectations[i]);
|
||||||
sharedPreferencesEditor.putString(
|
PreferencesUtils.setInt(
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_slow_key), slowSpeedsInShPre[i]);
|
context, R.string.track_color_mode_medium_key, normalSpeedExpectations[i]);
|
||||||
sharedPreferencesEditor.putString(
|
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_medium_key),
|
|
||||||
normalSpeedsInShPre[i]);
|
|
||||||
sharedPreferencesEditor.commit();
|
|
||||||
FixedSpeedTrackPathDescriptor fixedSpeedTrackPathDescriptor = new FixedSpeedTrackPathDescriptor(
|
FixedSpeedTrackPathDescriptor fixedSpeedTrackPathDescriptor = new FixedSpeedTrackPathDescriptor(
|
||||||
context);
|
context);
|
||||||
assertEquals(slowSpeedExpectations[i], fixedSpeedTrackPathDescriptor.getSlowSpeed());
|
assertEquals(slowSpeedExpectations[i], fixedSpeedTrackPathDescriptor.getSlowSpeed());
|
||||||
@@ -70,8 +60,7 @@ public class FixedSpeedTrackPathDescriptorTest extends AndroidTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link
|
* Tests {@link DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
||||||
* DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
|
||||||
* String)} when the key is null.
|
* String)} when the key is null.
|
||||||
*/
|
*/
|
||||||
public void testOnSharedPreferenceChanged_null_key() {
|
public void testOnSharedPreferenceChanged_null_key() {
|
||||||
@@ -80,22 +69,15 @@ public class FixedSpeedTrackPathDescriptorTest extends AndroidTestCase {
|
|||||||
int slowSpeed = fixedSpeedTrackPathDescriptor.getSlowSpeed();
|
int slowSpeed = fixedSpeedTrackPathDescriptor.getSlowSpeed();
|
||||||
int normalSpeed = fixedSpeedTrackPathDescriptor.getNormalSpeed();
|
int normalSpeed = fixedSpeedTrackPathDescriptor.getNormalSpeed();
|
||||||
// Change value in shared preferences
|
// Change value in shared preferences
|
||||||
sharedPreferencesEditor.putString(
|
PreferencesUtils.setInt(context, R.string.track_color_mode_slow_key, slowSpeed + 2);
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_slow_key),
|
PreferencesUtils.setInt(context, R.string.track_color_mode_medium_key, normalSpeed + 2);
|
||||||
Integer.toString(slowSpeed + 2));
|
|
||||||
sharedPreferencesEditor.putString(
|
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_medium_key),
|
|
||||||
Integer.toString(normalSpeed + 2));
|
|
||||||
sharedPreferencesEditor.commit();
|
|
||||||
|
|
||||||
fixedSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences, null);
|
fixedSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences, null);
|
||||||
assertEquals(slowSpeed, fixedSpeedTrackPathDescriptor.getSlowSpeed());
|
assertEquals(slowSpeed, fixedSpeedTrackPathDescriptor.getSlowSpeed());
|
||||||
assertEquals(normalSpeed, fixedSpeedTrackPathDescriptor.getNormalSpeed());
|
assertEquals(normalSpeed, fixedSpeedTrackPathDescriptor.getNormalSpeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link
|
* Tests {@link DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
||||||
* DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
|
||||||
* String)} when the key is not null, and not slowSpeed and not normalSpeed.
|
* String)} when the key is not null, and not slowSpeed and not normalSpeed.
|
||||||
*/
|
*/
|
||||||
public void testOnSharedPreferenceChanged_other_key() {
|
public void testOnSharedPreferenceChanged_other_key() {
|
||||||
@@ -104,84 +86,59 @@ public class FixedSpeedTrackPathDescriptorTest extends AndroidTestCase {
|
|||||||
int slowSpeed = fixedSpeedTrackPathDescriptor.getSlowSpeed();
|
int slowSpeed = fixedSpeedTrackPathDescriptor.getSlowSpeed();
|
||||||
int normalSpeed = fixedSpeedTrackPathDescriptor.getNormalSpeed();
|
int normalSpeed = fixedSpeedTrackPathDescriptor.getNormalSpeed();
|
||||||
// Change value in shared preferences
|
// Change value in shared preferences
|
||||||
sharedPreferencesEditor.putString(
|
PreferencesUtils.setInt(context, R.string.track_color_mode_slow_key, slowSpeed + 2);
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_slow_key),
|
PreferencesUtils.setInt(context, R.string.track_color_mode_medium_key, normalSpeed + 2);
|
||||||
Integer.toString(slowSpeed + 2));
|
|
||||||
sharedPreferencesEditor.putString(
|
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_medium_key),
|
|
||||||
Integer.toString(normalSpeed + 2));
|
|
||||||
sharedPreferencesEditor.commit();
|
|
||||||
fixedSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences, "anyKey");
|
fixedSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences, "anyKey");
|
||||||
assertEquals(slowSpeed, fixedSpeedTrackPathDescriptor.getSlowSpeed());
|
assertEquals(slowSpeed, fixedSpeedTrackPathDescriptor.getSlowSpeed());
|
||||||
assertEquals(normalSpeed, fixedSpeedTrackPathDescriptor.getNormalSpeed());
|
assertEquals(normalSpeed, fixedSpeedTrackPathDescriptor.getNormalSpeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link
|
* Tests {@link DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
||||||
* DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
|
||||||
* String)} when the key is slowSpeed.
|
* String)} when the key is slowSpeed.
|
||||||
*/
|
*/
|
||||||
public void testOnSharedPreferenceChanged_slowSpeedKey() {
|
public void testOnSharedPreferenceChanged_slowSpeedKey() {
|
||||||
FixedSpeedTrackPathDescriptor fixedSpeedTrackPathDescriptor = new FixedSpeedTrackPathDescriptor(
|
FixedSpeedTrackPathDescriptor fixedSpeedTrackPathDescriptor = new FixedSpeedTrackPathDescriptor(
|
||||||
context);
|
context);
|
||||||
int slowSpeed = fixedSpeedTrackPathDescriptor.getSlowSpeed();
|
int slowSpeed = fixedSpeedTrackPathDescriptor.getSlowSpeed();
|
||||||
int normalSpeed = fixedSpeedTrackPathDescriptor.getNormalSpeed();
|
|
||||||
// Change value in shared preferences
|
// Change value in shared preferences
|
||||||
sharedPreferencesEditor.putString(
|
PreferencesUtils.setInt(context, R.string.track_color_mode_slow_key, slowSpeed + 2);
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_slow_key),
|
fixedSpeedTrackPathDescriptor.onSharedPreferenceChanged(
|
||||||
Integer.toString(slowSpeed + 2));
|
sharedPreferences, context.getString(R.string.track_color_mode_slow_key));
|
||||||
sharedPreferencesEditor.putString(
|
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_medium_key),
|
|
||||||
Integer.toString(normalSpeed + 2));
|
|
||||||
sharedPreferencesEditor.commit();
|
|
||||||
fixedSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences,
|
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_slow_key));
|
|
||||||
assertEquals(slowSpeed + 2, fixedSpeedTrackPathDescriptor.getSlowSpeed());
|
assertEquals(slowSpeed + 2, fixedSpeedTrackPathDescriptor.getSlowSpeed());
|
||||||
assertEquals(normalSpeed + 2, fixedSpeedTrackPathDescriptor.getNormalSpeed());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link
|
* Tests {@link DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
||||||
* DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
|
||||||
* String)} when the key is normalSpeed.
|
* String)} when the key is normalSpeed.
|
||||||
*/
|
*/
|
||||||
public void testOnSharedPreferenceChanged_normalSpeedKey() {
|
public void testOnSharedPreferenceChanged_normalSpeedKey() {
|
||||||
FixedSpeedTrackPathDescriptor fixedSpeedTrackPathDescriptor = new FixedSpeedTrackPathDescriptor(
|
FixedSpeedTrackPathDescriptor fixedSpeedTrackPathDescriptor = new FixedSpeedTrackPathDescriptor(
|
||||||
context);
|
context);
|
||||||
int slowSpeed = fixedSpeedTrackPathDescriptor.getSlowSpeed();
|
|
||||||
int normalSpeed = fixedSpeedTrackPathDescriptor.getNormalSpeed();
|
int normalSpeed = fixedSpeedTrackPathDescriptor.getNormalSpeed();
|
||||||
sharedPreferencesEditor.putString(
|
PreferencesUtils.setInt(context, R.string.track_color_mode_medium_key, normalSpeed + 4);
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_slow_key),
|
fixedSpeedTrackPathDescriptor.onSharedPreferenceChanged(
|
||||||
Integer.toString(slowSpeed + 4));
|
sharedPreferences, context.getString(R.string.track_color_mode_medium_key));
|
||||||
sharedPreferencesEditor.putString(
|
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_medium_key),
|
|
||||||
Integer.toString(normalSpeed + 4));
|
|
||||||
sharedPreferencesEditor.commit();
|
|
||||||
|
|
||||||
fixedSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences,
|
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_medium_key));
|
|
||||||
assertEquals(slowSpeed + 4, fixedSpeedTrackPathDescriptor.getSlowSpeed());
|
|
||||||
assertEquals(normalSpeed + 4, fixedSpeedTrackPathDescriptor.getNormalSpeed());
|
assertEquals(normalSpeed + 4, fixedSpeedTrackPathDescriptor.getNormalSpeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link
|
* Tests {@link DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
||||||
* DynamicSpeedTrackPathDescriptor#onSharedPreferenceChanged(SharedPreferences,
|
|
||||||
* String)} when the values of slowSpeed and normalSpeed in SharedPreference
|
* String)} when the values of slowSpeed and normalSpeed in SharedPreference
|
||||||
* is "". In such situation, the default value should get returned.
|
* are the default values.
|
||||||
*/
|
*/
|
||||||
public void testOnSharedPreferenceChanged_emptyValue() {
|
public void testOnSharedPreferenceChanged_defaultValue() {
|
||||||
FixedSpeedTrackPathDescriptor fixedSpeedTrackPathDescriptor = new FixedSpeedTrackPathDescriptor(
|
FixedSpeedTrackPathDescriptor fixedSpeedTrackPathDescriptor = new FixedSpeedTrackPathDescriptor(
|
||||||
context);
|
context);
|
||||||
sharedPreferencesEditor.putString(
|
PreferencesUtils.setInt(context, R.string.track_color_mode_slow_key,
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_slow_key), "");
|
PreferencesUtils.TRACK_COLOR_MODE_SLOW_DEFAULT);
|
||||||
sharedPreferencesEditor.putString(
|
PreferencesUtils.setInt(context, R.string.track_color_mode_medium_key,
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_medium_key), "");
|
PreferencesUtils.TRACK_COLOR_MODE_MEDIUM_DEFAULT);
|
||||||
sharedPreferencesEditor.commit();
|
fixedSpeedTrackPathDescriptor.onSharedPreferenceChanged(
|
||||||
|
sharedPreferences, context.getString(R.string.track_color_mode_medium_key));
|
||||||
fixedSpeedTrackPathDescriptor.onSharedPreferenceChanged(sharedPreferences,
|
assertEquals(PreferencesUtils.TRACK_COLOR_MODE_SLOW_DEFAULT,
|
||||||
context.getString(R.string.track_color_mode_fixed_speed_medium_key));
|
fixedSpeedTrackPathDescriptor.getSlowSpeed());
|
||||||
assertEquals(slowDefault, fixedSpeedTrackPathDescriptor.getSlowSpeed());
|
assertEquals(PreferencesUtils.TRACK_COLOR_MODE_MEDIUM_DEFAULT,
|
||||||
assertEquals(normalDefault, fixedSpeedTrackPathDescriptor.getNormalSpeed());
|
fixedSpeedTrackPathDescriptor.getNormalSpeed());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+11
-17
@@ -15,11 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.maps;
|
package com.google.android.apps.mytracks.maps;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,25 +40,20 @@ public class TrackPathPainterFactoryTest extends TrackPathPainterTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
SharedPreferences prefs = context.getSharedPreferences(
|
|
||||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
|
||||||
if (prefs == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
testTrackPathPainterFactorySpecific(context, prefs, R.string.display_track_color_value_none,
|
testTrackPathPainterFactorySpecific(context,
|
||||||
SingleColorTrackPathPainter.class);
|
R.string.settings_map_track_color_mode_single_value, SingleColorTrackPathPainter.class);
|
||||||
testTrackPathPainterFactorySpecific(context, prefs, R.string.display_track_color_value_fixed,
|
testTrackPathPainterFactorySpecific(context, R.string.settings_map_track_color_mode_fixed_value,
|
||||||
DynamicSpeedTrackPathPainter.class);
|
|
||||||
testTrackPathPainterFactorySpecific(context, prefs, R.string.display_track_color_value_dynamic,
|
|
||||||
DynamicSpeedTrackPathPainter.class);
|
DynamicSpeedTrackPathPainter.class);
|
||||||
|
testTrackPathPainterFactorySpecific(context,
|
||||||
|
R.string.settings_map_track_color_mode_dynamic_value, DynamicSpeedTrackPathPainter.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void testTrackPathPainterFactorySpecific(Context context, SharedPreferences prefs,
|
private <T> void testTrackPathPainterFactorySpecific(
|
||||||
int track_color_mode, Class <?> c) {
|
Context context, int track_color_mode, Class<?> c) {
|
||||||
prefs.edit().putString(context.getString(R.string.track_color_mode_key),
|
PreferencesUtils.setString(
|
||||||
context.getString(track_color_mode)).apply();
|
context, R.string.track_color_mode_key, context.getString(track_color_mode));
|
||||||
|
|
||||||
int startLocationIdx = 0;
|
int startLocationIdx = 0;
|
||||||
Boolean alwaysVisible = true;
|
Boolean alwaysVisible = true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user