Merge heads

This commit is contained in:
youtaol
2012-04-26 18:59:06 +08:00
parent 420cb0f49b
commit 6848a7a475
43 changed files with 1658 additions and 1414 deletions
+9 -17
View File
@@ -171,6 +171,15 @@ limitations under the License.
<data android:scheme="file" />
</intent-filter>
</activity>
<activity
android:name="com.google.android.apps.mytracks.MarkerEditActivity"
android:windowSoftInputMode="stateHidden" />
<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.SearchActivity" />
</activity>
<activity
android:launchMode="singleTop"
android:name="com.google.android.apps.mytracks.SearchActivity" >
@@ -204,23 +213,6 @@ limitations under the License.
android:name="android.app.default_searchable"
android:value="com.google.android.apps.mytracks.SearchActivity" />
</activity>
<activity
android:label="@string/marker_detail_title"
android:name="com.google.android.apps.mytracks.WaypointDetails" >
<intent-filter>
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.waypoint" />
</intent-filter>
</activity>
<activity android:name="com.google.android.apps.mytracks.WaypointsList" >
<meta-data
android:name="android.app.default_searchable"
android:value="com.google.android.apps.mytracks.SearchActivity" />
</activity>
<activity android:name="com.google.android.apps.mytracks.io.backup.BackupActivity"/>
<activity android:name="com.google.android.apps.mytracks.io.backup.RestoreActivity"/>
<activity android:name="com.google.android.apps.mytracks.io.backup.RestoreChooserActivity"/>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,25 @@
<?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" >
<Button
android:id="@+id/marker_edit_cancel"
android:text="@string/generic_cancel"
style="@style/BottomButton" />
<Button
android:id="@+id/marker_edit_done"
style="@style/BottomButton" />
</merge>
+162
View File
@@ -0,0 +1,162 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010 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"
android:layout_height="fill_parent"
android:layout_width="fill_parent" >
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:padding="8dp" >
<TextView
android:id="@+id/marker_detail_name"
style="@style/MarkerDetailLabel" />
<LinearLayout
android:id="@+id/marker_detail_waypoint_section"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/marker_detail_marker_type"
style="@style/MarkerDetailLabel" />
<TextView
android:id="@+id/marker_detail_description"
style="@style/MarkerDetailLabel" />
</LinearLayout>
<TableLayout
android:id="@+id/marker_detail_statistics_section"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:shrinkColumns="0,2"
android:stretchColumns="0,2" >
<!-- Total distance and max speed (fastest pace) -->
<TableRow>
<TextView
android:text="@string/stat_total_distance"
style="@style/MarkerDetailStatisticsLabel" />
<TextView
android:id="@+id/marker_detail_max_speed_label"
android:layout_column="2"
style="@style/MarkerDetailStatisticsLabel" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/marker_detail_total_distance_value"
style="@style/MarkerDetailStatisticsValue" />
<TextView style="@style/MarkerDetailStatisticsSpacer" />
<TextView
android:id="@+id/marker_detail_max_speed_value"
style="@style/MarkerDetailStatisticsValue" />
</TableRow>
<!-- Total time and average speed (average pace) -->
<TableRow>
<TextView
android:text="@string/stat_total_time"
style="@style/MarkerDetailStatisticsLabel" />
<TextView
android:id="@+id/marker_detail_average_speed_label"
android:layout_column="2"
style="@style/MarkerDetailStatisticsLabel" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/marker_detail_total_time_value"
style="@style/MarkerDetailStatisticsValue" />
<TextView style="@style/MarkerDetailStatisticsSpacer" />
<TextView
android:id="@+id/marker_detail_average_speed_value"
style="@style/MarkerDetailStatisticsValue" />
</TableRow>
<!-- Moving time and average moving speed (average moving pace) -->
<TableRow>
<TextView
android:text="@string/stat_moving_time"
style="@style/MarkerDetailStatisticsLabel" />
<TextView
android:id="@+id/marker_detail_average_moving_speed_label"
android:layout_column="2"
style="@style/MarkerDetailStatisticsLabel" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/marker_detail_moving_time_value"
style="@style/MarkerDetailStatisticsValue" />
<TextView style="@style/MarkerDetailStatisticsSpacer" />
<TextView
android:id="@+id/marker_detail_average_moving_speed_value"
style="@style/MarkerDetailStatisticsValue" />
</TableRow>
<!-- Elevation and elevation gain -->
<TableRow>
<TextView
android:text="@string/stat_elevation"
style="@style/MarkerDetailStatisticsLabel" />
<TextView
android:layout_column="2"
android:text="@string/stat_elevation_gain"
style="@style/MarkerDetailStatisticsLabel" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/marker_detail_elevation_value"
style="@style/MarkerDetailStatisticsValue" />
<TextView style="@style/MarkerDetailStatisticsSpacer" />
<TextView
android:id="@+id/marker_detail_elevation_gain_value"
style="@style/MarkerDetailStatisticsValue" />
</TableRow>
<!-- Min and max elevation -->
<TableRow>
<TextView
android:text="@string/stat_min_elevation"
style="@style/MarkerDetailStatisticsLabel" />
<TextView
android:layout_column="2"
android:text="@string/stat_max_elevation"
style="@style/MarkerDetailStatisticsLabel" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/marker_detail_min_elevation_value"
style="@style/MarkerDetailStatisticsValue" />
<TextView style="@style/MarkerDetailStatisticsSpacer" />
<TextView
android:id="@+id/marker_detail_max_elevation_value"
style="@style/MarkerDetailStatisticsValue" />
</TableRow>
<!-- Min and max grade -->
<TableRow>
<TextView
android:text="@string/stat_min_grade"
style="@style/MarkerDetailStatisticsLabel" />
<TextView
android:layout_column="2"
android:text="@string/stat_max_grade"
style="@style/MarkerDetailStatisticsLabel" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/marker_detail_min_grade_value"
style="@style/MarkerDetailStatisticsValue" />
<TextView style="@style/MarkerDetailStatisticsSpacer" />
<TextView
android:id="@+id/marker_detail_max_grade_value"
style="@style/MarkerDetailStatisticsValue" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
+86
View File
@@ -0,0 +1,86 @@
<?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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical" >
<ScrollView
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="fill_parent" >
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:padding="8dp" >
<LinearLayout
android:id="@+id/marker_edit_type_section"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical" >
<TextView
android:text="@string/marker_edit_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"
style="@style/EditLabel" />
<RadioButton
android:id="@+id/marker_edit_type_waypoint"
android:text="@string/marker_edit_type_waypoint"
style="@style/EditLabel" />
</RadioGroup>
</LinearLayout>
<TextView
android:text="@string/generic_name"
style="@style/EditLabel" />
<EditText
android:hint="@string/generic_name"
android:id="@+id/marker_edit_name"
style="@style/EditName" />
<LinearLayout
android:id="@+id/marker_edit_waypoint_section"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical" >
<TextView
android:text="@string/marker_edit_marker_type"
style="@style/EditLabel" />
<AutoCompleteTextView
android:hint="@string/marker_edit_marker_type_hint"
android:id="@+id/marker_edit_marker_type"
android:imeOptions="actionNext"
style="@style/EditCategory" />
<TextView
android:text="@string/generic_description"
style="@style/EditLabel" />
<EditText
android:hint="@string/generic_description"
android:id="@+id/marker_edit_description"
android:imeOptions="actionDone"
style="@style/EditDescription" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout style="@style/BottomButtonBar" >
<include layout="@layout/marker_edit_buttons" />
</LinearLayout>
</LinearLayout>
@@ -0,0 +1,25 @@
<?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" >
<Button
android:id="@+id/marker_edit_done"
style="@style/BottomButton" />
<Button
android:id="@+id/marker_edit_cancel"
android:text="@string/generic_cancel"
style="@style/BottomButton" />
</merge>
+34
View File
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010 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.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent" >
<ListView
android:id="@+id/marker_list"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
<TextView
android:layout_gravity="center"
android:gravity="center"
android:id="@+id/marker_list_empty"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingBottom="8dp"
android:text="@string/marker_list_empty_message"
style="@android:style/TextAppearance.DeviceDefault.Large" >
</TextView>
</FrameLayout>
+41
View File
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010 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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="vertical"
android:padding="8dp" >
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/marker_list_item_name"
style="@style/ListItemName" />
<TextView
android:id="@+id/marker_list_item_category"
style="@style/ListItemCategory" />
</LinearLayout>
<TextView
android:id="@+id/marker_list_item_time"
style="@style/ListItemStat" />
<TextView
android:id="@+id/marker_list_item_description"
style="@style/ListItemDescription" />
</LinearLayout>
@@ -1,61 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010 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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="horizontal"
android:paddingBottom="2dp"
android:paddingTop="2dp" >
<ImageView
android:contentDescription="@string/marker_icon_description"
android:id="@+id/waypointslist_item_icon"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="6dp"
android:layout_width="wrap_content"
android:src="@drawable/ylw_pushpin" />
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/waypointslist_item_name"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="6dp"
android:layout_width="fill_parent"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/waypointslist_item_time"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_width="fill_parent"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#fff" />
<TextView
android:id="@+id/waypointslist_item_category"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_width="fill_parent"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#0f0" />
</LinearLayout>
</LinearLayout>
@@ -1,499 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010 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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#c000">
<ScrollView
android:id="@+id/scrolly"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="fill_parent"
android:scrollbarStyle="insideInset">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:text="@string/marker_detail_marker_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView android:id="@+id/waypointdetails_icon"
android:contentDescription="@string/marker_icon_description"
android:src="@drawable/ylw_pushpin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="4dp"
android:paddingRight="2dp"/>
<EditText android:id="@+id/waypointdetails_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:inputType="textAutoCorrect|textCapWords"
android:selectAllOnFocus="true"
android:hint="@string/marker_detail_marker_name"
android:imeOptions="actionNext"/>
</LinearLayout>
<LinearLayout android:id="@+id/waypointdetails_description_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:visibility="visible"
android:layout_weight="1">
<TextView android:id="@+id/waypointdetails_category_label"
android:text="@string/marker_detail_marker_type"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<AutoCompleteTextView android:id="@+id/waypointdetails_category"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="@string/marker_detail_marker_type_hint"
android:imeOptions="actionNext"/>
<TextView android:text="@string/marker_detail_marker_description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText android:id="@+id/waypointdetails_description"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:singleLine="false"
android:inputType="textAutoCorrect|textCapSentences"
android:selectAllOnFocus="true"
android:minLines="5"
android:maxLines="50"
android:gravity="top"
android:layout_weight="1"
android:hint="@string/marker_detail_marker_description"
android:imeOptions="actionDone"/>
</LinearLayout>
<TableLayout android:id="@+id/waypoint_stats"
android:visibility="gone"
android:padding="2dp"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:stretchColumns="1,4">
<!-- Total distance and max speed -->
<TableRow
android:padding="1dp">
<TextView
android:id="@+id/total_distance_label"
android:layout_column="1"
android:layout_span="3"
android:text="@string/stat_total_distance" />
<TextView
android:id="@+id/max_speed_label"
android:layout_column="4"
android:layout_span="2"
android:text="@string/stat_max_speed" />
</TableRow>
<TableRow
android:background="@color/stat_label_background">
<TextView
android:gravity="right"
android:id="@+id/total_distance_register"
android:layout_column="1"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:text="@string/value_unknown"
android:textColor="@color/stat_label_text"
android:textSize="40sp" />
<TextView
android:gravity="left"
android:id="@+id/total_distance_unit_label"
android:layout_column="2"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:text="@string/unit_mile"
android:textColor="@color/stat_label_text" />
<!-- TODO 4/08/2009
The following is a bad hack to get a spacer the same size as the
text. Ideally this should just be a View, however I don't know how to
set the view height properly. fill_parent on this element causes as
NullPointerException. This same filler is repeated on each line.-->
<TextView
android:background="@color/black"
android:layout_column="3"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:layout_width="5dp"
android:textSize="40sp" />
<TextView
android:gravity="right"
android:id="@+id/max_speed_register"
android:layout_column="4"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:text="@string/value_unknown"
android:textColor="@color/stat_label_text"
android:textSize="40sp" />
<LinearLayout
android:gravity="bottom"
android:layout_column="5"
android:layout_width="wrap_content"
android:lines="1"
android:orientation="vertical">
<TextView
android:id="@+id/max_speed_unit_label_top"
android:gravity="bottom"
android:layout_height="wrap_content"
android:layout_marginBottom="-1dp"
android:layout_marginTop="-1dp"
android:layout_width="wrap_content"
android:textColor="@color/stat_label_text" />
<TextView
android:background="@color/black"
android:layout_height="3dp"
android:layout_width="fill_parent" />
<TextView
android:id="@+id/max_speed_unit_label_bottom"
android:gravity="bottom"
android:layout_height="wrap_content"
android:layout_marginBottom="-1dp"
android:layout_marginTop="-1dp"
android:layout_width="wrap_content"
android:textColor="@color/stat_label_text" />
</LinearLayout>
</TableRow>
<!-- Total time and average speed -->
<TableRow>
<TextView
android:id="@+id/track_time_label"
android:layout_column="1"
android:layout_span="3"
android:text="@string/stat_total_time" />
<TextView
android:id="@+id/average_speed_label"
android:layout_column="4"
android:layout_span="2"
android:text="@string/stat_average_speed" />
</TableRow>
<TableRow
android:background="@color/stat_label_background">
<TextView
android:gravity="right"
android:id="@+id/total_time_register"
android:layout_column="1"
android:layout_height="wrap_content"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:layout_span="2"
android:layout_width="fill_parent"
android:text="@string/value_unknown"
android:textColor="@color/stat_label_text"
android:textSize="40sp" />
<TextView
android:background="@color/black"
android:layout_column="3"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:layout_width="5dp"
android:textSize="40sp" />
<TextView
android:gravity="right"
android:id="@+id/average_speed_register"
android:layout_column="4"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:text="@string/value_unknown"
android:textColor="@color/stat_label_text"
android:textSize="40sp" />
<LinearLayout
android:gravity="bottom"
android:layout_column="5"
android:layout_width="wrap_content"
android:lines="1"
android:orientation="vertical">
<TextView
android:id="@+id/average_speed_unit_label_top"
android:gravity="bottom"
android:layout_height="wrap_content"
android:layout_marginBottom="-1dp"
android:layout_marginTop="-1dp"
android:layout_width="wrap_content"
android:textColor="@color/stat_label_text" />
<TextView
android:background="@color/black"
android:layout_height="3dp"
android:layout_width="fill_parent" />
<TextView
android:id="@+id/average_speed_unit_label_bottom"
android:gravity="bottom"
android:layout_height="wrap_content"
android:layout_marginBottom="-1dp"
android:layout_marginTop="-1dp"
android:layout_width="wrap_content"
android:textColor="@color/stat_label_text" />
</LinearLayout>
</TableRow>
<!-- Moving time and average moving speed -->
<TableRow>
<TextView
android:id="@+id/moving_time_label"
android:layout_column="1"
android:layout_span="3"
android:text="@string/stat_moving_time" />
<TextView
android:id="@+id/average_moving_speed_label"
android:layout_column="4"
android:layout_span="2"
android:text="@string/stat_average_moving_speed" />
</TableRow>
<TableRow
android:background="@color/stat_label_background">
<TextView
android:gravity="right"
android:id="@+id/moving_time_register"
android:layout_column="1"
android:layout_height="wrap_content"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:layout_width="fill_parent"
android:layout_span="2"
android:text="@string/value_unknown"
android:textColor="@color/stat_label_text"
android:textSize="40sp" />
<TextView
android:background="@color/black"
android:layout_column="3"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:layout_width="5dp"
android:textSize="40sp" />
<TextView
android:gravity="right"
android:id="@+id/average_moving_speed_register"
android:layout_column="4"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:text="@string/value_unknown"
android:textColor="@color/stat_label_text"
android:textSize="40sp" />
<LinearLayout
android:gravity="bottom"
android:layout_column="5"
android:layout_width="wrap_content"
android:lines="1"
android:orientation="vertical">
<TextView
android:id="@+id/average_moving_speed_unit_label_top"
android:gravity="bottom"
android:layout_height="wrap_content"
android:layout_marginBottom="-1dp"
android:layout_marginTop="-1dp"
android:layout_width="wrap_content"
android:textColor="@color/stat_label_text" />
<TextView
android:background="@color/black"
android:layout_height="3dp"
android:layout_width="fill_parent" />
<TextView
android:id="@+id/average_moving_speed_unit_label_bottom"
android:gravity="bottom"
android:layout_height="wrap_content"
android:layout_marginBottom="-1dp"
android:layout_marginTop="-1dp"
android:layout_width="wrap_content"
android:textColor="@color/stat_label_text" />
</LinearLayout>
</TableRow>
<!-- Elevation and elevation gain -->
<TableRow>
<TextView
android:id="@+id/elevation_label"
android:layout_column="1"
android:layout_span="3"
android:text="@string/stat_elevation" />
<TextView
android:id="@+id/elevation_gain_label"
android:layout_column="4"
android:layout_span="2"
android:text="@string/stat_elevation_gain" />
</TableRow>
<TableRow
android:background="@color/stat_label_background">
<TextView
android:gravity="right"
android:id="@+id/elevation_register"
android:layout_column="1"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:text="@string/value_unknown"
android:textColor="@color/stat_label_text"
android:textSize="40sp" />
<TextView
android:gravity="left"
android:id="@+id/elevation_unit_label"
android:layout_column="2"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:text="@string/unit_feet"
android:textColor="@color/stat_label_text"/>
<TextView
android:background="@color/black"
android:layout_column="3"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:layout_width="5dp"
android:textSize="40sp" />
<TextView
android:gravity="right"
android:id="@+id/elevation_gain_register"
android:layout_column="4"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:text="@string/value_unknown"
android:textColor="@color/stat_label_text"
android:textSize="40sp" />
<TextView
android:gravity="left"
android:id="@+id/elevation_gain_unit_label"
android:layout_column="5"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:text="@string/unit_feet"
android:textColor="@color/stat_label_text" />
</TableRow>
<!-- Min and max elevation -->
<TableRow>
<TextView
android:id="@+id/min_elevation_label"
android:layout_column="1"
android:layout_span="3"
android:text="@string/stat_min_elevation" />
<TextView
android:id="@+id/max_elevation_label"
android:layout_column="4"
android:layout_span="3"
android:text="@string/stat_max_elevation" />
</TableRow>
<TableRow
android:background="@color/stat_label_background">
<TextView
android:gravity="right"
android:id="@+id/min_elevation_register"
android:layout_column="1"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:text="@string/value_unknown"
android:textColor="@color/stat_label_text"
android:textSize="40sp" />
<TextView
android:gravity="left"
android:id="@+id/min_elevation_unit_label"
android:layout_column="2"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:text="@string/unit_feet"
android:textColor="@color/stat_label_text" />
<TextView
android:background="@color/black"
android:layout_column="3"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:layout_width="5dp"
android:textSize="40sp" />
<TextView
android:gravity="right"
android:id="@+id/max_elevation_register"
android:layout_column="4"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:text="@string/value_unknown"
android:textColor="@color/stat_label_text"
android:textSize="40sp" />
<TextView
android:id="@+id/max_elevation_unit_label"
android:gravity="left"
android:layout_column="5"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:text="@string/unit_feet"
android:textColor="@color/stat_label_text" />
</TableRow>
<!-- Min and max grade -->
<TableRow>
<TextView
android:id="@+id/min_grade_label"
android:layout_column="1"
android:layout_span="3"
android:text="@string/stat_min_grade" />
<TextView
android:id="@+id/max_grade_label"
android:layout_column="4"
android:layout_span="2"
android:text="@string/stat_max_grade" />
</TableRow>
<TableRow
android:background="@color/stat_label_background">
<TextView
android:gravity="right"
android:id="@+id/min_grade_register"
android:layout_column="1"
android:layout_height="wrap_content"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:layout_width="fill_parent"
android:layout_span="2"
android:text="@string/value_unknown"
android:textColor="@color/stat_label_text"
android:textSize="40sp" />
<TextView
android:background="@color/black"
android:layout_column="3"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:layout_width="5dp"
android:textSize="40sp" />
<TextView
android:gravity="right"
android:id="@+id/max_grade_register"
android:layout_column="4"
android:layout_height="wrap_content"
android:layout_marginBottom="-9dp"
android:layout_marginTop="-9dp"
android:layout_width="fill_parent"
android:layout_span="2"
android:text="@string/value_unknown"
android:textColor="@color/stat_label_text"
android:textSize="40sp" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
<LinearLayout style="@style/BottomButtonBar" >
<Button
android:id="@+id/waypointdetails_save"
android:text="@string/generic_save"
style="@style/BottomButton" />
<Button
android:id="@+id/waypointdetails_cancel"
android:text="@string/generic_cancel"
style="@style/BottomButton" />
</LinearLayout>
</LinearLayout>
@@ -1,52 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010 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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apl/res/com.google.android.apps.mytracks"
android:id="@+id/waypointslist_root"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_bar"
android:layout_weight="0"
android:padding="3dp">
<TextView android:id="@+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="16dp"
android:textColor="#fff"
android:text="@string/marker_list_pick_one"
android:layout_weight="1"/>
</LinearLayout>
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<LinearLayout style="@style/BottomButtonBar" >
<Button
android:id="@+id/waypointslist_btn_insert_statistics"
android:text="@string/marker_list_insert_statistics"
style="@style/BottomButton" />
<Button
android:id="@+id/waypointslist_btn_insert_waypoint"
android:text="@string/marker_list_insert_waypoint"
style="@style/BottomButton" />
</LinearLayout>
</LinearLayout>
+10 -18
View File
@@ -28,38 +28,30 @@ limitations under the License.
android:orientation="vertical"
android:padding="8dp" >
<TextView
android:text="@string/track_edit_name"
style="@style/TrackEditLabelTextView" />
android:text="@string/generic_name"
style="@style/EditLabel" />
<EditText
android:drawableLeft="@drawable/track"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:hint="@string/track_edit_name"
android:hint="@string/generic_name"
android:id="@+id/track_edit_name"
android:imeOptions="actionNext"
android:inputType="textAutoCorrect|textCapWords"
android:singleLine="true"
style="@style/TrackEditValueEditText" />
style="@style/EditName" />
<TextView
android:text="@string/track_edit_activity_type"
style="@style/TrackEditLabelTextView" />
style="@style/EditLabel" />
<AutoCompleteTextView
android:hint="@string/track_edit_activity_type_hint"
android:id="@+id/track_edit_activity_type"
android:imeOptions="actionNext"
android:singleLine="true"
style="@style/TrackEditValueEditText" />
style="@style/EditCategory" />
<TextView
android:text="@string/track_edit_description"
style="@style/TrackEditLabelTextView" />
android:text="@string/generic_description"
style="@style/EditLabel" />
<EditText
android:hint="@string/track_edit_description"
android:hint="@string/generic_description"
android:id="@+id/track_edit_description"
android:imeOptions="actionDone"
android:inputType="textAutoCorrect|textCapSentences"
android:maxLines="50"
android:singleLine="false"
style="@style/TrackEditValueEditText" />
style="@style/EditDescription" />
</LinearLayout>
</ScrollView>
<LinearLayout style="@style/BottomButtonBar" >
+6 -18
View File
@@ -26,20 +26,11 @@ limitations under the License.
android:layout_width="fill_parent"
android:orientation="horizontal" >
<TextView
android:drawablePadding="8dp"
android:id="@+id/track_list_item_name"
android:gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:singleLine="true"
style="@android:style/TextAppearance.DeviceDefault.Large" />
style="@style/ListItemName" />
<TextView
android:id="@+id/track_list_item_category"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_width="wrap_content"
android:singleLine="true"
style="@android:style/TextAppearance.DeviceDefault.Small" />
style="@style/ListItemCategory" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
@@ -47,20 +38,17 @@ limitations under the License.
android:orientation="horizontal" >
<TextView
android:id="@+id/track_list_item_time"
style="@style/TrackListItemStatsTextView" />
style="@style/ListItemStat" />
<TextView
android:id="@+id/track_list_item_distance"
android:layout_marginLeft="8dp"
style="@style/TrackListItemStatsTextView" />
style="@style/ListItemStat" />
<TextView
android:id="@+id/track_list_item_start"
android:layout_marginLeft="8dp"
style="@style/TrackListItemStatsTextView" />
style="@style/ListItemStat" />
</LinearLayout>
<TextView
android:id="@+id/track_list_item_description"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:singleLine="false"
style="@android:style/TextAppearance.DeviceDefault.Small" />
style="@style/ListItemDescription" />
</LinearLayout>
+33
View File
@@ -0,0 +1,33 @@
<?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.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:icon="@drawable/menu_show_on_map"
android:id="@+id/marker_detail_show_on_map"
android:showAsAction="always"
android:title="@string/menu_show_on_map"/>
<item
android:icon="@drawable/menu_edit"
android:id="@+id/marker_detail_edit"
android:showAsAction="always"
android:title="@string/menu_edit"/>
<item
android:icon="@drawable/menu_delete"
android:id="@+id/marker_detail_delete"
android:showAsAction="ifRoom"
android:title="@string/menu_delete"/>
</menu>
@@ -16,8 +16,14 @@ limitations under the License.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:icon="@drawable/menu_search"
android:id="@+id/menu_search"
android:icon="@drawable/menu_insert_marker"
android:id="@+id/marker_list_insert_marker"
android:showAsAction="always"
android:title="@string/menu_insert_marker"/>
<item
android:actionViewClass="android.widget.SearchView"
android:icon="@drawable/menu_search"
android:id="@+id/marker_list_search"
android:showAsAction="always|collapseActionView"
android:title="@string/menu_search"/>
</menu>
@@ -0,0 +1,33 @@
<?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.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:icon="@drawable/menu_show_on_map"
android:id="@+id/marker_list_context_menu_show_on_map"
android:showAsAction="always"
android:title="@string/menu_show_on_map"/>
<item
android:icon="@drawable/menu_edit"
android:id="@+id/marker_list_context_menu_edit"
android:showAsAction="always"
android:title="@string/menu_edit"/>
<item
android:icon="@drawable/menu_delete"
android:id="@+id/marker_list_context_menu_delete"
android:showAsAction="always"
android:title="@string/menu_delete"/>
</menu>
+77 -99
View File
@@ -662,10 +662,18 @@ limitations under the License.
translation_description="The title on a confirmation dialog asking the user if he is sure?">
Are you sure?
</string>
<string name="generic_description"
translation_description="The text label for entering a description.">
Description
</string>
<string name="generic_error_title"
translation_description="The title on an alert dialog indicating error.">
Error
</string>
<string name="generic_name"
translation_description="The text label for entering a name.">
Name
</string>
<string name="generic_ok"
translation_description="The text on a button to say ok.">
OK
@@ -682,7 +690,7 @@ limitations under the License.
translation_description="The title on an alert dialog indicating success.">
Success
</string>
<!-- GPS -->
<string name="gps_need_to_enable"
translation_description="In the main view, the message on the top asking the user to enable
@@ -948,44 +956,67 @@ limitations under the License.
</string>
<!-- Marker -->
<string name="marker_detail_marker_description"
translation_description="In the detail page for a waypoint marker, the text field for the marker
description.">
Marker description
</string>
<string name="marker_detail_marker_name"
translation_description="In the detail page for a waypoint or statistics marker, text field for
the marker name.">
Marker name
<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.
%1$s marker description. E.g., 'At the top'.">
Description: %1$s
</string>
<string name="marker_detail_marker_type"
translation_description="In the detail page for a waypoint marker, the text field for the
marker type, including examples.">
Marker type (e.g. building, pothole, sight...)
translation_description="In the marker detail page, the label for the 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_detail_marker_type_hint"
translation_description="In the detail page for a waypoint marker, the hint in the 'Marker type'
text field when it is empty.">
Marker type
<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_detail_title"
translation_description="In the detail page for a waypoint or statistics marker, the title of
the page.">
Marker details
</string>
<string name="marker_icon_description"
translation_description="The accessibility description for the marker icon.">
Marker
</string>
<string name="marker_insert_error"
translation_description="When inserting a marker, message when not able to insert due to no GPS
location and asking the user to try again.">
Unable to insert a marker. No GPS location. Try again.
</string>
<string name="marker_insert_success"
translation_description="When inserting a new marker, a message indicating success.">
<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.">
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.">
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 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)'.
@@ -1000,54 +1031,9 @@ limitations under the License.
%1$s track name. E.g., 'track_name'.">
%1$s (Start)
</string>
<string name="marker_list_context_menu_title"
translation_description="In the context menu for a marker, the title indicating that all the
menu options below are for this marker.">
This marker
</string>
<string name="marker_list_delete_marker"
translation_description="In the context menu for a marker, the menu option to delete the
marker.">
Delete
</string>
<string name="marker_list_delete_marker_confirm_message"
translation_description="In the context menu for a marker, when pressing the 'Delete' option,
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_list_edit_marker"
translation_description="In the context menu for a marker, the menu option to edit the marker's
metadata (e.g., name, type, etc.).">
Edit
</string>
<string name="marker_list_insert_statistics"
translation_description="In the Markers page, the button on the bottom to insert a statistics
marker.">
Insert statistics
</string>
<string name="marker_list_insert_waypoint"
translation_description="In the Markers page, the button on the bottom to insert a waypoint
marker.">
Insert waypoint
</string>
<string name="marker_list_pick_one"
translation_description="In the Markers page, the instruction at the top of the page informing
the user he can press and hold a marker for more options.">
Pick a marker. Press &amp; hold for more options.
</string>
<string name="marker_list_show_on_map"
translation_description="In the context menu for a marker, the menu option to show the marker
on the map.">
Show on map
</string>
<string name="marker_type_statistics"
translation_description="When inserting a statistics marker, the default name of the marker.">
Statistics
</string>
<string name="marker_type_waypoint"
translation_description="When inserting a waypoint marker, the default name of the marker.">
Waypoint
<string name="marker_list_empty_message"
translation_description="The message when the marker list is empty.">
You don\'t have any markers.
</string>
<!-- Menu Items -->
@@ -1147,6 +1133,10 @@ limitations under the License.
translation_description="In the menu, to go to the settings page.">
Settings
</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_stop_recording"
translation_description="In the menu, to stop recording a track.">
Stop recording
@@ -1428,14 +1418,6 @@ limitations under the License.
sensor. E.g, 'Battery level: 50 %'.">
Battery level
</string>
<string name="sensor_state_battery_value"
translation_description="In the 'Sensor state' page, the value for the 'Battery level'. E.g,
'Battery level: 50 %'.
%1$d: a number. E.g., '50'.
%%: escape sequence for the '%' character.">
%1$d %%
</string>
<string name="sensor_state_cadence"
translation_description="In the 'Sensor state' page, the label for the cadence on the bike
sensor. Cadence is the number of revolutions of the crank per minute. E.g.,
@@ -2202,16 +2184,6 @@ limitations under the License.
when it is empty.">
Activity type
</string>
<string name="track_edit_description"
translation_description="In the page to edit a track, the label for the text field to edit the
track description.">
Description
</string>
<string name="track_edit_name"
translation_description="In the page to edit a track, the label for the text field to edit the
track name.">
Name
</string>
<string name="track_edit_new_track_title"
translation_description="The title of the track edit page when saving a new track.">
New Track
@@ -2420,6 +2392,12 @@ limitations under the License.
%1$d: an integer value. E.g., '2'">
%1$d min
</string>
<string name="value_integer_percent"
translation_description="To display a value in percent like 2 %.
%1$d: an integer value. E.g., '2'">
%1$d %%
</string>
<string name="value_integer_second"
translation_description="In a setting picker, the string format to display an integer value in
seconds (s).
+88 -24
View File
@@ -28,8 +28,92 @@ limitations under the License.
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item>
<item name="android:layout_width">0dp</item>
</style>
<!-- The style for the edit category -->
<style name="EditCategory" parent="@android:style/TextAppearance.DeviceDefault.Medium">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:selectAllOnFocus">true</item>
<item name="android:singleLine">true</item>
</style>
<!-- The style for the edit description -->
<style name="EditDescription" parent="@android:style/TextAppearance.DeviceDefault.Medium">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:selectAllOnFocus">true</item>
<item name="android:singleLine">false</item>
<item name="android:maxLines">50</item>
<item name="android:inputType">textAutoCorrect|textCapSentences</item>
</style>
<!-- The style for the edit label -->
<style name="EditLabel" parent="@android:style/TextAppearance.DeviceDefault.Medium">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
</style>
<!-- The style for the edit name -->
<style name="EditName" parent="@android:style/TextAppearance.DeviceDefault.Medium">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:selectAllOnFocus">true</item>
<item name="android:singleLine">true</item>
<item name="android:inputType">textAutoCorrect|textCapWords</item>
<item name="android:drawablePadding">8dp</item>
<item name="android:gravity">center_vertical</item>
</style>
<!-- The style for the list item category -->
<style name="ListItemCategory" parent="@android:style/TextAppearance.DeviceDefault.Small">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:singleLine">true</item>
<item name="android:layout_marginLeft">8dp</item>
</style>
<!-- The style for the list item description -->
<style name="ListItemDescription" parent="@android:style/TextAppearance.DeviceDefault.Small">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:singleLine">false</item>
</style>
<!-- The style for the list item name -->
<style name="ListItemName" parent="@android:style/TextAppearance.DeviceDefault.Large">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:singleLine">true</item>
<item name="android:gravity">center_vertical</item>
<item name="android:paddingLeft">9dp</item>
</style>
<!-- style for the list item stat -->
<style name="ListItemStat" parent="@android:style/TextAppearance.DeviceDefault.Small">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:singleLine">true</item>
<item name="android:textColor">@color/green</item>
</style>
<!-- The style for the marker detail label -->
<style name="MarkerDetailLabel" parent="@android:style/TextAppearance.DeviceDefault.Large">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
</style>
<!-- The style for the marker detail statistics label -->
<style name="MarkerDetailStatisticsLabel" parent="@android:style/TextAppearance.DeviceDefault.Medium">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">1</item>
</style>
<!-- The style for the marker detail statistics spacer -->
<style name="MarkerDetailStatisticsSpacer">
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_width">8dp</item>
</style>
<!-- The style for the marker detail statistics value -->
<style name="MarkerDetailStatisticsValue" parent="@android:style/TextAppearance.DeviceDefault.Large">
<item name="android:gravity">right</item>
<item name="android:textColor">@color/stat_label_text</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">1</item>
<item name="android:background">@android:color/background_light</item>
</style>
<style name="SensorStateLabel">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
@@ -107,34 +191,14 @@ limitations under the License.
<item name="android:layout_marginTop">-9dp</item>
<item name="android:textColor">@color/stat_label_text</item>
</style>
<!-- The style for the label in track_edit.xml -->
<style name="TrackEditLabelTextView" parent="@android:style/TextAppearance.DeviceDefault.Medium">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
</style>
<!-- The style for the value in track_edit.xml -->
<style name="TrackEditValueEditText" parent="@android:style/TextAppearance.DeviceDefault.Medium">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:selectAllOnFocus">true</item>
</style>
<!-- The style for the stats in track_list_item.xml -->
<style name="TrackListItemStatsTextView" parent="@android:style/TextAppearance.DeviceDefault.Small">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:singleLine">true</item>
<item name="android:textColor">@color/green</item>
</style>
<!-- The style for the answer in welcome.xml -->
<!-- The style for the welcome page answer -->
<style name="WelcomeAnswerTextView" parent="@android:style/TextAppearance.DeviceDefault.Small">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:paddingBottom">8dp</item>
</style>
<!-- The style for the question in welcome.xml -->
<!-- The style for welcome page question -->
<style name="WelcomeQuestionTextView" parent="@android:style/TextAppearance.DeviceDefault.Medium">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
@@ -485,9 +485,9 @@ public class ChartView extends View {
}
}
if (nearestWaypoint != null && dmin < 100) {
Intent intent =
new Intent(getContext(), WaypointDetails.class);
intent.putExtra(WaypointDetails.WAYPOINT_ID_EXTRA, nearestWaypoint.getId());
Intent intent = new Intent(getContext(), MarkerDetailActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(MarkerDetailActivity.EXTRA_MARKER_ID, nearestWaypoint.getId());
getContext().startActivity(intent);
return true;
}
@@ -33,18 +33,6 @@ public abstract class Constants {
*/
public static final String SDCARD_TOP_DIR = "MyTracks";
/*
* onActivityResult request codes:
*/
public static final int SHOW_WAYPOINT = 0;
/*
* Context menu ids. Sorted alphabetically.
*/
public static final int MENU_DELETE = 100;
public static final int MENU_EDIT = 101;
public static final int MENU_SHOW = 102;
/*
* Main screen tab tags:
*/
@@ -444,8 +444,9 @@ public class MapOverlay extends Overlay implements OnSharedPreferenceChangeListe
if (waypoint != null &&
dmin < 15000000 / Math.pow(2, mapView.getZoomLevel())) {
Intent intent = new Intent(context, WaypointDetails.class);
intent.putExtra(WaypointDetails.WAYPOINT_ID_EXTRA, waypoint.getId());
Intent intent = new Intent(context, MarkerDetailActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(MarkerDetailActivity.EXTRA_MARKER_ID, waypoint.getId());
context.startActivity(intent);
return true;
}
@@ -0,0 +1,166 @@
/*
* Copyright 2009 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;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.fragments.DeleteOneMarkerDialogFragment;
import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
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.speech.tts.TextToSpeech;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
/**
* An activity to display marker detail info.
*
* @author Leif Hendrik Wilden
*/
public class MarkerDetailActivity extends FragmentActivity {
public static final String EXTRA_MARKER_ID = "marker_id";
private static final String TAG = MarkerDetailActivity.class.getSimpleName();
private long markerId;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
ApiAdapterFactory.getApiAdapter().configureActionBarHomeAsUp(this);
setContentView(R.layout.marker_detail);
markerId = getIntent().getLongExtra(EXTRA_MARKER_ID, -1L);
if (markerId == -1L) {
Log.d(TAG, "invalid marker id");
finish();
return;
}
Waypoint waypoint = MyTracksProviderUtils.Factory.get(this).getWaypoint(markerId);
if (waypoint == null) {
Log.d(TAG, "waypoint is null");
finish();
return;
}
TextView name = (TextView) findViewById(R.id.marker_detail_name);
name.setText(getString(R.string.marker_detail_name, waypoint.getName()));
View waypointSection = findViewById(R.id.marker_detail_waypoint_section);
View statisticsSection = findViewById(R.id.marker_detail_statistics_section);
if (waypoint.getType() == Waypoint.TYPE_WAYPOINT) {
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()));
} 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.setSpeedLabel(this, R.id.marker_detail_max_speed_label, R.string.stat_max_speed,
R.string.stat_fastest_pace, reportSpeed);
StatsUtils.setSpeedLabel(this, R.id.marker_detail_average_speed_label,
R.string.stat_average_speed, R.string.stat_average_pace, reportSpeed);
StatsUtils.setSpeedLabel(this, R.id.marker_detail_average_moving_speed_label,
R.string.stat_average_moving_speed, R.string.stat_average_moving_pace, reportSpeed);
TripStatistics tripStatistics = waypoint.getStatistics();
StatsUtils.setDistanceValue(this, R.id.marker_detail_total_distance_value,
tripStatistics.getTotalDistance(), metricUnits);
StatsUtils.setSpeedValue(this, R.id.marker_detail_max_speed_value,
tripStatistics.getMaxSpeed(), reportSpeed, metricUnits);
StatsUtils.setTimeValue(
this, R.id.marker_detail_total_time_value, tripStatistics.getTotalTime());
StatsUtils.setSpeedValue(this, R.id.marker_detail_average_speed_value,
tripStatistics.getAverageSpeed(), reportSpeed, metricUnits);
StatsUtils.setTimeValue(
this, R.id.marker_detail_moving_time_value, tripStatistics.getMovingTime());
StatsUtils.setSpeedValue(this, R.id.marker_detail_average_moving_speed_value,
tripStatistics.getAverageMovingSpeed(), reportSpeed, metricUnits);
StatsUtils.setAltitudeValue(this, R.id.marker_detail_elevation_value,
waypoint.getLocation().getAltitude(), metricUnits);
StatsUtils.setAltitudeValue(this, R.id.marker_detail_elevation_gain_value,
tripStatistics.getTotalElevationGain(), metricUnits);
StatsUtils.setAltitudeValue(this, R.id.marker_detail_min_elevation_value,
tripStatistics.getMinElevation(), metricUnits);
StatsUtils.setAltitudeValue(this, R.id.marker_detail_max_elevation_value,
tripStatistics.getMaxElevation(), metricUnits);
StatsUtils.setGradeValue(
this, R.id.marker_detail_min_grade_value, tripStatistics.getMinGrade());
StatsUtils.setGradeValue(
this, R.id.marker_detail_max_grade_value, tripStatistics.getMaxGrade());
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.marker_detail, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.marker_detail_show_on_map:
startActivity(new Intent(this, TrackDetailActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(TrackDetailActivity.EXTRA_MARKER_ID, markerId));
return true;
case R.id.marker_detail_edit:
startActivity(new Intent(this, MarkerEditActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(MarkerEditActivity.EXTRA_MARKER_ID, markerId));
return true;
case R.id.marker_detail_delete:
DeleteOneMarkerDialogFragment.newInstance(markerId).show(getSupportFragmentManager(),
DeleteOneMarkerDialogFragment.DELETE_ONE_MARKER_DIALOG_TAG);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
@@ -0,0 +1,226 @@
/*
* 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;
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.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.TrackRecordingServiceConnectionUtils;
import com.google.android.maps.mytracks.R;
import android.app.Activity;
import android.os.Bundle;
import android.os.RemoteException;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.MenuItem;
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.
*
* @author Jimmy Shih
*/
public class MarkerEditActivity extends Activity {
private static final String TAG = MarkerEditActivity.class.getSimpleName();
public static final String EXTRA_MARKER_ID = "marker_id";
private long markerId;
private TrackRecordingServiceConnection trackRecordingServiceConnection;
private Waypoint waypoint;
// UI elements
private View typeSection;
private RadioGroup type;
private EditText name;
private View waypointSection;
private AutoCompleteTextView markerType;
private EditText description;
private Button done;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
ApiAdapterFactory.getApiAdapter().configureActionBarHomeAsUp(this);
setContentView(R.layout.marker_edit);
markerId = getIntent().getLongExtra(EXTRA_MARKER_ID, -1L);
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);
updateUiByMarkerType(statistics);
}
});
name = (EditText) findViewById(R.id.marker_edit_name);
waypointSection = findViewById(R.id.marker_edit_waypoint_section);
markerType = (AutoCompleteTextView) findViewById(R.id.marker_edit_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);
Button cancel = (Button) findViewById(R.id.marker_edit_cancel);
cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
done = (Button) findViewById(R.id.marker_edit_done);
updateUiByMarkerId();
}
/**
* Updates the UI based on the marker id.
*/
private void updateUiByMarkerId() {
final boolean newMarker = markerId == -1L;
setTitle(newMarker ? R.string.marker_edit_add_title : R.string.menu_edit);
typeSection.setVisibility(newMarker ? View.VISIBLE : View.GONE);
done.setText(newMarker ? R.string.marker_edit_add : R.string.generic_save);
done.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (newMarker) {
addMarker();
} else {
saveMarker();
}
finish();
}
});
if (newMarker) {
type.check(R.id.marker_edit_type_statistics);
} else {
waypoint = MyTracksProviderUtils.Factory.get(this).getWaypoint(markerId);
if (waypoint == null) {
Log.d(TAG, "waypoint is null");
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());
}
}
}
/**
* 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();
TrackRecordingServiceConnectionUtils.resume(this, trackRecordingServiceConnection);
}
@Override
protected void onDestroy() {
super.onDestroy();
trackRecordingServiceConnection.unbind();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() != android.R.id.home) {
return false;
}
finish();
return true;
}
/**
* 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);
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();
}
/**
* 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());
}
MyTracksProviderUtils.Factory.get(this).updateWaypoint(waypoint);
}
}
@@ -0,0 +1,282 @@
/*
* Copyright 2009 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;
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.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.maps.mytracks.R;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.database.Cursor;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v4.widget.ResourceCursorAdapter;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
/**
* Activity to show a list of markers in a track.
*
* @author Leif Hendrik Wilden
*/
public class MarkerListActivity extends FragmentActivity {
public static final String EXTRA_TRACK_ID = "track_id";
private static final String TAG = MarkerListActivity.class.getSimpleName();
private static final String[] PROJECTION = new String[] { WaypointsColumns._ID,
WaypointsColumns.TYPE,
WaypointsColumns.NAME,
WaypointsColumns.CATEGORY,
WaypointsColumns.TIME,
WaypointsColumns.DESCRIPTION };
// Callback when an item is selected in the contextual action mode
private ContextualActionModeCallback contextualActionModeCallback =
new ContextualActionModeCallback() {
@Override
public boolean onClick(int itemId, long id) {
return handleContextItem(itemId, id);
}
};
/*
* Note that sharedPreferenceChangeListener cannot be an anonymous inner
* class. Anonymous inner class will get garbage collected.
*/
private final OnSharedPreferenceChangeListener sharedPreferenceChangeListener =
new OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
// Note that key can be null
if (PreferencesUtils.getRecordingTrackIdKey(MarkerListActivity.this).equals(key)) {
updateMenu();
}
}
};
private long trackId = -1;
private ResourceCursorAdapter resourceCursorAdapter;
// UI elements
private MenuItem insertMarkerMenuItem;
private MenuItem searchMenuItem;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
trackId = getIntent().getLongExtra(EXTRA_TRACK_ID, -1L);
if (trackId == -1L) {
Log.d(TAG, "invalid track id");
finish();
return;
}
setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
ApiAdapterFactory.getApiAdapter().configureActionBarHomeAsUp(this);
setContentView(R.layout.marker_list);
SharedPreferences sharedPreferences = getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
ListView listView = (ListView) findViewById(R.id.marker_list);
listView.setEmptyView(findViewById(R.id.marker_list_empty));
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
startActivity(new Intent(MarkerListActivity.this, MarkerDetailActivity.class).addFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(MarkerDetailActivity.EXTRA_MARKER_ID, id));
}
});
resourceCursorAdapter = new ResourceCursorAdapter(this, R.layout.marker_list_item, null, 0) {
@Override
public void bindView(View view, Context context, Cursor cursor) {
int typeIndex = cursor.getColumnIndex(WaypointsColumns.TYPE);
int nameIndex = cursor.getColumnIndex(WaypointsColumns.NAME);
int categoryIndex = cursor.getColumnIndex(WaypointsColumns.CATEGORY);
int timeIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.TIME);
int descriptionIndex = cursor.getColumnIndex(WaypointsColumns.DESCRIPTION);
boolean statistics = cursor.getInt(typeIndex) == Waypoint.TYPE_STATISTICS;
TextView name = (TextView) view.findViewById(R.id.marker_list_item_name);
name.setText(cursor.getString(nameIndex));
name.setCompoundDrawablesWithIntrinsicBounds(statistics ? R.drawable.ylw_pushpin
: R.drawable.blue_pushpin, 0, 0, 0);
TextView category = (TextView) view.findViewById(R.id.marker_list_item_category);
if (!statistics) {
category.setText(cursor.getString(categoryIndex));
}
category.setVisibility(statistics || category.getText().length() == 0 ? View.GONE : View.VISIBLE);
TextView time = (TextView) view.findViewById(R.id.marker_list_item_time);
long timeValue = cursor.getLong(timeIndex);
if (timeValue == 0) {
time.setVisibility(View.GONE);
} else {
time.setText(StringUtils.formatDateTime(MarkerListActivity.this, timeValue));
time.setVisibility(View.VISIBLE);
}
TextView description = (TextView) view.findViewById(R.id.marker_list_item_description);
if (!statistics) {
description.setText(cursor.getString(descriptionIndex));
}
description.setVisibility(statistics || description.getText().length() == 0 ? View.GONE : View.VISIBLE);
}
};
listView.setAdapter(resourceCursorAdapter);
ApiAdapterFactory.getApiAdapter().configureListViewContextualMenu(
this, listView, R.menu.marker_list_context_menu, R.id.marker_list_item_name,
contextualActionModeCallback);
final long firstWaypointId = MyTracksProviderUtils.Factory.get(this).getFirstWaypointId(trackId);
getSupportLoaderManager().initLoader(0, null, new LoaderCallbacks<Cursor>() {
@Override
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
return new CursorLoader(MarkerListActivity.this,
WaypointsColumns.CONTENT_URI,
PROJECTION,
WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns._ID + "!=?",
new String[] { String.valueOf(trackId), String.valueOf(firstWaypointId) },
null);
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
resourceCursorAdapter.swapCursor(cursor);
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
resourceCursorAdapter.swapCursor(null);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.marker_list, menu);
insertMarkerMenuItem = menu.findItem(R.id.marker_list_insert_marker);
searchMenuItem = menu.findItem(R.id.marker_list_search);
ApiAdapterFactory.getApiAdapter().configureSearchWidget(this, searchMenuItem);
updateMenu();
return true;
}
private void updateMenu() {
if (insertMarkerMenuItem != null) {
insertMarkerMenuItem.setVisible(trackId == PreferencesUtils.getRecordingTrackId(this));
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.marker_list_insert_marker:
startActivity(new Intent(this, MarkerEditActivity.class).addFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
return true;
case R.id.marker_list_search:
return ApiAdapterFactory.getApiAdapter().handleSearchMenuSelection(this);
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
getMenuInflater().inflate(R.menu.marker_list_context_menu, menu);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
if (handleContextItem(
item.getItemId(), ((AdapterContextMenuInfo) item.getMenuInfo()).id)) {
return true;
}
return super.onContextItemSelected(item);
}
/**
* Handles a context item selection.
*
* @param itemId the menu item id
* @param markerId the marker id
* @return true if handled.
*/
private boolean handleContextItem(int itemId, long markerId) {
switch (itemId) {
case R.id.marker_list_context_menu_show_on_map:
startActivity(new Intent(this, TrackDetailActivity.class).addFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(TrackDetailActivity.EXTRA_MARKER_ID, markerId));
return true;
case R.id.marker_list_context_menu_edit:
startActivity(new Intent(this, MarkerEditActivity.class).addFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(MarkerEditActivity.EXTRA_MARKER_ID, markerId));
return true;
case R.id.marker_list_context_menu_delete:
DeleteOneMarkerDialogFragment.newInstance(markerId).show(getSupportFragmentManager(),
DeleteOneMarkerDialogFragment.DELETE_ONE_MARKER_DIALOG_TAG);
return true;
default:
return false;
}
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_SEARCH) {
if (ApiAdapterFactory.getApiAdapter().handleSearchKey(searchMenuItem)) { return true; }
}
return super.onKeyUp(keyCode, event);
}
}
@@ -248,10 +248,12 @@ public class SearchActivity extends ListActivity {
private Intent createViewDataIntent(Map<String, Object> clickedData) {
Intent intent = new Intent(this, TrackDetailActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(TrackDetailActivity.EXTRA_TRACK_ID, (Long) clickedData.get(TRACK_ID_FIELD));
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
if (clickedData.containsKey(WAYPOINT_ID_FIELD)) {
intent.putExtra(TrackDetailActivity.EXTRA_WAYPOINT_ID, (Long) clickedData.get(WAYPOINT_ID_FIELD));
intent.putExtra(
TrackDetailActivity.EXTRA_MARKER_ID, (Long) clickedData.get(WAYPOINT_ID_FIELD));
} else {
intent.putExtra(TrackDetailActivity.EXTRA_TRACK_ID, (Long) clickedData.get(TRACK_ID_FIELD));
}
return intent;
}
@@ -325,7 +325,7 @@ public class SensorStateActivity extends Activity {
String value;
if (sds.hasBatteryLevel() && sds.getBatteryLevel().hasValue()
&& sds.getBatteryLevel().getState() == Sensor.SensorState.SENDING) {
String format = getString(R.string.sensor_state_battery_value);
String format = getString(R.string.value_integer_percent);
value = String.format(format, sds.getBatteryLevel().getValue());
} else {
value = SensorUtils.getStateAsString(
@@ -16,6 +16,7 @@
package com.google.android.apps.mytracks;
import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.StatsUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.apps.mytracks.util.UnitConversions;
import com.google.android.maps.mytracks.R;
@@ -29,6 +30,8 @@ import java.text.NumberFormat;
/**
* Various utility functions for views that display statistics information.
*
* @deprecated use {@link StatsUtils}.
*
* @author Sandor Dornbush
*/
public class StatsUtilities {
@@ -20,7 +20,9 @@ import static com.google.android.apps.mytracks.Constants.CHART_TAB_TAG;
import static com.google.android.apps.mytracks.Constants.MAP_TAB_TAG;
import static com.google.android.apps.mytracks.Constants.STATS_TAB_TAG;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.TrackDataHub;
import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
import com.google.android.apps.mytracks.fragments.ChartFragment;
import com.google.android.apps.mytracks.fragments.ChartSettingsDialogFragment;
@@ -71,7 +73,7 @@ import java.util.List;
public class TrackDetailActivity extends FragmentActivity {
public static final String EXTRA_TRACK_ID = "track_id";
public static final String EXTRA_WAYPOINT_ID = "waypoint_id";
public static final String EXTRA_MARKER_ID = "marker_id";
private static final String TAG = TrackDetailActivity.class.getSimpleName();
private static final String CURRENT_TAG_KEY = "tab";
@@ -264,7 +266,8 @@ public class TrackDetailActivity extends FragmentActivity {
TrackRecordingServiceConnectionUtils.stop(this, trackRecordingServiceConnection);
return true;
case R.id.track_detail_insert_marker:
// TODO: Add insert marker when updating WaypointList to ICS
startActivity(new Intent(this, MarkerEditActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
return true;
case R.id.track_detail_play:
if (isEarthInstalled()) {
@@ -302,9 +305,10 @@ public class TrackDetailActivity extends FragmentActivity {
startSaveActivity(TrackFileFormat.TCX, true);
return true;
case R.id.track_detail_markers:
intent = new Intent(this, WaypointsList.class)
.putExtra("trackid", trackDataHub.getSelectedTrackId());
startActivityForResult(intent, Constants.SHOW_WAYPOINT);
intent = new Intent(this, MarkerListActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(MarkerListActivity.EXTRA_TRACK_ID, trackId);
startActivity(intent);
return true;
case R.id.track_detail_send_google:
intent = new Intent(this, UploadServiceChooserActivity.class)
@@ -361,25 +365,6 @@ public class TrackDetailActivity extends FragmentActivity {
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, final Intent results) {
if (requestCode != Constants.SHOW_WAYPOINT) {
Log.d(TAG, "Invalid request code: " + requestCode);
return;
}
if (results != null) {
long waypointId = results.getLongExtra(WaypointDetails.WAYPOINT_ID_EXTRA, -1L);
if (waypointId != -1L) {
MapFragment mapFragment = (MapFragment) getSupportFragmentManager()
.findFragmentByTag(MAP_TAB_TAG);
if (mapFragment != null) {
tabHost.setCurrentTab(0);
mapFragment.showWaypoint(waypointId);
}
}
}
}
@Override
public boolean onTrackballEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
@@ -401,9 +386,8 @@ public class TrackDetailActivity extends FragmentActivity {
Log.e(TAG, "Unable to insert waypoint", e);
}
Toast.makeText(this,
success ? R.string.marker_insert_success : R.string.marker_insert_error,
success ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG)
.show();
success ? R.string.marker_edit_add_success : R.string.marker_edit_add_error,
success ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG).show();
return true;
}
}
@@ -421,22 +405,30 @@ public class TrackDetailActivity extends FragmentActivity {
* Handles the data in the intent.
*/
private void handleIntent(Intent intent) {
// Get the trackid
trackId = intent.getLongExtra(EXTRA_TRACK_ID, -1L);
trackId = intent.getLongExtra(EXTRA_TRACK_ID, -1L);
long markerId = intent.getLongExtra(EXTRA_MARKER_ID, -1L);
if (markerId != -1L) {
Waypoint waypoint = MyTracksProviderUtils.Factory.get(this).getWaypoint(markerId);
if (waypoint == null) {
startTrackListActivity();
finish();
return;
}
trackId = waypoint.getTrackId();
}
if (trackId == -1L) {
startTrackListActivity();
finish();
return;
}
trackDataHub.loadTrack(trackId);
// Get the waypointId
long waypointId = intent.getLongExtra(EXTRA_WAYPOINT_ID, -1L);
if (waypointId != -1L) {
if (markerId != -1L) {
MapFragment mapFragmet = (MapFragment) getSupportFragmentManager()
.findFragmentByTag(MAP_TAB_TAG);
if (mapFragmet != null) {
tabHost.setCurrentTab(0);
mapFragmet.showWaypoint(trackId, waypointId);
tabHost.setCurrentTabByTag(MAP_TAB_TAG);
mapFragmet.showMarker(trackId, markerId);
} else {
Log.e(TAG, "MapFragment is null");
}
@@ -125,7 +125,7 @@ public class TrackListActivity extends FragmentActivity {
}
updateMenu();
}
adapter.notifyDataSetChanged();
resourceCursorAdapter.notifyDataSetChanged();
}
};
@@ -142,17 +142,17 @@ public class TrackListActivity extends FragmentActivity {
private boolean metricUnits;
private long recordingTrackId;
private ListView listView;
private ResourceCursorAdapter adapter;
private ResourceCursorAdapter resourceCursorAdapter;
// True to start a new recording.
private boolean startNewRecording = false;
private MenuItem recordTrack;
private MenuItem stopRecording;
private MenuItem search;
private MenuItem importAll;
private MenuItem exportAll;
private MenuItem deleteAll;
private MenuItem recordTrackMenuItem;
private MenuItem stopRecordingMenuItem;
private MenuItem searchMenuItem;
private MenuItem importAllMenuItem;
private MenuItem exportAllMenuItem;
private MenuItem deleteAllMenuItem;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -187,7 +187,7 @@ public class TrackListActivity extends FragmentActivity {
startTrackDetailActivity(id);
}
});
adapter = new ResourceCursorAdapter(this, R.layout.track_list_item, null, 0) {
resourceCursorAdapter = new ResourceCursorAdapter(this, R.layout.track_list_item, null, 0) {
@Override
public void bindView(View view, Context context, Cursor cursor) {
int idIndex = cursor.getColumnIndex(TracksColumns._ID);
@@ -227,7 +227,7 @@ public class TrackListActivity extends FragmentActivity {
description.setVisibility(description.getText().length() == 0 ? View.GONE : View.VISIBLE);
}
};
listView.setAdapter(adapter);
listView.setAdapter(resourceCursorAdapter);
ApiAdapterFactory.getApiAdapter().configureListViewContextualMenu(
this, listView, R.menu.track_list_context_menu, R.id.track_list_item_name,
contextualActionModeCallback);
@@ -245,12 +245,12 @@ public class TrackListActivity extends FragmentActivity {
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
adapter.swapCursor(cursor);
resourceCursorAdapter.swapCursor(cursor);
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
adapter.swapCursor(null);
resourceCursorAdapter.swapCursor(null);
}
});
@@ -289,14 +289,14 @@ public class TrackListActivity extends FragmentActivity {
menu.findItem(R.id.track_list_export_tcx)
.setTitle(getString(R.string.menu_export_all_format, fileTypes[3]));
recordTrack = menu.findItem(R.id.track_list_record_track);
stopRecording = menu.findItem(R.id.track_list_stop_recording);
search = menu.findItem(R.id.track_list_search);
importAll = menu.findItem(R.id.track_list_import_all);
exportAll = menu.findItem(R.id.track_list_export_all);
deleteAll = menu.findItem(R.id.track_list_delete_all);
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);
deleteAllMenuItem = menu.findItem(R.id.track_list_delete_all);
ApiAdapterFactory.getApiAdapter().configureSearchWidget(this, search);
ApiAdapterFactory.getApiAdapter().configureSearchWidget(this, searchMenuItem);
updateMenu();
return true;
}
@@ -315,20 +315,20 @@ public class TrackListActivity extends FragmentActivity {
* @param isRecording true if recording
*/
private void updateMenuItems(boolean isRecording) {
if (recordTrack != null) {
recordTrack.setVisible(!isRecording);
if (recordTrackMenuItem != null) {
recordTrackMenuItem.setVisible(!isRecording);
}
if (stopRecording != null) {
stopRecording.setVisible(isRecording);
if (stopRecordingMenuItem != null) {
stopRecordingMenuItem.setVisible(isRecording);
}
if (importAll != null) {
importAll.setVisible(!isRecording);
if (importAllMenuItem != null) {
importAllMenuItem.setVisible(!isRecording);
}
if (exportAll != null) {
exportAll.setVisible(!isRecording);
if (exportAllMenuItem != null) {
exportAllMenuItem.setVisible(!isRecording);
}
if (deleteAll != null) {
deleteAll.setVisible(!isRecording);
if (deleteAllMenuItem != null) {
deleteAllMenuItem.setVisible(!isRecording);
}
}
@@ -450,7 +450,7 @@ public class TrackListActivity extends FragmentActivity {
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_SEARCH) {
if (ApiAdapterFactory.getApiAdapter().handleSearchKey(search)) {
if (ApiAdapterFactory.getApiAdapter().handleSearchKey(searchMenuItem)) {
return true;
}
}
@@ -1,178 +0,0 @@
/*
* Copyright 2009 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;
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.stats.TripStatistics;
import com.google.android.maps.mytracks.R;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
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.ImageView;
/**
* Screen in which the user enters details about a waypoint.
*
* @author Leif Hendrik Wilden
*/
public class WaypointDetails extends Activity
implements OnClickListener {
public static final String WAYPOINT_ID_EXTRA = "com.google.android.apps.mytracks.WAYPOINT_ID";
/**
* The id of the way point being edited (taken from bundle with the above name).
*/
private Long waypointId;
private EditText name;
private EditText description;
private AutoCompleteTextView category;
private View detailsView;
private View statsView;
private StatsUtilities utils;
private Waypoint waypoint;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.mytracks_waypoint_details);
utils = new StatsUtilities(this);
SharedPreferences preferences = getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
if (preferences != null) {
boolean useMetric =
preferences.getBoolean(getString(R.string.metric_units_key), true);
utils.setMetricUnits(useMetric);
boolean displaySpeed =
preferences.getBoolean(getString(R.string.report_speed_key), true);
utils.setReportSpeed(displaySpeed);
utils.updateWaypointUnits();
utils.setSpeedLabels();
}
// Required extra when launching this intent:
waypointId = getIntent().getLongExtra(WAYPOINT_ID_EXTRA, -1);
if (waypointId < 0) {
Log.d(Constants.TAG,
"MyTracksWaypointsDetails intent was launched w/o waypoint id.");
finish();
return;
}
// Optional extra that can be used to suppress the cancel button:
boolean hasCancelButton =
getIntent().getBooleanExtra("hasCancelButton", true);
name = (EditText) findViewById(R.id.waypointdetails_name);
description = (EditText) findViewById(R.id.waypointdetails_description);
category =
(AutoCompleteTextView) findViewById(R.id.waypointdetails_category);
statsView = findViewById(R.id.waypoint_stats);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this,
R.array.waypoint_types,
android.R.layout.simple_dropdown_item_1line);
category.setAdapter(adapter);
detailsView = findViewById(R.id.waypointdetails_description_layout);
Button cancel = (Button) findViewById(R.id.waypointdetails_cancel);
if (hasCancelButton) {
cancel.setOnClickListener(this);
cancel.setVisibility(View.VISIBLE);
} else {
cancel.setVisibility(View.INVISIBLE);
}
Button save = (Button) findViewById(R.id.waypointdetails_save);
save.setOnClickListener(this);
fillDialog();
}
private void fillDialog() {
waypoint = MyTracksProviderUtils.Factory.get(this).getWaypoint(waypointId);
if (waypoint != null) {
name.setText(waypoint.getName());
ImageView icon = (ImageView) findViewById(R.id.waypointdetails_icon);
int iconId = -1;
switch(waypoint.getType()) {
case Waypoint.TYPE_WAYPOINT:
description.setText(waypoint.getDescription());
detailsView.setVisibility(View.VISIBLE);
category.setText(waypoint.getCategory());
statsView.setVisibility(View.GONE);
iconId = R.drawable.blue_pushpin;
break;
case Waypoint.TYPE_STATISTICS:
detailsView.setVisibility(View.GONE);
statsView.setVisibility(View.VISIBLE);
iconId = R.drawable.ylw_pushpin;
TripStatistics waypointStats = waypoint.getStatistics();
utils.setAllStats(waypointStats);
utils.setAltitude(
R.id.elevation_register, waypoint.getLocation().getAltitude());
name.setImeOptions(EditorInfo.IME_ACTION_DONE);
break;
}
icon.setImageDrawable(getResources().getDrawable(iconId));
}
}
private void saveDialog() {
ContentValues values = new ContentValues();
values.put(WaypointsColumns.NAME, name.getText().toString());
if (waypoint != null && waypoint.getType() == Waypoint.TYPE_WAYPOINT) {
values.put(WaypointsColumns.DESCRIPTION,
description.getText().toString());
values.put(WaypointsColumns.CATEGORY, category.getText().toString());
}
getContentResolver().update(
WaypointsColumns.CONTENT_URI,
values,
"_id = " + waypointId,
null /*selectionArgs*/);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.waypointdetails_cancel:
finish();
break;
case R.id.waypointdetails_save:
saveDialog();
finish();
break;
}
}
}
@@ -1,320 +0,0 @@
/*
* Copyright 2009 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;
import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl;
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.WaypointsColumns;
import com.google.android.apps.mytracks.services.ITrackRecordingService;
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.maps.mytracks.R;
import android.app.Dialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnCreateContextMenuListener;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.Toast;
/**
* Activity which shows the list of waypoints in a track.
*
* @author Leif Hendrik Wilden
*/
public class WaypointsList extends ListActivity implements View.OnClickListener {
private static final int DIALOG_DELETE_CURRENT_ID = 0;
private int contextPosition = -1;
private long trackId = -1;
private long selectedWaypointId = -1;
private ListView listView = null;
private Button insertWaypointButton = null;
private Button insertStatisticsButton = null;
private long recordingTrackId = -1;
private MyTracksProviderUtils providerUtils;
private TrackRecordingServiceConnection serviceConnection;
private Cursor waypointsCursor = null;
private final OnCreateContextMenuListener contextMenuListener =
new OnCreateContextMenuListener() {
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
menu.setHeaderTitle(R.string.marker_list_context_menu_title);
AdapterView.AdapterContextMenuInfo info =
(AdapterView.AdapterContextMenuInfo) menuInfo;
contextPosition = info.position;
selectedWaypointId = WaypointsList.this.listView.getAdapter()
.getItemId(contextPosition);
Waypoint waypoint = providerUtils.getWaypoint(info.id);
if (waypoint != null) {
int type = waypoint.getType();
menu.add(Menu.NONE, Constants.MENU_SHOW, Menu.NONE, R.string.marker_list_show_on_map);
menu.add(Menu.NONE, Constants.MENU_EDIT, Menu.NONE, R.string.marker_list_edit_marker);
MenuItem deleteMenu = menu.add(
Menu.NONE, Constants.MENU_DELETE, Menu.NONE, R.string.marker_list_delete_marker);
deleteMenu.setEnabled(recordingTrackId < 0
|| type == Waypoint.TYPE_WAYPOINT
|| type == Waypoint.TYPE_STATISTICS
|| info.id != providerUtils.getLastWaypointId(recordingTrackId));
}
}
};
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
editWaypoint(id);
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
if (!super.onMenuItemSelected(featureId, item)) {
switch (item.getItemId()) {
case Constants.MENU_SHOW: {
Intent result = new Intent();
result.putExtra("trackid", trackId);
result.putExtra(WaypointDetails.WAYPOINT_ID_EXTRA, selectedWaypointId);
setResult(RESULT_OK, result);
finish();
return true;
}
case Constants.MENU_EDIT: {
editWaypoint(selectedWaypointId);
return true;
}
case Constants.MENU_DELETE: {
showDialog(DIALOG_DELETE_CURRENT_ID);
}
}
}
return false;
}
private void editWaypoint(long waypointId) {
Intent intent = new Intent(this, WaypointDetails.class);
intent.putExtra("trackid", trackId);
intent.putExtra(WaypointDetails.WAYPOINT_ID_EXTRA, waypointId);
startActivity(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
providerUtils = MyTracksProviderUtils.Factory.get(this);
serviceConnection = new TrackRecordingServiceConnection(this, null);
// We don't need a window title bar:
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.mytracks_waypoints_list);
listView = getListView();
listView.setOnCreateContextMenuListener(contextMenuListener);
insertWaypointButton =
(Button) findViewById(R.id.waypointslist_btn_insert_waypoint);
insertWaypointButton.setOnClickListener(this);
insertStatisticsButton =
(Button) findViewById(R.id.waypointslist_btn_insert_statistics);
insertStatisticsButton.setOnClickListener(this);
recordingTrackId = PreferencesUtils.getRecordingTrackId(this);
long selectedTrackId = PreferencesUtils.getSelectedTrackId(this);
boolean selectedRecording = selectedTrackId != -1L && selectedTrackId == recordingTrackId;
insertWaypointButton.setEnabled(selectedRecording);
insertStatisticsButton.setEnabled(selectedRecording);
if (getIntent() != null && getIntent().getExtras() != null) {
trackId = getIntent().getExtras().getLong("trackid", -1);
} else {
trackId = -1;
}
final long firstWaypointId = providerUtils.getFirstWaypointId(trackId);
waypointsCursor = getContentResolver().query(
WaypointsColumns.CONTENT_URI, null,
WaypointsColumns.TRACKID + "=" + trackId + " AND "
+ WaypointsColumns._ID + "!=" + firstWaypointId, null, null);
startManagingCursor(waypointsCursor);
setListAdapter();
}
@Override
protected void onResume() {
super.onResume();
serviceConnection.bindIfRunning();
}
@Override
protected void onDestroy() {
serviceConnection.unbind();
super.onDestroy();
}
@Override
protected Dialog onCreateDialog(int id) {
if (id != DIALOG_DELETE_CURRENT_ID) {
return null;
}
return DialogUtils.createConfirmationDialog(this,
R.string.marker_list_delete_marker_confirm_message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
providerUtils.deleteWaypoint(
selectedWaypointId, new DescriptionGeneratorImpl(WaypointsList.this));
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search_only, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_search:
onSearchRequested();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onClick(View v) {
WaypointCreationRequest request;
switch (v.getId()) {
case R.id.waypointslist_btn_insert_waypoint:
request = WaypointCreationRequest.DEFAULT_MARKER;
break;
case R.id.waypointslist_btn_insert_statistics:
request = WaypointCreationRequest.DEFAULT_STATISTICS;
break;
default:
return;
}
long id = insertWaypoint(request);
if (id < 0) {
Toast.makeText(this, R.string.marker_insert_error, Toast.LENGTH_LONG).show();
Log.e(Constants.TAG, "Failed to insert marker.");
return;
}
Intent intent = new Intent(this, WaypointDetails.class);
intent.putExtra(WaypointDetails.WAYPOINT_ID_EXTRA, id);
startActivity(intent);
}
private long insertWaypoint(WaypointCreationRequest request) {
try {
ITrackRecordingService trackRecordingService = serviceConnection.getServiceIfBound();
if (trackRecordingService != null) {
long waypointId = trackRecordingService.insertWaypoint(request);
if (waypointId >= 0) {
Toast.makeText(this, R.string.marker_insert_success, Toast.LENGTH_LONG).show();
return waypointId;
}
} else {
Log.e(TAG, "Not connected to service, not inserting waypoint");
}
} catch (RemoteException e) {
Log.e(Constants.TAG, "Cannot insert marker.", e);
} catch (IllegalStateException e) {
Log.e(Constants.TAG, "Cannot insert marker.", e);
}
return -1;
}
private void setListAdapter() {
// Get a cursor with all tracks
SimpleCursorAdapter adapter = new SimpleCursorAdapter(
this,
R.layout.mytracks_marker_item,
waypointsCursor,
new String[] { WaypointsColumns.NAME, WaypointsColumns.TIME,
WaypointsColumns.CATEGORY, WaypointsColumns.TYPE },
new int[] { R.id.waypointslist_item_name,
R.id.waypointslist_item_time,
R.id.waypointslist_item_category,
R.id.waypointslist_item_icon });
final int timeIdx =
waypointsCursor.getColumnIndexOrThrow(WaypointsColumns.TIME);
final int typeIdx =
waypointsCursor.getColumnIndexOrThrow(WaypointsColumns.TYPE);
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
@Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
if (columnIndex == timeIdx) {
long time = cursor.getLong(timeIdx);
TextView textView = (TextView) view;
if (time == 0) {
textView.setVisibility(View.GONE);
} else {
textView.setText(StringUtils.formatDateTime(WaypointsList.this, time));
textView.setVisibility(View.VISIBLE);
}
} else if (columnIndex == typeIdx) {
int type = cursor.getInt(typeIdx);
ImageView imageView = (ImageView) view;
imageView.setImageDrawable(getResources().getDrawable(
type == Waypoint.TYPE_STATISTICS
? R.drawable.ylw_pushpin
: R.drawable.blue_pushpin));
} else {
TextView textView = (TextView) view;
textView.setText(cursor.getString(columnIndex));
textView.setVisibility(
textView.getText().length() < 1 ? View.GONE : View.VISIBLE);
}
return true;
}
});
setListAdapter(adapter);
}
}
@@ -0,0 +1,63 @@
/*
* 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.MarkerListActivity;
import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.maps.mytracks.R;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
/**
* A DialogFragment to delete one marker.
*
* @author Jimmy Shih
*/
public class DeleteOneMarkerDialogFragment extends DialogFragment {
public static final String DELETE_ONE_MARKER_DIALOG_TAG = "deleteOneMarkerDialog";
private static final String KEY_MARKER_ID = "markerId";
public static DeleteOneMarkerDialogFragment newInstance(long markerId) {
Bundle bundle = new Bundle();
bundle.putLong(KEY_MARKER_ID, markerId);
DeleteOneMarkerDialogFragment deleteOneMarkerDialogFragment = new DeleteOneMarkerDialogFragment();
deleteOneMarkerDialogFragment.setArguments(bundle);
return deleteOneMarkerDialogFragment;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return DialogUtils.createConfirmationDialog(getActivity(),
R.string.marker_delete_one_marker_confirm_message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
MyTracksProviderUtils.Factory.get(getActivity()).deleteWaypoint(
getArguments().getLong(KEY_MARKER_ID), new DescriptionGeneratorImpl(getActivity()));
startActivity(new Intent(getActivity(), MarkerListActivity.class).addFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
}
});
}
}
@@ -41,9 +41,9 @@ public class DeleteOneTrackDialogFragment extends DialogFragment {
Bundle bundle = new Bundle();
bundle.putLong(KEY_TRACK_ID, trackId);
DeleteOneTrackDialogFragment deleteTrackDialogFragment = new DeleteOneTrackDialogFragment();
deleteTrackDialogFragment.setArguments(bundle);
return deleteTrackDialogFragment;
DeleteOneTrackDialogFragment deleteOneTrackDialogFragment = new DeleteOneTrackDialogFragment();
deleteOneTrackDialogFragment.setArguments(bundle);
return deleteOneTrackDialogFragment;
}
@Override
@@ -70,11 +70,11 @@ public class MapFragment extends Fragment
// True to zoom to my location. Only apply when keepMyLocationVisible is true.
private boolean zoomToMyLocation;
// The track id of the waypoint to show.
private long waypointTrackId;
// The track id of the marker to show.
private long markerTrackId;
// The waypoint id to show
private long waypointId;
// The marker id to show
private long markerId;
// The current selected track id. Set in onSelectedTrackChanged.
private long currentSelectedTrackId;
@@ -166,11 +166,11 @@ public class MapFragment extends Fragment
}
/**
* Shows the waypoint.
* Shows the marker.
*
* @param id the waypoint id
* @param id the marker id
*/
public void showWaypoint(long id) {
private void showMarker(long id) {
MyTracksProviderUtils MyTracksProviderUtils = Factory.get(getActivity());
Waypoint waypoint = MyTracksProviderUtils.getWaypoint(id);
if (waypoint != null && waypoint.getLocation() != null) {
@@ -184,25 +184,25 @@ public class MapFragment extends Fragment
}
/**
* Shows the waypoint.
* Shows the marker.
*
* @param trackId the track id
* @param id the waypoint id
* @param id the marker id
*/
public void showWaypoint(long trackId, long id) {
public void showMarker(long trackId, long id) {
/*
* Synchronize to prevent race condition in changing waypointTrackId and
* waypointId variables.
* Synchronize to prevent race condition in changing markerTrackId and
* markerId variables.
*/
synchronized (this) {
if (trackId == currentSelectedTrackId) {
showWaypoint(id);
waypointTrackId = -1L;
waypointId = -1L;
showMarker(id);
markerTrackId = -1L;
markerId = -1L;
return;
}
waypointTrackId = trackId;
waypointId = id;
markerTrackId = trackId;
markerId = id;
}
}
@@ -314,8 +314,8 @@ public class MapFragment extends Fragment
synchronized (this) {
/*
* Synchronize to prevent race condition in changing waypointTrackId
* and waypointId variables.
* Synchronize to prevent race condition in changing markerTrackId
* and markerId variables.
*/
currentSelectedTrackId = track.getId();
updateMap(track);
@@ -424,17 +424,17 @@ public class MapFragment extends Fragment
}
/**
* Updates the map by either zooming to the requested waypoint or showing the track.
* Updates the map by either zooming to the requested marker or showing the track.
*
* @param track the track
*/
private void updateMap(Track track) {
if (track.getId() == waypointTrackId) {
// Show the waypoint
showWaypoint(waypointId);
if (track.getId() == markerTrackId) {
// Show the marker
showMarker(markerId);
waypointTrackId = -1L;
waypointId = -1L;
markerTrackId = -1L;
markerId = -1L;
} else {
// Show the track
showTrack(track);
@@ -57,6 +57,7 @@ public class RestoreActivity extends Activity {
if (date == -1L) {
Log.d(TAG, "Invalid date");
finish();
return;
}
restoreAsyncTask = new RestoreAsyncTask(this, new Date(date));
restoreAsyncTask.execute();
@@ -87,9 +87,9 @@ public class CsvTrackWriter implements TrackFormatWriter {
@Override
public void writeHeader() {
writeCommaSeparatedLine(context.getString(R.string.track_edit_name),
writeCommaSeparatedLine(context.getString(R.string.generic_name),
context.getString(R.string.track_edit_activity_type_hint),
context.getString(R.string.track_edit_description));
context.getString(R.string.generic_description));
writeCommaSeparatedLine(track.getName(), track.getCategory(), track.getDescription());
writeCommaSeparatedLine();
}
@@ -101,9 +101,9 @@ public class CsvTrackWriter implements TrackFormatWriter {
@Override
public void writeBeginWaypoints() {
writeCommaSeparatedLine(context.getString(R.string.marker_detail_marker_name),
context.getString(R.string.marker_detail_marker_type_hint),
context.getString(R.string.marker_detail_marker_description),
writeCommaSeparatedLine(context.getString(R.string.generic_name),
context.getString(R.string.marker_edit_marker_type_hint),
context.getString(R.string.generic_description),
context.getString(R.string.description_location_latitude),
context.getString(R.string.description_location_longitude),
context.getString(R.string.description_location_altitude),
@@ -972,10 +972,13 @@ public class TrackRecordingService extends Service {
wpt.setIcon(request.getIconUrl());
}
if (request.getName() == null) {
wpt.setName(getString(R.string.marker_type_waypoint));
wpt.setName(getString(R.string.marker_edit_type_waypoint));
} else {
wpt.setName(request.getName());
}
if (request.getCategory() != null) {
wpt.setCategory(request.getCategory());
}
if (request.getDescription() != null) {
wpt.setDescription(request.getDescription());
}
@@ -1000,7 +1003,7 @@ public class TrackRecordingService extends Service {
// Set the rest of the waypoint data
waypoint.setType(Waypoint.TYPE_STATISTICS);
waypoint.setName(getString(R.string.marker_type_statistics));
waypoint.setName(getString(R.string.marker_edit_type_statistics));
waypoint.setStatistics(waypointStatsBuilder.getStatistics());
waypoint.setDescription(descriptionGenerator.generateWaypointDescription(waypoint));
waypoint.setIcon(getString(R.string.marker_statistics_icon_url));
@@ -0,0 +1,159 @@
/*
* 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 com.google.android.maps.mytracks.R;
import android.app.Activity;
import android.widget.TextView;
/**
* Utilities for updating the statistics UI labels and values.
*
* @author Jimmy Shih
*/
public class StatsUtils {
private StatsUtils() {}
/**
* Sets a speed label.
*
* @param activity the activity
* @param id the speed label resource id
* @param speedId the speed string id
* @param paceId the pace string id
* @param reportSpeed true to report speed
*/
public static void setSpeedLabel(
Activity activity, int id, int speedId, int paceId, boolean reportSpeed) {
TextView textView = (TextView) activity.findViewById(id);
textView.setText(reportSpeed ? speedId : paceId);
}
/**
* Sets a speed value.
*
* @param activity the activity
* @param id the speed value resource id
* @param speed the speed in meters per second
* @param reportSpeed true to report speed
* @param metricUnits true to display in metric units
*/
public static void setSpeedValue(
Activity activity, int id, double speed, boolean reportSpeed, boolean metricUnits) {
TextView textView = (TextView) activity.findViewById(id);
speed *= UnitConversions.MS_TO_KMH;
String value;
if (metricUnits) {
if (reportSpeed) {
value = activity.getString(R.string.value_float_kilometer_hour, speed);
} else {
// convert from hours to minutes
double pace = speed == 0 ? 0.0 : 60.0 / speed;
value = activity.getString(R.string.value_float_minute_kilometer, pace);
}
} else {
speed *= UnitConversions.KM_TO_MI;
if (reportSpeed) {
value = activity.getString(R.string.value_float_mile_hour, speed);
} else {
// convert from hours to minutes
double pace = speed == 0 ? 0.0 : 60.0 / speed;
value = activity.getString(R.string.value_float_minute_mile, pace);
}
}
textView.setText(value);
}
/**
* Sets a distance value.
*
* @param activity the activity
* @param id the distance value resource id
* @param distance the distance in meters
* @param metricUnits true to display in metric units
*/
public static void setDistanceValue(
Activity activity, int id, double distance, boolean metricUnits) {
TextView textView = (TextView) activity.findViewById(id);
distance *= UnitConversions.M_TO_KM;
String value;
if (metricUnits) {
value = activity.getString(R.string.value_float_kilometer, distance);
} else {
distance *= UnitConversions.KM_TO_MI;
value = activity.getString(R.string.value_float_mile, distance);
}
textView.setText(value);
}
/**
* Sets a time value.
*
* @param activity the activity
* @param id the time value resource id
* @param time the time
*/
public static void setTimeValue(Activity activity, int id, long time) {
TextView textView = (TextView) activity.findViewById(id);
textView.setText(StringUtils.formatElapsedTime(time));
}
/**
* Sets an altitude value.
*
* @param activity the activity
* @param id the altitude value resource id
* @param altitude the altitude in meters
* @param metricUnits true to display in metric units
*/
public static void setAltitudeValue(
Activity activity, int id, double altitude, boolean metricUnits) {
TextView textView = (TextView) activity.findViewById(id);
String value;
if (Double.isNaN(altitude) || Double.isInfinite(altitude)) {
value = activity.getString(R.string.value_unknown);
} else {
if (metricUnits) {
value = activity.getString(R.string.value_float_meter, altitude);
} else {
altitude *= UnitConversions.M_TO_FT;
value = activity.getString(R.string.value_float_feet, altitude);
}
}
textView.setText(value);
}
/**
* Sets a grade value.
*
* @param activity the activity
* @param id the grade value resource id
* @param grade the grade in fraction between 0 and 1
*/
public static void setGradeValue(Activity activity, int id, double grade) {
TextView textView = (TextView) activity.findViewById(id);
String value;
if (Double.isNaN(grade) || Double.isInfinite(grade)) {
value = activity.getString(R.string.value_unknown);
} else {
value = activity.getString(R.string.value_integer_percent, Math.round(grade * 100));
}
textView.setText(value);
}
}
@@ -32,6 +32,7 @@ public class WaypointCreationRequest implements Parcelable {
private WaypointType type;
private String name;
private String category;
private String description;
private String iconUrl;
@@ -44,10 +45,11 @@ public class WaypointCreationRequest implements Parcelable {
this.type = type;
}
public WaypointCreationRequest(WaypointType type, String name,
public WaypointCreationRequest(WaypointType type, String name, String category,
String description, String iconUrl) {
this.type = type;
this.name = name;
this.category = category;
this.description = description;
this.iconUrl = iconUrl;
}
@@ -61,9 +63,10 @@ public class WaypointCreationRequest implements Parcelable {
throw new IllegalArgumentException("Could not find waypoint type: " + i);
}
WaypointCreationRequest request = new WaypointCreationRequest(WaypointType.values()[i]);
request.name = source.readString();
request.category = source.readString();
request.description = source.readString();
request.iconUrl = source.readString();
request.name = source.readString();
return request;
}
@@ -82,9 +85,10 @@ public class WaypointCreationRequest implements Parcelable {
@Override
public void writeToParcel(Parcel parcel, int arg1) {
parcel.writeInt(type.ordinal());
parcel.writeString(name);
parcel.writeString(category);
parcel.writeString(description);
parcel.writeString(iconUrl);
parcel.writeString(name);
}
public WaypointType getType() {
@@ -95,6 +99,10 @@ public class WaypointCreationRequest implements Parcelable {
return name;
}
public String getCategory() {
return category;
}
public String getDescription() {
return description;
}
@@ -42,13 +42,14 @@ public class WaypointCreationRequestTest extends AndroidTestCase {
public void testAllAttributesParceling() {
WaypointCreationRequest original =
new WaypointCreationRequest(WaypointType.MARKER, "name", "description", "img.png");
new WaypointCreationRequest(WaypointType.MARKER, "name", "category", "description", "img.png");
Parcel p = Parcel.obtain();
original.writeToParcel(p, 0);
p.setDataPosition(0);
WaypointCreationRequest copy = WaypointCreationRequest.CREATOR.createFromParcel(p);
assertEquals(original.getType(), copy.getType());
assertEquals("name", copy.getName());
assertEquals("category", copy.getCategory());
assertEquals("description", copy.getDescription());
assertEquals("img.png", copy.getIconUrl());
}
@@ -494,7 +494,7 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
Waypoint wpt = providerUtils.getWaypoint(1);
assertEquals(getContext().getString(R.string.marker_statistics_icon_url),
wpt.getIcon());
assertEquals(getContext().getString(R.string.marker_type_statistics),
assertEquals(getContext().getString(R.string.marker_edit_type_statistics),
wpt.getName());
assertEquals(Waypoint.TYPE_STATISTICS, wpt.getType());
assertEquals(123L, wpt.getTrackId());
@@ -530,7 +530,7 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
Waypoint wpt = providerUtils.getWaypoint(1);
assertEquals(getContext().getString(R.string.marker_waypoint_icon_url),
wpt.getIcon());
assertEquals(getContext().getString(R.string.marker_type_waypoint),
assertEquals(getContext().getString(R.string.marker_edit_type_waypoint),
wpt.getName());
assertEquals(Waypoint.TYPE_WAYPOINT, wpt.getType());
assertEquals(123L, wpt.getTrackId());