forked from upstream-mirrors/OpenTracks
remove weight from stats settings
This commit is contained in:
@@ -42,7 +42,6 @@ limitations under the License.
|
||||
<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_weight_key">statsWeight</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>
|
||||
@@ -69,6 +68,7 @@ limitations under the License.
|
||||
<string name="google_account_key">googleAccount</string>
|
||||
<string name="recording_track_id_key">recordingTrackId</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. -->
|
||||
<string name="settings_advanced_key">settingsAdvanced</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_root_key">settingsSensorRoot</string>
|
||||
<string name="settings_stats_key">settingsStats</string>
|
||||
<string name="settings_stats_weight_display_key">settingsStatsWeightDisplay</string>
|
||||
</resources>
|
||||
@@ -2033,12 +2033,6 @@ limitations under the License.
|
||||
Character limit: ~23 (1 line)">
|
||||
Grade/Elevation
|
||||
</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"
|
||||
translation_description="In the 'Stats' settings, the option to change the preferred rate,
|
||||
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 mi (poor GPS)
|
||||
</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"
|
||||
translation_description="In a setting picker, the string format to display an integer value in
|
||||
feet (ft).
|
||||
@@ -2617,12 +2605,6 @@ limitations under the License.
|
||||
translation_description="In a setting picker, the value to turn off the feature.">
|
||||
Off
|
||||
</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"
|
||||
translation_description="In a setting picker, the value to use the smallest value.">
|
||||
Smallest
|
||||
|
||||
@@ -24,12 +24,6 @@ limitations under the License.
|
||||
android:defaultValue="@string/stats_rate_speed"
|
||||
android:key="@string/stats_rate_key"
|
||||
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" >
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
|
||||
@@ -210,9 +210,9 @@ public class TrackEditActivity extends AbstractMyTracksActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChooseActivityTypeDone(String value, boolean newWeight) {
|
||||
if (!this.newWeight) {
|
||||
this.newWeight = newWeight;
|
||||
public void onChooseActivityTypeDone(String value, boolean hasNewWeight) {
|
||||
if (!newWeight) {
|
||||
newWeight = hasNewWeight;
|
||||
}
|
||||
setActivityTypeIcon(value);
|
||||
activityType.setText(getString(TrackIconUtils.getIconActivityType(value)));
|
||||
|
||||
@@ -453,7 +453,7 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
||||
|
||||
if (tripStatisticsUpdater != null) {
|
||||
tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
||||
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||
ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
|
||||
TripStatistics tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
||||
if (chartByDistance) {
|
||||
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.recording_track_id_key));
|
||||
doNotBackup.add(context.getString(R.string.recording_track_paused_key));
|
||||
doNotBackup.add(context.getString(R.string.weight_key));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -244,9 +244,9 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
return;
|
||||
}
|
||||
trackTripStatisticstrackUpdater.addLocation(trackPoint, recordingDistanceInterval, false,
|
||||
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||
ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
|
||||
markerTripStatisticsUpdater.addLocation(trackPoint, recordingDistanceInterval, false,
|
||||
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||
ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
|
||||
}
|
||||
if (waypoint.getLocation().getTime() > trackPoint.getTime()) {
|
||||
trackPoint = null;
|
||||
@@ -551,7 +551,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
location.getTime() != -1L ? location.getTime() : trackData.importTime);
|
||||
}
|
||||
trackData.tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
||||
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||
ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
|
||||
|
||||
trackData.bufferedLocations[trackData.numBufferedLocations] = location;
|
||||
trackData.numBufferedLocations++;
|
||||
|
||||
@@ -279,7 +279,7 @@ public class SendMapsAsyncTask extends AbstractSendAsyncTask {
|
||||
}
|
||||
|
||||
tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
||||
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||
ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
|
||||
if (i % elevationSamplingFrequency == 0) {
|
||||
distances.add(tripStatisticsUpdater.getTripStatistics().getTotalDistance());
|
||||
elevations.add(tripStatisticsUpdater.getSmoothedElevation());
|
||||
|
||||
@@ -668,10 +668,10 @@ public class TrackRecordingService extends Service {
|
||||
do {
|
||||
Location location = myTracksProviderUtils.createTrackPoint(cursor);
|
||||
trackTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
||||
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||
ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
|
||||
if (location.getTime() > markerStartTime) {
|
||||
markerTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
||||
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||
ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
|
||||
}
|
||||
} while (cursor.moveToPrevious());
|
||||
}
|
||||
@@ -1013,9 +1013,9 @@ public class TrackRecordingService extends Service {
|
||||
long trackPointId = Long.parseLong(uri.getLastPathSegment());
|
||||
trackTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, true,
|
||||
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,
|
||||
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||
ActivityType.INVALID, PreferencesUtils.WEIGHT_DEFAULT);
|
||||
updateRecordingTrack(track, trackPointId, LocationUtils.isValidLocation(location));
|
||||
} catch (SQLiteException e) {
|
||||
/*
|
||||
|
||||
@@ -17,19 +17,12 @@
|
||||
package com.google.android.apps.mytracks.settings;
|
||||
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.apps.mytracks.util.StringUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
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.
|
||||
@@ -38,19 +31,12 @@ import android.widget.TextView;
|
||||
*/
|
||||
public class StatsSettingsActivity extends AbstractSettingsActivity {
|
||||
|
||||
private EditTextPreference weightPreference;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
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
|
||||
* configureRateListPreference
|
||||
@@ -58,41 +44,6 @@ public class StatsSettingsActivity extends AbstractSettingsActivity {
|
||||
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.
|
||||
*/
|
||||
@@ -106,7 +57,6 @@ public class StatsSettingsActivity extends AbstractSettingsActivity {
|
||||
public boolean onPreferenceChange(Preference pref, Object newValue) {
|
||||
boolean metricUnits = PreferencesUtils.STATS_UNITS_DEFAULT.equals((String) newValue);
|
||||
configRateListPreference(metricUnits);
|
||||
updateWeightSummary(metricUnits);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -133,13 +83,4 @@ public class StatsSettingsActivity extends AbstractSettingsActivity {
|
||||
metricUnits ? R.array.stats_rate_metric_options : R.array.stats_rate_imperial_options);
|
||||
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,
|
||||
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT);
|
||||
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()) {
|
||||
tripStatisticsUpdater.addLocation(
|
||||
|
||||
@@ -107,7 +107,6 @@ public class PreferencesUtils {
|
||||
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";
|
||||
public static final float STATS_WEIGHT_DEFAULT = 65.0f; // in kilogram
|
||||
|
||||
// Track color
|
||||
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 VOICE_FREQUENCY_DEFAULT = 0;
|
||||
|
||||
public static final float WEIGHT_DEFAULT = 65.0f; // in kilogram
|
||||
|
||||
private static final String TAG = PreferencesUtils.class.getSimpleName();
|
||||
|
||||
private PreferencesUtils() {}
|
||||
@@ -350,9 +351,9 @@ public class PreferencesUtils {
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
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
|
||||
*/
|
||||
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(
|
||||
context, R.string.stats_weight_key, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||
if (!metricUnits) {
|
||||
context, R.string.weight_key, PreferencesUtils.WEIGHT_DEFAULT);
|
||||
if (!PreferencesUtils.isMetricUnits(context)) {
|
||||
value = value * UnitConversions.KG_TO_LB;
|
||||
}
|
||||
return value;
|
||||
|
||||
+3
-3
@@ -226,7 +226,7 @@ public class TripStatisticsUpdaterTest extends TestCase {
|
||||
startTime + (timeOffset + i) * TEN_SECONDS);
|
||||
tripStatisticsUpdater.addLocation(location,
|
||||
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, true, ActivityType.WALKING,
|
||||
PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||
PreferencesUtils.WEIGHT_DEFAULT);
|
||||
tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
||||
|
||||
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);
|
||||
tripStatisticsUpdater.addLocation(location,
|
||||
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, false, ActivityType.WALKING,
|
||||
PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||
PreferencesUtils.WEIGHT_DEFAULT);
|
||||
|
||||
tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
||||
assertEquals((i + timeOffset) * TEN_SECONDS, tripStatistics.getTotalTime());
|
||||
@@ -311,7 +311,7 @@ public class TripStatisticsUpdaterTest extends TestCase {
|
||||
startTime + (timeOffset + i) * TEN_SECONDS);
|
||||
tripStatisticsUpdater.addLocation(location,
|
||||
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, true, ActivityType.WALKING,
|
||||
PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||
PreferencesUtils.WEIGHT_DEFAULT);
|
||||
tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
||||
|
||||
assertTrue(tripStatistics.getMovingTime() <= tripStatistics.getTotalTime());
|
||||
|
||||
Reference in New Issue
Block a user