Merge heads

This commit is contained in:
youtaol
2013-08-22 10:14:45 +08:00
parent 83b1fb67bf
commit b6b54923b2
37 changed files with 434 additions and 221 deletions
+2 -2
View File
@@ -68,12 +68,12 @@ limitations under the License.
</TableLayout>
<ImageView
android:id="@+id/list_item_photo"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_weight="1"
android:layout_width="0dp"
android:scaleType="centerCrop" />
android:scaleType="fitCenter" />
</LinearLayout>
<TableLayout
android:layout_height="wrap_content"
@@ -27,10 +27,11 @@ limitations under the License.
android:layout_width="match_parent"
android:orientation="vertical" >
<ImageView
android:adjustViewBounds="true"
android:id="@+id/marker_detail_waypoint_photo"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:scaleType="centerInside" />
android:scaleType="fitCenter" />
<TextView
android:id="@+id/marker_detail_waypoint_name"
style="@style/TextLarge.WithTopMargin" />
-4
View File
@@ -43,9 +43,5 @@ limitations under the License.
android:singleLine="false"
android:visibility="gone" >
</MultiAutoCompleteTextView>
<TextView
android:text="@string/share_track_footer"
android:layout_marginTop="16dp"
style="@style/TextSmall" />
</LinearLayout>
</ScrollView>
@@ -92,6 +92,14 @@ limitations under the License.
<item>15</item>
<item>-1</item>
</string-array>
<string-array name="chart_x_axis_options">
<item>@string/settings_chart_by_distance</item>
<item>@string/settings_chart_by_time</item>
</string-array>
<string-array name="chart_x_axis_values">
<item>@string/chart_x_axis_distance</item>
<item>@string/chart_x_axis_time</item>
</string-array>
<string-array name="frequency_values">
<item>0</item>
<item>1</item>
@@ -176,6 +184,18 @@ limitations under the License.
<item>@string/sensor_type_value_zephyr</item>
<item>@string/sensor_type_value_none</item>
</string-array>
<string-array name="stats_rate_imperial_options">
<item>@string/description_speed_imperial</item>
<item>@string/description_pace_imperial</item>
</string-array>
<string-array name="stats_rate_metric_options">
<item>@string/description_speed_metric</item>
<item>@string/description_pace_metric</item>
</string-array>
<string-array name="stats_rate_values">
<item>@string/stats_rate_speed</item>
<item>@string/stats_rate_pace</item>
</string-array>
<string-array name="stats_units_options">
<item>@string/settings_stats_units_metric</item>
<item>@string/settings_stats_units_imperial</item>
+4
View File
@@ -16,6 +16,8 @@ limitations under the License.
-->
<resources>
<!-- DO NOT TRANSLATE ANY STRINGS IN THIS FILE. -->
<string name="chart_x_axis_distance">DISTANCE</string>
<string name="chart_x_axis_time">TIME</string>
<string name="eula_korean">위치정보서비스 및 위치기반서비스 이용약관\n
\n
다음은 구글코리아 유한회사(이하 “Google”)가 Google의 제품에 대하여 제공하고 있는 위치기반서비스에 적용되는 이용조건입니다. 아래 이용조건은 이동통신사업자의 가입신청서에 포함된 위치정보 수집동의 및 모바일 단말기 이용조건과 함께 적용됩니다.\n
@@ -93,6 +95,8 @@ Google은 이용자에 대한 위치정보의 이용∙제공사실을 위치정
<string name="settings_recording_track_name_date_local_value">DATE_LOCAL</string>
<string name="settings_recording_track_name_location_value">LOCATION</string>
<string name="settings_recording_track_name_number_value">NUMBER</string>
<string name="stats_rate_pace">PACE</string>
<string name="stats_rate_speed">SPEED</string>
<string name="stats_units_imperial">IMPERIAL</string>
<string name="stats_units_metric">METRIC</string>
<string name="track_action_end">com.google.android.apps.mytracks.END_CURRENT_TRACK</string>
+3 -3
View File
@@ -18,12 +18,12 @@ limitations under the License.
<!-- Keys for persisted preferences. Sorted alphabetically. DO NOT TRANSLATE. -->
<string name="allow_access_key">allowAccess</string>
<string name="auto_resume_track_timeout_key">autoResumeTrackTimeout</string>
<string name="chart_by_distance_key">chartByDistance</string>
<string name="chart_show_cadence_key">chartShowCadence</string>
<string name="chart_show_elevation_key">chartShowElevation</string>
<string name="chart_show_heart_rate_key">chartShowHeartRate</string>
<string name="chart_show_power_key">chartShowPower</string>
<string name="chart_show_speed_key">chartShowSpeed</string>
<string name="chart_x_axis_key">chartXAxis</string>
<string name="default_activity_key">defaultActivity</string>
<string name="export_external_storage_format_key">exportExternalStorageFormat</string>
<string name="export_google_fusion_tables_public_key">exportGoogleFusionTablesPublic</string>
@@ -34,14 +34,14 @@ limitations under the License.
<string name="min_recording_interval_key">minRecordingInterval</string>
<string name="recording_distance_interval_key">recordingDistanceInterval</string>
<string name="recording_gps_accuracy_key">recordingGpsAccuracy</string>
<string name="report_speed_key">reportSpeed</string>
<string name="sensor_type_key">sensorType</string>
<string name="share_track_invite_key">shareTrackInvite</string>
<string name="share_track_public_key">shareTrackPublic</string>
<string name="split_frequency_key">splitFrequency</string>
<string name="stats_rate_key">statsRate</string>
<string name="stats_show_coordinate_key">statsShowCoordinate</string>
<string name="stats_show_grade_elevation_key">statsShowGradeElevation</string>
<string name="stats_units_key">statsdUnits</string>
<string name="stats_units_key">statsUnits</string>
<string name="track_color_mode_medium_key">trackColorModeMedium</string>
<string name="track_color_mode_percentage_key">trackColorModePercentage</string>
<string name="track_color_mode_slow_key">trackColorModeSlow</string>
+70 -38
View File
@@ -774,10 +774,10 @@ limitations under the License.
translation_description="The text on a button to say cancel.">
Cancel
</string>
<string name="generic_confirm_title"
translation_description="The title on a confirmation dialog asking the user if he is sure?">
Are you sure?
</string>
<string name="generic_delete_selected_confirm_title"
translation_description="When deleting selected items, the title of the confirmation dialog.">
Delete selected?
</string>
<string name="generic_description"
translation_description="The text label for entering a description.">
Description
@@ -1001,6 +1001,10 @@ limitations under the License.
translation_description="When deleting one marker, the confirmation message.">
The marker will be permanently deleted from the device.
</string>
<string name="marker_delete_one_confirm_title"
translation_description="When deleting one marker, the title of the confirmation dialog.">
Delete marker?
</string>
<string name="marker_delete_multiple_confirm_message"
translation_description="When deleting multiple markers, the confirmation message.">
All markers for this track will be permanently deleted from the device.
@@ -1484,29 +1488,39 @@ limitations under the License.
Backup &amp; reset
</string>
<!-- Settings Backup Now -->
<string name="settings_backup_now"
<!-- Settings Backup -->
<string name="settings_backup"
translation_description="In the 'Backup and reset' settings, the option to backup to the
external storage now.
external storage.
Character limit: ~26 (1 line)">
Backup now
Backup
</string>
<string name="settings_backup_confirm_message"
translation_description="In the 'Backup and reset' settings, after pressing the 'Backup' option,
the confirmation message.
%1$s the directory. E.g., '/MyTracks/backups'.">
This will write a full copy of all your tracks and settings to &#8216;%1$s&#8217; on the
external storage.
</string>
<string name="settings_backup_confirm_title"
translation_description="In the 'Backup and reset' settings, after pressing the 'Backup' option,
the title of the confirmation dialog.
Character limit: ~26 (1 line)">
Backup now?
</string>
<string name="settings_backup_now_error"
translation_description="When backing up to the external storage, the error message.">
Unable to backup.
</string>
<string name="settings_backup_now_progress_message"
translation_description="In the 'Backup and reset' settings, after pressing the 'Backup now'
option, the progress message telling the user that it is writing all tracks and settings to
the external storage.">
translation_description="In the 'Backup and reset' settings, after pressing the 'Backup' option,
the progress message telling the user that it is writing all tracks and settings to the
external storage.">
Writing all tracks and settings&#8230;
</string>
<string name="settings_backup_now_summary"
translation_description="In the 'Backup and reset' settings, the summary for the 'Backup now'
option explaining that all tracks and settings will be written to the external storage.">
Write a full copy of all your tracks and settings to the external storage
</string>
<string name="settings_backup_now_success"
translation_description="When backing up to the external storage, the success message">
Finished backup.
@@ -1518,22 +1532,26 @@ limitations under the License.
external storage.
Character limit: ~26 (1 line)">
Restore now
Restore
</string>
<string name="settings_backup_restore_confirm_message"
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore now'
option, the message in the alert dialog asking the user to confirm that he wants to restore
from a backup.">
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore'
option, the confirmation message.">
Restoring a backup from external storage will delete all your tracks and settings, and update
them with the backup copy. Google Drive sync will be turned off. No tracks will be deleted on
Google Drive and on external storage.
</string>
<string name="settings_backup_restore_confirm_title"
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore'
option, the title of the confirmation dialog.">
Restore now?
</string>
<string name="settings_backup_restore_error"
translation_description="When restoring from backup, the error message.">
Unable to restore from backup.
</string>
<string name="settings_backup_restore_no_backups"
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore now'
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore'
option, the message in the alert dialog informing the user that there is no backups to restore
from.
@@ -1541,21 +1559,16 @@ limitations under the License.
No backups found in %1$s.
</string>
<string name="settings_backup_restore_progress_message"
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore now'
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore'
option, the progress message informing that My Tracks is reading all tracks and settings from
the backup on the external storage.">
Reading all tracks and settings&#8230;
</string>
<string name="settings_backup_restore_select_title"
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore now'
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore'
option, the title in the picker dialog asking the user to select a backup.">
Select a backup to restore
</string>
<string name="settings_backup_restore_summary"
translation_description="In the 'Backup and reset' settings, the summary for the 'Restore now'
option explaining that it restores all tracks and settings from the external storage.">
Restore all tracks and settings from the external storage
</string>
<string name="settings_backup_restore_success"
translation_description="When restoring from backup, the success message.">
Finished restoring from backup.
@@ -1595,6 +1608,11 @@ limitations under the License.
This will remove any association between your tracks and %1$s Google Drive. Google Drive sync
will be turned off. No tracks will be deleted on %1$s Google Drive.
</string>
<string name="settings_google_account_confirm_title"
translation_description="In the 'Accounts and sync' settings, after pressing 'Switch account',
the title of the confirmation dialog.">
Switch account?
</string>
<string name="settings_google_account_title"
translation_description="In the 'Accounts and sync' settings, the option to switch Google
account.
@@ -1818,17 +1836,17 @@ limitations under the License.
All settings will be reverted to the default values. This will not delete any tracks on the
device or on Google Drive.
</string>
<string name="settings_reset_confirm_title"
translation_description="In the 'Backup and reset' settings, after pressing the 'Reset' option,
the title of the confirmation dialog.">
Reset now?
</string>
<string name="settings_reset_done"
translation_description="In the 'Backup and reset' settings, after pressing the 'Reset' option,
the confirmation dialog informing the user that all settings have been reverted to the default
values.">
All settings have been reverted to the default values.
</string>
<string name="settings_reset_summary"
translation_description="In the 'Backup and reset' settings, the summary for the 'Reset' option
explaining it will revert all settings to the default values.">
Revert all your settings to the default values
</string>
<!-- Settings Sensor -->
<string name="settings_sensor"
@@ -1964,6 +1982,11 @@ limitations under the License.
Other apps, including future apps, will be able to control and access My Tracks data. There will
be no further notification.
</string>
<string name="settings_sharing_allow_access_confirm_title"
translation_description="In the 'Sharing' settings, after checking the 'Allow access' checkbox,
the title of the confirmation dialog.">
Allow access?
</string>
<string name="settings_sharing_allow_access_summary_off"
translation_description="In the 'Sharing' settings, the summary for the 'Allow access' checkbox
option when it is unchecked explaining that other apps cannot read, write, start/stop
@@ -2021,10 +2044,6 @@ limitations under the License.
translation_description="The hint for the auto complete text box for entering email addresses.">
Email addresses
</string>
<string name="share_track_footer"
translation_description="The dialog footer when sharing a track via Google Drive.">
This will upload your track to Google Drive.
</string>
<string name="share_track_invite"
translation_description="The checkbox to invite people to view a track.">
Invite people to view
@@ -2213,11 +2232,19 @@ limitations under the License.
All tracks and markers will be permanently deleted from the device. Google Drive sync will be
turned off. No tracks will be deleted on Google Drive and on external storage.
</string>
<string name="track_delete_all_confirm_title"
translation_description="When deleting all the tracks, the title of the confirmation dialog.">
Delete all?
</string>
<string name="track_delete_one_confirm_message"
translation_description="When deleting one track, the confirmation message.">
The track and its markers will be permanently deleted from the device. If Google Drive sync is
enabled, this will also delete the track on Google Drive.
</string>
<string name="track_delete_one_confirm_title"
translation_description="When deleting one track, the title of the confirmation dialog.">
Delete track?
</string>
<string name="track_delete_multiple_confirm_message"
translation_description="When deleting multiple tracks, the confirmation message.">
The selected tracks and their markers will be permanently deleted from the device. If Google
@@ -2254,7 +2281,12 @@ limitations under the License.
</string>
<string name="track_detail_play_confirm_message"
translation_description="The confirmation message when playing a track in Google Earth.">
Play in Google Earth will save your track to external storage.
This will save your track to external storage.
</string>
<string name="track_detail_play_confirm_title"
translation_description="When playing a track in Google Earth, the title of the confirmation
dialog.">
Play in Google Earth?
</string>
<string name="track_detail_stats_tab"
translation_description="In the track detail page, the title of the tab showing the stats.">
+1 -1
View File
@@ -19,7 +19,7 @@ limitations under the License.
<Preference
android:key="@string/settings_backup_key"
android:persistent="false"
android:title="@string/settings_backup_now" />
android:title="@string/settings_backup" />
<Preference
android:key="@string/settings_restore_key"
android:persistent="false"
+3 -5
View File
@@ -16,11 +16,9 @@ limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/track_detail_chart_tab" >
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/chart_by_distance_key"
android:summaryOff="@string/settings_chart_by_time"
android:summaryOn="@string/settings_chart_by_distance"
<ListPreference
android:defaultValue="@string/chart_x_axis_distance"
android:key="@string/chart_x_axis_key"
android:title="@string/settings_chart_x_axis" />
<PreferenceCategory android:title="@string/settings_show" >
<CheckBoxPreference
+3 -3
View File
@@ -20,9 +20,9 @@ limitations under the License.
android:defaultValue="@string/stats_units_metric"
android:key="@string/stats_units_key"
android:title="@string/settings_stats_units_title" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/report_speed_key"
<ListPreference
android:defaultValue="@string/stats_rate_speed"
android:key="@string/stats_rate_key"
android:title="@string/settings_stats_rate_title" />
<PreferenceCategory android:title="@string/settings_show" >
<CheckBoxPreference
@@ -282,9 +282,8 @@ public class TrackDataHub implements DataSourceListener {
}
}
if (key == null
|| key.equals(PreferencesUtils.getKey(context, R.string.report_speed_key))) {
reportSpeed = PreferencesUtils.getBoolean(
context, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
|| key.equals(PreferencesUtils.getKey(context, R.string.stats_rate_key))) {
reportSpeed = PreferencesUtils.isReportSpeed(context);
if (key != null) {
for (TrackDataListener trackDataListener :
trackDataManager.getListeners(TrackDataType.PREFERENCE)) {
@@ -65,7 +65,7 @@ public class ChartFragment extends Fragment implements TrackDataListener {
private long startTime;
private boolean metricUnits = true;
private boolean reportSpeed = PreferencesUtils.REPORT_SPEED_DEFAULT;
private boolean reportSpeed = true;
private int recordingDistanceInterval = PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT;
// Modes of operation
@@ -305,8 +305,7 @@ public class ChartFragment extends Fragment implements TrackDataListener {
*/
private void checkChartSettings() {
boolean needUpdate = false;
if (chartByDistance != PreferencesUtils.getBoolean(getActivity(),
R.string.chart_by_distance_key, PreferencesUtils.CHART_BY_DISTANCE_DEFAULT)) {
if (chartByDistance != PreferencesUtils.isChartByDistance(getActivity())) {
chartByDistance = !chartByDistance;
chartView.setChartByDistance(chartByDistance);
reloadTrackDataHub();
@@ -82,15 +82,19 @@ public class ConfirmDeleteDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final long[] trackIds = getArguments().getLongArray(KEY_TRACK_IDS);
int titleId;
int messageId;
if (trackIds.length == 1 && trackIds[0] == -1L) {
titleId = R.string.track_delete_all_confirm_title;
messageId = R.string.track_delete_all_confirm_message;
} else {
titleId = trackIds.length > 1 ? R.string.generic_delete_selected_confirm_title
: R.string.track_delete_one_confirm_title;
messageId = trackIds.length > 1 ? R.string.track_delete_multiple_confirm_message
: R.string.track_delete_one_confirm_message;
}
return DialogUtils.createConfirmationDialog(
getActivity(), messageId, new DialogInterface.OnClickListener() {
getActivity(), titleId, getString(messageId), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
caller.onConfirmDeleteDone(trackIds);
@@ -16,11 +16,11 @@
package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -92,8 +92,8 @@ public class ConfirmPlayDialogFragment extends DialogFragment {
textView.setText(R.string.track_detail_play_confirm_message);
checkBox = (CheckBox) view.findViewById(R.id.confirm_dialog_check_box);
return new AlertDialog.Builder(fragmentActivity).setNegativeButton(R.string.generic_no, null)
.setPositiveButton(R.string.generic_yes, new DialogInterface.OnClickListener() {
return DialogUtils.createConfirmationDialog(fragmentActivity,
R.string.track_detail_play_confirm_title, view, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
long[] trackIds = getArguments().getLongArray(KEY_TRACK_IDS);
@@ -101,6 +101,6 @@ public class ConfirmPlayDialogFragment extends DialogFragment {
fragmentActivity, R.string.confirm_play_earth_key, !checkBox.isChecked());
caller.onConfirmPlayDone(trackIds);
}
}).setTitle(R.string.generic_confirm_title).setView(view).create();
});
}
}
@@ -77,10 +77,12 @@ public class DeleteMarkerDialogFragment extends DialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
final FragmentActivity fragmentActivity = getActivity();
final long[] markerIds = getArguments().getLongArray(KEY_MARKER_IDS);
int titleId = markerIds.length > 1 ? R.string.generic_delete_selected_confirm_title
: R.string.marker_delete_one_confirm_title;
int messageId = markerIds.length > 1 ? R.string.marker_delete_multiple_confirm_message
: R.string.marker_delete_one_confirm_message;
return DialogUtils.createConfirmationDialog(
fragmentActivity, messageId, new DialogInterface.OnClickListener() {
fragmentActivity, titleId, getString(messageId), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
new Thread(new Runnable() {
@@ -181,7 +181,7 @@ public class MarkerDetailFragment extends Fragment {
@SuppressWarnings("deprecation")
int displayHeight = defaultDisplay.getHeight();
bitmap = PhotoUtils.setImageVew(
imageView, Uri.parse(photoUrl), displayWidth, displayHeight, true);
imageView, Uri.parse(photoUrl), displayWidth, displayHeight);
}
TextView name = (TextView) getView().findViewById(R.id.marker_detail_waypoint_name);
@@ -18,6 +18,7 @@ package com.google.android.apps.mytracks.io.file;
import com.google.android.apps.mytracks.content.DescriptionGenerator;
import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl;
import com.google.android.apps.mytracks.content.MyTracksLocation;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Sensor;
import com.google.android.apps.mytracks.content.Sensor.SensorData;
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
@@ -30,7 +31,9 @@ import com.google.android.maps.mytracks.R;
import com.google.common.annotations.VisibleForTesting;
import android.content.Context;
import android.database.Cursor;
import android.location.Location;
import android.net.Uri;
import java.io.OutputStream;
import java.io.PrintWriter;
@@ -65,7 +68,8 @@ public class KmlTrackWriter implements TrackFormatWriter {
TRACK_ICON = "http://earth.google.com/images/kml-icons/track-directional/track-0.png";
private final Context context;
private final DescriptionGenerator descriptionGenerator;
private final DescriptionGenerator descriptionGenerator;
private final MyTracksProviderUtils myTracksProviderUtils;
private PrintWriter printWriter;
private ArrayList<Integer> powerList = new ArrayList<Integer>();
private ArrayList<Integer> cadenceList = new ArrayList<Integer>();
@@ -82,6 +86,7 @@ public class KmlTrackWriter implements TrackFormatWriter {
KmlTrackWriter(Context context, DescriptionGenerator descriptionGenerator) {
this.context = context;
this.descriptionGenerator = descriptionGenerator;
this.myTracksProviderUtils = MyTracksProviderUtils.Factory.get(context);
}
@Override
@@ -158,8 +163,15 @@ public class KmlTrackWriter implements TrackFormatWriter {
if (printWriter != null) {
String styleName = waypoint.getType() == WaypointType.STATISTICS ? STATISTICS_STYLE
: WAYPOINT_STYLE;
writePlacemark(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(),
styleName, waypoint.getLocation());
String photoUrl = waypoint.getPhotoUrl();
if (photoUrl != null && !photoUrl.equals("")) {
float heading = getHeading(waypoint.getTrackId(), waypoint.getLocation());
writePhotoOverlay(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(),
styleName, waypoint.getLocation(), photoUrl, heading);
} else {
writePlacemark(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(),
styleName, waypoint.getLocation());
}
}
}
@@ -307,6 +319,76 @@ public class KmlTrackWriter implements TrackFormatWriter {
}
}
/**
* Writes a photo overlay.
*
* @param name the name
* @param category the category
* @param description the description
* @param styleName the style name
* @param location the location
* @param photoUrl the photo url
* @param heading the heading
*/
private void writePhotoOverlay(String name, String category, String description, String styleName,
Location location, String photoUrl, float heading) {
if (location != null) {
printWriter.println("<PhotoOverlay>");
printWriter.println("<name>" + StringUtils.formatCData(name) + "</name>");
printWriter.println("<description>"
+ StringUtils.formatCData(StringUtils.getCategoryDescription(category, description))
+ "</description>");
printWriter.print("<Camera>");
printWriter.print("<longitude>" + location.getLongitude() + "</longitude>");
printWriter.print("<latitude>" + location.getLatitude() + "</latitude>");
printWriter.print("<altitude>20</altitude>");
printWriter.print("<heading>" + heading + "</heading>");
printWriter.print("<tilt>90</tilt>");
printWriter.println("</Camera>");
printWriter.println("<styleUrl>#" + styleName + "</styleUrl>");
printWriter.println("<Icon><href>" + Uri.decode(photoUrl) + "</href></Icon>");
printWriter.print("<ViewVolume>");
printWriter.print("<near>10</near>");
printWriter.print("<leftFov>-60</leftFov>");
printWriter.print("<rightFov>60</rightFov>");
printWriter.print("<bottomFov>-45</bottomFov>");
printWriter.print("<topFov>45</topFov>");
printWriter.println("</ViewVolume>");
printWriter.println("<Point>");
printWriter.println("<coordinates>" + getCoordinates(location, ",") + "</coordinates>");
printWriter.println("</Point>");
printWriter.println("</PhotoOverlay>");
}
}
/**
* Gets the heading to a location.
*
* @param trackId the track id containing the location
* @param location the location
*/
private float getHeading(long trackId, Location location) {
long trackPointId = myTracksProviderUtils.getTrackPointId(trackId, location);
if (trackPointId == -1L) {
return location.getBearing();
}
Cursor cursor = null;
Location viewLocation;
try {
cursor = myTracksProviderUtils.getTrackPointCursor(trackId, trackPointId, 10, true);
if (cursor == null || cursor.getCount() == 0) {
return location.getBearing();
}
cursor.moveToPosition(cursor.getCount() - 1);
viewLocation = myTracksProviderUtils.createTrackPoint(cursor);
} finally {
if (cursor != null) {
cursor.close();
}
}
return viewLocation.bearingTo(location);
}
private String getCoordinates(Location location, String separator) {
StringBuffer buffer = new StringBuffer();
buffer.append(location.getLongitude() + separator + location.getLatitude());
@@ -228,8 +228,7 @@ public class AnnouncementPeriodicTask implements PeriodicTask {
@VisibleForTesting
protected String getAnnouncement(TripStatistics tripStatistics) {
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
boolean reportSpeed = PreferencesUtils.getBoolean(
context, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
boolean reportSpeed = PreferencesUtils.isReportSpeed(context);
double distance = tripStatistics.getTotalDistance() * UnitConversions.M_TO_KM;
double speed = tripStatistics.getAverageMovingSpeed() * UnitConversions.MS_TO_KMH;
@@ -21,6 +21,7 @@ import com.google.android.apps.mytracks.io.backup.BackupActivity;
import com.google.android.apps.mytracks.io.backup.RestoreChooserActivity;
import com.google.android.apps.mytracks.io.sync.SyncUtils;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.apps.mytracks.util.FileUtils;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
@@ -45,8 +46,9 @@ import android.widget.Toast;
public class BackupResetSettingsActivity extends AbstractSettingsActivity {
private static final String TAG = BackupResetSettingsActivity.class.getSimpleName();
private static final int DIALOG_CONFIRM_RESTORE_ID = 0;
private static final int DIALOG_CONFIRM_RESET_ID = 1;
private static final int DIALOG_CONFIRM_BACKUP_ID = 0;
private static final int DIALOG_CONFIRM_RESTORE_ID = 1;
private static final int DIALOG_CONFIRM_RESET_ID = 2;
private SharedPreferences sharedPreferences;
private Preference backupPreference;
@@ -88,10 +90,8 @@ public class BackupResetSettingsActivity extends AbstractSettingsActivity {
backupPreference = findPreference(getString(R.string.settings_backup_key));
backupPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = IntentUtils.newIntent(
BackupResetSettingsActivity.this, BackupActivity.class);
startActivity(intent);
public boolean onPreferenceClick(Preference preference) {
showDialog(DIALOG_CONFIRM_BACKUP_ID);
return true;
}
});
@@ -116,11 +116,26 @@ public class BackupResetSettingsActivity extends AbstractSettingsActivity {
@Override
protected Dialog onCreateDialog(int id) {
String message;
Dialog dialog;
switch (id) {
case DIALOG_CONFIRM_BACKUP_ID:
message = getString(R.string.settings_backup_confirm_message,
FileUtils.getDirectoryDisplayName(FileUtils.BACKUPS_DIR));
dialog = DialogUtils.createConfirmationDialog(this, R.string.settings_backup_confirm_title,
message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int which) {
Intent intent = IntentUtils.newIntent(
BackupResetSettingsActivity.this, BackupActivity.class);
startActivity(intent);
}
});
break;
case DIALOG_CONFIRM_RESTORE_ID:
message = getString(R.string.settings_backup_restore_confirm_message);
dialog = DialogUtils.createConfirmationDialog(this,
R.string.settings_backup_restore_confirm_message,
R.string.settings_backup_restore_confirm_title, message,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int which) {
@@ -131,8 +146,9 @@ public class BackupResetSettingsActivity extends AbstractSettingsActivity {
});
break;
case DIALOG_CONFIRM_RESET_ID:
dialog = DialogUtils.createConfirmationDialog(
this, R.string.settings_reset_confirm_message, new DialogInterface.OnClickListener() {
message = getString(R.string.settings_reset_confirm_message);
dialog = DialogUtils.createConfirmationDialog(this, R.string.settings_reset_confirm_title,
message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int button) {
onResetPreferencesConfirmed();
@@ -164,17 +180,13 @@ public class BackupResetSettingsActivity extends AbstractSettingsActivity {
*/
private void updateUi() {
boolean isRecording = recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
String summary = isRecording ? getString(R.string.settings_not_while_recording) : "";
backupPreference.setEnabled(!isRecording);
backupPreference.setSummary(
isRecording ? R.string.settings_not_while_recording : R.string.settings_backup_now_summary);
backupPreference.setSummary(summary);
restoreNowPreference.setEnabled(!isRecording);
restoreNowPreference.setSummary(isRecording ? R.string.settings_not_while_recording
: R.string.settings_backup_restore_summary);
restoreNowPreference.setSummary(summary);
resetPreference.setEnabled(!isRecording);
resetPreference.setSummary(
isRecording ? R.string.settings_not_while_recording : R.string.settings_reset_summary);
resetPreference.setSummary(summary);
}
/**
@@ -21,6 +21,7 @@ import com.google.android.maps.mytracks.R;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
/**
* An activity for accessing chart settings.
@@ -34,6 +35,7 @@ public class ChartSettingsActivity extends AbstractSettingsActivity {
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
addPreferencesFromResource(R.xml.chart_settings);
configXAxisListPreference();
}
@Override
@@ -46,9 +48,21 @@ public class ChartSettingsActivity extends AbstractSettingsActivity {
private void updateUi() {
CheckBoxPreference speedCheckBoxPreference = (CheckBoxPreference) findPreference(
getString(R.string.chart_show_speed_key));
boolean reportSpeed = PreferencesUtils.getBoolean(
this, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
speedCheckBoxPreference.setTitle(reportSpeed ? R.string.stats_speed
: R.string.stats_pace);
speedCheckBoxPreference.setTitle(
PreferencesUtils.isReportSpeed(this) ? R.string.stats_speed : R.string.stats_pace);
}
/**
* Configures the x axis list preference.
*/
private void configXAxisListPreference() {
@SuppressWarnings("deprecation")
ListPreference listPreference = (ListPreference) findPreference(
getString(R.string.chart_x_axis_key));
String value = PreferencesUtils.getString(
this, R.string.chart_x_axis_key, PreferencesUtils.CHART_X_AXIS_DEFAULT);
String[] values = getResources().getStringArray(R.array.chart_x_axis_values);
String[] options = getResources().getStringArray(R.array.chart_x_axis_options);
configureListPreference(listPreference, options, options, values, value, null);
}
}
@@ -140,12 +140,13 @@ public class GoogleSettingsActivity extends AbstractSettingsActivity {
Dialog dialog;
switch (id) {
case DIALOG_CONFIRM_SWITCH_ACCOUNT:
dialog = DialogUtils.createConfirmationDialog(
this, R.string.settings_google_account_confirm_message, null);
dialog = DialogUtils.createConfirmationDialog(this,
R.string.settings_google_account_confirm_title,
getString(R.string.settings_google_account_confirm_message), null);
break;
case DIALOG_CONFIRM_DRIVE_SYNC_ON:
dialog = DialogUtils.createConfirmationDialog(this, R.string.sync_drive_title,
R.string.sync_drive_confirm_message, null, new DialogInterface.OnClickListener() {
getString(R.string.sync_drive_confirm_message), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int button) {
final String googleAccount = PreferencesUtils.getString(GoogleSettingsActivity.this,
@@ -179,7 +180,7 @@ public class GoogleSettingsActivity extends AbstractSettingsActivity {
});
thread.start();
}
}, null);
});
break;
default:
dialog = null;
@@ -64,7 +64,8 @@ public class SharingSettingsActivity extends AbstractSettingsActivity {
return null;
}
return DialogUtils.createConfirmationDialog(this,
R.string.settings_sharing_allow_access_confirm_message,
R.string.settings_sharing_allow_access_confirm_title,
getString(R.string.settings_sharing_allow_access_confirm_message),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int button) {
@@ -20,7 +20,6 @@ import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
@@ -32,21 +31,30 @@ import android.preference.Preference.OnPreferenceChangeListener;
*/
public class StatsSettingsActivity extends AbstractSettingsActivity {
private String statsUnits;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
addPreferencesFromResource(R.xml.stats_settings);
ListPreference preference = (ListPreference) findPreference(
/*
* Note configureUnitsListPreference will trigger
* configureRateListPreference
*/
configUnitsListPreference();
}
/**
* Configures the preferred units list preference.
*/
private void configUnitsListPreference() {
@SuppressWarnings("deprecation")
ListPreference listPreference = (ListPreference) findPreference(
getString(R.string.stats_units_key));
OnPreferenceChangeListener listener = new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference pref, Object newValue) {
statsUnits = (String) newValue;
updateUi();
configRateListPreference(PreferencesUtils.STATS_UNITS_DEFAULT.equals((String) newValue));
return true;
}
};
@@ -54,27 +62,23 @@ public class StatsSettingsActivity extends AbstractSettingsActivity {
this, R.string.stats_units_key, PreferencesUtils.STATS_UNITS_DEFAULT);
String[] values = getResources().getStringArray(R.array.stats_units_values);
String[] options = getResources().getStringArray(R.array.stats_units_options);
configureListPreference(preference, options, options, values, value, listener);
configureListPreference(listPreference, options, options, values, value, listener);
}
@Override
protected void onResume() {
super.onResume();
statsUnits = PreferencesUtils.getString(
this, R.string.stats_units_key, PreferencesUtils.STATS_UNITS_DEFAULT);
updateUi();
}
@SuppressWarnings("deprecation")
private void updateUi() {
CheckBoxPreference reportSpeedCheckBoxPreference = (CheckBoxPreference) findPreference(
getString(R.string.report_speed_key));
boolean metricUnits = PreferencesUtils.STATS_UNITS_DEFAULT.equals(statsUnits);
reportSpeedCheckBoxPreference.setSummaryOn(
metricUnits ? getString(R.string.description_speed_metric)
: getString(R.string.description_speed_imperial));
reportSpeedCheckBoxPreference.setSummaryOff(
metricUnits ? getString(R.string.description_pace_metric)
: getString(R.string.description_pace_imperial));
/**
* Configures the preferred rate list preference.
*
* @param metricUnits true if metric units
*/
private void configRateListPreference(boolean metricUnits) {
@SuppressWarnings("deprecation")
ListPreference listPreference = (ListPreference) findPreference(
getString(R.string.stats_rate_key));
String value = PreferencesUtils.getString(
this, R.string.stats_rate_key, PreferencesUtils.STATS_RATE_DEFAULT);
String[] values = getResources().getStringArray(R.array.stats_rate_values);
String[] options = getResources().getStringArray(
metricUnits ? R.array.stats_rate_metric_options : R.array.stats_rate_imperial_options);
configureListPreference(listPreference, options, options, values, value, null);
}
}
@@ -38,40 +38,26 @@ public class DialogUtils {
* Creates a confirmation dialog.
*
* @param context the context
* @param messageId the message id
* @param titleId the title
* @param message the message
* @param okListener the listener when OK is clicked
*/
public static Dialog createConfirmationDialog(
Context context, int messageId, DialogInterface.OnClickListener okListener) {
return createConfirmationDialog(
context, R.string.generic_confirm_title, messageId, null, okListener, null);
Context context, int titleId, String message, DialogInterface.OnClickListener okListener) {
return createConfirmationDialog(context, titleId, message, null, okListener);
}
/**
* Creates a confirmation dialog.
*
* @param context the context
* @param titleId the titleId
* @param messageId the messageId
* @param titleId the title
* @param view the view
* @param okListener the listener when OK is clicked
* @param cancelListener the listener when cancel is clicked
*/
public static Dialog createConfirmationDialog(Context context, int titleId, int messageId,
View view, DialogInterface.OnClickListener okListener,
DialogInterface.OnClickListener cancelListener) {
AlertDialog.Builder builder = new AlertDialog.Builder(context).setCancelable(true)
.setIcon(android.R.drawable.ic_dialog_alert)
.setNegativeButton(R.string.generic_no, cancelListener)
.setPositiveButton(R.string.generic_yes, okListener).setTitle(titleId);
if (messageId != -1) {
builder.setMessage(messageId);
}
if (view != null) {
builder.setView(view);
}
return builder.create();
public static Dialog createConfirmationDialog(
Context context, int titleId, View view, DialogInterface.OnClickListener okListener) {
return createConfirmationDialog(context, titleId, null, view, okListener);
}
/**
@@ -99,6 +85,21 @@ public class DialogUtils {
return createProgressDialog(false, context, messageId, onCancelListener, formatArgs);
}
private static Dialog createConfirmationDialog(Context context, int titleId, String message,
View view, DialogInterface.OnClickListener okListener) {
AlertDialog.Builder builder = new AlertDialog.Builder(context).setCancelable(true)
.setIcon(android.R.drawable.ic_dialog_alert).setNegativeButton(R.string.generic_no, null)
.setPositiveButton(R.string.generic_yes, okListener).setTitle(titleId);
if (message != null) {
builder.setMessage(message);
}
if (view != null) {
builder.setView(view);
}
return builder.create();
}
/**
* Creates a progress dialog.
*
@@ -94,9 +94,10 @@ public class ListItemUtils {
} else {
photo.setVisibility(View.VISIBLE);
Display defaultDisplay = activity.getWindowManager().getDefaultDisplay();
// Set the initial width to 35% of the display width
int width = (int) (defaultDisplay.getWidth() * .35);
PhotoUtils.setImageVew(photo, Uri.parse(photoUrl), width, 0, false);
// Set the initial width to 33% of the display width.
int width = (int) (defaultDisplay.getWidth() * .33);
int height = 0;
PhotoUtils.setImageVew(photo, Uri.parse(photoUrl), width, height);
}
// Set date/time
@@ -109,7 +110,8 @@ public class ListItemUtils {
// Set category/description
TextView descriptionTextView = (TextView) view.findViewById(R.id.list_item_description);
setTextView(descriptionTextView, getDescription(isRecording, category, description));
setTextView(descriptionTextView,
isRecording ? null : StringUtils.getCategoryDescription(category, description));
}
/**
@@ -146,30 +148,6 @@ public class ListItemUtils {
return buffer.toString();
}
/**
* Gets the description text.
*
* @param isRecording true if recording
* @param category the category
* @param description the description
*/
private static String getDescription(boolean isRecording, String category, String description) {
if (isRecording) {
return null;
}
if (category == null || category.length() == 0) {
return description;
}
StringBuffer buffer = new StringBuffer();
buffer.append("[" + category + "]");
if (description != null && description.length() != 0) {
buffer.append(" " + description);
}
return buffer.toString();
}
/**
* Gets the start time text.
*
@@ -44,12 +44,10 @@ public class PhotoUtils {
* @param uri the image uri
* @param displayWidth the display width
* @param displayHeight the display height
* @param fitWithIn true to fit within the display area. False to crop and fill
* the display area.
*/
public static Bitmap setImageVew(
ImageView imageView, Uri uri, int displayWidth, int displayHeight, boolean fitWithIn) {
ImageView imageView, Uri uri, int displayWidth, int displayHeight) {
// Get the image dimensions
BitmapFactory.Options options = new BitmapFactory.Options();
@@ -61,7 +59,6 @@ public class PhotoUtils {
int targetHeight = displayHeight;
if (targetHeight == 0) {
targetHeight = (int) (targetWidth * ((float) options.outHeight / (float) options.outWidth));
imageView.getLayoutParams().height = targetHeight;
}
// Set imageWidth and imageHeight based on image rotation
@@ -79,8 +76,7 @@ public class PhotoUtils {
// Get a scaled down version of the image
options.inJustDecodeBounds = false;
options.inSampleSize = getInSampleSize(
imageWidth, imageHeight, targetWidth, targetHeight, fitWithIn);
options.inSampleSize = getInSampleSize(imageWidth, imageHeight, targetWidth, targetHeight);
options.inPurgeable = true;
Bitmap scaledBitmap = BitmapFactory.decodeFile(uri.getPath(), options);
@@ -133,11 +129,9 @@ public class PhotoUtils {
* @param imageHeight the image height
* @param targetWidth the target width
* @param targetHeight the target height
* @param fitWithin true to fit within the target area. False to crop and fill
* all target area.
*/
private static int getInSampleSize(
int imageWidth, int imageHeight, int targetWidth, int targetHeight, boolean fitWithin) {
int imageWidth, int imageHeight, int targetWidth, int targetHeight) {
float widthRatio = 1;
if (imageWidth > targetWidth) {
widthRatio = (float) imageWidth / (float) targetWidth;
@@ -150,11 +144,9 @@ public class PhotoUtils {
/*
* To fit within the target area, return the larger sample ratio so the
* image will not be larger than the target dimensions. To crop and fill the
* target area, return the smaller sample ratio so the image will be greater
* than the target dimensions. Use Math.floor to not under sample.
* image will not be larger than the target dimensions. Use Math.floor to
* not under sample.
*/
return (int) Math.floor(
fitWithin ? Math.max(widthRatio, heightRatio) : Math.min(widthRatio, heightRatio));
return (int) Math.floor(Math.max(widthRatio, heightRatio));
}
}
@@ -50,12 +50,12 @@ public class PreferencesUtils {
public static final String BLUETOOTH_SENSOR_DEFAULT = "";
public static final boolean CHART_BY_DISTANCE_DEFAULT = true;
public static final boolean CHART_SHOW_CADENCE_DEFAULT = true;
public static final boolean CHART_SHOW_ELEVATION_DEFAULT = true;
public static final boolean CHART_SHOW_HEART_RATE_DEFAULT = true;
public static final boolean CHART_SHOW_POWER_DEFAULT = true;
public static final boolean CHART_SHOW_SPEED_DEFAULT = true;
public static final String CHART_X_AXIS_DEFAULT = "DISTANCE";
public static final boolean CONFIRM_PLAY_EARTH_DEFAULT = true;
@@ -91,7 +91,6 @@ public class PreferencesUtils {
public static final long RECORDING_TRACK_ID_DEFAULT = -1L;
public static final boolean RECORDING_TRACK_PAUSED_DEFAULT = true;
public static final boolean REPORT_SPEED_DEFAULT = true;
public static final long SELECTED_TRACK_ID_DEFAULT = -1L;
public static final String SENSOR_TYPE_DEFAULT = "NONE";
@@ -102,6 +101,7 @@ public class PreferencesUtils {
public static final int SPLIT_FREQUENCY_DEFAULT = 0;
// Stats
public static final String STATS_RATE_DEFAULT = "SPEED";
public static final boolean STATS_SHOW_COORDINATE_DEFAULT = false;
public static final boolean STATS_SHOW_GRADE_ELEVATION_DEFAULT = false;
public static final String STATS_UNITS_DEFAULT = "METRIC";
@@ -257,4 +257,25 @@ public class PreferencesUtils {
return PreferencesUtils.STATS_UNITS_DEFAULT.equals(
getString(context, R.string.stats_units_key, PreferencesUtils.STATS_UNITS_DEFAULT));
}
/**
* Returns true if the preferred rate is speed, false if the preferred rate is
* pace.
*
* @param context the context
*/
public static boolean isReportSpeed(Context context) {
return PreferencesUtils.STATS_RATE_DEFAULT.equals(
getString(context, R.string.stats_rate_key, PreferencesUtils.STATS_RATE_DEFAULT));
}
/**
* Returns true if chart x axis is by distance, false if by time.
*
* @param context the context
*/
public static boolean isChartByDistance(Context context) {
return PreferencesUtils.CHART_X_AXIS_DEFAULT.equals(
getString(context, R.string.chart_x_axis_key, PreferencesUtils.CHART_X_AXIS_DEFAULT));
}
}
@@ -51,8 +51,7 @@ public class StatsUtils {
*/
public static void setLocationValues(Activity activity, Location location, boolean isRecording) {
boolean metricUnits = PreferencesUtils.isMetricUnits(activity);
boolean reportSpeed = PreferencesUtils.getBoolean(
activity, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
boolean reportSpeed = PreferencesUtils.isReportSpeed(activity);
// Set speed/pace
double speed = isRecording && location != null && location.hasSpeed() ? location.getSpeed()
@@ -112,8 +111,7 @@ public class StatsUtils {
*/
public static void setTripStatisticsValues(Activity activity, TripStatistics tripStatistics) {
boolean metricUnits = PreferencesUtils.isMetricUnits(activity);
boolean reportSpeed = PreferencesUtils.getBoolean(
activity, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
boolean reportSpeed = PreferencesUtils.isReportSpeed(activity);
// Set total distance
double totalDistance = tripStatistics == null ? Double.NaN : tripStatistics.getTotalDistance();
@@ -228,6 +228,26 @@ public class StringUtils {
return result;
}
/**
* Gets a string for category and description.
*
* @param category the category
* @param description the description
*/
public static String getCategoryDescription(String category, String description) {
if (category == null || category.length() == 0) {
return description;
}
StringBuffer buffer = new StringBuffer();
buffer.append("[" + category + "]");
if (description != null && description.length() != 0) {
buffer.append(" " + description);
}
return buffer.toString();
}
/**
* Formats the given text as a XML CDATA element. This includes adding the
* starting and ending CDATA tags. Please notice that this may result in
@@ -60,8 +60,7 @@ public class TrackWidgetConfigActivity extends Activity {
item3 = (Spinner) findViewById(R.id.track_widget_config_item3);
item4 = (Spinner) findViewById(R.id.track_widget_config_item4);
boolean reportSpeed = PreferencesUtils.getBoolean(
this, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
boolean reportSpeed = PreferencesUtils.isReportSpeed(this);
List<CharSequence> list = new ArrayList<CharSequence>();
addItem(list, R.string.stats_distance);
@@ -196,8 +196,7 @@ public class TrackWidgetProvider extends AppWidgetProvider {
boolean isPaused = PreferencesUtils.getBoolean(context, R.string.recording_track_paused_key,
PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
boolean reportSpeed = PreferencesUtils.getBoolean(
context, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
boolean reportSpeed = PreferencesUtils.isReportSpeed(context);
int item1 = PreferencesUtils.getInt(
context, R.string.track_widget_item1, PreferencesUtils.TRACK_WIDGET_ITEM1_DEFAULT);
int item2 = PreferencesUtils.getInt(
@@ -237,6 +237,15 @@ public interface MyTracksProviderUtils {
*/
public long getLastTrackPointId(long trackId);
/**
* Gets the track point id of a location.
*
* @param trackId the track id
* @param location the location
* @return track point id if the location is in the track. -1L otherwise.
*/
public long getTrackPointId(long trackId, Location location);
/**
* Gets the first valid location for a track. Returns null if it doesn't
* exist.
@@ -794,6 +794,31 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
}
return -1L;
}
@Override
public long getTrackPointId(long trackId, Location location) {
if (trackId < 0) {
return -1L;
}
Cursor cursor = null;
try {
String selection = TrackPointsColumns._ID + "=(select max(" + TrackPointsColumns._ID
+ ") from " + TrackPointsColumns.TABLE_NAME + " WHERE " + TrackPointsColumns.TRACKID
+ "=? AND " + TrackPointsColumns.TIME + "=?)";
String[] selectionArgs = new String[] {
Long.toString(trackId), Long.toString(location.getTime()) };
cursor = getTrackPointCursor(new String[] { TrackPointsColumns._ID }, selection,
selectionArgs, TrackPointsColumns._ID);
if (cursor != null && cursor.moveToFirst()) {
return cursor.getLong(cursor.getColumnIndexOrThrow(TrackPointsColumns._ID));
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return -1L;
}
@Override
public Location getFirstValidTrackPoint(long trackId) {
@@ -526,7 +526,8 @@ public class TrackDataHubTest extends AndroidTestCase {
public void testPreferencesChange() throws Exception {
// Register two listeners
PreferencesUtils.setBoolean(context, R.string.report_speed_key, true);
PreferencesUtils.setString(
context, R.string.stats_rate_key, PreferencesUtils.STATS_RATE_DEFAULT);
PreferencesUtils.setString(
context, R.string.stats_units_key, PreferencesUtils.STATS_UNITS_DEFAULT);
PreferencesUtils.setInt(context, R.string.recording_gps_accuracy_key,
@@ -563,10 +564,11 @@ public class TrackDataHubTest extends AndroidTestCase {
expect(trackDataListener2.onReportSpeedChanged(false)).andReturn(false);
replay();
PreferencesUtils.setBoolean(context, R.string.report_speed_key, false);
PreferencesUtils.setString(
context, R.string.stats_rate_key, context.getString(R.string.stats_rate_pace));
OnSharedPreferenceChangeListener listener = preferenceChangeListenerCapture.getValue();
listener.onSharedPreferenceChanged(
sharedPreferences, PreferencesUtils.getKey(context, R.string.report_speed_key));
sharedPreferences, PreferencesUtils.getKey(context, R.string.stats_rate_key));
verifyAndReset();
// Change metric units to false
@@ -785,14 +787,16 @@ public class TrackDataHubTest extends AndroidTestCase {
* the key is R.string.metric_units_key.
*/
public void testNotifyPreferenceChanged_reportSpeedNoNotify() {
boolean value = false;
PreferencesUtils.setBoolean(context, R.string.report_speed_key, value);
String value = context.getString(R.string.stats_rate_pace);
PreferencesUtils.setString(context, R.string.stats_rate_key, value);
trackDataHub.notifyPreferenceChanged(PreferencesUtils
.getKey(context, R.string.report_speed_key));
assertEquals(value, trackDataHub.isReportSpeed());
PreferencesUtils.setBoolean(context, R.string.report_speed_key, !value);
.getKey(context, R.string.stats_rate_key));
assertEquals(false, trackDataHub.isReportSpeed());
value = context.getString(R.string.stats_rate_speed);
PreferencesUtils.setString(context, R.string.stats_rate_key, value);
trackDataHub.notifyPreferenceChanged(PreferencesUtils
.getKey(context, R.string.report_speed_key));
assertEquals(!value, trackDataHub.isReportSpeed());
.getKey(context, R.string.stats_rate_key));
assertEquals(true, trackDataHub.isReportSpeed());
}
}
@@ -843,7 +843,7 @@ public class EndToEndTestUtils {
findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup_reset));
Assert.assertTrue(SOLO.waitForText(activityMyTracks.getString(R.string.settings_reset)));
SOLO.clickOnText(activityMyTracks.getString(R.string.settings_reset_summary));
SOLO.clickOnText(activityMyTracks.getString(R.string.settings_reset));
getButtonOnScreen(activityMytracks.getString(R.string.generic_yes), true, true);
Assert.assertTrue(SOLO.waitForText(activityMyTracks.getString(R.string.settings_reset_done)));
instrumentation.waitForIdleSync();
@@ -99,7 +99,7 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
// Reset all settings.
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup_reset));
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_reset_summary));
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_reset));
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_yes), true,
true);
EndToEndTestUtils.SOLO.waitForText(activityMyTracks.getString(R.string.settings_reset_done), 1,
@@ -283,7 +283,7 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
// Write to SD card.
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup_reset));
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup_now));
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup));
assertTrue(EndToEndTestUtils.SOLO.waitForText(
activityMyTracks.getString(R.string.settings_backup_now_success), 0,
EndToEndTestUtils.SUPER_LONG_WAIT_TIME));
@@ -298,7 +298,7 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
// Read from SD card.
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup_reset));
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup_now));
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup));
EndToEndTestUtils.SOLO
.clickOnText(activityMyTracks.getString(R.string.settings_backup_restore));
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_yes), true,
@@ -187,11 +187,10 @@ public class SyncTestUtils {
if (EndToEndTestUtils.SOLO.waitForText(accountName, 1, EndToEndTestUtils.SHORT_WAIT_TIME)) {
EndToEndTestUtils.SOLO.clickOnText(accountName);
EndToEndTestUtils.instrumentation.waitForIdleSync();
if (EndToEndTestUtils.SOLO.waitForText(
EndToEndTestUtils.activityMytracks.getString(R.string.generic_confirm_title), 1,
EndToEndTestUtils.SHORT_WAIT_TIME)) {
EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.activityMytracks
.getString(R.string.generic_yes));
if (EndToEndTestUtils.SOLO.waitForText(EndToEndTestUtils.activityMytracks.getString(
R.string.settings_google_account_confirm_title), 1, EndToEndTestUtils.SHORT_WAIT_TIME)) {
EndToEndTestUtils.SOLO.clickOnText(
EndToEndTestUtils.activityMytracks.getString(R.string.generic_yes));
}
} else {
Assert.fail();