remove weight from stats settings

This commit is contained in:
Jimmy Shih
2013-11-14 15:55:44 -08:00
parent 982828d0af
commit 857b53c4ca
13 changed files with 24 additions and 116 deletions
+1 -2
View File
@@ -42,7 +42,6 @@ limitations under the License.
<string name="stats_rate_key">statsRate</string> <string name="stats_rate_key">statsRate</string>
<string name="stats_show_coordinate_key">statsShowCoordinate</string> <string name="stats_show_coordinate_key">statsShowCoordinate</string>
<string name="stats_show_grade_elevation_key">statsShowGradeElevation</string> <string name="stats_show_grade_elevation_key">statsShowGradeElevation</string>
<string name="stats_weight_key">statsWeight</string>
<string name="stats_units_key">statsUnits</string> <string name="stats_units_key">statsUnits</string>
<string name="track_color_mode_medium_key">trackColorModeMedium</string> <string name="track_color_mode_medium_key">trackColorModeMedium</string>
<string name="track_color_mode_percentage_key">trackColorModePercentage</string> <string name="track_color_mode_percentage_key">trackColorModePercentage</string>
@@ -69,6 +68,7 @@ limitations under the License.
<string name="google_account_key">googleAccount</string> <string name="google_account_key">googleAccount</string>
<string name="recording_track_id_key">recordingTrackId</string> <string name="recording_track_id_key">recordingTrackId</string>
<string name="recording_track_paused_key">recordingTrackPaused</string> <string name="recording_track_paused_key">recordingTrackPaused</string>
<string name="weight_key">weight</string>
<!-- Keys for non-persisted preferences. Sorted alphabetically. DO NOT TRANSLATE. --> <!-- Keys for non-persisted preferences. Sorted alphabetically. DO NOT TRANSLATE. -->
<string name="settings_advanced_key">settingsAdvanced</string> <string name="settings_advanced_key">settingsAdvanced</string>
<string name="settings_backup_key">settingsBackup</string> <string name="settings_backup_key">settingsBackup</string>
@@ -92,5 +92,4 @@ limitations under the License.
<string name="settings_sensor_bluetooth_pairing_key">settingsSensorBluetoothPairing</string> <string name="settings_sensor_bluetooth_pairing_key">settingsSensorBluetoothPairing</string>
<string name="settings_sensor_root_key">settingsSensorRoot</string> <string name="settings_sensor_root_key">settingsSensorRoot</string>
<string name="settings_stats_key">settingsStats</string> <string name="settings_stats_key">settingsStats</string>
<string name="settings_stats_weight_display_key">settingsStatsWeightDisplay</string>
</resources> </resources>
-18
View File
@@ -2033,12 +2033,6 @@ limitations under the License.
Character limit: ~23 (1 line)"> Character limit: ~23 (1 line)">
Grade/Elevation Grade/Elevation
</string> </string>
<string name="settings_stats_weight"
translation_description="In the 'Stats settings, the option to configure user's weight.
Character limit: ~23 (1 line)">
Weight
</string>
<string name="settings_stats_rate_title" <string name="settings_stats_rate_title"
translation_description="In the 'Stats' settings, the option to change the preferred rate, translation_description="In the 'Stats' settings, the option to change the preferred rate,
either speed (mi/hr) or pace (min/mi). either speed (mi/hr) or pace (min/mi).
@@ -2491,12 +2485,6 @@ limitations under the License.
%1$.1f a float number. E.g., '2.2'."> %1$.1f a float number. E.g., '2.2'.">
%1$.1f mi (poor GPS) %1$.1f mi (poor GPS)
</string> </string>
<string name="value_kilogram"
translation_description="Display a value in kilogram (kg).
%1$s a value. E.g., '150.2'.">
%1$s kg
</string>
<string name="value_integer_feet" <string name="value_integer_feet"
translation_description="In a setting picker, the string format to display an integer value in translation_description="In a setting picker, the string format to display an integer value in
feet (ft). feet (ft).
@@ -2617,12 +2605,6 @@ limitations under the License.
translation_description="In a setting picker, the value to turn off the feature."> translation_description="In a setting picker, the value to turn off the feature.">
Off Off
</string> </string>
<string name="value_pound"
translation_description="Display a value in pound (lb).
%1$s a value. E.g., '155.2'.">
%1$s lb
</string>
<string name="value_smallest" <string name="value_smallest"
translation_description="In a setting picker, the value to use the smallest value."> translation_description="In a setting picker, the value to use the smallest value.">
Smallest Smallest
-6
View File
@@ -24,12 +24,6 @@ limitations under the License.
android:defaultValue="@string/stats_rate_speed" android:defaultValue="@string/stats_rate_speed"
android:key="@string/stats_rate_key" android:key="@string/stats_rate_key"
android:title="@string/settings_stats_rate_title" /> android:title="@string/settings_stats_rate_title" />
<EditTextPreference
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:key="@string/settings_stats_weight_display_key"
android:persistent="false"
android:title="@string/settings_stats_weight" />
<PreferenceCategory android:title="@string/settings_show" > <PreferenceCategory android:title="@string/settings_show" >
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
@@ -210,9 +210,9 @@ public class TrackEditActivity extends AbstractMyTracksActivity
} }
@Override @Override
public void onChooseActivityTypeDone(String value, boolean newWeight) { public void onChooseActivityTypeDone(String value, boolean hasNewWeight) {
if (!this.newWeight) { if (!newWeight) {
this.newWeight = newWeight; newWeight = hasNewWeight;
} }
setActivityTypeIcon(value); setActivityTypeIcon(value);
activityType.setText(getString(TrackIconUtils.getIconActivityType(value))); activityType.setText(getString(TrackIconUtils.getIconActivityType(value)));
@@ -453,7 +453,7 @@ public class ChartFragment extends Fragment implements TrackDataListener {
if (tripStatisticsUpdater != null) { if (tripStatisticsUpdater != null) {
tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false, tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT); ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
TripStatistics tripStatistics = tripStatisticsUpdater.getTripStatistics(); TripStatistics tripStatistics = tripStatisticsUpdater.getTripStatistics();
if (chartByDistance) { if (chartByDistance) {
double distance = tripStatistics.getTotalDistance() * UnitConversions.M_TO_KM; double distance = tripStatistics.getTotalDistance() * UnitConversions.M_TO_KM;
@@ -59,6 +59,7 @@ public class PreferenceBackupHelper {
doNotBackup.add(context.getString(R.string.google_account_key)); doNotBackup.add(context.getString(R.string.google_account_key));
doNotBackup.add(context.getString(R.string.recording_track_id_key)); doNotBackup.add(context.getString(R.string.recording_track_id_key));
doNotBackup.add(context.getString(R.string.recording_track_paused_key)); doNotBackup.add(context.getString(R.string.recording_track_paused_key));
doNotBackup.add(context.getString(R.string.weight_key));
} }
/** /**
@@ -244,9 +244,9 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
return; return;
} }
trackTripStatisticstrackUpdater.addLocation(trackPoint, recordingDistanceInterval, false, trackTripStatisticstrackUpdater.addLocation(trackPoint, recordingDistanceInterval, false,
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT); ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
markerTripStatisticsUpdater.addLocation(trackPoint, recordingDistanceInterval, false, markerTripStatisticsUpdater.addLocation(trackPoint, recordingDistanceInterval, false,
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT); ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
} }
if (waypoint.getLocation().getTime() > trackPoint.getTime()) { if (waypoint.getLocation().getTime() > trackPoint.getTime()) {
trackPoint = null; trackPoint = null;
@@ -551,7 +551,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
location.getTime() != -1L ? location.getTime() : trackData.importTime); location.getTime() != -1L ? location.getTime() : trackData.importTime);
} }
trackData.tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false, trackData.tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT); ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
trackData.bufferedLocations[trackData.numBufferedLocations] = location; trackData.bufferedLocations[trackData.numBufferedLocations] = location;
trackData.numBufferedLocations++; trackData.numBufferedLocations++;
@@ -279,7 +279,7 @@ public class SendMapsAsyncTask extends AbstractSendAsyncTask {
} }
tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false, tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT); ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
if (i % elevationSamplingFrequency == 0) { if (i % elevationSamplingFrequency == 0) {
distances.add(tripStatisticsUpdater.getTripStatistics().getTotalDistance()); distances.add(tripStatisticsUpdater.getTripStatistics().getTotalDistance());
elevations.add(tripStatisticsUpdater.getSmoothedElevation()); elevations.add(tripStatisticsUpdater.getSmoothedElevation());
@@ -668,10 +668,10 @@ public class TrackRecordingService extends Service {
do { do {
Location location = myTracksProviderUtils.createTrackPoint(cursor); Location location = myTracksProviderUtils.createTrackPoint(cursor);
trackTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false, trackTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT); ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
if (location.getTime() > markerStartTime) { if (location.getTime() > markerStartTime) {
markerTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false, markerTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT); ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
} }
} while (cursor.moveToPrevious()); } while (cursor.moveToPrevious());
} }
@@ -1013,9 +1013,9 @@ public class TrackRecordingService extends Service {
long trackPointId = Long.parseLong(uri.getLastPathSegment()); long trackPointId = Long.parseLong(uri.getLastPathSegment());
trackTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, true, trackTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, true,
CalorieUtils.getActivityType(context, track.getCategory()), PreferencesUtils.getFloat(context, CalorieUtils.getActivityType(context, track.getCategory()), PreferencesUtils.getFloat(context,
R.string.stats_weight_key, PreferencesUtils.STATS_WEIGHT_DEFAULT)); R.string.weight_key, PreferencesUtils.WEIGHT_DEFAULT));
markerTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false, markerTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT); ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
updateRecordingTrack(track, trackPointId, LocationUtils.isValidLocation(location)); updateRecordingTrack(track, trackPointId, LocationUtils.isValidLocation(location));
} catch (SQLiteException e) { } catch (SQLiteException e) {
/* /*
@@ -17,19 +17,12 @@
package com.google.android.apps.mytracks.settings; package com.google.android.apps.mytracks.settings;
import com.google.android.apps.mytracks.util.PreferencesUtils; import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.app.Dialog;
import android.os.Bundle; import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;
/** /**
* An activity for accessing stats settings. * An activity for accessing stats settings.
@@ -38,19 +31,12 @@ import android.widget.TextView;
*/ */
public class StatsSettingsActivity extends AbstractSettingsActivity { public class StatsSettingsActivity extends AbstractSettingsActivity {
private EditTextPreference weightPreference;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected void onCreate(Bundle bundle) { protected void onCreate(Bundle bundle) {
super.onCreate(bundle); super.onCreate(bundle);
addPreferencesFromResource(R.xml.stats_settings); addPreferencesFromResource(R.xml.stats_settings);
weightPreference = (EditTextPreference) findPreference(
getString(R.string.settings_stats_weight_display_key));
configWeightPreference();
updateWeightSummary(PreferencesUtils.isMetricUnits(this));
/* /*
* Note configureUnitsListPreference will trigger * Note configureUnitsListPreference will trigger
* configureRateListPreference * configureRateListPreference
@@ -58,41 +44,6 @@ public class StatsSettingsActivity extends AbstractSettingsActivity {
configUnitsListPreference(); configUnitsListPreference();
} }
/**
* Configures the weight preference.
*/
private void configWeightPreference() {
weightPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
PreferencesUtils.storeWeightValue(StatsSettingsActivity.this, (String) newValue);
updateWeightSummary(PreferencesUtils.isMetricUnits(StatsSettingsActivity.this));
return true;
}
});
weightPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference pref) {
double value = PreferencesUtils.getWeightDisplayValue(StatsSettingsActivity.this);
((EditTextPreference) pref).getEditText().setText(StringUtils.formatWeight(value));
return true;
}
});
weightPreference.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
Dialog dialog = weightPreference.getDialog();
weightPreference.onClick(dialog, Dialog.BUTTON_POSITIVE);
dialog.dismiss();
return true;
}
return false;
}
});
}
/** /**
* Configures the preferred units list preference. * Configures the preferred units list preference.
*/ */
@@ -106,7 +57,6 @@ public class StatsSettingsActivity extends AbstractSettingsActivity {
public boolean onPreferenceChange(Preference pref, Object newValue) { public boolean onPreferenceChange(Preference pref, Object newValue) {
boolean metricUnits = PreferencesUtils.STATS_UNITS_DEFAULT.equals((String) newValue); boolean metricUnits = PreferencesUtils.STATS_UNITS_DEFAULT.equals((String) newValue);
configRateListPreference(metricUnits); configRateListPreference(metricUnits);
updateWeightSummary(metricUnits);
return true; return true;
} }
}; };
@@ -133,13 +83,4 @@ public class StatsSettingsActivity extends AbstractSettingsActivity {
metricUnits ? R.array.stats_rate_metric_options : R.array.stats_rate_imperial_options); metricUnits ? R.array.stats_rate_metric_options : R.array.stats_rate_imperial_options);
configureListPreference(listPreference, options, options, values, value, null); configureListPreference(listPreference, options, options, values, value, null);
} }
/**
* Updates the weight summary.
*/
private void updateWeightSummary(boolean metricUnits) {
weightPreference.setSummary(getString(
metricUnits ? R.string.value_kilogram : R.string.value_pound, StringUtils.formatWeight(
PreferencesUtils.getWeightDisplayValue(StatsSettingsActivity.this, metricUnits))));
}
} }
@@ -104,7 +104,7 @@ public class CalorieUtils {
R.string.recording_distance_interval_key, R.string.recording_distance_interval_key,
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT); PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT);
double weight = PreferencesUtils.getFloat( double weight = PreferencesUtils.getFloat(
context, R.string.stats_weight_key, PreferencesUtils.STATS_WEIGHT_DEFAULT); context, R.string.weight_key, PreferencesUtils.WEIGHT_DEFAULT);
while (iterator.hasNext()) { while (iterator.hasNext()) {
tripStatisticsUpdater.addLocation( tripStatisticsUpdater.addLocation(
@@ -107,7 +107,6 @@ public class PreferencesUtils {
public static final boolean STATS_SHOW_COORDINATE_DEFAULT = false; public static final boolean STATS_SHOW_COORDINATE_DEFAULT = false;
public static final boolean STATS_SHOW_GRADE_ELEVATION_DEFAULT = false; public static final boolean STATS_SHOW_GRADE_ELEVATION_DEFAULT = false;
public static final String STATS_UNITS_DEFAULT = "METRIC"; public static final String STATS_UNITS_DEFAULT = "METRIC";
public static final float STATS_WEIGHT_DEFAULT = 65.0f; // in kilogram
// Track color // Track color
public static final String TRACK_COLOR_MODE_DEFAULT = "SINGLE"; public static final String TRACK_COLOR_MODE_DEFAULT = "SINGLE";
@@ -124,6 +123,8 @@ public class PreferencesUtils {
public static final int TRACK_WIDGET_ITEM4_DEFAULT = 2; // average speed public static final int TRACK_WIDGET_ITEM4_DEFAULT = 2; // average speed
public static final int VOICE_FREQUENCY_DEFAULT = 0; public static final int VOICE_FREQUENCY_DEFAULT = 0;
public static final float WEIGHT_DEFAULT = 65.0f; // in kilogram
private static final String TAG = PreferencesUtils.class.getSimpleName(); private static final String TAG = PreferencesUtils.class.getSimpleName();
private PreferencesUtils() {} private PreferencesUtils() {}
@@ -350,9 +351,9 @@ public class PreferencesUtils {
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Log.e(TAG, "invalid value " + displayValue); Log.e(TAG, "invalid value " + displayValue);
value = PreferencesUtils.STATS_WEIGHT_DEFAULT; value = PreferencesUtils.WEIGHT_DEFAULT;
} }
PreferencesUtils.setFloat(context, R.string.stats_weight_key, (float) value); PreferencesUtils.setFloat(context, R.string.weight_key, (float) value);
} }
/** /**
@@ -361,19 +362,9 @@ public class PreferencesUtils {
* @param context the context * @param context the context
*/ */
public static double getWeightDisplayValue(Context context) { public static double getWeightDisplayValue(Context context) {
return getWeightDisplayValue(context, PreferencesUtils.isMetricUnits(context));
}
/**
* Gets the weight display value.
*
* @param context the context
* @param metricUnits true to get display value in metric units
*/
public static double getWeightDisplayValue(Context context, boolean metricUnits) {
double value = PreferencesUtils.getFloat( double value = PreferencesUtils.getFloat(
context, R.string.stats_weight_key, PreferencesUtils.STATS_WEIGHT_DEFAULT); context, R.string.weight_key, PreferencesUtils.WEIGHT_DEFAULT);
if (!metricUnits) { if (!PreferencesUtils.isMetricUnits(context)) {
value = value * UnitConversions.KG_TO_LB; value = value * UnitConversions.KG_TO_LB;
} }
return value; return value;
@@ -226,7 +226,7 @@ public class TripStatisticsUpdaterTest extends TestCase {
startTime + (timeOffset + i) * TEN_SECONDS); startTime + (timeOffset + i) * TEN_SECONDS);
tripStatisticsUpdater.addLocation(location, tripStatisticsUpdater.addLocation(location,
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, true, ActivityType.WALKING, PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, true, ActivityType.WALKING,
PreferencesUtils.STATS_WEIGHT_DEFAULT); PreferencesUtils.WEIGHT_DEFAULT);
tripStatistics = tripStatisticsUpdater.getTripStatistics(); tripStatistics = tripStatisticsUpdater.getTripStatistics();
assertEquals((timeOffset + i) * TEN_SECONDS, tripStatistics.getTotalTime()); assertEquals((timeOffset + i) * TEN_SECONDS, tripStatistics.getTotalTime());
@@ -273,7 +273,7 @@ public class TripStatisticsUpdaterTest extends TestCase {
locationOffset, locationOffset * .001, 0, startTime + (i + timeOffset) * TEN_SECONDS); locationOffset, locationOffset * .001, 0, startTime + (i + timeOffset) * TEN_SECONDS);
tripStatisticsUpdater.addLocation(location, tripStatisticsUpdater.addLocation(location,
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, false, ActivityType.WALKING, PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, false, ActivityType.WALKING,
PreferencesUtils.STATS_WEIGHT_DEFAULT); PreferencesUtils.WEIGHT_DEFAULT);
tripStatistics = tripStatisticsUpdater.getTripStatistics(); tripStatistics = tripStatisticsUpdater.getTripStatistics();
assertEquals((i + timeOffset) * TEN_SECONDS, tripStatistics.getTotalTime()); assertEquals((i + timeOffset) * TEN_SECONDS, tripStatistics.getTotalTime());
@@ -311,7 +311,7 @@ public class TripStatisticsUpdaterTest extends TestCase {
startTime + (timeOffset + i) * TEN_SECONDS); startTime + (timeOffset + i) * TEN_SECONDS);
tripStatisticsUpdater.addLocation(location, tripStatisticsUpdater.addLocation(location,
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, true, ActivityType.WALKING, PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, true, ActivityType.WALKING,
PreferencesUtils.STATS_WEIGHT_DEFAULT); PreferencesUtils.WEIGHT_DEFAULT);
tripStatistics = tripStatisticsUpdater.getTripStatistics(); tripStatistics = tripStatisticsUpdater.getTripStatistics();
assertTrue(tripStatistics.getMovingTime() <= tripStatistics.getTotalTime()); assertTrue(tripStatistics.getMovingTime() <= tripStatistics.getTotalTime());