merge heads

This commit is contained in:
Jimmy Shih
2012-05-01 18:09:53 -07:00
100 changed files with 1562 additions and 963 deletions
+17 -7
View File
@@ -19,6 +19,7 @@ limitations under the License.
android:versionCode="39"
android:versionName="1.1.16"
package="com.google.android.maps.mytracks" >
<!-- Permission to initialize services -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- Permissions to record locations -->
@@ -78,6 +79,7 @@ limitations under the License.
android:name="com.google.android.apps.mytracks.WRITE_TRACK_DATA"
android:permissionGroup="android.permission-group.LOCATION"
android:protectionLevel="dangerous" />
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="15" />
@@ -113,18 +115,21 @@ limitations under the License.
<uses-feature
android:name="android.hardware.touchscreen.multitouch"
android:required="false" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<application
android:backupAgent="com.google.android.apps.mytracks.io.backup.MyTracksBackupAgent"
android:icon="@drawable/arrow_icon"
android:icon="@drawable/my_tracks_icon"
android:label="@string/my_tracks_app_name"
android:name="com.google.android.apps.mytracks.MyTracksApplication"
android:theme="@style/ThemeSelector" >
<!-- For data backup -->
<meta-data
android:name="com.google.android.backup.api_key"
@@ -133,18 +138,18 @@ limitations under the License.
<activity
android:label="@string/menu_aggregated_statistics"
android:name="com.google.android.apps.mytracks.AggregatedStatsActivity" />
<activity android:name="com.google.android.apps.mytracks.ExportActivity" />
<activity
android:label="@string/menu_help"
android:name="com.google.android.apps.mytracks.HelpActivity" />
<activity
android:label="@string/my_tracks_importer"
android:name="com.google.android.apps.mytracks.ImportActivity" >
<intent-filter>
<action android:name="android.intent.action.ATTACH_DATA" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/gpx" />
<data android:mimeType="application/gpx+xml" />
<data android:mimeType="application/vnd.google-earth.gpx" />
@@ -153,20 +158,21 @@ limitations under the License.
</intent-filter>
</activity>
<activity
android:name="com.google.android.apps.mytracks.MarkerEditActivity"
android:windowSoftInputMode="stateHidden" />
android:name="com.google.android.apps.mytracks.MarkerEditActivity" />
<activity android:name="com.google.android.apps.mytracks.MarkerDetailActivity" />
<activity android:name="com.google.android.apps.mytracks.MarkerListActivity" >
<meta-data
android:name="android.app.default_searchable"
android:value="com.google.android.apps.mytracks.SearchListActivity" />
</activity>
<activity android:name="com.google.android.apps.mytracks.SaveAllActivity" />
<activity
android:launchMode="singleTop"
android:name="com.google.android.apps.mytracks.SearchListActivity" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/search" />
@@ -179,13 +185,14 @@ limitations under the License.
android:name="com.google.android.apps.mytracks.SettingsActivity" />
<activity android:name="com.google.android.apps.mytracks.TrackDetailActivity" />
<activity
android:name="com.google.android.apps.mytracks.TrackEditActivity"
android:windowSoftInputMode="stateHidden" />
android:name="com.google.android.apps.mytracks.TrackEditActivity" />
<activity android:name="com.google.android.apps.mytracks.TrackListActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.default_searchable"
android:value="com.google.android.apps.mytracks.SearchListActivity" />
@@ -227,6 +234,7 @@ limitations under the License.
<action android:name="com.google.android.apps.mytracks.TRACK_STARTED" />
<action android:name="com.google.android.apps.mytracks.TRACK_STOPPED" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/track_widget_info" />
@@ -244,6 +252,8 @@ limitations under the License.
android:authorities="com.google.android.maps.mytracks.search"
android:exported="false"
android:name="com.google.android.apps.mytracks.content.SearchEngineProvider" />
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 945 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 812 B

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010 Google Inc.
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.
@@ -14,7 +14,8 @@ 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.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/ScrollView" >
<include layout="@layout/help_content" />
</ScrollView>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/my_location_pressed" />
<item android:drawable="@drawable/my_location_normal" />
</selector>
+1 -1
View File
@@ -22,7 +22,7 @@ limitations under the License.
android:orientation="vertical"
android:padding="8dp" >
<TextView
android:drawableLeft="@drawable/arrow_icon"
android:drawableLeft="@drawable/my_tracks_icon"
android:text="@string/about_copyright_notice"
style="@style/TextMedium.WithIcon" />
<TextView
+96 -1
View File
@@ -19,7 +19,102 @@ limitations under the License.
android:layout_width="fill_parent"
android:orientation="vertical" >
<ScrollView style="@style/ScrollView.WithBottomButtons" >
<include layout="@layout/help_content" />
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:padding="8dp" >
<ImageView
android:contentDescription="@string/my_tracks_app_name"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:scaleType="fitStart"
android:src="@drawable/my_tracks_icon" />
<TextView
android:text="@string/help_my_tracks_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_my_tracks_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_location_precision_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_location_precision_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_gps_fix_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_gps_fix_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_data_connection_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_data_connection_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_elevation_precision_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_elevation_precision_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_battery_life_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_battery_life_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_share_friends_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_share_friends_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_share_visibility_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_share_visibility_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_split_track_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_split_track_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_saved_files_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_saved_files_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_waypoint_marker_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_waypoint_marker_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_statistics_marker_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_statistics_marker_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_delete_tracks_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_delete_tracks_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_edit_tracks_question"
style="@style/HelpQuestion" />
<TextView
android:text="@string/help_edit_tracks_answer"
style="@style/HelpAnswer" />
</LinearLayout>
</ScrollView>
<LinearLayout style="@style/BottomButtonBar" >
<include layout="@layout/help_buttons" />
-114
View File
@@ -1,114 +0,0 @@
<?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.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:padding="8dp" >
<ImageView
android:contentDescription="@string/my_tracks_app_name"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:scaleType="fitStart"
android:src="@drawable/arrow_icon" />
<TextView
android:text="@string/help_my_tracks_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_my_tracks_answer"
style="@style/WelcomeAnswerTextView" />
<TextView
android:text="@string/help_location_precision_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_location_precision_answer"
style="@style/WelcomeAnswerTextView" />
<TextView
android:text="@string/help_gps_fix_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_gps_fix_answer"
style="@style/WelcomeAnswerTextView" />
<TextView
android:text="@string/help_data_connection_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_data_connection_answer"
style="@style/WelcomeAnswerTextView" />
<TextView
android:text="@string/help_elevation_precision_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_elevation_precision_answer"
style="@style/WelcomeAnswerTextView" />
<TextView
android:text="@string/help_battery_life_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_battery_life_answer"
style="@style/WelcomeAnswerTextView" />
<TextView
android:text="@string/help_share_friends_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_share_friends_answer"
style="@style/WelcomeAnswerTextView" />
<TextView
android:text="@string/help_share_visibility_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_share_visibility_answer"
style="@style/WelcomeAnswerTextView" />
<TextView
android:text="@string/help_split_track_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_split_track_answer"
style="@style/WelcomeAnswerTextView" />
<TextView
android:text="@string/help_saved_files_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_saved_files_answer"
style="@style/WelcomeAnswerTextView" />
<TextView
android:text="@string/help_waypoint_marker_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_waypoint_marker_answer"
style="@style/WelcomeAnswerTextView" />
<TextView
android:text="@string/help_statistics_marker_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_statistics_marker_answer"
style="@style/WelcomeAnswerTextView" />
<TextView
android:text="@string/help_delete_tracks_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_delete_tracks_answer"
style="@style/WelcomeAnswerTextView" />
<TextView
android:text="@string/help_edit_tracks_question"
style="@style/WelcomeQuestionTextView" />
<TextView
android:text="@string/help_edit_tracks_answer"
style="@style/WelcomeAnswerTextView" />
</LinearLayout>
</merge>
+11 -1
View File
@@ -26,8 +26,18 @@ limitations under the License.
android:id="@+id/map_view"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
<ImageButton
android:background="@drawable/my_location"
android:contentDescription="@string/my_location"
android:id="@+id/map_my_location"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:layout_width="wrap_content" />
<TextView
android:background="@color/background_warning"
android:background="@color/warning_background"
android:drawableLeft="@android:drawable/ic_dialog_alert"
android:gravity="center"
android:id="@+id/map_message"
+46
View File
@@ -0,0 +1,46 @@
<?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.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/ScrollView" >
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:padding="8dp" >
<RadioGroup
android:id="@+id/marker_add_type"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content" >
<RadioButton
android:id="@+id/marker_add_statistics"
android:text="@string/marker_statistics"
style="@style/TextMedium" />
<RadioButton
android:id="@+id/marker_add_waypoint"
android:text="@string/marker_waypoint"
style="@style/TextMedium" />
</RadioGroup>
<Button
android:id="@+id/marker_add_more_options"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/generic_more_options" />
</RelativeLayout>
</ScrollView>
+2 -2
View File
@@ -30,10 +30,10 @@ limitations under the License.
android:layout_width="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/marker_detail_marker_type"
android:id="@+id/marker_detail_waypoint_marker_type"
style="@style/TextLarge" />
<TextView
android:id="@+id/marker_detail_description"
android:id="@+id/marker_detail_waypoint_description"
style="@style/TextLarge" />
</LinearLayout>
<TableLayout
+31 -17
View File
@@ -30,48 +30,62 @@ limitations under the License.
android:layout_width="fill_parent"
android:orientation="vertical" >
<TextView
android:text="@string/marker_edit_type"
style="@style/TextMedium" />
android:text="@string/marker_type"
style="@style/EditLabel" />
<RadioGroup
android:id="@+id/marker_edit_type"
android:layout_height="wrap_content"
android:layout_width="wrap_content" >
<RadioButton
android:id="@+id/marker_edit_type_statistics"
android:text="@string/marker_edit_type_statistics"
android:id="@+id/marker_edit_statistics"
android:text="@string/marker_statistics"
style="@style/TextMedium" />
<RadioButton
android:id="@+id/marker_edit_type_waypoint"
android:text="@string/marker_edit_type_waypoint"
android:id="@+id/marker_edit_waypoint"
android:text="@string/marker_waypoint"
style="@style/TextMedium" />
</RadioGroup>
</LinearLayout>
<TextView
android:text="@string/generic_name"
style="@style/TextMedium" />
<EditText
android:hint="@string/generic_name"
android:id="@+id/marker_edit_name"
style="@style/EditName" />
style="@style/EditLabel" />
<LinearLayout
android:id="@+id/marker_edit_statistics_section"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical" >
<EditText
android:drawableLeft="@drawable/yellow_pushpin"
android:hint="@string/generic_name"
android:id="@+id/marker_edit_statistics_name"
android:imeOptions="actionDone"
style="@style/EditName" />
</LinearLayout>
<LinearLayout
android:id="@+id/marker_edit_waypoint_section"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical" >
<EditText
android:drawableLeft="@drawable/blue_pushpin"
android:hint="@string/generic_name"
android:id="@+id/marker_edit_waypoint_name"
android:imeOptions="actionNext"
style="@style/EditName" />
<TextView
android:text="@string/marker_edit_marker_type"
style="@style/TextMedium" />
android:text="@string/marker_edit_waypoint_marker_type"
style="@style/EditLabel.WithPaddingTop" />
<AutoCompleteTextView
android:hint="@string/marker_edit_marker_type_hint"
android:id="@+id/marker_edit_marker_type"
android:hint="@string/marker_edit_waypoint_marker_type_hint"
android:id="@+id/marker_edit_waypoint_marker_type"
android:imeOptions="actionNext"
style="@style/EditCategory" />
<TextView
android:text="@string/generic_description"
style="@style/TextMedium" />
style="@style/EditLabel.WithPaddingTop" />
<EditText
android:hint="@string/generic_description"
android:id="@+id/marker_edit_description"
android:id="@+id/marker_edit_waypoint_description"
android:imeOptions="actionDone"
style="@style/EditDescription" />
</LinearLayout>
+2 -3
View File
@@ -34,8 +34,7 @@ limitations under the License.
style="@style/StatsValue" />
</TableRow>
<include layout="@layout/stats_core" />
<!-- Latitude and longitude -->
<TableRow>
<TableRow android:id="@+id/stats_coordinate_label_table_row" >
<TextView
android:text="@string/stats_latitude"
style="@style/StatsLabel" />
@@ -44,7 +43,7 @@ limitations under the License.
android:text="@string/stats_longitude"
style="@style/StatsLabel" />
</TableRow>
<TableRow>
<TableRow android:id="@+id/stats_coordinate_value_table_row" >
<TextView
android:id="@+id/stats_latitude_value"
style="@style/StatsValue" />
+30 -46
View File
@@ -15,11 +15,33 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Total distance and max speed (fastest pace) -->
<!-- Total distance -->
<TableRow>
<TextView
android:text="@string/stats_total_distance"
style="@style/StatsLabel" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/stats_total_distance_value"
style="@style/StatsValue" />
</TableRow>
<!-- Total time/moving time -->
<TableRow>
<TextView
android:id="@+id/stats_total_time_label"
style="@style/StatsLabel" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/stats_total_time_value"
style="@style/StatsValue" />
</TableRow>
<!-- Average speed/average moving speed and max speed (average pace/average moving pace and fastest pace) -->
<TableRow>
<TextView
android:id="@+id/stats_average_speed_label"
style="@style/StatsLabel" />
<TextView
android:id="@+id/stats_max_speed_label"
android:layout_column="2"
@@ -27,53 +49,15 @@ limitations under the License.
</TableRow>
<TableRow>
<TextView
android:id="@+id/stats_total_distance_value"
android:id="@+id/stats_average_speed_value"
style="@style/StatsValue" />
<TextView style="@style/StatsSpacer" />
<TextView
android:id="@+id/stats_max_speed_value"
style="@style/StatsValue" />
</TableRow>
<!-- Total time and average speed (average pace) -->
<TableRow>
<TextView
android:text="@string/stats_total_time"
style="@style/StatsLabel" />
<TextView
android:id="@+id/stats_average_speed_label"
android:layout_column="2"
style="@style/StatsLabel" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/stats_total_time_value"
style="@style/StatsValue" />
<TextView style="@style/StatsSpacer" />
<TextView
android:id="@+id/stats_average_speed_value"
style="@style/StatsValue" />
</TableRow>
<!-- Moving time and average moving speed (average moving pace) -->
<TableRow>
<TextView
android:text="@string/stats_moving_time"
style="@style/StatsLabel" />
<TextView
android:id="@+id/stats_average_moving_speed_label"
android:layout_column="2"
style="@style/StatsLabel" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/stats_moving_time_value"
style="@style/StatsValue" />
<TextView style="@style/StatsSpacer" />
<TextView
android:id="@+id/stats_average_moving_speed_value"
style="@style/StatsValue" />
</TableRow>
<!-- Elevation and elevation gain -->
<TableRow>
<TableRow android:id="@+id/stats_elevation_label_table_row1" >
<TextView
android:text="@string/stats_elevation"
style="@style/StatsLabel" />
@@ -82,7 +66,7 @@ limitations under the License.
android:text="@string/stats_elevation_gain"
style="@style/StatsLabel" />
</TableRow>
<TableRow>
<TableRow android:id="@+id/stats_elevation_value_table_row1" >
<TextView
android:id="@+id/stats_elevation_value"
style="@style/StatsValue" />
@@ -92,7 +76,7 @@ limitations under the License.
style="@style/StatsValue" />
</TableRow>
<!-- Min and max elevation -->
<TableRow>
<TableRow android:id="@+id/stats_elevation_label_table_row2" >
<TextView
android:text="@string/stats_min_elevation"
style="@style/StatsLabel" />
@@ -101,7 +85,7 @@ limitations under the License.
android:text="@string/stats_max_elevation"
style="@style/StatsLabel" />
</TableRow>
<TableRow>
<TableRow android:id="@+id/stats_elevation_value_table_row2" >
<TextView
android:id="@+id/stats_min_elevation_value"
style="@style/StatsValue" />
@@ -111,7 +95,7 @@ limitations under the License.
style="@style/StatsValue" />
</TableRow>
<!-- Min and max grade -->
<TableRow>
<TableRow android:id="@+id/stats_grade_label_table_row" >
<TextView
android:text="@string/stats_min_grade"
style="@style/StatsLabel" />
@@ -120,7 +104,7 @@ limitations under the License.
android:text="@string/stats_max_grade"
style="@style/StatsLabel" />
</TableRow>
<TableRow>
<TableRow android:id="@+id/stats_grade_value_table_row" >
<TextView
android:id="@+id/stats_min_grade_value"
style="@style/StatsValue" />
+56
View File
@@ -0,0 +1,56 @@
<?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.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/ScrollView" >
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:padding="8dp" >
<TextView
android:text="@string/stats_settings_time"
style="@style/TextLarge" />
<RadioGroup
android:id="@+id/stats_settings_time"
android:layout_height="wrap_content"
android:layout_width="wrap_content" >
<RadioButton
android:id="@+id/stats_settings_total_time"
android:text="@string/stats_total_time"
style="@style/TextMedium" />
<RadioButton
android:id="@+id/stats_settings_moving_time"
android:text="@string/stats_moving_time"
style="@style/TextMedium" />
</RadioGroup>
<TextView
android:text="@string/stats_settings_show"
style="@style/TextLarge" />
<CheckBox
android:id="@+id/stats_settings_elevation"
android:text="@string/stats_elevation"
style="@style/TextMedium" />
<CheckBox
android:id="@+id/stats_settings_grade"
android:text="@string/stats_settings_grade"
style="@style/TextMedium" />
<CheckBox
android:id="@+id/stats_settings_coordinate"
android:text="@string/stats_settings_coordinate"
style="@style/TextMedium" />
</LinearLayout>
</ScrollView>
+6 -6
View File
@@ -16,17 +16,17 @@ limitations under the License.
-->
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_height="match_parent"
android:layout_width="match_parent" >
android:layout_height="fill_parent"
android:layout_width="fill_parent" >
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:orientation="horizontal" />
<FrameLayout
android:id="@android:id/tabcontent"
@@ -37,6 +37,6 @@ limitations under the License.
android:id="@+id/realtabcontent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent" />
android:layout_width="fill_parent" />
</LinearLayout>
</TabHost>
+3 -3
View File
@@ -26,7 +26,7 @@ limitations under the License.
android:padding="8dp" >
<TextView
android:text="@string/generic_name"
style="@style/TextMedium" />
style="@style/EditLabel" />
<EditText
android:drawableLeft="@drawable/track"
android:hint="@string/generic_name"
@@ -35,7 +35,7 @@ limitations under the License.
style="@style/EditName" />
<TextView
android:text="@string/track_edit_activity_type"
style="@style/TextMedium" />
style="@style/EditLabel.WithPaddingTop" />
<AutoCompleteTextView
android:hint="@string/track_edit_activity_type_hint"
android:id="@+id/track_edit_activity_type"
@@ -43,7 +43,7 @@ limitations under the License.
style="@style/EditCategory" />
<TextView
android:text="@string/generic_description"
style="@style/TextMedium" />
style="@style/EditLabel.WithPaddingTop" />
<EditText
android:hint="@string/generic_description"
android:id="@+id/track_edit_description"
+3
View File
@@ -28,7 +28,9 @@ limitations under the License.
android:layout_width="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/track_list_empty_message"
android:text="@string/track_list_empty_message"
android:visibility="gone"
style="@style/ListEmptyTextView" >
</TextView>
<ImageButton
@@ -38,6 +40,7 @@ limitations under the License.
android:layout_width="wrap_content"
android:padding="16dp"
android:src="@drawable/menu_record_track"
android:visibility="gone"
style="@android:style/Widget.DeviceDefault.ImageButton" />
</LinearLayout>
</merge>
+2 -2
View File
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/appwidget_background"
android:background="@drawable/app_widget_background"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:paddingBottom="5dp"
@@ -30,7 +30,7 @@ limitations under the License.
android:layout_width="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:src="@drawable/appwidget_button_disabled" />
android:src="@drawable/app_widget_button_disabled" />
<LinearLayout
android:clickable="true"
android:id="@+id/appwidget_track_statistics"
@@ -24,7 +24,7 @@ limitations under the License.
<TableRow android:id="@+id/send_google_maps_row" >
<ImageView
android:contentDescription="@string/send_google_maps"
android:src="@drawable/maps_icon"
android:src="@drawable/google_maps_icon"
style="@style/UploadServiceChooserImageView" />
<CheckBox
android:id="@+id/send_google_maps"
@@ -50,7 +50,7 @@ limitations under the License.
<TableRow android:id="@+id/send_google_fusion_tables_row" >
<ImageView
android:contentDescription="@string/send_google_fusion_tables"
android:src="@drawable/googledocs_icon"
android:src="@drawable/google_fusion_tables_icon"
style="@style/UploadServiceChooserImageView" />
<CheckBox
android:id="@+id/send_google_fusion_tables"
@@ -60,7 +60,7 @@ limitations under the License.
<TableRow android:id="@+id/send_google_docs_row" >
<ImageView
android:contentDescription="@string/send_google_docs"
android:src="@drawable/googledocs_icon"
android:src="@drawable/google_docs_icon"
style="@style/UploadServiceChooserImageView" />
<CheckBox
android:id="@+id/send_google_docs"
+11 -11
View File
@@ -37,11 +37,11 @@ limitations under the License.
android:title="@string/menu_share">
<menu>
<item
android:id="@+id/track_detail_share_map"
android:title="@string/menu_share_map"/>
android:id="@+id/track_detail_share_map_url"
android:title="@string/menu_share_map_url"/>
<item
android:id="@+id/track_detail_share_fusion_table"
android:title="@string/menu_share_fusion_table"/>
android:id="@+id/track_detail_share_fusion_table_url"
android:title="@string/menu_share_fusion_table_url"/>
<item android:id="@+id/track_detail_share_gpx"/>
<item android:id="@+id/track_detail_share_kml"/>
<item android:id="@+id/track_detail_share_csv"/>
@@ -76,22 +76,22 @@ limitations under the License.
android:icon="@drawable/menu_delete"
android:id="@+id/track_detail_delete"
android:title="@string/menu_delete"/>
<item
android:icon="@drawable/menu_my_location"
android:id="@+id/track_detail_my_location"
android:title="@string/menu_my_location"/>
<item
android:icon="@drawable/menu_satellite_mode"
android:id="@+id/track_detail_satellite_mode"
android:title="@string/menu_satellite_mode"/>
<item
android:icon="@drawable/menu_sensor_state"
android:id="@+id/track_detail_sensor_state"
android:title="@string/menu_sensor_state"/>
<item
android:icon="@drawable/menu_chart_settings"
android:id="@+id/track_detail_chart_settings"
android:title="@string/menu_chart_settings"/>
<item
android:icon="@drawable/menu_sensor_state"
android:id="@+id/track_detail_sensor_state"
android:title="@string/menu_sensor_state"/>
android:icon="@drawable/menu_stats_settings"
android:id="@+id/track_detail_stats_settings"
android:title="@string/menu_stats_settings"/>
<item
android:icon="@drawable/menu_settings"
android:id="@+id/track_detail_settings"
+10 -10
View File
@@ -32,18 +32,18 @@ limitations under the License.
android:showAsAction="always|collapseActionView"
android:title="@string/menu_search"/>
<item
android:icon="@drawable/menu_import_all"
android:id="@+id/track_list_import_all"
android:title="@string/menu_import_all"/>
android:icon="@drawable/menu_import"
android:id="@+id/track_list_import"
android:title="@string/menu_import"/>
<item
android:icon="@drawable/menu_export_all"
android:id="@+id/track_list_export_all"
android:title="@string/menu_export_all">
android:icon="@drawable/menu_save_all"
android:id="@+id/track_list_save_all"
android:title="@string/menu_save_all">
<menu>
<item android:id="@+id/track_list_export_gpx"/>
<item android:id="@+id/track_list_export_kml"/>
<item android:id="@+id/track_list_export_csv"/>
<item android:id="@+id/track_list_export_tcx"/>
<item android:id="@+id/track_list_save_all_gpx"/>
<item android:id="@+id/track_list_save_all_kml"/>
<item android:id="@+id/track_list_save_all_csv"/>
<item android:id="@+id/track_list_save_all_tcx"/>
</menu>
</item>
<item
+1 -2
View File
@@ -22,7 +22,7 @@ limitations under the License.
<color name="white">#FFFFFFFF</color>
<!-- holo_orange_dark -->
<color name="background_warning">#FFFF8800</color>
<color name="warning_background">#FFFF8800</color>
<!-- Chart colors by series. -->
<!-- Green and a transparent green -->
@@ -46,7 +46,6 @@ limitations under the License.
<color name="power_fill">#40401465</color>
<!-- AppWidget colors -->
<color name="appwidget_text">#EDEDED</color>
<color name="appwidget_hr">#99999999</color>
<!-- Colors for dynamic track drawing -->
+16 -14
View File
@@ -15,13 +15,15 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<!-- Keys for application preferences. Sorted alphabetically. - DO NOT TRANSLATE -->
<!-- Keys for persisted preferences. Sorted alphabetically. - DO NOT TRANSLATE -->
<string name="allow_access_key">allowAccess</string>
<string name="announcement_frequency_key">announcementFrequency</string>
<string name="ant_cadence_sensor_id_key">antCadenceSensorId</string>
<string name="ant_cadence_speed_sensor_id_key">antCadenceSpeedSensorId</string>
<string name="ant_heart_rate_sensor_id_key">antHeartRateSensorId</string>
<string name="ant_srm_bridge_sensor_id_key">antSRMBridgeSensorId</string>
<string name="auto_resume_track_current_retry_key">autoResumeTrackCurrentRetry</string>
<string name="auto_resume_track_timeout_key">autoResumeTrackTimeout</string>
<string name="bluetooth_pairing_key">bluetoothPairing</string>
<string name="bluetooth_sensor_key">bluetoothSensor</string>
@@ -33,31 +35,31 @@ limitations under the License.
<string name="min_recording_interval_key">minRecordingInterval</string>
<string name="min_required_accuracy_key">minRequiredAccuracy</string>
<string name="pick_existing_map_key">pickExistingMap</string>
<string name="pick_statistics_marker_key">pickStatisticsMarker</string>
<string name="preferred_account_key">preferredAccount</string>
<string name="recording_track_id_key">recordingTrackId</string>
<string name="report_speed_key">reportSpeed</string>
<string name="selected_track_id_key">selectedTrackId</string>
<string name="send_to_docs_key">sendToDocs</string>
<string name="send_to_fusion_tables_key">sendToFusionTables</string>
<string name="send_to_maps_key">sendToMaps</string>
<string name="sensor_type_key">sensorType</string>
<string name="share_url_only_key">shareUrlOnly</string>
<string name="show_check_units_dialog_key">showCheckUnitsDialog</string>
<string name="show_welcome_dialog_key">showWelcomeDialog</string>
<string name="split_frequency_key">splitFrequency</string>
<string name="track_color_mode_dynamic_speed_variation_key">trackColorModeDynamicVariation
</string>
<string name="track_color_mode_fixed_speed_medium_display_key">trackColorModeFixedMediumDisplay
</string>
<string name="stats_show_coordinate_key">statsShowCoordinate</string>
<string name="stats_show_elevation_key">statsShowElevation</string>
<string name="stats_show_grade_key">statsShowGrade</string>
<string name="stats_show_total_time_key">statsShowTotalTime</string>
<string name="track_color_mode_dynamic_speed_variation_key">trackColorModeDynamicVariation</string>
<string name="track_color_mode_fixed_speed_medium_display_key">trackColorModeFixedMediumDisplay</string>
<string name="track_color_mode_fixed_speed_medium_key">trackColorModeFixedMedium</string>
<string name="track_color_mode_fixed_speed_slow_display_key">trackColorModeFixedSlowDisplay
</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_name_key">trackName</string>
<!-- Preference keys which keep transient state (not user preferences). Sorted alphabetically.
- DO NOT TRANSLATE -->
<string name="auto_resume_track_current_retry_key">autoResumeTrackCurrentRetry</string>
<string name="recording_track_id_key">recordingTrackId</string>
<string name="selected_track_id_key">selectedTrackId</string>
<!-- Keys for non-persisted preferences. Sorted alphabetically. - DO NOT TRANSLATE -->
<string name="ant_options_key">antOptions</string>
<string name="backup_to_sd_key">backupToSd</string>
@@ -65,4 +67,4 @@ limitations under the License.
<string name="restore_from_sd_key">restoreFromSd</string>
<string name="sensor_options_key">sensorOptions</string>
<string name="track_color_mode_fixed_speed_options_key">trackColorModeFixedOptions</string>
</resources>
</resources>
+149 -114
View File
@@ -637,23 +637,11 @@ limitations under the License.
Terms of Service
</string>
<!-- Export -->
<string name="export_error"
translation_description="When exporting all the tracks to the SD card, a toast message
indicating error.">
Unable to export.
</string>
<string name="export_progress_message"
translation_description="When exporting all the tracks to the SD card, the progress message.">
Exporting all tracks...
</string>
<string name="export_success"
translation_description="When exporting all the tracks to the SD card, a toast message
indicating success.">
Export finished.
</string>
<!-- Generic Strings -->
<string name="generic_add"
translation_description="The text on a button to say add.">
Add
</string>
<string name="generic_cancel"
translation_description="The text on a button to say cancel.">
Cancel
@@ -670,6 +658,10 @@ limitations under the License.
translation_description="The title on an alert dialog indicating error.">
Error
</string>
<string name="generic_more_options"
translation_description="The text on a button to say more options.">
More options
</string>
<string name="generic_name"
translation_description="The text label for entering a name.">
Name
@@ -951,67 +943,47 @@ limitations under the License.
</string>
<!-- Marker -->
<string name="marker_add_error"
translation_description="When adding a marker, the message indicating error.">
Unable to insert a marker. Try again.
</string>
<string name="marker_add_success"
translation_description="When adding a marker, the message indicating success.">
A marker was inserted.
</string>
<string name="marker_delete_one_marker_confirm_message"
translation_description="When deleting a marker, the confirmation dialog message informing the
user that the marker will be permanently deleted from the phone.">
The marker will be permanently deleted from the phone.
</string>
<string name="marker_detail_description"
translation_description="In the marker detail page, the label for the description.
<string name="marker_detail_name"
translation_description="In the marker detail page, the label for the marker name.
%1$s marker name. E.g., 'Waypoint 1'.">
Name: %1$s
</string>
<string name="marker_detail_waypoint_description"
translation_description="In the marker detail page, the label for the waypoint description.
%1$s marker description. E.g., 'At the top'.">
Description: %1$s
</string>
<string name="marker_detail_marker_type"
translation_description="In the marker detail page, the label for the marker type.
<string name="marker_detail_waypoint_marker_type"
translation_description="In the marker detail page, the label for the waypoint marker type.
%1$s marker type. E.g., 'building'.">
Marker type: %1$s
</string>
<string name="marker_detail_name"
translation_description="In the marker detail page, the label for the marker name.
%1$s marker name. E.g., 'Waypoint1'.">
Name: %1$s
</string>
<string name="marker_edit_add"
translation_description="The label on the button to add a marker.">
Add
</string>
<string name="marker_edit_add_error"
translation_description="When adding a marker, the message indicating error.">
Unable to insert a marker. Try again.
</string>
<string name="marker_edit_add_success"
translation_description="When adding a marker, the message indicating success.">
A marker was inserted.
</string>
<string name="marker_edit_add_title"
translation_description="The title of the page to add a new marker.">
New Marker
</string>
<string name="marker_edit_marker_type"
translation_description="The label for the text field to edit the marker type, including some
exmaples.">
<string name="marker_edit_waypoint_marker_type"
translation_description="In the marker edit page, the label for the waypoint marker type,
including some exmaples.">
Marker type (e.g. building, pothole...)
</string>
<string name="marker_edit_marker_type_hint"
translation_description="The hint in the 'Marker type' text field when it is empty.">
<string name="marker_edit_waypoint_marker_type_hint"
translation_description="In the marker edit page, the hint in the waypoint marker type text
field when it is empty.">
Marker type
</string>
<string name="marker_edit_type"
translation_description="When adding a marker, the label to select a type, statistics or
waypoint.">
Type
</string>
<string name="marker_edit_type_statistics"
translation_description="The label to add a statistics marker.">
Statistics
</string>
<string name="marker_edit_type_waypoint"
translation_description="The label to add a waypoint marker.">
Waypoint
</string>
</string>
<string name="marker_label_end"
translation_description="When inserting a marker to indicate the end of a track, the marker's
name. E.g., 'track_name (End)'.
@@ -1030,7 +1002,33 @@ limitations under the License.
translation_description="The message when the marker list is empty.">
You don\'t have any markers.
</string>
<string name="marker_statistics"
translation_description="The label to add a statistics marker.">
Statistics
</string>
<string name="marker_statistics_name_format"
translation_description="When adding a statistics marker, the string format for the default
name.
%1$d: number. E.g., '1'.">
Statistics %1$d
</string>
<string name="marker_type"
translation_description="When adding a marker, the label to select a type, statistics or
waypoint.">
Type
</string>
<string name="marker_waypoint"
translation_description="The label to add a waypoint marker.">
Waypoint
</string>
<string name="marker_waypoint_name_format"
translation_description="When adding a waypoint marker, the string format for the default name.
%1$d: number. E.g., '1'.">
Waypoint %1$d
</string>
<!-- Menu Items -->
<string name="menu_aggregated_statistics"
translation_description="In the menu, to go to the aggregated statistics page.">
@@ -1052,25 +1050,13 @@ limitations under the License.
translation_description="In the menu, to edit a track or a marker.">
Edit
</string>
<string name="menu_export_all"
translation_description="In the menu, to export all the tracks to the SD card. This menu item
has a submenu.">
Export all...
</string>
<string name="menu_export_all_format"
translation_description="Under the 'Export all' menu option, the option to export all tracks as
a certain file format.
%1$s: file format. 'GPX', 'KML', 'CSV', or 'TCX'.">
Export as %1$s
</string>
<string name="menu_help"
translation_description="In the menu, to go to the help page.">
Help
</string>
<string name="menu_import_all"
translation_description="In the menu, to import all the tracks from the SD card.">
Import all
<string name="menu_import"
translation_description="In the menu, to import tracks from the SD card.">
Import from SD card
</string>
<string name="menu_insert_marker"
translation_description="In the menu, to insert a marker.">
@@ -1084,10 +1070,6 @@ limitations under the License.
translation_description="In the menu, to show a list of markers for the current track.">
Markers
</string>
<string name="menu_my_location"
translation_description="In the menu, to display the user's current location.">
My location
</string>
<string name="menu_play"
translation_description="In the menu, to play a track.">
Play
@@ -1105,12 +1087,17 @@ limitations under the License.
submenu.">
Save to SD card...
</string>
<string name="menu_save_all"
translation_description="In the menu, to save all the tracks to the SD card. This menu item has
a submenu.">
Save all to SD card...
</string>
<string name="menu_save_format"
translation_description="Under the 'Save to SD card...' menu option, the option to save a track
translation_description="Under the save to SD card menu option, the option to save a track
as a certain file format.
%1$s: file format. 'GPX', 'KML', 'CSV', or 'TCX'.">
As a %1$s file
Save as %1$s
</string>
<string name="menu_search"
translation_description="In the menu, to start a textual search for tracks or waypoints.">
@@ -1128,40 +1115,47 @@ limitations under the License.
translation_description="In the menu, to go to the settings page.">
Settings
</string>
<string name="menu_share"
translation_description="In the menu, to share a track.">
Share
</string>
<string name="menu_share_file"
translation_description="Under the 'Share' menu option, the option to share a track as a
certain file format.
%1$s: file format. 'GPX', 'KML', 'CSV', or 'TCX'.">
%1$s file
</string>
<string name="menu_share_fusion_table_url"
translation_description="Under the 'Share' menu option, the option to save a track to Google
Fusion Tables and share the Fusion Table URL with friends. 'Fusion Table URL' in this context
means a Google Fusion Table URL.">
Fusion Table URL
</string>
<string name="menu_share_map_url"
translation_description="Under the 'Share' menu option, the option to save a track to Google
Maps and share the Map URL with friends. 'Map URL' in this context means a Google Map URL.">
Map URL
</string>
<string name="menu_show_on_map"
translation_description="In the menu, to show a marker on map.">
Show on map
</string>
<string name="menu_stats_settings"
translation_description="In the menu, to change the stats settings.">
Stats settings
</string>
<string name="menu_stop_recording"
translation_description="In the menu, to stop recording a track.">
Stop recording
</string>
<string name="menu_share"
translation_description="In the menu, to share a track with friends through other
applications.">
Share with friends...
</string>
<string name="menu_share_file"
translation_description="Under the 'Share with friends...' menu option, the option to share a
track as a certain file format.
%1$s: file format. 'GPX', 'KML', 'CSV', or 'TCX'.">
A %1$s file
</string>
<string name="menu_share_fusion_table"
translation_description="Under the 'Share with friends...' menu option, the option to save a
track to Google Fusion Tables and share the Fusion Table url with friends. 'Fusion Table' in
this context means a Google Fusion Table.">
Fusion Table
</string>
<string name="menu_share_map"
translation_description="Under the 'Share with friends...' menu option, the option to save a
track to Google Maps and share the Map url with friends. 'Map' in this context means a Google
Map.">
Map
</string>
<!-- My Location -->
<string name="my_location"
translation_description="The accessibility description for the My Location button on the map
view.">
My Location
</string>
<string name="my_location_approximate_location"
translation_description="When displaying the user's current location, a status message
indicating that GPS is not available and an approximate location is used instead.">
@@ -1179,11 +1173,6 @@ limitations under the License.
translation_description="The My Tracks application name.">
My Tracks
</string>
<string name="my_tracks_importer"
translation_description="When opening a GPX file from a file manager, the name of the My Tracks
application that can import the file to My Tracks.">
My Tracks Importer
</string>
<string name="my_tracks_recording_service"
translation_description="When viewing the 'Running services' on Android, the name of the My
Tracks service that is recording a track in the background.
@@ -1228,19 +1217,35 @@ limitations under the License.
<string name="preferred_units_imperial"
translation_description="In the dialog asking the user to choose a preferred units, the option
to choose the imperial units.">
Imperial
Imperial (mi, ft)
</string>
<string name="preferred_units_metric"
translation_description="In the dialog asking the user to choose a preferred units, the option
to choose the metric units.">
Metric
Metric (km, m)
</string>
<string name="preferred_units_title"
translation_description="The title of the dialog asking the user to choose a preferred units,
metric or imperial.">
Preferred units
Preferred Units
</string>
<!-- Save All -->
<string name="save_all_error"
translation_description="When saving all the tracks to the SD card, a toast message indicating
error.">
Unable to save.
</string>
<string name="save_all_progress_message"
translation_description="When saving all the tracks to the SD card, the progress message.">
Saving all tracks...
</string>
<string name="save_all_success"
translation_description="When saving all the tracks to the SD card, a toast message indicating
success.">
Save finished.
</string>
<!-- SD Card -->
<string name="sd_card_canceled"
translation_description="When exporting a track to the SD card, a message indicating that the
@@ -2140,6 +2145,28 @@ limitations under the License.
Total time
</string>
<!-- Stats Settings -->
<string name="stats_settings_show"
translation_description="In the 'Stats settings' dialog, the section label to show additional
stats.">
Show
</string>
<string name="stats_settings_grade"
translation_description="In the 'Stats settings' dialog, the option to show grade. Grade is
the amount of inclination to the horizontal, also known as slope or incline.">
Grade
</string>
<string name="stats_settings_coordinate"
translation_description="In the 'Stats settings' dialog, the option to show latitude and
longitude.">
Latitude/Longitude
</string>
<string name="stats_settings_time"
translation_description="In the 'Stats settings' dialog, the section label to choose between
displaying total time or moving time.">
Time
</string>
<!-- Track -->
<string name="track_detail_chart_tab"
translation_description="In the track detail page, the title of the tab showing the chart.">
@@ -2926,6 +2953,14 @@ limitations under the License.
</string>
<!-- Welcome -->
<string name="welcome_message"
translation_description="The message of the welcome dialog.">
Use My Tracks while you run, bike, hike, or do anything outdoor to record your path. While
recording, you can visualize your track and watch live statistics. You can also add
markers, have markers inserted periodically, or hear automatic voice announcements of
your progress. For recorded tracks, you can play them on Google Earth, share with friends, or
upload to Google Maps, Google Fusion Tables, or Google Docs.
</string>
<string name="welcome_title"
translation_description="The title of the welcome dialog.">
Welcome to My Tracks
+15 -9
View File
@@ -45,6 +45,12 @@ limitations under the License.
<item name="android:selectAllOnFocus">true</item>
<item name="android:singleLine">false</item>
</style>
<!-- The style for the edit label -->
<style name="EditLabel" parent="@style/TextMedium" />
<!-- The style for the edit lable with padding top -->
<style name="EditLabel.WithPaddingTop">
<item name="android:paddingTop">16dp</item>
</style>
<!-- The style for the edit name -->
<style name="EditName" parent="@style/TextMedium.WithIcon">
<item name="android:inputType">textAutoCorrect|textCapWords</item>
@@ -52,6 +58,15 @@ limitations under the License.
<item name="android:selectAllOnFocus">true</item>
<item name="android:singleLine">true</item>
</style>
<!-- The style for the help answer -->
<style name="HelpAnswer" parent="@style/TextSmall">
<item name="android:paddingBottom">8dp</item>
</style>
<!-- The style for help question -->
<style name="HelpQuestion" parent="@style/TextMedium">
<item name="android:paddingTop">8dp</item>
<item name="android:textStyle">bold</item>
</style>
<!-- The style for the list empty text view -->
<style name="ListEmptyTextView" parent="@style/TextLarge">
<item name="android:gravity">center</item>
@@ -147,13 +162,4 @@ limitations under the License.
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
</style>
<!-- The style for the welcome page answer -->
<style name="WelcomeAnswerTextView" parent="@style/TextSmall">
<item name="android:paddingBottom">8dp</item>
</style>
<!-- The style for welcome page question -->
<style name="WelcomeQuestionTextView" parent="@style/TextMedium">
<item name="android:paddingTop">8dp</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
+11 -9
View File
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/search_hint"
android:includeInGlobalSearch="true"
android:label="@string/my_tracks_app_name"
android:searchSettingsDescription="@string/search_global_description"
android:voicePromptText="@string/search_voice_prompt"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
android:searchSuggestAuthority="com.google.android.maps.mytracks.search"
android:searchSuggestThreshold="2"
android:searchSuggestSelection=" ? " />
android:hint="@string/search_hint"
android:imeOptions="actionSearch"
android:includeInGlobalSearch="true"
android:label="@string/my_tracks_app_name"
android:queryAfterZeroResults="true"
android:searchSettingsDescription="@string/search_global_description"
android:searchSuggestAuthority="com.google.android.maps.mytracks.search"
android:searchSuggestSelection=" ? "
android:searchSuggestThreshold="1"
android:voicePromptText="@string/search_voice_prompt"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" />
@@ -22,8 +22,6 @@ import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.StatsUtils;
import com.google.android.maps.mytracks.R;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import java.util.List;
@@ -39,15 +37,8 @@ public class AggregatedStatsActivity extends AbstractMyTracksActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.aggregated_stats);
SharedPreferences preferences = getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
boolean metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true);
boolean reportSpeed = preferences.getBoolean(getString(R.string.report_speed_key), true);
StatsUtils.setSpeedLabels(this, reportSpeed, false);
StatsUtils.setTripStatisticsValues(this, getTripStatistics(), metricUnits, reportSpeed);
StatsUtils.setLocationElevationValue(this, Double.NaN, metricUnits);
StatsUtils.setTripStatisticsValues(this, getTripStatistics());
StatsUtils.setLocationValues(this, null, false);
}
/**
@@ -76,7 +76,7 @@ public class ChartView extends View {
/**
* Unscaled top border of the chart.
*/
private static final int TOP_BORDER = 15;
private static final int TOP_BORDER = 16;
/**
* Device scaled top border of the chart.
@@ -86,7 +86,7 @@ public class ChartView extends View {
/**
* Unscaled bottom border of the chart.
*/
private static final float BOTTOM_BORDER = 40;
private static final float BOTTOM_BORDER = 8;
/**
* Device scaled bottom border of the chart.
@@ -191,7 +191,7 @@ public class ChartView extends View {
pointer.setBounds(0, 0,
pointer.getIntrinsicWidth(), pointer.getIntrinsicHeight());
statsMarker = getResources().getDrawable(R.drawable.ylw_pushpin);
statsMarker = getResources().getDrawable(R.drawable.yellow_pushpin);
markerWidth = statsMarker.getIntrinsicWidth();
markerHeight = statsMarker.getIntrinsicHeight();
statsMarker.setBounds(0, 0, markerWidth, markerHeight);
@@ -509,10 +509,16 @@ public class ChartView extends View {
return true;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
updateEffectiveDimensionsIfChanged(
View.MeasureSpec.getSize(widthMeasureSpec), View.MeasureSpec.getSize(heightMeasureSpec));
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onDraw(Canvas c) {
synchronized (data) {
updateEffectiveDimensionsIfChanged(c);
// Keep original state.
c.save();
@@ -742,13 +748,16 @@ public class ChartView extends View {
/**
* Updates the effective dimensions where the graph will be drawn, only if the
* dimensions of the given canvas have changed since the last call.
* dimensions have changed since the last call.
*
* @param newWidth the new width
* @param newHeight the new height
*/
private void updateEffectiveDimensionsIfChanged(Canvas c) {
if (w != c.getWidth() || h != c.getHeight()) {
private void updateEffectiveDimensionsIfChanged(int newWidth, int newHeight) {
if (w != newWidth || h != newHeight) {
// Dimensions have changed (for example due to orientation change).
w = c.getWidth();
h = c.getHeight();
w = newWidth;
h = newHeight;
updateEffectiveDimensions();
setUpPath();
}
@@ -146,7 +146,7 @@ public class MapOverlay extends Overlay implements OnSharedPreferenceChangeListe
arrow.setBounds(0, 0, arrowWidth, arrowHeight);
}
statsMarker = resources.getDrawable(R.drawable.ylw_pushpin);
statsMarker = resources.getDrawable(R.drawable.yellow_pushpin);
markerWidth = statsMarker.getIntrinsicWidth();
markerHeight = statsMarker.getIntrinsicHeight();
statsMarker.setBounds(0, 0, markerWidth, markerHeight);
@@ -23,9 +23,7 @@ import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.StatsUtils;
import com.google.android.maps.mytracks.R;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
@@ -74,23 +72,17 @@ public class MarkerDetailActivity extends AbstractMyTracksActivity {
waypointSection.setVisibility(View.VISIBLE);
statisticsSection.setVisibility(View.GONE);
TextView markerType = (TextView) findViewById(R.id.marker_detail_marker_type);
markerType.setText(getString(R.string.marker_detail_marker_type, waypoint.getCategory()));
TextView description = (TextView) findViewById(R.id.marker_detail_description);
description.setText(getString(R.string.marker_detail_description, waypoint.getDescription()));
TextView markerType = (TextView) findViewById(R.id.marker_detail_waypoint_marker_type);
markerType.setText(getString(
R.string.marker_detail_waypoint_marker_type, waypoint.getCategory()));
TextView description = (TextView) findViewById(R.id.marker_detail_waypoint_description);
description.setText(getString(
R.string.marker_detail_waypoint_description, waypoint.getDescription()));
} else {
waypointSection.setVisibility(View.GONE);
statisticsSection.setVisibility(View.VISIBLE);
SharedPreferences preferences = getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
boolean metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true);
boolean reportSpeed = preferences.getBoolean(getString(R.string.report_speed_key), true);
StatsUtils.setSpeedLabels(this, reportSpeed, false);
StatsUtils.setTripStatisticsValues(this, waypoint.getStatistics(), metricUnits, reportSpeed);
StatsUtils.setLocationElevationValue(this, waypoint.getLocation().getAltitude(), metricUnits);
StatsUtils.setTripStatisticsValues(this, waypoint.getStatistics());
StatsUtils.setLocationValues(this, waypoint.getLocation(), false);
}
}
@@ -20,23 +20,20 @@ import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
import com.google.android.apps.mytracks.content.WaypointCreationRequest.WaypointType;
import com.google.android.apps.mytracks.services.ITrackRecordingService;
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.TrackRecordingServiceConnectionUtils;
import com.google.android.maps.mytracks.R;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.Toast;
/**
* An activity to add/edit a marker.
@@ -47,19 +44,25 @@ public class MarkerEditActivity extends AbstractMyTracksActivity {
private static final String TAG = MarkerEditActivity.class.getSimpleName();
public static final String EXTRA_TRACK_ID = "track_id";
public static final String EXTRA_MARKER_ID = "marker_id";
public static final String EXTRA_STATISTICS_MARKER = "statistics_marker";
private long trackId;
private long markerId;
private boolean statisticsMarker;
private TrackRecordingServiceConnection trackRecordingServiceConnection;
private Waypoint waypoint;
// UI elements
private View typeSection;
private RadioGroup type;
private EditText name;
private View statisticsSection;
private EditText statisticsName;
private View waypointSection;
private AutoCompleteTextView markerType;
private EditText description;
private EditText waypointName;
private AutoCompleteTextView waypointMarkerType;
private EditText waypointDescription;
private Button done;
@Override
@@ -67,30 +70,48 @@ public class MarkerEditActivity extends AbstractMyTracksActivity {
super.onCreate(bundle);
setContentView(R.layout.marker_edit);
trackId = getIntent().getLongExtra(EXTRA_TRACK_ID, -1L);
markerId = getIntent().getLongExtra(EXTRA_MARKER_ID, -1L);
trackRecordingServiceConnection = new TrackRecordingServiceConnection(this, null);
statisticsMarker = getIntent().getBooleanExtra(EXTRA_STATISTICS_MARKER, true);
trackRecordingServiceConnection = new TrackRecordingServiceConnection(this, null);
// Setup UI elements
typeSection = findViewById(R.id.marker_edit_type_section);
type = (RadioGroup) findViewById(R.id.marker_edit_type);
type.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
boolean statistics = checkedId == R.id.marker_edit_type_statistics;
name.setText(
statistics ? R.string.marker_edit_type_statistics : R.string.marker_edit_type_waypoint);
// Call selectAll so that all EditText have selectAllOnFocus style.
name.selectAll();
updateUiByMarkerType(statistics);
boolean statistics = checkedId == R.id.marker_edit_statistics;
statisticsSection.setVisibility(statistics ? View.VISIBLE : View.GONE);
waypointSection.setVisibility(statistics ? View.GONE : View.VISIBLE);
int nextMarkerNumber = trackId == -1L ? -1
: MyTracksProviderUtils.Factory.get(MarkerEditActivity.this)
.getNextMarkerNumber(trackId, statistics);
if (statistics) {
String name = nextMarkerNumber == -1 ? getString(R.string.marker_type_statistics)
: getString(R.string.marker_statistics_name_format, nextMarkerNumber);
statisticsName.setText(name);
statisticsName.selectAll();
} else {
String name = nextMarkerNumber == -1 ? getString(R.string.marker_type_waypoint)
: getString(R.string.marker_waypoint_name_format, nextMarkerNumber);
waypointName.setText(name);
waypointName.selectAll();
waypointMarkerType.setText("");
waypointDescription.setText("");
}
}
});
name = (EditText) findViewById(R.id.marker_edit_name);
statisticsSection = findViewById(R.id.marker_edit_statistics_section);
statisticsName = (EditText) findViewById(R.id.marker_edit_statistics_name);
waypointSection = findViewById(R.id.marker_edit_waypoint_section);
markerType = (AutoCompleteTextView) findViewById(R.id.marker_edit_marker_type);
waypointName = (EditText) findViewById(R.id.marker_edit_waypoint_name);
waypointMarkerType = (AutoCompleteTextView) findViewById(R.id.marker_edit_waypoint_marker_type);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.waypoint_types, android.R.layout.simple_dropdown_item_1line);
markerType.setAdapter(adapter);
description = (EditText) findViewById(R.id.marker_edit_description);
waypointMarkerType.setAdapter(adapter);
waypointDescription = (EditText) findViewById(R.id.marker_edit_waypoint_description);
Button cancel = (Button) findViewById(R.id.marker_edit_cancel);
cancel.setOnClickListener(new OnClickListener() {
@@ -109,9 +130,9 @@ public class MarkerEditActivity extends AbstractMyTracksActivity {
private void updateUiByMarkerId() {
final boolean newMarker = markerId == -1L;
setTitle(newMarker ? R.string.marker_edit_add_title : R.string.menu_edit);
setTitle(newMarker ? R.string.menu_insert_marker : R.string.menu_edit);
typeSection.setVisibility(newMarker ? View.VISIBLE : View.GONE);
done.setText(newMarker ? R.string.marker_edit_add : R.string.generic_save);
done.setText(newMarker ? R.string.generic_add : R.string.generic_save);
done.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -125,7 +146,7 @@ public class MarkerEditActivity extends AbstractMyTracksActivity {
});
if (newMarker) {
type.check(R.id.marker_edit_type_statistics);
type.check(statisticsMarker ? R.id.marker_edit_statistics : R.id.marker_edit_waypoint);
} else {
waypoint = MyTracksProviderUtils.Factory.get(this).getWaypoint(markerId);
if (waypoint == null) {
@@ -133,29 +154,19 @@ public class MarkerEditActivity extends AbstractMyTracksActivity {
finish();
return;
}
name.setText(waypoint.getName());
boolean statistics = waypoint.getType() == Waypoint.TYPE_STATISTICS;
updateUiByMarkerType(statistics);
if (!statistics) {
markerType.setText(waypoint.getCategory());
description.setText(waypoint.getDescription());
}
statisticsSection.setVisibility(statistics ? View.VISIBLE : View.GONE);
waypointSection.setVisibility(statistics ? View.GONE : View.VISIBLE);
if (statistics) {
statisticsName.setText(waypoint.getName());
} else {
waypointName.setText(waypoint.getName());
waypointMarkerType.setText(waypoint.getCategory());
waypointDescription.setText(waypoint.getDescription());
}
}
}
/**
* Updates the UI by marker type.
*
* @param statistics true for a statistics marker
*/
private void updateUiByMarkerType(boolean statistics) {
name.setCompoundDrawablesWithIntrinsicBounds(
statistics ? R.drawable.ylw_pushpin : R.drawable.blue_pushpin, 0, 0, 0);
name.setImeOptions(statistics ? EditorInfo.IME_ACTION_DONE : EditorInfo.IME_ACTION_NEXT);
waypointSection.setVisibility(statistics ? View.GONE : View.VISIBLE);
}
@Override
protected void onResume() {
super.onResume();
@@ -172,41 +183,33 @@ public class MarkerEditActivity extends AbstractMyTracksActivity {
* Adds a marker.
*/
private void addMarker() {
boolean statistics = type.getCheckedRadioButtonId() == R.id.marker_edit_type_statistics;
WaypointType waypointType = statistics ? WaypointType.STATISTICS : WaypointType.MARKER;
String markerCategory = statistics ? null : markerType.getText().toString();
String markerDescription = statistics ? null : description.getText().toString();
String markerIconUrl = getString(
statistics ? R.string.marker_statistics_icon_url : R.string.marker_waypoint_icon_url);
boolean statistics = type.getCheckedRadioButtonId() == R.id.marker_edit_statistics;
PreferencesUtils.setBoolean(this, R.string.pick_statistics_marker_key, statistics);
WaypointType waypointType = statistics ? WaypointType.STATISTICS : WaypointType.WAYPOINT;
String markerName = statistics ? statisticsName.getText().toString()
: waypointName.getText().toString();
String markerCategory = statistics ? null : waypointMarkerType.getText().toString();
String markerDescription = statistics ? null : waypointDescription.getText().toString();
String markerIconUrl = getString(statistics ? R.string.marker_statistics_icon_url
: R.string.marker_waypoint_icon_url);
WaypointCreationRequest waypointCreationRequest = new WaypointCreationRequest(
waypointType, name.getText().toString(), markerCategory, markerDescription, markerIconUrl);
ITrackRecordingService trackRecordingService =
trackRecordingServiceConnection.getServiceIfBound();
if (trackRecordingService == null) {
Log.d(TAG, "Unable to add marker, no track recording service");
} else {
try {
if (trackRecordingService.insertWaypoint(waypointCreationRequest) != -1L) {
Toast.makeText(this, R.string.marker_edit_add_success, Toast.LENGTH_SHORT).show();
return;
}
} catch (RemoteException e) {
Log.e(TAG, "Unable to add marker", e);
} catch (IllegalStateException e) {
Log.e(TAG, "Unable to add marker.", e);
}
}
Toast.makeText(this, R.string.marker_edit_add_error, Toast.LENGTH_LONG).show();
waypointType, markerName, markerCategory, markerDescription, markerIconUrl);
TrackRecordingServiceConnectionUtils.addMarker(
this, trackRecordingServiceConnection, waypointCreationRequest);
}
/**
* Saves a marker.
*/
private void saveMarker() {
waypoint.setName(name.getText().toString());
if (waypoint.getType() == Waypoint.TYPE_WAYPOINT) {
waypoint.setCategory(markerType.getText().toString());
waypoint.setDescription(description.getText().toString());
boolean statistics = waypoint.getType() == Waypoint.TYPE_STATISTICS;
if (statistics) {
waypoint.setName(statisticsName.getText().toString());
} else {
waypoint.setName(waypointName.getText().toString());
waypoint.setCategory(waypointMarkerType.getText().toString());
waypoint.setDescription(waypointDescription.getText().toString());
}
MyTracksProviderUtils.Factory.get(this).updateWaypoint(waypoint);
}
@@ -20,9 +20,10 @@ import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.content.WaypointsColumns;
import com.google.android.apps.mytracks.fragments.DeleteOneMarkerDialogFragment;
import com.google.android.apps.mytracks.fragments.MarkerAddDialogFragment;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.ListItemUtil;
import com.google.android.apps.mytracks.util.ListItemUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.maps.mytracks.R;
@@ -137,13 +138,13 @@ public class MarkerListActivity extends AbstractMyTracksActivity {
boolean statistics = cursor.getInt(typeIndex) == Waypoint.TYPE_STATISTICS;
String name = cursor.getString(nameIndex);
int iconId = statistics ? R.drawable.ylw_pushpin : R.drawable.blue_pushpin;
int iconId = statistics ? R.drawable.yellow_pushpin : R.drawable.blue_pushpin;
String category = statistics ? null : cursor.getString(categoryIndex);
long time = cursor.getLong(timeIndex);
String startTime = time == 0
? null : StringUtils.formatDateTime(MarkerListActivity.this, time);
String description = statistics ? null : cursor.getString(descriptionIndex);
ListItemUtil.setListItem(view, name, iconId, category, null, null, startTime, description);
ListItemUtils.setListItem(view, name, iconId, category, null, null, startTime, description);
}
};
listView.setAdapter(resourceCursorAdapter);
@@ -195,8 +196,8 @@ public class MarkerListActivity extends AbstractMyTracksActivity {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.marker_list_insert_marker:
Intent intent = IntentUtils.newIntent(this, MarkerEditActivity.class);
startActivity(intent);
MarkerAddDialogFragment.newInstance(trackId)
.show(getSupportFragmentManager(), MarkerAddDialogFragment.MARKER_ADD_DIALOG_TAG);
return true;
case R.id.marker_list_search:
return ApiAdapterFactory.getApiAdapter().handleSearchMenuSelection(this);
@@ -28,17 +28,17 @@ import android.os.Bundle;
import android.widget.Toast;
/**
* An activity to export all the tracks to the SD card.
* An activity to save all the tracks to the SD card.
*
* @author Sandor Dornbush
*/
public class ExportActivity extends Activity {
public class SaveAllActivity extends Activity {
public static final String EXTRA_TRACK_FILE_FORMAT = "track_file_format";
private static final int DIALOG_PROGRESS_ID = 0;
private ExportAsyncTask exportAsyncTask;
private SaveAllAsyncTask saveAllAsyncTask;
private ProgressDialog progressDialog;
@Override
@@ -46,22 +46,22 @@ public class ExportActivity extends Activity {
super.onCreate(savedInstanceState);
Object retained = getLastNonConfigurationInstance();
if (retained instanceof ExportAsyncTask) {
exportAsyncTask = (ExportAsyncTask) retained;
exportAsyncTask.setActivity(this);
if (retained instanceof SaveAllAsyncTask) {
saveAllAsyncTask = (SaveAllAsyncTask) retained;
saveAllAsyncTask.setActivity(this);
} else {
Intent intent = getIntent();
TrackFileFormat trackFileFormat = intent.getParcelableExtra(EXTRA_TRACK_FILE_FORMAT);
exportAsyncTask = new ExportAsyncTask(this, trackFileFormat);
exportAsyncTask.execute();
saveAllAsyncTask = new SaveAllAsyncTask(this, trackFileFormat);
saveAllAsyncTask.execute();
}
}
@Override
public Object onRetainNonConfigurationInstance() {
exportAsyncTask.setActivity(null);
return exportAsyncTask;
saveAllAsyncTask.setActivity(null);
return saveAllAsyncTask;
}
@Override
@@ -70,10 +70,10 @@ public class ExportActivity extends Activity {
return null;
}
progressDialog = DialogUtils.createHorizontalProgressDialog(
this, R.string.export_progress_message, new DialogInterface.OnCancelListener() {
this, R.string.save_all_progress_message, new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
exportAsyncTask.cancel(true);
saveAllAsyncTask.cancel(true);
finish();
}
});
@@ -102,7 +102,7 @@ public class ExportActivity extends Activity {
/**
* Sets the progress dialog value.
*
* @param number the number of tracks exported
* @param number the number of tracks saved
* @param max the maximum number of tracks
*/
public void setProgressDialogValue(int number, int max) {
@@ -31,13 +31,13 @@ import android.os.AsyncTask;
import android.os.PowerManager.WakeLock;
/**
* AsyncTask to export all the tracks to the SD card.
* AsyncTask to save all the tracks to the SD card.
*
* @author Jimmy Shih
*/
public class ExportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
public class SaveAllAsyncTask extends AsyncTask<Void, Integer, Boolean> {
private ExportActivity exportActivity;
private SaveAllActivity saveAllActivity;
private final TrackFileFormat trackFileFormat;
private final Context context;
private final MyTracksProviderUtils myTracksProviderUtils;
@@ -56,40 +56,40 @@ public class ExportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
/**
* Creates an AsyncTask.
*
* @param exportActivity the activity currently associated with this AsyncTask
* @param saveAllActivity the activity currently associated with this AsyncTask
* @param trackFileFormat the track file format
*/
public ExportAsyncTask(ExportActivity exportActivity, TrackFileFormat trackFileFormat) {
this.exportActivity = exportActivity;
public SaveAllAsyncTask(SaveAllActivity saveAllActivity, TrackFileFormat trackFileFormat) {
this.saveAllActivity = saveAllActivity;
this.trackFileFormat = trackFileFormat;
context = exportActivity.getApplicationContext();
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(exportActivity);
context = saveAllActivity.getApplicationContext();
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(saveAllActivity);
// Get the wake lock if not recording
if (PreferencesUtils.getRecordingTrackId(exportActivity) == -1L) {
wakeLock = SystemUtils.acquireWakeLock(exportActivity, wakeLock);
if (PreferencesUtils.getRecordingTrackId(saveAllActivity) == -1L) {
wakeLock = SystemUtils.acquireWakeLock(saveAllActivity, wakeLock);
}
success = false;
completed = false;
messageId = R.string.export_error;
messageId = R.string.save_all_error;
}
/**
* Sets the current {@link ExportActivity} associated with this AyncTask.
* Sets the current {@link SaveAllActivity} associated with this AyncTask.
*
* @param exportActivity the current {@link ExportActivity}, can be null
* @param saveAllActivity the current {@link SaveAllActivity}, can be null
*/
public void setActivity(ExportActivity exportActivity) {
this.exportActivity = exportActivity;
if (completed && exportActivity != null) {
exportActivity.onAsyncTaskCompleted(success, messageId);
public void setActivity(SaveAllActivity saveAllActivity) {
this.saveAllActivity = saveAllActivity;
if (completed && saveAllActivity != null) {
saveAllActivity.onAsyncTaskCompleted(success, messageId);
}
}
@Override
protected void onPreExecute() {
if (exportActivity != null) {
exportActivity.showProgressDialog();
if (saveAllActivity != null) {
saveAllActivity.showProgressDialog();
}
}
@@ -99,7 +99,7 @@ public class ExportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
try {
cursor = myTracksProviderUtils.getTracksCursor(null, null, TracksColumns._ID);
if (cursor == null) {
messageId = R.string.export_success;
messageId = R.string.save_all_success;
return true;
}
int count = cursor.getCount();
@@ -123,7 +123,7 @@ public class ExportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
}
publishProgress(i + 1, count);
}
messageId = R.string.export_success;
messageId = R.string.save_all_success;
return true;
} finally {
if (cursor != null) {
@@ -138,8 +138,8 @@ public class ExportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
@Override
protected void onProgressUpdate(Integer... values) {
if (exportActivity != null) {
exportActivity.setProgressDialogValue(values[0], values[1]);
if (saveAllActivity != null) {
saveAllActivity.setProgressDialogValue(values[0], values[1]);
}
}
@@ -147,8 +147,8 @@ public class ExportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
protected void onPostExecute(Boolean result) {
success = result;
completed = true;
if (exportActivity != null) {
exportActivity.onAsyncTaskCompleted(success, messageId);
if (saveAllActivity != null) {
saveAllActivity.onAsyncTaskCompleted(success, messageId);
}
}
@@ -28,7 +28,7 @@ import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.ListItemUtil;
import com.google.android.apps.mytracks.util.ListItemUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.maps.mytracks.R;
@@ -105,7 +105,6 @@ public class SearchListActivity extends AbstractMyTracksActivity {
private SearchEngine searchEngine;
private SearchRecentSuggestions searchRecentSuggestions;
private LocationManager locationManager;
private SharedPreferences sharedPreferences;
private long recordingTrackId;
private boolean metricUnits;
private ArrayAdapter<Map<String, Object>> arrayAdapter;
@@ -124,7 +123,8 @@ public class SearchListActivity extends AbstractMyTracksActivity {
searchEngine = new SearchEngine(myTracksProviderUtils);
searchRecentSuggestions = SearchEngineProvider.newHelper(this);
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
SharedPreferences sharedPreferences = getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
recordingTrackId = PreferencesUtils.getRecordingTrackId(this);
@@ -165,7 +165,7 @@ public class SearchListActivity extends AbstractMyTracksActivity {
String totalDistance = (String) resultMap.get(TOTAL_DISTANCE_FIELD);
String startTime = (String) resultMap.get(START_TIME_FIELD);
String description = (String) resultMap.get(DESCRIPTION_FIELD);
ListItemUtil.setListItem(view,
ListItemUtils.setListItem(view,
name,
iconId,
category,
@@ -185,12 +185,11 @@ public class SearchListActivity extends AbstractMyTracksActivity {
@Override
protected void onResume() {
super.onResume();
metricUnits = sharedPreferences.getBoolean(getString(R.string.metric_units_key), true);
metricUnits = PreferencesUtils.isMetricUnits(this);
}
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
handleIntent(intent);
}
@@ -270,6 +269,8 @@ public class SearchListActivity extends AbstractMyTracksActivity {
.putExtra(TrackEditActivity.EXTRA_TRACK_ID, trackId);
}
startActivity(intent);
// Close the search result since its content can change after edit.
finish();
return true;
case R.id.list_context_menu_delete:
if (markerId != null) {
@@ -378,7 +379,7 @@ public class SearchListActivity extends AbstractMyTracksActivity {
boolean statistics = waypoint.getType() == Waypoint.TYPE_STATISTICS;
resultMap.put(NAME_FIELD, waypoint.getName());
resultMap.put(ICON_FIELD, statistics ? R.drawable.ylw_pushpin : R.drawable.blue_pushpin);
resultMap.put(ICON_FIELD, statistics ? R.drawable.yellow_pushpin : R.drawable.blue_pushpin);
resultMap.put(CATEGORY_FIELD, statistics ? null : waypoint.getCategory());
long time = waypoint.getLocation().getTime();
@@ -131,8 +131,7 @@ public class SettingsActivity extends PreferenceActivity {
// Hook up switching of displayed list entries between metric and imperial
// units
CheckBoxPreference metricUnitsPreference =
(CheckBoxPreference) findPreference(
getString(R.string.metric_units_key));
(CheckBoxPreference) findPreference(PreferencesUtils.getMetricUnitsKey(this));
metricUnitsPreference.setOnPreferenceChangeListener(
new OnPreferenceChangeListener() {
@Override
@@ -643,9 +642,7 @@ public class SettingsActivity extends PreferenceActivity {
* If the units are not metric convert the value before displaying.
*/
private void viewTrackColorModeSettings(EditTextPreference preference, int id) {
CheckBoxPreference metricUnitsPreference = (CheckBoxPreference) findPreference(
getString(R.string.metric_units_key));
if(metricUnitsPreference.isChecked()) {
if (PreferencesUtils.isMetricUnits(this)) {
return;
}
// Convert miles/h to km/h
@@ -665,10 +662,10 @@ public class SettingsActivity extends PreferenceActivity {
* If the units are not metric convert the value before saving.
*/
private void validateTrackColorModeSettings(String newValue, int id) {
CheckBoxPreference metricUnitsPreference = (CheckBoxPreference) findPreference(
getString(R.string.metric_units_key));
String metricspeed;
if(!metricUnitsPreference.isChecked()) {
if (PreferencesUtils.isMetricUnits(this)) {
metricspeed = newValue;
} else {
// Convert miles/h to km/h
try {
metricspeed = String.valueOf(
@@ -676,8 +673,6 @@ public class SettingsActivity extends PreferenceActivity {
} catch (NumberFormatException e) {
metricspeed = "0";
}
} else {
metricspeed = newValue;
}
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
Editor editor = prefs.edit();
@@ -25,12 +25,14 @@ import com.google.android.apps.mytracks.fragments.ChartSettingsDialogFragment;
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
import com.google.android.apps.mytracks.fragments.InstallEarthDialogFragment;
import com.google.android.apps.mytracks.fragments.MapFragment;
import com.google.android.apps.mytracks.fragments.MarkerAddDialogFragment;
import com.google.android.apps.mytracks.fragments.StatsFragment;
import com.google.android.apps.mytracks.fragments.StatsSettingsDialogFragment;
import com.google.android.apps.mytracks.fragments.StatsSettingsDialogFragment.OnStatsSettingsChangedListener;
import com.google.android.apps.mytracks.io.file.SaveActivity;
import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileFormat;
import com.google.android.apps.mytracks.io.sendtogoogle.SendRequest;
import com.google.android.apps.mytracks.io.sendtogoogle.UploadServiceChooserActivity;
import com.google.android.apps.mytracks.services.ITrackRecordingService;
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
import com.google.android.apps.mytracks.util.AnalyticsUtils;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
@@ -47,7 +49,6 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.RemoteException;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@@ -55,7 +56,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.Toast;
import java.util.List;
@@ -65,7 +65,8 @@ import java.util.List;
* @author Leif Hendrik Wilden
* @author Rodrigo Damazio
*/
public class TrackDetailActivity extends AbstractMyTracksActivity {
public class TrackDetailActivity extends AbstractMyTracksActivity
implements OnStatsSettingsChangedListener {
public static final String EXTRA_TRACK_ID = "track_id";
public static final String EXTRA_MARKER_ID = "marker_id";
@@ -160,7 +161,6 @@ public class TrackDetailActivity extends AbstractMyTracksActivity {
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
handleIntent(intent);
}
@@ -235,16 +235,22 @@ public class TrackDetailActivity extends AbstractMyTracksActivity {
String currentTabTag = tabHost.getCurrentTabTag();
menu.findItem(R.id.track_detail_chart_settings).setVisible(
ChartFragment.CHART_FRAGMENT_TAG.equals(currentTabTag));
menu.findItem(R.id.track_detail_my_location)
menu.findItem(R.id.track_detail_stats_settings).setVisible(
StatsFragment.STATS_FRAGMENT_TAG.equals(currentTabTag));
MenuItem satelliteMode = menu.findItem(R.id.track_detail_satellite_mode)
.setVisible(MapFragment.MAP_FRAGMENT_TAG.equals(currentTabTag));
// Set map or satellite mode
MapFragment mapFragment = (MapFragment) getSupportFragmentManager()
.findFragmentByTag(MapFragment.MAP_FRAGMENT_TAG);
boolean isSatelliteMode = mapFragment != null ? mapFragment.isSatelliteView() : false;
menu.findItem(R.id.track_detail_satellite_mode)
.setVisible(MapFragment.MAP_FRAGMENT_TAG.equals(currentTabTag))
.setTitle(isSatelliteMode ? R.string.menu_map_mode : R.string.menu_satellite_mode);
if (satelliteMode.isVisible()) {
MapFragment mapFragment = (MapFragment) getSupportFragmentManager()
.findFragmentByTag(MapFragment.MAP_FRAGMENT_TAG);
/*
* The current tag is mapFragment, thus safe to call its methods like
* isSatelliteView.
*/
boolean isSatelliteMode = mapFragment != null ? mapFragment.isSatelliteView() : false;
menu.findItem(R.id.track_detail_satellite_mode).setTitle(
isSatelliteMode ? R.string.menu_map_mode : R.string.menu_satellite_mode);
}
return super.onPrepareOptionsMenu(menu);
}
@@ -265,8 +271,8 @@ public class TrackDetailActivity extends AbstractMyTracksActivity {
TrackRecordingServiceConnectionUtils.stop(this, trackRecordingServiceConnection);
return true;
case R.id.track_detail_insert_marker:
intent = IntentUtils.newIntent(this, MarkerEditActivity.class);
startActivity(intent);
MarkerAddDialogFragment.newInstance(trackId)
.show(getSupportFragmentManager(), MarkerAddDialogFragment.MARKER_ADD_DIALOG_TAG);
return true;
case R.id.track_detail_play:
if (isEarthInstalled()) {
@@ -281,12 +287,12 @@ public class TrackDetailActivity extends AbstractMyTracksActivity {
getSupportFragmentManager(), InstallEarthDialogFragment.INSTALL_EARTH_DIALOG_TAG);
}
return true;
case R.id.track_detail_share_map:
case R.id.track_detail_share_map_url:
intent = IntentUtils.newIntent(this, UploadServiceChooserActivity.class)
.putExtra(SendRequest.SEND_REQUEST_KEY, new SendRequest(trackId, true, false, false));
startActivity(intent);
return true;
case R.id.track_detail_share_fusion_table:
case R.id.track_detail_share_fusion_table_url:
intent = IntentUtils.newIntent(this, UploadServiceChooserActivity.class)
.putExtra(SendRequest.SEND_REQUEST_KEY, new SendRequest(trackId, false, true, false));
startActivity(intent);
@@ -334,13 +340,6 @@ public class TrackDetailActivity extends AbstractMyTracksActivity {
DeleteOneTrackDialogFragment.newInstance(trackId).show(
getSupportFragmentManager(), DeleteOneTrackDialogFragment.DELETE_ONE_TRACK_DIALOG_TAG);
return true;
case R.id.track_detail_my_location:
mapFragment = (MapFragment) getSupportFragmentManager()
.findFragmentByTag(MapFragment.MAP_FRAGMENT_TAG);
if (mapFragment != null) {
mapFragment.showMyLocation();
}
return true;
case R.id.track_detail_satellite_mode:
mapFragment = (MapFragment) getSupportFragmentManager()
.findFragmentByTag(MapFragment.MAP_FRAGMENT_TAG);
@@ -348,13 +347,17 @@ public class TrackDetailActivity extends AbstractMyTracksActivity {
mapFragment.setSatelliteView(!mapFragment.isSatelliteView());
}
return true;
case R.id.track_detail_sensor_state:
intent = IntentUtils.newIntent(this, SensorStateActivity.class);
startActivity(intent);
return true;
case R.id.track_detail_chart_settings:
new ChartSettingsDialogFragment().show(
getSupportFragmentManager(), ChartSettingsDialogFragment.CHART_SETTINGS_DIALOG_TAG);
return true;
case R.id.track_detail_sensor_state:
intent = IntentUtils.newIntent(this, SensorStateActivity.class);
startActivity(intent);
case R.id.track_detail_stats_settings:
new StatsSettingsDialogFragment().show(
getSupportFragmentManager(), StatsSettingsDialogFragment.STATS_SETTINGS_DIALOG_TAG);
return true;
case R.id.track_detail_settings:
intent = IntentUtils.newIntent(this, SettingsActivity.class);
@@ -373,25 +376,8 @@ public class TrackDetailActivity extends AbstractMyTracksActivity {
public boolean onTrackballEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (TrackRecordingServiceConnectionUtils.isRecording(this, trackRecordingServiceConnection)) {
ITrackRecordingService trackRecordingService = trackRecordingServiceConnection
.getServiceIfBound();
if (trackRecordingService == null) {
Log.e(TAG, "The track recording service is null");
return true;
}
boolean success = false;
try {
long waypointId = trackRecordingService.insertWaypoint(
WaypointCreationRequest.DEFAULT_STATISTICS);
if (waypointId != -1L) {
success = true;
}
} catch (RemoteException e) {
Log.e(TAG, "Unable to insert waypoint", e);
}
Toast.makeText(this,
success ? R.string.marker_edit_add_success : R.string.marker_edit_add_error,
success ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG).show();
TrackRecordingServiceConnectionUtils.addMarker(
this, trackRecordingServiceConnection, WaypointCreationRequest.DEFAULT_STATISTICS);
return true;
}
}
@@ -405,6 +391,13 @@ public class TrackDetailActivity extends AbstractMyTracksActivity {
return mapViewContainer;
}
@Override
public void onStatsSettingsChanged() {
StatsFragment statsFragment = (StatsFragment) getSupportFragmentManager()
.findFragmentByTag(StatsFragment.STATS_FRAGMENT_TAG);
statsFragment.updateUi();
}
/**
* Handles the data in the intent.
*/
@@ -17,16 +17,18 @@
package com.google.android.apps.mytracks;
import com.google.android.apps.mytracks.content.TracksColumns;
import com.google.android.apps.mytracks.fragments.CheckUnitsDialogFragment;
import com.google.android.apps.mytracks.fragments.DeleteAllTrackDialogFragment;
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
import com.google.android.apps.mytracks.fragments.EulaDialogFragment;
import com.google.android.apps.mytracks.fragments.WelcomeDialogFragment;
import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileFormat;
import com.google.android.apps.mytracks.services.ITrackRecordingService;
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.EulaUtils;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.ListItemUtil;
import com.google.android.apps.mytracks.util.ListItemUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.apps.mytracks.util.TrackRecordingServiceConnectionUtils;
@@ -99,7 +101,6 @@ public class TrackListActivity extends FragmentActivity {
startActivity(intent);
Toast.makeText(
TrackListActivity.this, R.string.track_list_record_success, Toast.LENGTH_SHORT).show();
Log.d(TAG, "Started a new recording");
} catch (Exception e) {
Toast.makeText(TrackListActivity.this, R.string.track_list_record_error, Toast.LENGTH_LONG)
.show();
@@ -116,9 +117,11 @@ public class TrackListActivity extends FragmentActivity {
sharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
boolean updateList = false;
// Note that key can be null
if (getString(R.string.metric_units_key).equals(key)) {
metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true);
if (PreferencesUtils.getMetricUnitsKey(TrackListActivity.this).equals(key)) {
metricUnits = PreferencesUtils.isMetricUnits(TrackListActivity.this);
updateList = true;
}
if (PreferencesUtils.getRecordingTrackIdKey(TrackListActivity.this).equals(key)) {
recordingTrackId = PreferencesUtils.getRecordingTrackId(TrackListActivity.this);
@@ -127,8 +130,11 @@ public class TrackListActivity extends FragmentActivity {
trackRecordingServiceConnection.startAndBind();
}
updateMenu();
updateList = true;
}
if (updateList) {
resourceCursorAdapter.notifyDataSetChanged();
}
resourceCursorAdapter.notifyDataSetChanged();
}
};
@@ -153,8 +159,8 @@ public class TrackListActivity extends FragmentActivity {
private MenuItem recordTrackMenuItem;
private MenuItem stopRecordingMenuItem;
private MenuItem searchMenuItem;
private MenuItem importAllMenuItem;
private MenuItem exportAllMenuItem;
private MenuItem importMenuItem;
private MenuItem saveAllMenuItem;
private MenuItem deleteAllMenuItem;
@Override
@@ -170,7 +176,7 @@ public class TrackListActivity extends FragmentActivity {
SharedPreferences sharedPreferences = getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
metricUnits = sharedPreferences.getBoolean(getString(R.string.metric_units_key), true);
metricUnits = PreferencesUtils.isMetricUnits(this);
recordingTrackId = PreferencesUtils.getRecordingTrackId(this);
ImageButton recordImageButton = (ImageButton) findViewById(R.id.track_list_record_button);
@@ -217,7 +223,7 @@ public class TrackListActivity extends FragmentActivity {
startTime = null;
}
String description = cursor.getString(descriptionIndex);
ListItemUtil.setListItem(view,
ListItemUtils.setListItem(view,
name,
iconId,
category,
@@ -254,15 +260,48 @@ public class TrackListActivity extends FragmentActivity {
}
});
showStartupDialogs();
}
/**
* Shows start up dialogs.
*/
public void showStartupDialogs() {
if (!EulaUtils.getEulaValue(this)) {
Fragment fragment = getSupportFragmentManager()
.findFragmentByTag(EulaDialogFragment.EULA_DIALOG_TAG);
if (fragment == null) {
EulaDialogFragment.newInstance(false).show(
getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
EulaDialogFragment.newInstance(false)
.show(getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
}
} else if (PreferencesUtils.isShowWelcomeDialog(this)) {
Fragment fragment = getSupportFragmentManager()
.findFragmentByTag(WelcomeDialogFragment.WELCOME_DIALOG_TAG);
if (fragment == null) {
new WelcomeDialogFragment().show(
getSupportFragmentManager(), WelcomeDialogFragment.WELCOME_DIALOG_TAG);
}
} else if (PreferencesUtils.isShowCheckUnitsDialog(this)) {
Fragment fragment = getSupportFragmentManager()
.findFragmentByTag(CheckUnitsDialogFragment.CHECK_UNITS_DIALOG_TAG);
if (fragment == null) {
new CheckUnitsDialogFragment().show(
getSupportFragmentManager(), CheckUnitsDialogFragment.CHECK_UNITS_DIALOG_TAG);
}
} else {
enableEmptyView();
}
}
/**
* Enables the content of the empty view.
*/
private void enableEmptyView() {
View emptyMessage = findViewById(R.id.track_list_empty_message);
emptyMessage.setVisibility(View.VISIBLE);
View recordButton = findViewById(R.id.track_list_record_button);
recordButton.setVisibility(View.VISIBLE);
}
@Override
protected void onResume() {
@@ -280,20 +319,20 @@ public class TrackListActivity extends FragmentActivity {
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.track_list, menu);
String fileTypes[] = getResources().getStringArray(R.array.file_types);
menu.findItem(R.id.track_list_export_gpx)
.setTitle(getString(R.string.menu_export_all_format, fileTypes[0]));
menu.findItem(R.id.track_list_export_kml)
.setTitle(getString(R.string.menu_export_all_format, fileTypes[1]));
menu.findItem(R.id.track_list_export_csv)
.setTitle(getString(R.string.menu_export_all_format, fileTypes[2]));
menu.findItem(R.id.track_list_export_tcx)
.setTitle(getString(R.string.menu_export_all_format, fileTypes[3]));
menu.findItem(R.id.track_list_save_all_gpx)
.setTitle(getString(R.string.menu_save_format, fileTypes[0]));
menu.findItem(R.id.track_list_save_all_kml)
.setTitle(getString(R.string.menu_save_format, fileTypes[1]));
menu.findItem(R.id.track_list_save_all_csv)
.setTitle(getString(R.string.menu_save_format, fileTypes[2]));
menu.findItem(R.id.track_list_save_all_tcx)
.setTitle(getString(R.string.menu_save_format, fileTypes[3]));
recordTrackMenuItem = menu.findItem(R.id.track_list_record_track);
stopRecordingMenuItem = menu.findItem(R.id.track_list_stop_recording);
searchMenuItem = menu.findItem(R.id.track_list_search);
importAllMenuItem = menu.findItem(R.id.track_list_import_all);
exportAllMenuItem = menu.findItem(R.id.track_list_export_all);
importMenuItem = menu.findItem(R.id.track_list_import);
saveAllMenuItem = menu.findItem(R.id.track_list_save_all);
deleteAllMenuItem = menu.findItem(R.id.track_list_delete_all);
ApiAdapterFactory.getApiAdapter().configureSearchWidget(this, searchMenuItem);
@@ -321,11 +360,11 @@ public class TrackListActivity extends FragmentActivity {
if (stopRecordingMenuItem != null) {
stopRecordingMenuItem.setVisible(isRecording);
}
if (importAllMenuItem != null) {
importAllMenuItem.setVisible(!isRecording);
if (importMenuItem != null) {
importMenuItem.setVisible(!isRecording);
}
if (exportAllMenuItem != null) {
exportAllMenuItem.setVisible(!isRecording);
if (saveAllMenuItem != null) {
saveAllMenuItem.setVisible(!isRecording);
}
if (deleteAllMenuItem != null) {
deleteAllMenuItem.setVisible(!isRecording);
@@ -346,29 +385,29 @@ public class TrackListActivity extends FragmentActivity {
return true;
case R.id.track_list_search:
return ApiAdapterFactory.getApiAdapter().handleSearchMenuSelection(this);
case R.id.track_list_import_all:
case R.id.track_list_import:
intent = IntentUtils.newIntent(this, ImportActivity.class)
.putExtra(ImportActivity.EXTRA_IMPORT_ALL, true);
startActivity(intent);
return true;
case R.id.track_list_export_gpx:
intent = IntentUtils.newIntent(this, ExportActivity.class)
.putExtra(ExportActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.GPX);
case R.id.track_list_save_all_gpx:
intent = IntentUtils.newIntent(this, SaveAllActivity.class)
.putExtra(SaveAllActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.GPX);
startActivity(intent);
return true;
case R.id.track_list_export_kml:
intent = IntentUtils.newIntent(this, ExportActivity.class)
.putExtra(ExportActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.KML);
case R.id.track_list_save_all_kml:
intent = IntentUtils.newIntent(this, SaveAllActivity.class)
.putExtra(SaveAllActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.KML);
startActivity(intent);
return true;
case R.id.track_list_export_csv:
intent = IntentUtils.newIntent(this, ExportActivity.class)
.putExtra(ExportActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.CSV);
case R.id.track_list_save_all_csv:
intent = IntentUtils.newIntent(this, SaveAllActivity.class)
.putExtra(SaveAllActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.CSV);
startActivity(intent);
return true;
case R.id.track_list_export_tcx:
intent = IntentUtils.newIntent(this, ExportActivity.class)
.putExtra(ExportActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.TCX);
case R.id.track_list_save_all_tcx:
intent = IntentUtils.newIntent(this, SaveAllActivity.class)
.putExtra(SaveAllActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.TCX);
startActivity(intent);
return true;
case R.id.track_list_delete_all:
@@ -60,8 +60,6 @@ public class TrackDataHub {
// Preference keys
private final String MIN_REQUIRED_ACCURACY_KEY;
private final String METRIC_UNITS_KEY;
private final String SPEED_REPORTING_KEY;
// Overridable constants
private final int targetNumPoints;
@@ -171,7 +169,7 @@ public class TrackDataHub {
// Cached preference values
private int minRequiredAccuracy;
private boolean useMetricUnits;
private boolean metricUnits;
private boolean reportSpeed;
// Cached sensor readings
@@ -222,8 +220,6 @@ public class TrackDataHub {
this.locationFactory = new DoubleBufferedLocationFactory();
MIN_REQUIRED_ACCURACY_KEY = context.getString(R.string.min_required_accuracy_key);
METRIC_UNITS_KEY = context.getString(R.string.metric_units_key);
SPEED_REPORTING_KEY = context.getString(R.string.report_speed_key);
resetState();
}
@@ -299,8 +295,8 @@ public class TrackDataHub {
private void loadSharedPreferences() {
selectedTrackId = PreferencesUtils.getSelectedTrackId(context);
useMetricUnits = preferences.getBoolean(METRIC_UNITS_KEY, true);
reportSpeed = preferences.getBoolean(SPEED_REPORTING_KEY, true);
metricUnits = PreferencesUtils.isMetricUnits(context);
reportSpeed = PreferencesUtils.isReportSpeed(context);
minRequiredAccuracy = preferences.getInt(MIN_REQUIRED_ACCURACY_KEY,
DEFAULT_MIN_REQUIRED_ACCURACY);
}
@@ -495,7 +491,7 @@ public class TrackDataHub {
Set<TrackDataListener> listenerSet = Collections.singleton(listener);
if (registration.isInterestedIn(ListenerDataType.DISPLAY_PREFERENCES)) {
reloadAll |= listener.onUnitsChanged(useMetricUnits);
reloadAll |= listener.onUnitsChanged(metricUnits);
reloadAll |= listener.onReportSpeedChanged(reportSpeed);
}
@@ -577,7 +573,7 @@ public class TrackDataHub {
// Ignore the return values here, we're already sending the full data set anyway
for (TrackDataListener listener :
getListenersFor(ListenerDataType.DISPLAY_PREFERENCES)) {
listener.onUnitsChanged(useMetricUnits);
listener.onUnitsChanged(metricUnits);
listener.onReportSpeedChanged(reportSpeed);
}
@@ -616,11 +612,11 @@ public class TrackDataHub {
if (MIN_REQUIRED_ACCURACY_KEY.equals(key)) {
minRequiredAccuracy = preferences.getInt(MIN_REQUIRED_ACCURACY_KEY,
DEFAULT_MIN_REQUIRED_ACCURACY);
} else if (METRIC_UNITS_KEY.equals(key)) {
useMetricUnits = preferences.getBoolean(METRIC_UNITS_KEY, true);
} else if (PreferencesUtils.getMetricUnitsKey(context).equals(key)) {
metricUnits = PreferencesUtils.isMetricUnits(context);
notifyUnitsChanged();
} else if (SPEED_REPORTING_KEY.equals(key)) {
reportSpeed = preferences.getBoolean(SPEED_REPORTING_KEY, true);
} else if (PreferencesUtils.getReportSpeedKey(context).equals(key)) {
reportSpeed = PreferencesUtils.isReportSpeed(context);
notifySpeedReportingChanged();
} else if (PreferencesUtils.getSelectedTrackIdKey(context).equals(key)) {
loadTrack(PreferencesUtils.getSelectedTrackId(context));
@@ -659,7 +655,7 @@ public class TrackDataHub {
Set<TrackDataListener> displayListeners = getListenersFor(ListenerDataType.DISPLAY_PREFERENCES);
for (TrackDataListener listener : displayListeners) {
if (listener.onUnitsChanged(useMetricUnits)) {
if (listener.onUnitsChanged(metricUnits)) {
synchronized (dataListeners) {
reloadDataForListener(listener);
}
@@ -42,7 +42,6 @@ public class AboutDialogFragment extends DialogFragment {
TextView aboutVersion = (TextView) view.findViewById(R.id.about_version);
aboutVersion.setText(SystemUtils.getMyTracksVersion(getActivity()));
return new AlertDialog.Builder(getActivity())
.setCancelable(true)
.setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@@ -133,8 +133,9 @@ public class ChartFragment extends Fragment implements TrackDataListener {
public void onStart() {
super.onStart();
ViewGroup layout = (ViewGroup) getActivity().findViewById(R.id.chart_view_layout);
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
@SuppressWarnings("deprecation")
LayoutParams layoutParams = new LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
layout.addView(chartView, layoutParams);
}
@@ -64,7 +64,6 @@ public class ChartSettingsDialogFragment extends DialogFragment {
? R.string.stats_speed : R.string.stats_pace);
return new AlertDialog.Builder(getActivity())
.setCancelable(true)
.setNegativeButton(R.string.generic_cancel, null)
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
@Override
@@ -16,22 +16,21 @@
package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.CheckUnitsUtils;
import com.google.android.apps.mytracks.TrackListActivity;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import java.util.Locale;
/**
* A DialogFragment to check preferred units.
*
*
* @author Jimmy Shih
*/
public class CheckUnitsDialogFragment extends DialogFragment {
@@ -39,31 +38,38 @@ public class CheckUnitsDialogFragment extends DialogFragment {
public static final String CHECK_UNITS_DIALOG_TAG = "checkUnitsDialog";
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
public void onCancel(DialogInterface arg0) {
onDone();
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Locale defaultLocale = Locale.getDefault();
boolean defaultMetric = !defaultLocale.equals(Locale.US) && !defaultLocale.equals(Locale.UK);
PreferencesUtils.setMetricUnits(getActivity(), defaultMetric);
final String metric = getString(R.string.preferred_units_metric);
final String imperial = getString(R.string.preferred_units_imperial);
final CharSequence[] items = defaultMetric ? new CharSequence[] { metric, imperial }
: new CharSequence[] { imperial, metric };
return new AlertDialog.Builder(getActivity())
.setCancelable(true)
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
CheckUnitsUtils.setCheckUnitsValue(getActivity());
}
})
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
CheckUnitsUtils.setCheckUnitsValue(getActivity());
int position = ((AlertDialog) dialog).getListView().getSelectedItemPosition();
SharedPreferences sharedPreferences = getActivity()
.getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(sharedPreferences.edit()
.putBoolean(getString(R.string.metric_units_key), position == 0));
int position = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
PreferencesUtils.setMetricUnits(getActivity(), items[position].equals(metric));
onDone();
}
})
.setSingleChoiceItems(new CharSequence[] { getString(R.string.preferred_units_metric),
getString(R.string.preferred_units_imperial) }, 0, null)
.setTitle(R.string.preferred_units_title)
.create();
.setSingleChoiceItems(items, 0, null)
.setTitle(R.string.preferred_units_title).create();
}
/**
* Tasks to perform when done.
*/
private void onDone() {
PreferencesUtils.setShowCheckUnitsDialog(getActivity());
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
trackListActivity.showStartupDialogs();
}
}
@@ -61,6 +61,8 @@ public class DeleteOneMarkerDialogFragment extends DialogFragment {
Intent intent = IntentUtils.newIntent(getActivity(), MarkerListActivity.class)
.putExtra(MarkerListActivity.EXTRA_TRACK_ID, getArguments().getLong(KEY_TRACK_ID));
startActivity(intent);
// Close the activity since its content can change after delete.
getActivity().finish();
}
});
}
@@ -57,6 +57,8 @@ public class DeleteOneTrackDialogFragment extends DialogFragment {
.deleteTrack(getArguments().getLong(KEY_TRACK_ID));
Intent intent = IntentUtils.newIntent(getActivity(), TrackListActivity.class);
startActivity(intent);
// Close the activity since its content can change after delete.
getActivity().finish();
}
});
}
@@ -16,6 +16,7 @@
package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.TrackListActivity;
import com.google.android.apps.mytracks.util.EulaUtils;
import com.google.android.maps.mytracks.R;
@@ -49,11 +50,17 @@ public class EulaDialogFragment extends DialogFragment {
return eulaDialogFragment;
}
@Override
public void onCancel(DialogInterface arg0) {
if (!getArguments().getBoolean(KEY_HAS_ACCEPTED)) {
exitApp();
}
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
boolean hasAccepted = getArguments().getBoolean(KEY_HAS_ACCEPTED);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
.setCancelable(true)
.setMessage(EulaUtils.getEulaMessage(getActivity()))
.setTitle(R.string.eula_title);
@@ -63,24 +70,25 @@ public class EulaDialogFragment extends DialogFragment {
builder.setNegativeButton(R.string.eula_decline, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
getActivity().finish();
}
})
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
getActivity().finish();
exitApp();
}
})
.setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
EulaUtils.setEulaValue(getActivity());
new WelcomeDialogFragment().show(
getActivity().getSupportFragmentManager(), WelcomeDialogFragment.WELCOME_DIALOG_TAG);
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
trackListActivity.showStartupDialogs();
}
});
}
return builder.create();
}
/**
* Exits the application.
*/
private void exitApp() {
getActivity().finish();
}
}
@@ -39,7 +39,6 @@ public class InstallEarthDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setCancelable(true)
.setMessage(R.string.track_detail_install_earth_message)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@@ -43,6 +43,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
@@ -86,6 +87,7 @@ public class MapFragment extends Fragment
private View mapViewContainer;
private MapOverlay mapOverlay;
private MapView mapView;
private ImageButton myLocationImageButton;
private TextView messageTextView;
@Override
@@ -100,6 +102,13 @@ public class MapFragment extends Fragment
mapView.setOnTouchListener(this);
mapView.setBuiltInZoomControls(true);
mapView.getOverlays().add(mapOverlay);
myLocationImageButton = (ImageButton) mapViewContainer.findViewById(R.id.map_my_location);
myLocationImageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showMyLocation();
}
});
messageTextView = (TextView) mapViewContainer.findViewById(R.id.map_message);
return mapViewContainer;
@@ -150,7 +159,7 @@ public class MapFragment extends Fragment
/**
* Shows my location.
*/
public void showMyLocation() {
private void showMyLocation() {
updateTrackDataHub();
keepMyLocationVisible = true;
zoomToMyLocation = true;
@@ -0,0 +1,122 @@
/*
* 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.fragments;
import com.google.android.apps.mytracks.MarkerEditActivity;
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.TrackRecordingServiceConnectionUtils;
import com.google.android.maps.mytracks.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;
/**
* A DialogFragment to add a marker.
*
* @author Jimmy Shih
*/
public class MarkerAddDialogFragment extends DialogFragment {
public static final String MARKER_ADD_DIALOG_TAG = "markerAddDialog";
private static final String KEY_TRACK_ID = "trackId";
private TrackRecordingServiceConnection trackRecordingServiceConnection;
private RadioGroup radioGroup;
private Button moreOptions;
/**
* Creates a new instance of {@link MarkerAddDialogFragment}.
*
* @param trackId the track id
*/
public static MarkerAddDialogFragment newInstance(long trackId) {
Bundle bundle = new Bundle();
bundle.putLong(KEY_TRACK_ID, trackId);
MarkerAddDialogFragment markerAddDialogFragment = new MarkerAddDialogFragment();
markerAddDialogFragment.setArguments(bundle);
return markerAddDialogFragment;
}
@Override
public void onCreate(Bundle arg0) {
super.onCreate(arg0);
trackRecordingServiceConnection = new TrackRecordingServiceConnection(getActivity(), null);
}
@Override
public void onResume() {
super.onResume();
TrackRecordingServiceConnectionUtils.resume(getActivity(), trackRecordingServiceConnection);
}
@Override
public void onDestroy() {
super.onDestroy();
trackRecordingServiceConnection.unbind();
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.marker_add, null);
radioGroup = (RadioGroup) view.findViewById(R.id.marker_add_type);
moreOptions = (Button) view.findViewById(R.id.marker_add_more_options);
moreOptions.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean statisticsMarker = radioGroup.getCheckedRadioButtonId()
== R.id.marker_add_statistics;
Intent intent = IntentUtils.newIntent(getActivity(), MarkerEditActivity.class);
intent.putExtra(MarkerEditActivity.EXTRA_TRACK_ID, getArguments().getLong(KEY_TRACK_ID));
intent.putExtra(MarkerEditActivity.EXTRA_STATISTICS_MARKER, statisticsMarker);
startActivity(intent);
dismiss();
}
});
boolean pickStatisticsMarker = PreferencesUtils.getBoolean(
getActivity(), R.string.pick_statistics_marker_key, true);
radioGroup.check(pickStatisticsMarker ? R.id.marker_add_statistics : R.id.marker_add_waypoint);
return new AlertDialog.Builder(getActivity())
.setNegativeButton(R.string.generic_cancel, null)
.setPositiveButton(R.string.generic_add, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
boolean statisticsMarker = radioGroup.getCheckedRadioButtonId()
== R.id.marker_add_statistics;
PreferencesUtils.setBoolean(
getActivity(), R.string.pick_statistics_marker_key, statisticsMarker);
TrackRecordingServiceConnectionUtils.addMarker(getActivity(),
trackRecordingServiceConnection,
statisticsMarker ? WaypointCreationRequest.DEFAULT_STATISTICS
: WaypointCreationRequest.DEFAULT_WAYPOINT);
}
})
.setTitle(R.string.menu_insert_marker)
.setView(view)
.create();
}
}
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksApplication;
import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.content.TrackDataHub;
@@ -28,8 +27,6 @@ import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.StatsUtils;
import com.google.android.maps.mytracks.R;
import android.content.Context;
import android.content.SharedPreferences;
import android.location.Location;
import android.os.Bundle;
import android.support.v4.app.Fragment;
@@ -58,8 +55,6 @@ public class StatsFragment extends Fragment implements TrackDataListener {
// The start time of the current track.
private long startTime = -1L;
private boolean metricUnits = true;
private boolean reportSpeed = true;
private Location lastLocation = null;
private TripStatistics lastTripStatistics = null;
@@ -101,10 +96,6 @@ public class StatsFragment extends Fragment implements TrackDataListener {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
SharedPreferences preferences = getActivity().getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true);
reportSpeed = preferences.getBoolean(getString(R.string.report_speed_key), true);
updateUi();
}
@@ -131,7 +122,7 @@ public class StatsFragment extends Fragment implements TrackDataListener {
@Override
public void run() {
lastLocation = null;
StatsUtils.setLocationValues(getActivity(), lastLocation, metricUnits, reportSpeed);
StatsUtils.setLocationValues(getActivity(), lastLocation, true);
}
});
}
@@ -144,7 +135,7 @@ public class StatsFragment extends Fragment implements TrackDataListener {
@Override
public void run() {
lastLocation = location;
StatsUtils.setLocationValues(getActivity(), lastLocation, metricUnits, reportSpeed);
StatsUtils.setLocationValues(getActivity(), lastLocation, true);
}
});
}
@@ -233,7 +224,6 @@ public class StatsFragment extends Fragment implements TrackDataListener {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
metricUnits = metric;
updateUi();
}
});
@@ -245,7 +235,6 @@ public class StatsFragment extends Fragment implements TrackDataListener {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
reportSpeed = speed;
updateUi();
}
});
@@ -282,9 +271,8 @@ public class StatsFragment extends Fragment implements TrackDataListener {
return trackDataHub != null && trackDataHub.isRecordingSelected();
}
private void updateUi() {
StatsUtils.setSpeedLabels(getActivity(), reportSpeed, true);
StatsUtils.setTripStatisticsValues(getActivity(), lastTripStatistics, metricUnits, reportSpeed);
StatsUtils.setLocationValues(getActivity(), lastLocation, metricUnits, reportSpeed);
public void updateUi() {
StatsUtils.setTripStatisticsValues(getActivity(), lastTripStatistics);
StatsUtils.setLocationValues(getActivity(), lastLocation, true);
}
}
@@ -0,0 +1,96 @@
/*
* 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.fragments;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.View;
import android.widget.CheckBox;
import android.widget.RadioGroup;
/**
* A DialogFragment to show stats settings.
*
* @author Jimmy Shih
*/
public class StatsSettingsDialogFragment extends DialogFragment {
public static final String STATS_SETTINGS_DIALOG_TAG = "statsSettingsDialog";
public interface OnStatsSettingsChangedListener {
public void onStatsSettingsChanged();
}
private OnStatsSettingsChangedListener listener;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
listener = (OnStatsSettingsChangedListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnArticleSelectedListener");
}
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.stats_settings, null);
final RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.stats_settings_time);
boolean totalTime = PreferencesUtils.getBoolean(
getActivity(), R.string.stats_show_total_time_key, true);
radioGroup.check(totalTime ? R.id.stats_settings_total_time : R.id.stats_settings_moving_time);
final CheckBox elevation = (CheckBox) view.findViewById(R.id.stats_settings_elevation);
final CheckBox grade = (CheckBox) view.findViewById(R.id.stats_settings_grade);
final CheckBox coordinate = (CheckBox) view.findViewById(R.id.stats_settings_coordinate);
elevation.setChecked(
PreferencesUtils.getBoolean(getActivity(), R.string.stats_show_elevation_key, false));
grade.setChecked(
PreferencesUtils.getBoolean(getActivity(), R.string.stats_show_grade_key, false));
coordinate.setChecked(
PreferencesUtils.getBoolean(getActivity(), R.string.stats_show_coordinate_key, false));
return new AlertDialog.Builder(getActivity()).setNegativeButton(R.string.generic_cancel, null)
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
PreferencesUtils.setBoolean(getActivity(), R.string.stats_show_total_time_key,
radioGroup.getCheckedRadioButtonId() == R.id.stats_settings_total_time);
PreferencesUtils.setBoolean(
getActivity(), R.string.stats_show_elevation_key, elevation.isChecked());
PreferencesUtils.setBoolean(
getActivity(), R.string.stats_show_grade_key, grade.isChecked());
PreferencesUtils.setBoolean(
getActivity(), R.string.stats_show_coordinate_key, coordinate.isChecked());
listener.onStatsSettingsChanged();
}
})
.setTitle(R.string.menu_stats_settings)
.setView(view)
.create();
}
}
@@ -16,6 +16,8 @@
package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.TrackListActivity;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.app.AlertDialog;
@@ -23,7 +25,6 @@ import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.View;
/**
* A DialogFrament to show the welcome info.
@@ -34,30 +35,28 @@ public class WelcomeDialogFragment extends DialogFragment {
public static final String WELCOME_DIALOG_TAG = "welcomeDialog";
@Override
public void onCancel(DialogInterface arg0) {
onDone();
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.welcome, null);
return new AlertDialog.Builder(getActivity())
.setCancelable(true)
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
checkUnits();
}
})
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
checkUnits();
onDone();
}
})
.setTitle(R.string.welcome_title)
.setView(view)
.setMessage(R.string.welcome_message)
.create();
}
private void checkUnits() {
new CheckUnitsDialogFragment().show(
getActivity().getSupportFragmentManager(), CheckUnitsDialogFragment.CHECK_UNITS_DIALOG_TAG);
private void onDone() {
PreferencesUtils.setShowWelcome(getActivity());
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
trackListActivity.showStartupDialogs();
}
}
@@ -21,6 +21,7 @@ import com.google.android.apps.mytracks.io.gdata.docs.DocumentsClient;
import com.google.android.apps.mytracks.io.gdata.docs.SpreadsheetsClient;
import com.google.android.apps.mytracks.io.gdata.docs.SpreadsheetsClient.WorksheetEntry;
import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.ResourceUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.apps.mytracks.util.UnitConversions;
@@ -33,7 +34,6 @@ import com.google.wireless.gdata.parser.ParseException;
import com.google.wireless.gdata2.client.AuthenticationException;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import java.io.BufferedReader;
@@ -270,10 +270,7 @@ public class SendDocsUtils {
Track track, String spreadsheetId, String worksheetId, String authToken, Context context)
throws IOException {
String worksheetUri = String.format(GET_WORKSHEET_URI, spreadsheetId, worksheetId);
SharedPreferences prefs = context.getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
boolean metricUnits = prefs.getBoolean(context.getString(R.string.metric_units_key), true);
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
addRow(worksheetUri, getRowContent(track, metricUnits, context), authToken);
}
@@ -102,7 +102,7 @@ public class CsvTrackWriter implements TrackFormatWriter {
@Override
public void writeBeginWaypoints() {
writeCommaSeparatedLine(context.getString(R.string.generic_name),
context.getString(R.string.marker_edit_marker_type_hint),
context.getString(R.string.marker_edit_waypoint_marker_type_hint),
context.getString(R.string.generic_description),
context.getString(R.string.description_location_latitude),
context.getString(R.string.description_location_longitude),
@@ -14,6 +14,7 @@ import com.google.android.apps.mytracks.stats.DoubleBuffer;
import com.google.android.apps.mytracks.stats.TripStatisticsBuilder;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.SystemUtils;
import com.google.android.apps.mytracks.util.UnitConversions;
import com.google.android.maps.mytracks.R;
@@ -32,7 +33,6 @@ import android.accounts.AccountManager;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.location.Location;
import android.util.Log;
@@ -205,9 +205,7 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
private boolean uploadAllTrackPoints(Track track) {
Cursor locationsCursor = null;
try {
SharedPreferences prefs = context.getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
boolean metricUnits = prefs.getBoolean(context.getString(R.string.metric_units_key), true);
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
locationsCursor = myTracksProviderUtils.getLocationsCursor(trackId, 0, -1, false);
if (locationsCursor == null) {
@@ -31,6 +31,7 @@ import com.google.android.apps.mytracks.io.sendtogoogle.SendToGoogleUtils;
import com.google.android.apps.mytracks.stats.DoubleBuffer;
import com.google.android.apps.mytracks.stats.TripStatisticsBuilder;
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.common.gdata.AndroidXmlParserFactory;
import com.google.android.maps.mytracks.R;
@@ -257,9 +258,7 @@ public class SendMapsAsyncTask extends AbstractSendAsyncTask {
boolean uploadAllTrackPoints(Track track) {
Cursor locationsCursor = null;
try {
SharedPreferences prefs = context.getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
boolean metricUnits = prefs.getBoolean(context.getString(R.string.metric_units_key), true);
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
locationsCursor = myTracksProviderUtils.getLocationsCursor(trackId, 0, -1, false);
if (locationsCursor == null) {
@@ -38,7 +38,6 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener {
private final String autoResumeTrackCurrentRetryKey;
private final String autoResumeTrackTimeoutKey;
private final String maxRecordingDistanceKey;
private final String metricUnitsKey;
private final String minRecordingDistanceKey;
private final String minRecordingIntervalKey;
private final String minRequiredAccuracyKey;
@@ -63,8 +62,6 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener {
service.getString(R.string.auto_resume_track_timeout_key);
maxRecordingDistanceKey =
service.getString(R.string.max_recording_distance_key);
metricUnitsKey =
service.getString(R.string.metric_units_key);
minRecordingDistanceKey =
service.getString(R.string.min_recording_distance_key);
minRecordingIntervalKey =
@@ -160,9 +157,8 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener {
service.setSplitFrequency(
sharedPreferences.getInt(splitFrequencyKey, 0));
}
if (key == null || key.equals(metricUnitsKey)) {
service.setMetricUnits(
sharedPreferences.getBoolean(metricUnitsKey, true));
if (key == null || key.equals(PreferencesUtils.getMetricUnitsKey(service))) {
service.setMetricUnits(PreferencesUtils.isMetricUnits(service));
}
}
@@ -486,11 +486,11 @@ public class TrackRecordingService extends Service {
private void showNotification() {
if (isRecording) {
Notification notification = new Notification(
R.drawable.arrow_320, null /* tickerText */,
System.currentTimeMillis());
R.drawable.my_tracks_notification_icon, null, System.currentTimeMillis());
Intent intent = IntentUtils.newIntent(this, TrackDetailActivity.class)
.putExtra(TrackDetailActivity.EXTRA_TRACK_ID, recordingTrackId);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);
PendingIntent contentIntent = PendingIntent.getActivity(
this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(this, getString(R.string.my_tracks_app_name),
getString(R.string.track_record_notification), contentIntent);
notification.flags += Notification.FLAG_NO_CLEAR;
@@ -933,12 +933,12 @@ public class TrackRecordingService extends Service {
"Unable to insert waypoint marker while not recording!");
}
if (request == null) {
request = WaypointCreationRequest.DEFAULT_MARKER;
request = WaypointCreationRequest.DEFAULT_WAYPOINT;
}
Waypoint wpt = new Waypoint();
switch (request.getType()) {
case MARKER:
buildMarker(wpt, request);
case WAYPOINT:
buildWaypointMarker(wpt, request);
break;
case STATISTICS:
buildStatisticsMarker(wpt, request);
@@ -963,18 +963,22 @@ public class TrackRecordingService extends Service {
return Long.parseLong(uri.getLastPathSegment());
}
private void buildMarker(Waypoint wpt, WaypointCreationRequest request) {
private void buildWaypointMarker(Waypoint wpt, WaypointCreationRequest request) {
wpt.setType(Waypoint.TYPE_WAYPOINT);
if (request.getIconUrl() == null) {
wpt.setIcon(getString(R.string.marker_waypoint_icon_url));
} else {
wpt.setIcon(request.getIconUrl());
}
if (request.getName() == null) {
wpt.setName(getString(R.string.marker_edit_type_waypoint));
String name;
if (request.getName() != null) {
name = request.getName();
} else {
wpt.setName(request.getName());
int nextMarkerNumber = providerUtils.getNextMarkerNumber(recordingTrackId, false);
name = nextMarkerNumber == -1 ? getString(R.string.marker_type_waypoint)
: getString(R.string.marker_waypoint_name_format, nextMarkerNumber);
}
wpt.setName(name);
if (request.getCategory() != null) {
wpt.setCategory(request.getCategory());
}
@@ -1003,8 +1007,15 @@ public class TrackRecordingService extends Service {
// Set the rest of the waypoint data
waypoint.setType(Waypoint.TYPE_STATISTICS);
waypoint.setName(request.getName() != null ? request.getName()
: getString(R.string.marker_edit_type_statistics));
String name;
if (request.getName() != null) {
name = request.getName();
} else {
int nextMarkerNumber = providerUtils.getNextMarkerNumber(recordingTrackId, true);
name = nextMarkerNumber == -1 ? getString(R.string.marker_type_statistics)
: getString(R.string.marker_statistics_name_format, nextMarkerNumber);
}
waypoint.setName(name);
waypoint.setStatistics(waypointStatsBuilder.getStatistics());
waypoint.setDescription(descriptionGenerator.generateWaypointDescription(waypoint));
waypoint.setIcon(getString(R.string.marker_statistics_icon_url));
@@ -21,13 +21,13 @@ import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.services.TrackRecordingService;
import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.apps.mytracks.util.UnitConversions;
import com.google.android.maps.mytracks.R;
import com.google.common.annotations.VisibleForTesting;
import android.content.Context;
import android.content.SharedPreferences;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.telephony.PhoneStateListener;
@@ -150,15 +150,8 @@ public class StatusAnnouncerTask implements PeriodicTask {
*/
// @VisibleForTesting
protected String getAnnouncement(TripStatistics stats) {
boolean metricUnits = true;
boolean reportSpeed = true;
SharedPreferences preferences = context.getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
if (preferences != null) {
metricUnits = preferences.getBoolean(context.getString(R.string.metric_units_key), true);
reportSpeed = preferences.getBoolean(context.getString(R.string.report_speed_key), true);
}
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
boolean reportSpeed = PreferencesUtils.isReportSpeed(context);
double d = stats.getTotalDistance() * UnitConversions.M_TO_KM;
double s = stats.getAverageMovingSpeed() * UnitConversions.MS_TO_KMH;
@@ -86,6 +86,7 @@ public class Api11Adapter extends Api10Adapter {
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
mode.finish();
return contextualActionModeCallback.onClick(item.getItemId(), position, id);
}
});
@@ -100,10 +101,35 @@ public class Api11Adapter extends Api10Adapter {
};
@Override
public void configureSearchWidget(Activity activity, MenuItem menuItem) {
public void configureSearchWidget(Activity activity, final MenuItem menuItem) {
SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menuItem.getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName()));
searchView.setQueryRefinementEnabled(true);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
menuItem.collapseActionView();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
@Override
public boolean onSuggestionSelect(int position) {
return false;
}
@Override
public boolean onSuggestionClick(int position) {
menuItem.collapseActionView();
return false;
}
});
}
@Override
@@ -16,13 +16,11 @@
package com.google.android.apps.mytracks.util;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.maps.mytracks.R;
import android.content.Context;
import android.content.SharedPreferences;
import java.util.Vector;
@@ -47,18 +45,11 @@ public class ChartURLGenerator {
* @param track The track for this chart
* @param context The current appplication context
*/
public static String getChartUrl(Vector<Double> distances,
Vector<Double> elevations, Track track, Context context) {
SharedPreferences preferences = context.getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
boolean metricUnits = true;
if (preferences != null) {
metricUnits = preferences.getBoolean(
context.getString(R.string.metric_units_key), true);
}
return getChartUrl(distances, elevations, track,
context.getString(R.string.stats_elevation), metricUnits);
public static String getChartUrl(
Vector<Double> distances, Vector<Double> elevations, Track track, Context context) {
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
return getChartUrl(
distances, elevations, track, context.getString(R.string.stats_elevation), metricUnits);
}
/**
@@ -1,47 +0,0 @@
/*
* 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.util;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
/**
* Utilities for checking units.
*
* @author Jimmy Shih
*/
public class CheckUnitsUtils {
private static final String CHECK_UNITS_PREFERENCE_FILE = "checkunits";
private static final String CHECK_UNITS_PREFERENCE_KEY = "checkunits.checked";
private CheckUnitsUtils() {}
public static boolean getCheckUnitsValue(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences(
CHECK_UNITS_PREFERENCE_FILE, Context.MODE_PRIVATE);
return sharedPreferences.getBoolean(CHECK_UNITS_PREFERENCE_KEY, false);
}
public static void setCheckUnitsValue(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences(
CHECK_UNITS_PREFERENCE_FILE, Context.MODE_PRIVATE);
Editor editor = sharedPreferences.edit().putBoolean(CHECK_UNITS_PREFERENCE_KEY, true);
ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(editor);
}
}
@@ -26,9 +26,9 @@ import android.widget.TextView;
*
* @author Jimmy Shih
*/
public class ListItemUtil {
public class ListItemUtils {
private ListItemUtil() {}
private ListItemUtils() {}
/**
* Sets a list item.
@@ -32,6 +32,34 @@ public class PreferencesUtils {
private PreferencesUtils() {}
/**
* Gets the metric units key.
*
* @param context the context
*/
public static String getMetricUnitsKey(Context context) {
return getKey(context, R.string.metric_units_key);
}
/**
* Returns the metric units value.
*
* @param context the context
*/
public static boolean isMetricUnits(Context context) {
return getBoolean(context, R.string.metric_units_key, true);
}
/**
* Sets the metric units value.
*
* @param context the context
* @param value the value
*/
public static void setMetricUnits(Context context, boolean value) {
setBoolean(context, R.string.metric_units_key, value);
}
/**
* Gets the recording track id key.
*
@@ -60,6 +88,34 @@ public class PreferencesUtils {
setLong(context, R.string.recording_track_id_key, trackId);
}
/**
* Gets the report speed key.
*
* @param context the context
*/
public static String getReportSpeedKey(Context context) {
return getKey(context, R.string.report_speed_key);
}
/**
* Returns the report speed value.
*
* @param context the context
*/
public static boolean isReportSpeed(Context context) {
return getBoolean(context, R.string.report_speed_key, true);
}
/**
* Sets the report speed value.
*
* @param context the context
* @param value the value
*/
public static void setReportSpeed(Context context, boolean value) {
setBoolean(context, R.string.report_speed_key, value);
}
/**
* Gets the selected track id key.
*
@@ -88,6 +144,42 @@ public class PreferencesUtils {
setLong(context, R.string.selected_track_id_key, trackId);
}
/**
* Returns the show check units dialog value.
*
* @param context the context
*/
public static boolean isShowCheckUnitsDialog(Context context) {
return getBoolean(context, R.string.show_check_units_dialog_key, true);
}
/**
* Sets the show check units dialog value to false.
*
* @param context the context
*/
public static void setShowCheckUnitsDialog(Context context) {
setBoolean(context, R.string.show_check_units_dialog_key, false);
}
/**
* Returns the show welcomes dialog value.
*
* @param context the context
*/
public static boolean isShowWelcomeDialog(Context context) {
return getBoolean(context, R.string.show_welcome_dialog_key, true);
}
/**
* Sets the show welcome dialog value to false.
*
* @param context the context
*/
public static void setShowWelcome(Context context) {
setBoolean(context, R.string.show_welcome_dialog_key, false);
}
/**
* Gets a preference key
*
@@ -98,6 +190,34 @@ public class PreferencesUtils {
return context.getString(keyId);
}
/**
* Gets a boolean preference value.
*
* @param context the context
* @param keyId the key id
* @param defaultValue the default value
*/
public static boolean getBoolean(Context context, int keyId, boolean defaultValue) {
SharedPreferences sharedPreferences = context.getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
return sharedPreferences.getBoolean(getKey(context, keyId), defaultValue);
}
/**
* Sets a boolean preference value.
*
* @param context the context
* @param keyId the key id
* @param value the value
*/
public static void setBoolean(Context context, int keyId, boolean value) {
SharedPreferences sharedPreferences = context.getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
Editor editor = sharedPreferences.edit();
editor.putBoolean(getKey(context, keyId), value);
ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(editor);
}
/**
* Gets a long preference value.
*
@@ -21,6 +21,7 @@ import com.google.android.maps.mytracks.R;
import android.app.Activity;
import android.location.Location;
import android.view.View;
import android.widget.TextView;
/**
@@ -33,111 +34,158 @@ public class StatsUtils {
private StatsUtils() {}
/**
* Sets the speed labels.
* Sets the location values.
*
* @param activity the activity
* @param reportSpeed true to report speed
* @param includeLocationSpeed true to include the current location speed
* @param location the location
* @param showAll true to show all the fields, false to show only the
* elevation field
*/
public static void setSpeedLabels(
Activity activity, boolean reportSpeed, boolean includeLocationSpeed) {
StatsUtils.setSpeedLabel(activity, R.id.stats_max_speed_label, R.string.stats_max_speed,
R.string.stats_fastest_pace, reportSpeed);
StatsUtils.setSpeedLabel(activity, R.id.stats_average_speed_label, R.string.stats_average_speed,
R.string.stats_average_pace, reportSpeed);
StatsUtils.setSpeedLabel(activity, R.id.stats_average_moving_speed_label,
R.string.stats_average_moving_speed, R.string.stats_average_moving_pace, reportSpeed);
if (includeLocationSpeed) {
StatsUtils.setSpeedLabel(
activity, R.id.stats_speed_label, R.string.stats_speed, R.string.stats_pace, reportSpeed);
public static void setLocationValues(Activity activity, Location location, boolean showAll) {
boolean metricUnits = PreferencesUtils.getBoolean(activity, R.string.metric_units_key, true);
boolean reportSpeed = PreferencesUtils.getBoolean(activity, R.string.report_speed_key, true);
// Set elevation
boolean showElevation = PreferencesUtils.getBoolean(
activity, R.string.stats_show_elevation_key, false);
if (showElevation) {
double altitude = location == null ? Double.NaN : location.getAltitude();
setElevationValue(activity, R.id.stats_elevation_value, altitude, metricUnits);
}
if (!showAll) {
return;
}
// Set speed/pace
setSpeedLabel(
activity, R.id.stats_speed_label, R.string.stats_speed, R.string.stats_pace, reportSpeed);
double speed = location == null ? Double.NaN : location.getSpeed();
setSpeedValue(activity, R.id.stats_speed_value, speed, metricUnits, reportSpeed);
// Set coordinate
boolean showCoordinate = PreferencesUtils.getBoolean(
activity, R.string.stats_show_coordinate_key, false);
View coordinateLabelTableRow = activity.findViewById(R.id.stats_coordinate_label_table_row);
View coordinateValueTableRow = activity.findViewById(R.id.stats_coordinate_value_table_row);
coordinateLabelTableRow.setVisibility(showCoordinate ? View.VISIBLE : View.GONE);
coordinateValueTableRow.setVisibility(showCoordinate ? View.VISIBLE : View.GONE);
if (showCoordinate) {
double latitude = location == null ? Double.NaN : location.getLatitude();
double longitude = location == null ? Double.NaN : location.getLongitude();
setCoordinateValue(activity, R.id.stats_latitude_value, latitude);
setCoordinateValue(activity, R.id.stats_longitude_value, longitude);
}
}
/**
* Sets the trip statistics values.
*
* @param activity the activity
* @param tripStatistics the trip statistics
* @param metricUnits true to display in metric units
* @param reportSpeed true to report speed
*/
public static void setTripStatisticsValues(
Activity activity, TripStatistics tripStatistics, boolean metricUnits, boolean reportSpeed) {
double totalDistance = tripStatistics == null ? Double.NaN : tripStatistics.getTotalDistance();
double maxSpeed = tripStatistics == null ? Double.NaN : tripStatistics.getMaxSpeed();
long totalTime = tripStatistics == null ? -1L : tripStatistics.getTotalTime();
double averageSpeed = tripStatistics == null ? Double.NaN : tripStatistics.getAverageSpeed();
long movingTime = tripStatistics == null ? -1L : tripStatistics.getMovingTime();
double averageMovingSpeed = tripStatistics == null ? Double.NaN
: tripStatistics.getAverageMovingSpeed();
double elevationGain = tripStatistics == null ? Double.NaN
: tripStatistics.getTotalElevationGain();
double minElevation = tripStatistics == null ? Double.NaN : tripStatistics.getMinElevation();
double maxElevation = tripStatistics == null ? Double.NaN : tripStatistics.getMaxElevation();
double minGrade = tripStatistics == null ? Double.NaN : tripStatistics.getMinGrade();
double maxGrade = tripStatistics == null ? Double.NaN : tripStatistics.getMaxGrade();
StatsUtils.setDistanceValue(
activity, R.id.stats_total_distance_value, totalDistance, metricUnits);
StatsUtils.setSpeedValue(
activity, R.id.stats_max_speed_value, maxSpeed, metricUnits, reportSpeed);
StatsUtils.setTimeValue(activity, R.id.stats_total_time_value, totalTime);
StatsUtils.setSpeedValue(
activity, R.id.stats_average_speed_value, averageSpeed, metricUnits, reportSpeed);
StatsUtils.setTimeValue(activity, R.id.stats_moving_time_value, movingTime);
StatsUtils.setSpeedValue(activity, R.id.stats_average_moving_speed_value, averageMovingSpeed,
metricUnits, reportSpeed);
StatsUtils.setAltitudeValue(
activity, R.id.stats_elevation_gain_value, elevationGain, metricUnits);
StatsUtils.setAltitudeValue(
activity, R.id.stats_min_elevation_value, minElevation, metricUnits);
StatsUtils.setAltitudeValue(
activity, R.id.stats_max_elevation_value, maxElevation, metricUnits);
StatsUtils.setGradeValue(activity, R.id.stats_min_grade_value, minGrade);
StatsUtils.setGradeValue(activity, R.id.stats_max_grade_value, maxGrade);
}
/**
* Sets the location values.
*
* @param activity the activity
* @param location the location
* @param metricUnits true to display in metric units
* @param reportSpeed true to report speed
*/
public static void setLocationValues(
Activity activity, Location location, boolean metricUnits, boolean reportSpeed) {
double speed = location == null ? Double.NaN : location.getSpeed();
double altitude = location == null ? Double.NaN : location.getAltitude();
double latitude = location == null ? Double.NaN : location.getLatitude();
double longitude = location == null ? Double.NaN : location.getLongitude();
StatsUtils.setSpeedValue(activity, R.id.stats_speed_value, speed, metricUnits, reportSpeed);
StatsUtils.setAltitudeValue(activity, R.id.stats_elevation_value, altitude, metricUnits);
StatsUtils.setCoordinateValue(activity, R.id.stats_latitude_value, latitude);
StatsUtils.setCoordinateValue(activity, R.id.stats_longitude_value, longitude);
}
/**
* Sets the location elevation value.
*
* @param activity the activity
* @param elevation the elevation in meters
* @param metricUnits true to display in metric units
*/
public static void setLocationElevationValue(
Activity activity, double elevation, boolean metricUnits) {
StatsUtils.setAltitudeValue(activity, R.id.stats_elevation_value, elevation, metricUnits);
}
/**
* Sets the total time value.
*
*
* @param activity the activity
* @param totalTime the total time
*/
public static void setTotalTimeValue(Activity activity, long totalTime) {
StatsUtils.setTimeValue(activity, R.id.stats_total_time_value, totalTime);
setTimeValue(activity, R.id.stats_total_time_value, totalTime);
}
/**
* Sets the trip statistics values.
*
* @param activity the activity
* @param tripStatistics the trip statistics
*/
public static void setTripStatisticsValues(Activity activity, TripStatistics tripStatistics) {
boolean metricUnits = PreferencesUtils.getBoolean(activity, R.string.metric_units_key, true);
boolean reportSpeed = PreferencesUtils.getBoolean(activity, R.string.report_speed_key, true);
boolean showTotalTime = PreferencesUtils.getBoolean(
activity, R.string.stats_show_total_time_key, true);
// Set total distance
double totalDistance = tripStatistics == null ? Double.NaN : tripStatistics.getTotalDistance();
setDistanceValue(activity, R.id.stats_total_distance_value, totalDistance, metricUnits);
// Set total time/moving time
setTimeLabel(activity, R.id.stats_total_time_label, R.string.stats_total_time,
R.string.stats_moving_time, showTotalTime);
long totalTime;
if (tripStatistics == null) {
totalTime = -1L;
} else {
totalTime = showTotalTime ? tripStatistics.getTotalTime() : tripStatistics.getMovingTime();
}
setTimeValue(activity, R.id.stats_total_time_value, totalTime);
// Set average speed/moving average speed
if (showTotalTime) {
setSpeedLabel(activity, R.id.stats_average_speed_label, R.string.stats_average_speed,
R.string.stats_average_pace, reportSpeed);
} else {
setSpeedLabel(activity, R.id.stats_average_speed_label, R.string.stats_average_moving_speed,
R.string.stats_average_moving_pace, reportSpeed);
}
double averageSpeed;
if (tripStatistics == null) {
averageSpeed = Double.NaN;
} else {
averageSpeed = showTotalTime ? tripStatistics.getAverageSpeed()
: tripStatistics.getAverageMovingSpeed();
}
setSpeedValue(activity, R.id.stats_average_speed_value, averageSpeed, metricUnits, reportSpeed);
// Set max speed
setSpeedLabel(activity, R.id.stats_max_speed_label, R.string.stats_max_speed,
R.string.stats_fastest_pace, reportSpeed);
double maxSpeed = tripStatistics == null ? Double.NaN : tripStatistics.getMaxSpeed();
setSpeedValue(activity, R.id.stats_max_speed_value, maxSpeed, metricUnits, reportSpeed);
// Set elevation
boolean showElevation = PreferencesUtils.getBoolean(
activity, R.string.stats_show_elevation_key, false);
View elevationLabelTableRow1 = activity.findViewById(R.id.stats_elevation_label_table_row1);
View elevationValueTableRow1 = activity.findViewById(R.id.stats_elevation_value_table_row1);
View elevationLabelTableRow2 = activity.findViewById(R.id.stats_elevation_label_table_row2);
View elevationValueTableRow2 = activity.findViewById(R.id.stats_elevation_value_table_row2);
elevationLabelTableRow1.setVisibility(showElevation ? View.VISIBLE : View.GONE);
elevationValueTableRow1.setVisibility(showElevation ? View.VISIBLE : View.GONE);
elevationLabelTableRow2.setVisibility(showElevation ? View.VISIBLE : View.GONE);
elevationValueTableRow2.setVisibility(showElevation ? View.VISIBLE : View.GONE);
if (showElevation) {
double elevationGain = tripStatistics == null ? Double.NaN
: tripStatistics.getTotalElevationGain();
double minElevation = tripStatistics == null ? Double.NaN : tripStatistics.getMinElevation();
double maxElevation = tripStatistics == null ? Double.NaN : tripStatistics.getMaxElevation();
setElevationValue(activity, R.id.stats_elevation_gain_value, elevationGain, metricUnits);
setElevationValue(activity, R.id.stats_min_elevation_value, minElevation, metricUnits);
setElevationValue(activity, R.id.stats_max_elevation_value, maxElevation, metricUnits);
}
// Set grade
boolean showGrade = PreferencesUtils.getBoolean(activity, R.string.stats_show_grade_key, false);
View gradeLabelTableRow = activity.findViewById(R.id.stats_grade_label_table_row);
View gradeValueTableRow = activity.findViewById(R.id.stats_grade_value_table_row);
gradeLabelTableRow.setVisibility(showGrade ? View.VISIBLE : View.GONE);
gradeValueTableRow.setVisibility(showGrade ? View.VISIBLE : View.GONE);
if (showGrade) {
double minGrade = tripStatistics == null ? Double.NaN : tripStatistics.getMinGrade();
double maxGrade = tripStatistics == null ? Double.NaN : tripStatistics.getMaxGrade();
setGradeValue(activity, R.id.stats_min_grade_value, minGrade);
setGradeValue(activity, R.id.stats_max_grade_value, maxGrade);
}
}
/**
* Sets a time label.
*
* @param activity the activity
* @param id the time label resource id
* @param totalTimeId the total time string id
* @param movingTimeId the moving time string id
* @param totalTime true to use total time
*/
private static void setTimeLabel(Activity activity, int id, int totalTimeId, int movingTimeId,
boolean totalTime) {
TextView textView = (TextView) activity.findViewById(id);
textView.setText(totalTime ? totalTimeId : movingTimeId);
}
/**
@@ -235,25 +283,25 @@ public class StatsUtils {
}
/**
* Sets an altitude value.
* Sets an elevation value.
*
* @param activity the activity
* @param id the altitude value resource id
* @param altitude the altitude in meters
* @param id the elevation value resource id
* @param elevation the elevation in meters
* @param metricUnits true to display in metric units
*/
private static void setAltitudeValue(
Activity activity, int id, double altitude, boolean metricUnits) {
private static void setElevationValue(
Activity activity, int id, double elevation, boolean metricUnits) {
TextView textView = (TextView) activity.findViewById(id);
String value;
if (Double.isNaN(altitude) || Double.isInfinite(altitude)) {
if (Double.isNaN(elevation) || Double.isInfinite(elevation)) {
value = activity.getString(R.string.value_unknown);
} else {
if (metricUnits) {
value = activity.getString(R.string.value_float_meter, altitude);
value = activity.getString(R.string.value_float_meter, elevation);
} else {
altitude *= UnitConversions.M_TO_FT;
value = activity.getString(R.string.value_float_feet, altitude);
elevation *= UnitConversions.M_TO_FT;
value = activity.getString(R.string.value_float_feet, elevation);
}
}
textView.setText(value);
@@ -17,9 +17,11 @@
package com.google.android.apps.mytracks.util;
import com.google.android.apps.mytracks.TrackEditActivity;
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
import com.google.android.apps.mytracks.services.ITrackRecordingService;
import com.google.android.apps.mytracks.services.TrackRecordingService;
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
import com.google.android.maps.mytracks.R;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
@@ -28,6 +30,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.RemoteException;
import android.util.Log;
import android.widget.Toast;
import java.util.List;
@@ -122,7 +125,7 @@ public class TrackRecordingServiceConnectionUtils {
/**
* Resumes the track recording service connection.
*
*
* @param context the context
* @param trackRecordingServiceConnection the track recording service
* connection
@@ -134,4 +137,29 @@ public class TrackRecordingServiceConnectionUtils {
PreferencesUtils.setRecordingTrackId(context, -1L);
}
}
/**
* Adds a marker.
*/
public static void addMarker(Context context,
TrackRecordingServiceConnection trackRecordingServiceConnection,
WaypointCreationRequest waypointCreationRequest) {
ITrackRecordingService trackRecordingService = trackRecordingServiceConnection
.getServiceIfBound();
if (trackRecordingService == null) {
Log.d(TAG, "Unable to add marker, no track recording service");
} else {
try {
if (trackRecordingService.insertWaypoint(waypointCreationRequest) != -1L) {
Toast.makeText(context, R.string.marker_add_success, Toast.LENGTH_SHORT).show();
return;
}
} catch (RemoteException e) {
Log.e(TAG, "Unable to add marker", e);
} catch (IllegalStateException e) {
Log.e(TAG, "Unable to add marker.", e);
}
}
Toast.makeText(context, R.string.marker_add_error, Toast.LENGTH_LONG).show();
}
}
@@ -71,7 +71,7 @@ public class TrackWidgetProvider
private Context context;
private String unknown;
private TrackObserver trackObserver;
private boolean isMetric;
private boolean metricUnits;
private boolean reportSpeed;
private long selectedTrackId;
private SharedPreferences sharedPreferences;
@@ -178,11 +178,11 @@ public class TrackWidgetProvider
if (TRACK_STARTED_ACTION.equals(action)) {
// If a new track is started by this appwidget or elsewhere,
// toggle the button to active and have it disable the track if pressed.
setButtonIntent(views, R.string.track_action_end, R.drawable.appwidget_button_enabled);
setButtonIntent(views, R.string.track_action_end, R.drawable.app_widget_button_enabled);
} else {
// If a track is stopped by this appwidget or elsewhere,
// toggle the button to inactive and have it start a new track if pressed.
setButtonIntent(views, R.string.track_action_start, R.drawable.appwidget_button_disabled);
setButtonIntent(views, R.string.track_action_start, R.drawable.app_widget_button_disabled);
}
}
@@ -218,10 +218,10 @@ public class TrackWidgetProvider
}
TripStatistics stats = track.getStatistics();
String distance = StringUtils.formatDistance(context, stats.getTotalDistance(), isMetric);
String distance = StringUtils.formatDistance(context, stats.getTotalDistance(), metricUnits);
String time = StringUtils.formatElapsedTime(stats.getMovingTime());
String speed = StringUtils.formatSpeed(
context, stats.getAverageMovingSpeed(), isMetric, reportSpeed);
context, stats.getAverageMovingSpeed(), metricUnits, reportSpeed);
views.setTextViewText(R.id.appwidget_distance_text, distance);
views.setTextViewText(R.id.appwidget_time_text, time);
@@ -230,14 +230,12 @@ public class TrackWidgetProvider
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
String metricUnitsKey = context.getString(R.string.metric_units_key);
if (key == null || key.equals(metricUnitsKey)) {
isMetric = prefs.getBoolean(metricUnitsKey, true);
if (key == null || key.equals(PreferencesUtils.getMetricUnitsKey(context))) {
metricUnits = PreferencesUtils.isMetricUnits(context);
}
String reportSpeedKey = context.getString(R.string.report_speed_key);
if (key == null || key.equals(reportSpeedKey)) {
reportSpeed = prefs.getBoolean(reportSpeedKey, true);
if (key == null || key.equals(PreferencesUtils.getReportSpeedKey(context))) {
reportSpeed = PreferencesUtils.isReportSpeed(context);
}
if (key == null || key.equals(PreferencesUtils.getSelectedTrackIdKey(context))) {
+1 -1
View File
@@ -29,7 +29,7 @@ limitations under the License.
android:targetSdkVersion="15" />
<application
android:icon="@drawable/arrow_icon"
android:icon="@drawable/my_tracks_icon"
android:label="@string/lib_name" >
</application>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

@@ -129,6 +129,15 @@ public interface MyTracksProviderUtils {
*/
long getLastWaypointId(long trackId);
/**
* Gets the next marker number.
*
* @param trackId the track id
* @param statistics true for statistics marker, false for waypoint marker
* @return the next number or -1 if unable to get the value
*/
int getNextMarkerNumber(long trackId, boolean statistics);
/**
* Finds the last recorded track from the track provider.
*
@@ -794,6 +794,37 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
return -1;
}
@Override
public int getNextMarkerNumber(long trackId, boolean statistics) {
if (trackId == -1L) {
return -1;
}
String[] projection = { "_id" };
String selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns.TYPE + "=?";
String[] selectionArgs = new String[] { String.valueOf(trackId),
String.valueOf(statistics ? Waypoint.TYPE_STATISTICS : Waypoint.TYPE_WAYPOINT) };
Cursor cursor = null;
try {
cursor = contentResolver.query(
WaypointsColumns.CONTENT_URI, projection, selection, selectionArgs, null);
if (cursor != null) {
int count = cursor.getCount();
/*
* For statistics markers, the first marker is for the track statistics,
* thus just return the count as the next user visible number.
*/
return statistics ? count : count + 1;
}
} catch (RuntimeException e) {
Log.w(TAG, "Caught unexpected exception.", e);
} finally {
if (cursor != null) {
cursor.close();
}
}
return -1;
}
@Override
public Track getLastTrack() {
Cursor cursor = null;
@@ -26,7 +26,7 @@ import android.os.Parcelable;
public class WaypointCreationRequest implements Parcelable {
public static enum WaypointType {
MARKER,
WAYPOINT,
STATISTICS;
}
@@ -36,8 +36,8 @@ public class WaypointCreationRequest implements Parcelable {
private String description;
private String iconUrl;
public final static WaypointCreationRequest DEFAULT_MARKER =
new WaypointCreationRequest(WaypointType.MARKER);
public final static WaypointCreationRequest DEFAULT_WAYPOINT =
new WaypointCreationRequest(WaypointType.WAYPOINT);
public final static WaypointCreationRequest DEFAULT_STATISTICS =
new WaypointCreationRequest(WaypointType.STATISTICS);
@@ -30,7 +30,6 @@ import com.google.android.apps.mytracks.content.TrackDataHub.ListenerDataType;
import com.google.android.apps.mytracks.content.TrackDataListener.ProviderState;
import com.google.android.apps.mytracks.services.TrackRecordingServiceTest.MockContext;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import com.google.android.testing.mocking.AndroidMock;
import android.content.Context;
@@ -798,12 +797,12 @@ public class TrackDataHubTest extends AndroidTestCase {
}
public void testDisplayPreferencesListen() throws Exception {
String metricUnitsKey = context.getString(R.string.metric_units_key);
String speedKey = context.getString(R.string.report_speed_key);
String metricUnitsKey = PreferencesUtils.getMetricUnitsKey(context);
String reportSpeedKey = PreferencesUtils.getReportSpeedKey(context);
prefs.edit()
.putBoolean(metricUnitsKey, true)
.putBoolean(speedKey, true)
.putBoolean(reportSpeedKey, true)
.apply();
Capture<OnSharedPreferenceChangeListener> listenerCapture =
@@ -829,10 +828,10 @@ public class TrackDataHubTest extends AndroidTestCase {
replay();
prefs.edit()
.putBoolean(speedKey, false)
.putBoolean(reportSpeedKey, false)
.apply();
OnSharedPreferenceChangeListener listener = listenerCapture.getValue();
listener.onSharedPreferenceChanged(prefs, speedKey);
listener.onSharedPreferenceChanged(prefs, reportSpeedKey);
AndroidMock.verify(dataSources, providerUtils, listener1, listener2);
AndroidMock.reset(dataSources, providerUtils, listener1, listener2);
@@ -29,7 +29,7 @@ import android.test.AndroidTestCase;
public class WaypointCreationRequestTest extends AndroidTestCase {
public void testTypeParceling() {
WaypointCreationRequest original = WaypointCreationRequest.DEFAULT_MARKER;
WaypointCreationRequest original = WaypointCreationRequest.DEFAULT_WAYPOINT;
Parcel p = Parcel.obtain();
original.writeToParcel(p, 0);
p.setDataPosition(0);
@@ -42,7 +42,7 @@ public class WaypointCreationRequestTest extends AndroidTestCase {
public void testAllAttributesParceling() {
WaypointCreationRequest original =
new WaypointCreationRequest(WaypointType.MARKER, "name", "category", "description", "img.png");
new WaypointCreationRequest(WaypointType.WAYPOINT, "name", "category", "description", "img.png");
Parcel p = Parcel.obtain();
original.writeToParcel(p, 0);
p.setDataPosition(0);
@@ -31,9 +31,16 @@ public class CsvTrackWriterTest extends TrackFormatWriterTest {
String expectedTrackHeader = getExpectedLine(
"Name", "Activity type", "Description");
String expectedTrack = getExpectedLine(TRACK_NAME, TRACK_CATEGORY, TRACK_DESCRIPTION);
String expectedMarkerHeader = getExpectedLine("Marker name", "Marker type",
"Marker description", "Latitude (deg)", "Longitude (deg)", "Altitude (m)", "Bearing (deg)",
"Accuracy (m)", "Speed (m/s)", "Time");
String expectedMarkerHeader = getExpectedLine("Name",
"Marker type",
"Description",
"Latitude (deg)",
"Longitude (deg)",
"Altitude (m)",
"Bearing (deg)",
"Accuracy (m)",
"Speed (m/s)",
"Time");
String expectedMarker1 = getExpectedLine(WAYPOINT1_NAME, WAYPOINT1_CATEGORY,
WAYPOINT1_DESCRIPTION, "1.0", "-1.0", "10.0", "100.0", "1,000", "10,000",
"1970-01-01T00:01:40.000Z");
@@ -491,11 +491,9 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
assertEquals(1, service.insertWaypoint(WaypointCreationRequest.DEFAULT_STATISTICS));
assertEquals(2, service.insertWaypoint(WaypointCreationRequest.DEFAULT_STATISTICS));
Waypoint wpt = providerUtils.getWaypoint(1);
assertEquals(getContext().getString(R.string.marker_statistics_icon_url),
wpt.getIcon());
assertEquals(getContext().getString(R.string.marker_edit_type_statistics),
wpt.getName());
Waypoint wpt = providerUtils.getWaypoint(2);
assertEquals(getContext().getString(R.string.marker_statistics_icon_url), wpt.getIcon());
assertEquals(getContext().getString(R.string.marker_statistics_name_format, 1), wpt.getName());
assertEquals(Waypoint.TYPE_STATISTICS, wpt.getType());
assertEquals(123L, wpt.getTrackId());
assertEquals(0.0, wpt.getLength());
@@ -512,7 +510,7 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
assertFalse(service.isRecording());
try {
service.insertWaypoint(WaypointCreationRequest.DEFAULT_MARKER);
service.insertWaypoint(WaypointCreationRequest.DEFAULT_WAYPOINT);
fail("Expecting IllegalStateException");
} catch (IllegalStateException e) {
// Expected.
@@ -526,12 +524,11 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
ITrackRecordingService service = bindAndGetService(createStartIntent());
assertTrue(service.isRecording());
assertEquals(1, service.insertWaypoint(WaypointCreationRequest.DEFAULT_MARKER));
assertEquals(1, service.insertWaypoint(WaypointCreationRequest.DEFAULT_WAYPOINT));
Waypoint wpt = providerUtils.getWaypoint(1);
assertEquals(getContext().getString(R.string.marker_waypoint_icon_url),
wpt.getIcon());
assertEquals(getContext().getString(R.string.marker_edit_type_waypoint),
wpt.getName());
assertEquals(getContext().getString(R.string.marker_waypoint_name_format, 1), wpt.getName());
assertEquals(Waypoint.TYPE_WAYPOINT, wpt.getType());
assertEquals(123L, wpt.getTrackId());
assertEquals(0.0, wpt.getLength());
@@ -727,7 +724,7 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
if (i % 10 == 0) {
service.insertWaypoint(WaypointCreationRequest.DEFAULT_STATISTICS);
} else if (i % 7 == 0) {
service.insertWaypoint(WaypointCreationRequest.DEFAULT_MARKER);
service.insertWaypoint(WaypointCreationRequest.DEFAULT_WAYPOINT);
}
}