forked from upstream-mirrors/OpenTracks
Improve the startup sequence.
- new welcome dialog message. - new check units text. - for US and UK, default to imperial. - for fragments, fix handling of onCancel. No need to handle onCancel at the dialog level.
This commit is contained in:
@@ -19,7 +19,102 @@ limitations under the License.
|
||||
android:layout_width="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
<ScrollView style="@style/ScrollView.WithBottomButtons" >
|
||||
<include layout="@layout/help_content" />
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp" >
|
||||
<ImageView
|
||||
android:contentDescription="@string/my_tracks_app_name"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:scaleType="fitStart"
|
||||
android:src="@drawable/arrow_icon" />
|
||||
<TextView
|
||||
android:text="@string/help_my_tracks_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_my_tracks_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
<TextView
|
||||
android:text="@string/help_location_precision_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_location_precision_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
<TextView
|
||||
android:text="@string/help_gps_fix_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_gps_fix_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
<TextView
|
||||
android:text="@string/help_data_connection_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_data_connection_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
<TextView
|
||||
android:text="@string/help_elevation_precision_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_elevation_precision_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
<TextView
|
||||
android:text="@string/help_battery_life_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_battery_life_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
<TextView
|
||||
android:text="@string/help_share_friends_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_share_friends_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
<TextView
|
||||
android:text="@string/help_share_visibility_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_share_visibility_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
<TextView
|
||||
android:text="@string/help_split_track_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_split_track_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
<TextView
|
||||
android:text="@string/help_saved_files_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_saved_files_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
<TextView
|
||||
android:text="@string/help_waypoint_marker_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_waypoint_marker_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
<TextView
|
||||
android:text="@string/help_statistics_marker_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_statistics_marker_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
<TextView
|
||||
android:text="@string/help_delete_tracks_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_delete_tracks_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
<TextView
|
||||
android:text="@string/help_edit_tracks_question"
|
||||
style="@style/HelpQuestion" />
|
||||
<TextView
|
||||
android:text="@string/help_edit_tracks_answer"
|
||||
style="@style/HelpAnswer" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
<LinearLayout style="@style/BottomButtonBar" >
|
||||
<include layout="@layout/help_buttons" />
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2012 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp" >
|
||||
<ImageView
|
||||
android:contentDescription="@string/my_tracks_app_name"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:scaleType="fitStart"
|
||||
android:src="@drawable/arrow_icon" />
|
||||
<TextView
|
||||
android:text="@string/help_my_tracks_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_my_tracks_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_location_precision_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_location_precision_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_gps_fix_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_gps_fix_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_data_connection_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_data_connection_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_elevation_precision_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_elevation_precision_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_battery_life_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_battery_life_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_share_friends_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_share_friends_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_share_visibility_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_share_visibility_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_split_track_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_split_track_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_saved_files_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_saved_files_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_waypoint_marker_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_waypoint_marker_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_statistics_marker_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_statistics_marker_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_delete_tracks_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_delete_tracks_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_edit_tracks_question"
|
||||
style="@style/WelcomeQuestionTextView" />
|
||||
<TextView
|
||||
android:text="@string/help_edit_tracks_answer"
|
||||
style="@style/WelcomeAnswerTextView" />
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
@@ -1,20 +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.
|
||||
-->
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/ScrollView" >
|
||||
<include layout="@layout/help_content" />
|
||||
</ScrollView>
|
||||
@@ -15,13 +15,15 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<!-- Keys for application preferences. Sorted alphabetically. - DO NOT TRANSLATE -->
|
||||
|
||||
<!-- Keys for persisted preferences. Sorted alphabetically. - DO NOT TRANSLATE -->
|
||||
<string name="allow_access_key">allowAccess</string>
|
||||
<string name="announcement_frequency_key">announcementFrequency</string>
|
||||
<string name="ant_cadence_sensor_id_key">antCadenceSensorId</string>
|
||||
<string name="ant_cadence_speed_sensor_id_key">antCadenceSpeedSensorId</string>
|
||||
<string name="ant_heart_rate_sensor_id_key">antHeartRateSensorId</string>
|
||||
<string name="ant_srm_bridge_sensor_id_key">antSRMBridgeSensorId</string>
|
||||
<string name="auto_resume_track_current_retry_key">autoResumeTrackCurrentRetry</string>
|
||||
<string name="auto_resume_track_timeout_key">autoResumeTrackTimeout</string>
|
||||
<string name="bluetooth_pairing_key">bluetoothPairing</string>
|
||||
<string name="bluetooth_sensor_key">bluetoothSensor</string>
|
||||
@@ -34,30 +36,25 @@ limitations under the License.
|
||||
<string name="min_required_accuracy_key">minRequiredAccuracy</string>
|
||||
<string name="pick_existing_map_key">pickExistingMap</string>
|
||||
<string name="preferred_account_key">preferredAccount</string>
|
||||
<string name="recording_track_id_key">recordingTrackId</string>
|
||||
<string name="report_speed_key">reportSpeed</string>
|
||||
<string name="selected_track_id_key">selectedTrackId</string>
|
||||
<string name="send_to_docs_key">sendToDocs</string>
|
||||
<string name="send_to_fusion_tables_key">sendToFusionTables</string>
|
||||
<string name="send_to_maps_key">sendToMaps</string>
|
||||
<string name="sensor_type_key">sensorType</string>
|
||||
<string name="share_url_only_key">shareUrlOnly</string>
|
||||
<string name="show_check_units_dialog_key">showCheckUnitsDialog</string>
|
||||
<string name="show_welcome_dialog_key">showWelcomeDialog</string>
|
||||
<string name="split_frequency_key">splitFrequency</string>
|
||||
<string name="track_color_mode_dynamic_speed_variation_key">trackColorModeDynamicVariation
|
||||
</string>
|
||||
<string name="track_color_mode_fixed_speed_medium_display_key">trackColorModeFixedMediumDisplay
|
||||
</string>
|
||||
<string name="track_color_mode_dynamic_speed_variation_key">trackColorModeDynamicVariation</string>
|
||||
<string name="track_color_mode_fixed_speed_medium_display_key">trackColorModeFixedMediumDisplay</string>
|
||||
<string name="track_color_mode_fixed_speed_medium_key">trackColorModeFixedMedium</string>
|
||||
<string name="track_color_mode_fixed_speed_slow_display_key">trackColorModeFixedSlowDisplay
|
||||
</string>
|
||||
<string name="track_color_mode_fixed_speed_slow_display_key">trackColorModeFixedSlowDisplay</string>
|
||||
<string name="track_color_mode_fixed_speed_slow_key">trackColorModeFixedSlow</string>
|
||||
<string name="track_color_mode_key">trackColorMode</string>
|
||||
<string name="track_name_key">trackName</string>
|
||||
|
||||
<!-- Preference keys which keep transient state (not user preferences). Sorted alphabetically.
|
||||
- DO NOT TRANSLATE -->
|
||||
<string name="auto_resume_track_current_retry_key">autoResumeTrackCurrentRetry</string>
|
||||
<string name="recording_track_id_key">recordingTrackId</string>
|
||||
<string name="selected_track_id_key">selectedTrackId</string>
|
||||
|
||||
<!-- Keys for non-persisted preferences. Sorted alphabetically. - DO NOT TRANSLATE -->
|
||||
<string name="ant_options_key">antOptions</string>
|
||||
<string name="backup_to_sd_key">backupToSd</string>
|
||||
@@ -65,4 +62,4 @@ limitations under the License.
|
||||
<string name="restore_from_sd_key">restoreFromSd</string>
|
||||
<string name="sensor_options_key">sensorOptions</string>
|
||||
<string name="track_color_mode_fixed_speed_options_key">trackColorModeFixedOptions</string>
|
||||
</resources>
|
||||
</resources>
|
||||
@@ -1226,17 +1226,17 @@ limitations under the License.
|
||||
<string name="preferred_units_imperial"
|
||||
translation_description="In the dialog asking the user to choose a preferred units, the option
|
||||
to choose the imperial units.">
|
||||
Imperial
|
||||
Imperial (mi, ft)
|
||||
</string>
|
||||
<string name="preferred_units_metric"
|
||||
translation_description="In the dialog asking the user to choose a preferred units, the option
|
||||
to choose the metric units.">
|
||||
Metric
|
||||
Metric (km, m)
|
||||
</string>
|
||||
<string name="preferred_units_title"
|
||||
translation_description="The title of the dialog asking the user to choose a preferred units,
|
||||
metric or imperial.">
|
||||
Preferred units
|
||||
Preferred Units
|
||||
</string>
|
||||
|
||||
<!-- SD Card -->
|
||||
@@ -2924,6 +2924,14 @@ limitations under the License.
|
||||
</string>
|
||||
|
||||
<!-- Welcome -->
|
||||
<string name="welcome_message"
|
||||
translation_description="The message of the welcome dialog.">
|
||||
Use My Tracks while you run, bike, hike, or do anything outdoor to record your path. While
|
||||
recording, you can visualize your track and watch live statistics. You can also add
|
||||
markers, have markers inserted periodically, or hear automatic voice announcements of
|
||||
your progress. For recorded tracks, you can play them on Google Earth, share with friends, or
|
||||
upload to Google Maps, Google Fusion Tables, or Google Docs.
|
||||
</string>
|
||||
<string name="welcome_title"
|
||||
translation_description="The title of the welcome dialog.">
|
||||
Welcome to My Tracks
|
||||
|
||||
@@ -52,6 +52,15 @@ limitations under the License.
|
||||
<item name="android:selectAllOnFocus">true</item>
|
||||
<item name="android:singleLine">true</item>
|
||||
</style>
|
||||
<!-- The style for the help answer -->
|
||||
<style name="HelpAnswer" parent="@style/TextSmall">
|
||||
<item name="android:paddingBottom">8dp</item>
|
||||
</style>
|
||||
<!-- The style for help question -->
|
||||
<style name="HelpQuestion" parent="@style/TextMedium">
|
||||
<item name="android:paddingTop">8dp</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
</style>
|
||||
<!-- The style for the list empty text view -->
|
||||
<style name="ListEmptyTextView" parent="@style/TextLarge">
|
||||
<item name="android:gravity">center</item>
|
||||
@@ -147,13 +156,4 @@ limitations under the License.
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
</style>
|
||||
<!-- The style for the welcome page answer -->
|
||||
<style name="WelcomeAnswerTextView" parent="@style/TextSmall">
|
||||
<item name="android:paddingBottom">8dp</item>
|
||||
</style>
|
||||
<!-- The style for welcome page question -->
|
||||
<style name="WelcomeQuestionTextView" parent="@style/TextMedium">
|
||||
<item name="android:paddingTop">8dp</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -19,11 +19,10 @@ package com.google.android.apps.mytracks;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.apps.mytracks.util.StatsUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import java.util.List;
|
||||
@@ -40,10 +39,8 @@ public class AggregatedStatsActivity extends AbstractMyTracksActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.aggregated_stats);
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
boolean metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true);
|
||||
boolean reportSpeed = preferences.getBoolean(getString(R.string.report_speed_key), true);
|
||||
boolean metricUnits = PreferencesUtils.isMetricUnits(this);
|
||||
boolean reportSpeed = PreferencesUtils.isReportSpeed(this);
|
||||
|
||||
StatsUtils.setStats(this,
|
||||
getTripStatistics(),
|
||||
|
||||
@@ -20,12 +20,11 @@ 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.util.IntentUtils;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.apps.mytracks.util.StatsUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
@@ -83,11 +82,9 @@ public class MarkerDetailActivity extends AbstractMyTracksActivity {
|
||||
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);
|
||||
|
||||
boolean metricUnits = PreferencesUtils.isMetricUnits(this);
|
||||
boolean reportSpeed = PreferencesUtils.isReportSpeed(this);
|
||||
|
||||
StatsUtils.setStats(this,
|
||||
waypoint.getStatistics(),
|
||||
null,
|
||||
|
||||
@@ -105,7 +105,6 @@ public class SearchListActivity extends AbstractMyTracksActivity {
|
||||
private SearchEngine searchEngine;
|
||||
private SearchRecentSuggestions searchRecentSuggestions;
|
||||
private LocationManager locationManager;
|
||||
private SharedPreferences sharedPreferences;
|
||||
private long recordingTrackId;
|
||||
private boolean metricUnits;
|
||||
private ArrayAdapter<Map<String, Object>> arrayAdapter;
|
||||
@@ -124,7 +123,8 @@ public class SearchListActivity extends AbstractMyTracksActivity {
|
||||
searchEngine = new SearchEngine(myTracksProviderUtils);
|
||||
searchRecentSuggestions = SearchEngineProvider.newHelper(this);
|
||||
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
|
||||
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedPreferences = getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
|
||||
recordingTrackId = PreferencesUtils.getRecordingTrackId(this);
|
||||
|
||||
@@ -185,7 +185,7 @@ public class SearchListActivity extends AbstractMyTracksActivity {
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
metricUnits = sharedPreferences.getBoolean(getString(R.string.metric_units_key), true);
|
||||
metricUnits = PreferencesUtils.isMetricUnits(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -131,8 +131,7 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
// Hook up switching of displayed list entries between metric and imperial
|
||||
// units
|
||||
CheckBoxPreference metricUnitsPreference =
|
||||
(CheckBoxPreference) findPreference(
|
||||
getString(R.string.metric_units_key));
|
||||
(CheckBoxPreference) findPreference(PreferencesUtils.getMetricUnitsKey(this));
|
||||
metricUnitsPreference.setOnPreferenceChangeListener(
|
||||
new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
@@ -643,9 +642,7 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
* If the units are not metric convert the value before displaying.
|
||||
*/
|
||||
private void viewTrackColorModeSettings(EditTextPreference preference, int id) {
|
||||
CheckBoxPreference metricUnitsPreference = (CheckBoxPreference) findPreference(
|
||||
getString(R.string.metric_units_key));
|
||||
if(metricUnitsPreference.isChecked()) {
|
||||
if (PreferencesUtils.isMetricUnits(this)) {
|
||||
return;
|
||||
}
|
||||
// Convert miles/h to km/h
|
||||
@@ -665,10 +662,10 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
* If the units are not metric convert the value before saving.
|
||||
*/
|
||||
private void validateTrackColorModeSettings(String newValue, int id) {
|
||||
CheckBoxPreference metricUnitsPreference = (CheckBoxPreference) findPreference(
|
||||
getString(R.string.metric_units_key));
|
||||
String metricspeed;
|
||||
if(!metricUnitsPreference.isChecked()) {
|
||||
if (PreferencesUtils.isMetricUnits(this)) {
|
||||
metricspeed = newValue;
|
||||
} else {
|
||||
// Convert miles/h to km/h
|
||||
try {
|
||||
metricspeed = String.valueOf(
|
||||
@@ -676,8 +673,6 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
} catch (NumberFormatException e) {
|
||||
metricspeed = "0";
|
||||
}
|
||||
} else {
|
||||
metricspeed = newValue;
|
||||
}
|
||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
||||
Editor editor = prefs.edit();
|
||||
|
||||
@@ -17,14 +17,15 @@
|
||||
package com.google.android.apps.mytracks;
|
||||
|
||||
import com.google.android.apps.mytracks.content.TracksColumns;
|
||||
import com.google.android.apps.mytracks.fragments.CheckUnitsDialogFragment;
|
||||
import com.google.android.apps.mytracks.fragments.DeleteAllTrackDialogFragment;
|
||||
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
|
||||
import com.google.android.apps.mytracks.fragments.EulaDialogFragment;
|
||||
import com.google.android.apps.mytracks.fragments.WelcomeDialogFragment;
|
||||
import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileFormat;
|
||||
import com.google.android.apps.mytracks.services.ITrackRecordingService;
|
||||
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
|
||||
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
||||
import com.google.android.apps.mytracks.util.CheckUnitsUtils;
|
||||
import com.google.android.apps.mytracks.util.EulaUtils;
|
||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||
import com.google.android.apps.mytracks.util.ListItemUtil;
|
||||
@@ -118,8 +119,8 @@ public class TrackListActivity extends FragmentActivity {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||
// Note that key can be null
|
||||
if (getString(R.string.metric_units_key).equals(key)) {
|
||||
metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true);
|
||||
if (PreferencesUtils.getMetricUnitsKey(TrackListActivity.this).equals(key)) {
|
||||
metricUnits = PreferencesUtils.isMetricUnits(TrackListActivity.this);
|
||||
}
|
||||
if (PreferencesUtils.getRecordingTrackIdKey(TrackListActivity.this).equals(key)) {
|
||||
recordingTrackId = PreferencesUtils.getRecordingTrackId(TrackListActivity.this);
|
||||
@@ -171,7 +172,7 @@ public class TrackListActivity extends FragmentActivity {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
|
||||
metricUnits = sharedPreferences.getBoolean(getString(R.string.metric_units_key), true);
|
||||
metricUnits = PreferencesUtils.isMetricUnits(this);
|
||||
recordingTrackId = PreferencesUtils.getRecordingTrackId(this);
|
||||
|
||||
ImageButton recordImageButton = (ImageButton) findViewById(R.id.track_list_record_button);
|
||||
@@ -255,29 +256,49 @@ public class TrackListActivity extends FragmentActivity {
|
||||
}
|
||||
});
|
||||
|
||||
showStartupDialogs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows start up dialogs.
|
||||
*/
|
||||
public void showStartupDialogs() {
|
||||
if (!EulaUtils.getEulaValue(this)) {
|
||||
Fragment fragment = getSupportFragmentManager()
|
||||
.findFragmentByTag(EulaDialogFragment.EULA_DIALOG_TAG);
|
||||
if (fragment == null) {
|
||||
EulaDialogFragment.newInstance(false).show(
|
||||
getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
|
||||
EulaDialogFragment.newInstance(false)
|
||||
.show(getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
|
||||
}
|
||||
}
|
||||
if (CheckUnitsUtils.getCheckUnitsValue(this)) {
|
||||
} else if (PreferencesUtils.isShowWelcomeDialog(this)) {
|
||||
Fragment fragment = getSupportFragmentManager()
|
||||
.findFragmentByTag(WelcomeDialogFragment.WELCOME_DIALOG_TAG);
|
||||
if (fragment == null) {
|
||||
new WelcomeDialogFragment().show(
|
||||
getSupportFragmentManager(), WelcomeDialogFragment.WELCOME_DIALOG_TAG);
|
||||
}
|
||||
} else if (PreferencesUtils.isShowCheckUnitsDialog(this)) {
|
||||
Fragment fragment = getSupportFragmentManager()
|
||||
.findFragmentByTag(CheckUnitsDialogFragment.CHECK_UNITS_DIALOG_TAG);
|
||||
if (fragment == null) {
|
||||
new CheckUnitsDialogFragment().show(
|
||||
getSupportFragmentManager(), CheckUnitsDialogFragment.CHECK_UNITS_DIALOG_TAG);
|
||||
}
|
||||
} else {
|
||||
enableEmptyView();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enables the content of the empty view.
|
||||
*/
|
||||
public void enableEmptyView() {
|
||||
private void enableEmptyView() {
|
||||
View emptyMessage = findViewById(R.id.track_list_empty_message);
|
||||
emptyMessage.setVisibility(View.VISIBLE);
|
||||
View recordButton = findViewById(R.id.track_list_record_button);
|
||||
recordButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -60,8 +60,6 @@ public class TrackDataHub {
|
||||
|
||||
// Preference keys
|
||||
private final String MIN_REQUIRED_ACCURACY_KEY;
|
||||
private final String METRIC_UNITS_KEY;
|
||||
private final String SPEED_REPORTING_KEY;
|
||||
|
||||
// Overridable constants
|
||||
private final int targetNumPoints;
|
||||
@@ -171,7 +169,7 @@ public class TrackDataHub {
|
||||
|
||||
// Cached preference values
|
||||
private int minRequiredAccuracy;
|
||||
private boolean useMetricUnits;
|
||||
private boolean metricUnits;
|
||||
private boolean reportSpeed;
|
||||
|
||||
// Cached sensor readings
|
||||
@@ -222,8 +220,6 @@ public class TrackDataHub {
|
||||
this.locationFactory = new DoubleBufferedLocationFactory();
|
||||
|
||||
MIN_REQUIRED_ACCURACY_KEY = context.getString(R.string.min_required_accuracy_key);
|
||||
METRIC_UNITS_KEY = context.getString(R.string.metric_units_key);
|
||||
SPEED_REPORTING_KEY = context.getString(R.string.report_speed_key);
|
||||
|
||||
resetState();
|
||||
}
|
||||
@@ -299,8 +295,8 @@ public class TrackDataHub {
|
||||
|
||||
private void loadSharedPreferences() {
|
||||
selectedTrackId = PreferencesUtils.getSelectedTrackId(context);
|
||||
useMetricUnits = preferences.getBoolean(METRIC_UNITS_KEY, true);
|
||||
reportSpeed = preferences.getBoolean(SPEED_REPORTING_KEY, true);
|
||||
metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||
reportSpeed = PreferencesUtils.isReportSpeed(context);
|
||||
minRequiredAccuracy = preferences.getInt(MIN_REQUIRED_ACCURACY_KEY,
|
||||
DEFAULT_MIN_REQUIRED_ACCURACY);
|
||||
}
|
||||
@@ -495,7 +491,7 @@ public class TrackDataHub {
|
||||
Set<TrackDataListener> listenerSet = Collections.singleton(listener);
|
||||
|
||||
if (registration.isInterestedIn(ListenerDataType.DISPLAY_PREFERENCES)) {
|
||||
reloadAll |= listener.onUnitsChanged(useMetricUnits);
|
||||
reloadAll |= listener.onUnitsChanged(metricUnits);
|
||||
reloadAll |= listener.onReportSpeedChanged(reportSpeed);
|
||||
}
|
||||
|
||||
@@ -577,7 +573,7 @@ public class TrackDataHub {
|
||||
// Ignore the return values here, we're already sending the full data set anyway
|
||||
for (TrackDataListener listener :
|
||||
getListenersFor(ListenerDataType.DISPLAY_PREFERENCES)) {
|
||||
listener.onUnitsChanged(useMetricUnits);
|
||||
listener.onUnitsChanged(metricUnits);
|
||||
listener.onReportSpeedChanged(reportSpeed);
|
||||
}
|
||||
|
||||
@@ -616,11 +612,11 @@ public class TrackDataHub {
|
||||
if (MIN_REQUIRED_ACCURACY_KEY.equals(key)) {
|
||||
minRequiredAccuracy = preferences.getInt(MIN_REQUIRED_ACCURACY_KEY,
|
||||
DEFAULT_MIN_REQUIRED_ACCURACY);
|
||||
} else if (METRIC_UNITS_KEY.equals(key)) {
|
||||
useMetricUnits = preferences.getBoolean(METRIC_UNITS_KEY, true);
|
||||
} else if (PreferencesUtils.getMetricUnitsKey(context).equals(key)) {
|
||||
metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||
notifyUnitsChanged();
|
||||
} else if (SPEED_REPORTING_KEY.equals(key)) {
|
||||
reportSpeed = preferences.getBoolean(SPEED_REPORTING_KEY, true);
|
||||
} else if (PreferencesUtils.getReportSpeedKey(context).equals(key)) {
|
||||
reportSpeed = PreferencesUtils.isReportSpeed(context);
|
||||
notifySpeedReportingChanged();
|
||||
} else if (PreferencesUtils.getSelectedTrackIdKey(context).equals(key)) {
|
||||
loadTrack(PreferencesUtils.getSelectedTrackId(context));
|
||||
@@ -659,7 +655,7 @@ public class TrackDataHub {
|
||||
Set<TrackDataListener> displayListeners = getListenersFor(ListenerDataType.DISPLAY_PREFERENCES);
|
||||
|
||||
for (TrackDataListener listener : displayListeners) {
|
||||
if (listener.onUnitsChanged(useMetricUnits)) {
|
||||
if (listener.onUnitsChanged(metricUnits)) {
|
||||
synchronized (dataListeners) {
|
||||
reloadDataForListener(listener);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ public class AboutDialogFragment extends DialogFragment {
|
||||
TextView aboutVersion = (TextView) view.findViewById(R.id.about_version);
|
||||
aboutVersion.setText(SystemUtils.getMyTracksVersion(getActivity()));
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
-1
@@ -64,7 +64,6 @@ public class ChartSettingsDialogFragment extends DialogFragment {
|
||||
? R.string.stats_speed : R.string.stats_pace);
|
||||
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(R.string.generic_cancel, null)
|
||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
||||
+27
-30
@@ -16,20 +16,18 @@
|
||||
|
||||
package com.google.android.apps.mytracks.fragments;
|
||||
|
||||
import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.apps.mytracks.TrackListActivity;
|
||||
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
||||
import com.google.android.apps.mytracks.util.CheckUnitsUtils;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A DialogFragment to check preferred units.
|
||||
*
|
||||
@@ -38,41 +36,40 @@ import android.support.v4.app.DialogFragment;
|
||||
public class CheckUnitsDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String CHECK_UNITS_DIALOG_TAG = "checkUnitsDialog";
|
||||
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
|
||||
public void onCancel(DialogInterface arg0) {
|
||||
onDone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
Locale defaultLocale = Locale.getDefault();
|
||||
boolean defaultMetric = !defaultLocale.equals(Locale.US) && !defaultLocale.equals(Locale.UK);
|
||||
PreferencesUtils.setMetricUnits(getActivity(), defaultMetric);
|
||||
final String metric = getString(R.string.preferred_units_metric);
|
||||
final String imperial = getString(R.string.preferred_units_imperial);
|
||||
final CharSequence[] items = defaultMetric ? new CharSequence[] { metric, imperial }
|
||||
: new CharSequence[] { imperial, metric };
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setCancelable(true)
|
||||
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
handleButtonClicked();
|
||||
}
|
||||
})
|
||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int position = ((AlertDialog) dialog).getListView().getSelectedItemPosition();
|
||||
SharedPreferences sharedPreferences = getActivity()
|
||||
.getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(sharedPreferences.edit()
|
||||
.putBoolean(getString(R.string.metric_units_key), position == 0));
|
||||
handleButtonClicked();
|
||||
int position = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||
PreferencesUtils.setMetricUnits(getActivity(), items[position].equals(metric));
|
||||
onDone();
|
||||
}
|
||||
})
|
||||
.setSingleChoiceItems(new CharSequence[] { getString(R.string.preferred_units_metric),
|
||||
getString(R.string.preferred_units_imperial) }, 0, null)
|
||||
.setTitle(R.string.preferred_units_title)
|
||||
.create();
|
||||
.setSingleChoiceItems(items, 0, null)
|
||||
.setTitle(R.string.preferred_units_title).create();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles a button click.
|
||||
* Tasks to perform when done.
|
||||
*/
|
||||
private void handleButtonClicked() {
|
||||
CheckUnitsUtils.setCheckUnitsValue(getActivity());
|
||||
private void onDone() {
|
||||
PreferencesUtils.setShowCheckUnitsDialog(getActivity());
|
||||
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
|
||||
trackListActivity.enableEmptyView();
|
||||
trackListActivity.showStartupDialogs();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.google.android.apps.mytracks.fragments;
|
||||
|
||||
import com.google.android.apps.mytracks.TrackListActivity;
|
||||
import com.google.android.apps.mytracks.util.EulaUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
@@ -49,11 +50,17 @@ public class EulaDialogFragment extends DialogFragment {
|
||||
return eulaDialogFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface arg0) {
|
||||
if (!getArguments().getBoolean(KEY_HAS_ACCEPTED)) {
|
||||
exitApp();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
boolean hasAccepted = getArguments().getBoolean(KEY_HAS_ACCEPTED);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
|
||||
.setCancelable(true)
|
||||
.setMessage(EulaUtils.getEulaMessage(getActivity()))
|
||||
.setTitle(R.string.eula_title);
|
||||
|
||||
@@ -63,24 +70,25 @@ public class EulaDialogFragment extends DialogFragment {
|
||||
builder.setNegativeButton(R.string.eula_decline, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
getActivity().finish();
|
||||
}
|
||||
})
|
||||
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
getActivity().finish();
|
||||
exitApp();
|
||||
}
|
||||
})
|
||||
.setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
EulaUtils.setEulaValue(getActivity());
|
||||
new WelcomeDialogFragment().show(
|
||||
getActivity().getSupportFragmentManager(), WelcomeDialogFragment.WELCOME_DIALOG_TAG);
|
||||
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
|
||||
trackListActivity.showStartupDialogs();
|
||||
}
|
||||
});
|
||||
}
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exits the application.
|
||||
*/
|
||||
private void exitApp() {
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
-1
@@ -39,7 +39,6 @@ public class InstallEarthDialogFragment extends DialogFragment {
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setCancelable(true)
|
||||
.setMessage(R.string.track_detail_install_earth_message)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.google.android.apps.mytracks.fragments;
|
||||
|
||||
import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.apps.mytracks.MyTracksApplication;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.TrackDataHub;
|
||||
@@ -28,8 +27,6 @@ import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.apps.mytracks.util.StatsUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
@@ -101,10 +98,8 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
SharedPreferences preferences = getActivity().getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true);
|
||||
reportSpeed = preferences.getBoolean(getString(R.string.report_speed_key), true);
|
||||
metricUnits = PreferencesUtils.isMetricUnits(getActivity());
|
||||
reportSpeed = PreferencesUtils.isReportSpeed(getActivity());
|
||||
updateUi();
|
||||
}
|
||||
|
||||
|
||||
+13
-14
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.google.android.apps.mytracks.fragments;
|
||||
|
||||
import com.google.android.apps.mytracks.TrackListActivity;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
@@ -23,7 +25,6 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* A DialogFrament to show the welcome info.
|
||||
@@ -34,30 +35,28 @@ public class WelcomeDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String WELCOME_DIALOG_TAG = "welcomeDialog";
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface arg0) {
|
||||
onDone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.welcome, null);
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setCancelable(true)
|
||||
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
checkUnits();
|
||||
}
|
||||
})
|
||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
checkUnits();
|
||||
onDone();
|
||||
}
|
||||
})
|
||||
.setTitle(R.string.welcome_title)
|
||||
.setView(view)
|
||||
.setMessage(R.string.welcome_message)
|
||||
.create();
|
||||
}
|
||||
|
||||
private void checkUnits() {
|
||||
new CheckUnitsDialogFragment().show(
|
||||
getActivity().getSupportFragmentManager(), CheckUnitsDialogFragment.CHECK_UNITS_DIALOG_TAG);
|
||||
private void onDone() {
|
||||
PreferencesUtils.setShowWelcome(getActivity());
|
||||
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
|
||||
trackListActivity.showStartupDialogs();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.android.apps.mytracks.io.gdata.docs.DocumentsClient;
|
||||
import com.google.android.apps.mytracks.io.gdata.docs.SpreadsheetsClient;
|
||||
import com.google.android.apps.mytracks.io.gdata.docs.SpreadsheetsClient.WorksheetEntry;
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.apps.mytracks.util.ResourceUtils;
|
||||
import com.google.android.apps.mytracks.util.StringUtils;
|
||||
import com.google.android.apps.mytracks.util.UnitConversions;
|
||||
@@ -33,7 +34,6 @@ import com.google.wireless.gdata.parser.ParseException;
|
||||
import com.google.wireless.gdata2.client.AuthenticationException;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -270,10 +270,7 @@ public class SendDocsUtils {
|
||||
Track track, String spreadsheetId, String worksheetId, String authToken, Context context)
|
||||
throws IOException {
|
||||
String worksheetUri = String.format(GET_WORKSHEET_URI, spreadsheetId, worksheetId);
|
||||
SharedPreferences prefs = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
boolean metricUnits = prefs.getBoolean(context.getString(R.string.metric_units_key), true);
|
||||
|
||||
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||
addRow(worksheetUri, getRowContent(track, metricUnits, context), authToken);
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -14,6 +14,7 @@ import com.google.android.apps.mytracks.stats.DoubleBuffer;
|
||||
import com.google.android.apps.mytracks.stats.TripStatisticsBuilder;
|
||||
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
||||
import com.google.android.apps.mytracks.util.LocationUtils;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.apps.mytracks.util.SystemUtils;
|
||||
import com.google.android.apps.mytracks.util.UnitConversions;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
@@ -32,7 +33,6 @@ import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.location.Location;
|
||||
import android.util.Log;
|
||||
@@ -205,9 +205,7 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
||||
private boolean uploadAllTrackPoints(Track track) {
|
||||
Cursor locationsCursor = null;
|
||||
try {
|
||||
SharedPreferences prefs = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
boolean metricUnits = prefs.getBoolean(context.getString(R.string.metric_units_key), true);
|
||||
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||
|
||||
locationsCursor = myTracksProviderUtils.getLocationsCursor(trackId, 0, -1, false);
|
||||
if (locationsCursor == null) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.google.android.apps.mytracks.io.sendtogoogle.SendToGoogleUtils;
|
||||
import com.google.android.apps.mytracks.stats.DoubleBuffer;
|
||||
import com.google.android.apps.mytracks.stats.TripStatisticsBuilder;
|
||||
import com.google.android.apps.mytracks.util.LocationUtils;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.apps.mytracks.util.UnitConversions;
|
||||
import com.google.android.common.gdata.AndroidXmlParserFactory;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
@@ -257,9 +258,7 @@ public class SendMapsAsyncTask extends AbstractSendAsyncTask {
|
||||
boolean uploadAllTrackPoints(Track track) {
|
||||
Cursor locationsCursor = null;
|
||||
try {
|
||||
SharedPreferences prefs = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
boolean metricUnits = prefs.getBoolean(context.getString(R.string.metric_units_key), true);
|
||||
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||
|
||||
locationsCursor = myTracksProviderUtils.getLocationsCursor(trackId, 0, -1, false);
|
||||
if (locationsCursor == null) {
|
||||
|
||||
@@ -38,7 +38,6 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener {
|
||||
private final String autoResumeTrackCurrentRetryKey;
|
||||
private final String autoResumeTrackTimeoutKey;
|
||||
private final String maxRecordingDistanceKey;
|
||||
private final String metricUnitsKey;
|
||||
private final String minRecordingDistanceKey;
|
||||
private final String minRecordingIntervalKey;
|
||||
private final String minRequiredAccuracyKey;
|
||||
@@ -63,8 +62,6 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener {
|
||||
service.getString(R.string.auto_resume_track_timeout_key);
|
||||
maxRecordingDistanceKey =
|
||||
service.getString(R.string.max_recording_distance_key);
|
||||
metricUnitsKey =
|
||||
service.getString(R.string.metric_units_key);
|
||||
minRecordingDistanceKey =
|
||||
service.getString(R.string.min_recording_distance_key);
|
||||
minRecordingIntervalKey =
|
||||
@@ -160,9 +157,8 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener {
|
||||
service.setSplitFrequency(
|
||||
sharedPreferences.getInt(splitFrequencyKey, 0));
|
||||
}
|
||||
if (key == null || key.equals(metricUnitsKey)) {
|
||||
service.setMetricUnits(
|
||||
sharedPreferences.getBoolean(metricUnitsKey, true));
|
||||
if (key == null || key.equals(PreferencesUtils.getMetricUnitsKey(service))) {
|
||||
service.setMetricUnits(PreferencesUtils.isMetricUnits(service));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-10
@@ -21,13 +21,13 @@ import static com.google.android.apps.mytracks.Constants.TAG;
|
||||
import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.apps.mytracks.services.TrackRecordingService;
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.apps.mytracks.util.StringUtils;
|
||||
import com.google.android.apps.mytracks.util.UnitConversions;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.speech.tts.TextToSpeech;
|
||||
import android.speech.tts.TextToSpeech.OnInitListener;
|
||||
import android.telephony.PhoneStateListener;
|
||||
@@ -150,15 +150,8 @@ public class StatusAnnouncerTask implements PeriodicTask {
|
||||
*/
|
||||
// @VisibleForTesting
|
||||
protected String getAnnouncement(TripStatistics stats) {
|
||||
boolean metricUnits = true;
|
||||
boolean reportSpeed = true;
|
||||
SharedPreferences preferences = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
if (preferences != null) {
|
||||
metricUnits = preferences.getBoolean(context.getString(R.string.metric_units_key), true);
|
||||
reportSpeed = preferences.getBoolean(context.getString(R.string.report_speed_key), true);
|
||||
}
|
||||
|
||||
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||
boolean reportSpeed = PreferencesUtils.isReportSpeed(context);
|
||||
double d = stats.getTotalDistance() * UnitConversions.M_TO_KM;
|
||||
double s = stats.getAverageMovingSpeed() * UnitConversions.MS_TO_KMH;
|
||||
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
|
||||
package com.google.android.apps.mytracks.util;
|
||||
|
||||
import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
@@ -47,18 +45,11 @@ public class ChartURLGenerator {
|
||||
* @param track The track for this chart
|
||||
* @param context The current appplication context
|
||||
*/
|
||||
public static String getChartUrl(Vector<Double> distances,
|
||||
Vector<Double> elevations, Track track, Context context) {
|
||||
SharedPreferences preferences = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
boolean metricUnits = true;
|
||||
if (preferences != null) {
|
||||
metricUnits = preferences.getBoolean(
|
||||
context.getString(R.string.metric_units_key), true);
|
||||
}
|
||||
|
||||
return getChartUrl(distances, elevations, track,
|
||||
context.getString(R.string.stats_elevation), metricUnits);
|
||||
public static String getChartUrl(
|
||||
Vector<Double> distances, Vector<Double> elevations, Track track, Context context) {
|
||||
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||
return getChartUrl(
|
||||
distances, elevations, track, context.getString(R.string.stats_elevation), metricUnits);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package com.google.android.apps.mytracks.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
|
||||
/**
|
||||
* Utilities for checking units.
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class CheckUnitsUtils {
|
||||
|
||||
private static final String CHECK_UNITS_PREFERENCE_FILE = "checkunits";
|
||||
private static final String CHECK_UNITS_PREFERENCE_KEY = "checkunits.checked";
|
||||
|
||||
private CheckUnitsUtils() {}
|
||||
|
||||
public static boolean getCheckUnitsValue(Context context) {
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences(
|
||||
CHECK_UNITS_PREFERENCE_FILE, Context.MODE_PRIVATE);
|
||||
return sharedPreferences.getBoolean(CHECK_UNITS_PREFERENCE_KEY, false);
|
||||
}
|
||||
|
||||
public static void setCheckUnitsValue(Context context) {
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences(
|
||||
CHECK_UNITS_PREFERENCE_FILE, Context.MODE_PRIVATE);
|
||||
Editor editor = sharedPreferences.edit().putBoolean(CHECK_UNITS_PREFERENCE_KEY, true);
|
||||
ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(editor);
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,34 @@ public class PreferencesUtils {
|
||||
|
||||
private PreferencesUtils() {}
|
||||
|
||||
/**
|
||||
* Gets the metric units key.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static String getMetricUnitsKey(Context context) {
|
||||
return getKey(context, R.string.metric_units_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the metric units value.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static boolean isMetricUnits(Context context) {
|
||||
return getBoolean(context, R.string.metric_units_key, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the metric units value.
|
||||
*
|
||||
* @param context the context
|
||||
* @param value the value
|
||||
*/
|
||||
public static void setMetricUnits(Context context, boolean value) {
|
||||
setBoolean(context, R.string.metric_units_key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the recording track id key.
|
||||
*
|
||||
@@ -60,6 +88,34 @@ public class PreferencesUtils {
|
||||
setLong(context, R.string.recording_track_id_key, trackId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the report speed key.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static String getReportSpeedKey(Context context) {
|
||||
return getKey(context, R.string.report_speed_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the report speed value.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static boolean isReportSpeed(Context context) {
|
||||
return getBoolean(context, R.string.report_speed_key, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the report speed value.
|
||||
*
|
||||
* @param context the context
|
||||
* @param value the value
|
||||
*/
|
||||
public static void setReportSpeed(Context context, boolean value) {
|
||||
setBoolean(context, R.string.report_speed_key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the selected track id key.
|
||||
*
|
||||
@@ -88,6 +144,42 @@ public class PreferencesUtils {
|
||||
setLong(context, R.string.selected_track_id_key, trackId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the show check units dialog value.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static boolean isShowCheckUnitsDialog(Context context) {
|
||||
return getBoolean(context, R.string.show_check_units_dialog_key, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the show check units dialog value to false.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static void setShowCheckUnitsDialog(Context context) {
|
||||
setBoolean(context, R.string.show_check_units_dialog_key, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the show welcomes dialog value.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static boolean isShowWelcomeDialog(Context context) {
|
||||
return getBoolean(context, R.string.show_welcome_dialog_key, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the show welcome dialog value to false.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static void setShowWelcome(Context context) {
|
||||
setBoolean(context, R.string.show_welcome_dialog_key, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a preference key
|
||||
*
|
||||
@@ -98,6 +190,34 @@ public class PreferencesUtils {
|
||||
return context.getString(keyId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a boolean preference value.
|
||||
*
|
||||
* @param context the context
|
||||
* @param keyId the key id
|
||||
* @param defaultValue the default value
|
||||
*/
|
||||
private static boolean getBoolean(Context context, int keyId, boolean defaultValue) {
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
return sharedPreferences.getBoolean(getKey(context, keyId), defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a boolean preference value.
|
||||
*
|
||||
* @param context the context
|
||||
* @param keyId the key id
|
||||
* @param value the value
|
||||
*/
|
||||
private static void setBoolean(Context context, int keyId, boolean value) {
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean(getKey(context, keyId), value);
|
||||
ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(editor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a long preference value.
|
||||
*
|
||||
|
||||
@@ -71,7 +71,7 @@ public class TrackWidgetProvider
|
||||
private Context context;
|
||||
private String unknown;
|
||||
private TrackObserver trackObserver;
|
||||
private boolean isMetric;
|
||||
private boolean metricUnits;
|
||||
private boolean reportSpeed;
|
||||
private long selectedTrackId;
|
||||
private SharedPreferences sharedPreferences;
|
||||
@@ -218,10 +218,10 @@ public class TrackWidgetProvider
|
||||
}
|
||||
|
||||
TripStatistics stats = track.getStatistics();
|
||||
String distance = StringUtils.formatDistance(context, stats.getTotalDistance(), isMetric);
|
||||
String distance = StringUtils.formatDistance(context, stats.getTotalDistance(), metricUnits);
|
||||
String time = StringUtils.formatElapsedTime(stats.getMovingTime());
|
||||
String speed = StringUtils.formatSpeed(
|
||||
context, stats.getAverageMovingSpeed(), isMetric, reportSpeed);
|
||||
context, stats.getAverageMovingSpeed(), metricUnits, reportSpeed);
|
||||
|
||||
views.setTextViewText(R.id.appwidget_distance_text, distance);
|
||||
views.setTextViewText(R.id.appwidget_time_text, time);
|
||||
@@ -230,14 +230,12 @@ public class TrackWidgetProvider
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
||||
String metricUnitsKey = context.getString(R.string.metric_units_key);
|
||||
if (key == null || key.equals(metricUnitsKey)) {
|
||||
isMetric = prefs.getBoolean(metricUnitsKey, true);
|
||||
if (key == null || key.equals(PreferencesUtils.getMetricUnitsKey(context))) {
|
||||
metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||
}
|
||||
|
||||
String reportSpeedKey = context.getString(R.string.report_speed_key);
|
||||
if (key == null || key.equals(reportSpeedKey)) {
|
||||
reportSpeed = prefs.getBoolean(reportSpeedKey, true);
|
||||
if (key == null || key.equals(PreferencesUtils.getReportSpeedKey(context))) {
|
||||
reportSpeed = PreferencesUtils.isReportSpeed(context);
|
||||
}
|
||||
|
||||
if (key == null || key.equals(PreferencesUtils.getSelectedTrackIdKey(context))) {
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.google.android.apps.mytracks.content.TrackDataHub.ListenerDataType;
|
||||
import com.google.android.apps.mytracks.content.TrackDataListener.ProviderState;
|
||||
import com.google.android.apps.mytracks.services.TrackRecordingServiceTest.MockContext;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
import com.google.android.testing.mocking.AndroidMock;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -798,12 +797,12 @@ public class TrackDataHubTest extends AndroidTestCase {
|
||||
}
|
||||
|
||||
public void testDisplayPreferencesListen() throws Exception {
|
||||
String metricUnitsKey = context.getString(R.string.metric_units_key);
|
||||
String speedKey = context.getString(R.string.report_speed_key);
|
||||
|
||||
String metricUnitsKey = PreferencesUtils.getMetricUnitsKey(context);
|
||||
String reportSpeedKey = PreferencesUtils.getReportSpeedKey(context);
|
||||
|
||||
prefs.edit()
|
||||
.putBoolean(metricUnitsKey, true)
|
||||
.putBoolean(speedKey, true)
|
||||
.putBoolean(reportSpeedKey, true)
|
||||
.apply();
|
||||
|
||||
Capture<OnSharedPreferenceChangeListener> listenerCapture =
|
||||
@@ -829,10 +828,10 @@ public class TrackDataHubTest extends AndroidTestCase {
|
||||
replay();
|
||||
|
||||
prefs.edit()
|
||||
.putBoolean(speedKey, false)
|
||||
.putBoolean(reportSpeedKey, false)
|
||||
.apply();
|
||||
OnSharedPreferenceChangeListener listener = listenerCapture.getValue();
|
||||
listener.onSharedPreferenceChanged(prefs, speedKey);
|
||||
listener.onSharedPreferenceChanged(prefs, reportSpeedKey);
|
||||
|
||||
AndroidMock.verify(dataSources, providerUtils, listener1, listener2);
|
||||
AndroidMock.reset(dataSources, providerUtils, listener1, listener2);
|
||||
|
||||
Reference in New Issue
Block a user