forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.google.android.apps.mytracks.content;
|
||||
|
||||
import static com.google.android.apps.mytracks.Constants.DEFAULT_MIN_REQUIRED_ACCURACY;
|
||||
import static com.google.android.apps.mytracks.Constants.MAX_DISPLAYED_WAYPOINTS_POINTS;
|
||||
import static com.google.android.apps.mytracks.Constants.MAX_LOCATION_AGE_MS;
|
||||
import static com.google.android.apps.mytracks.Constants.MAX_NETWORK_AGE_MS;
|
||||
@@ -58,9 +57,6 @@ import java.util.Set;
|
||||
*/
|
||||
public class TrackDataHub {
|
||||
|
||||
// Preference keys
|
||||
private final String MIN_REQUIRED_ACCURACY_KEY;
|
||||
|
||||
// Overridable constants
|
||||
private final int targetNumPoints;
|
||||
|
||||
@@ -219,8 +215,6 @@ public class TrackDataHub {
|
||||
this.targetNumPoints = targetNumPoints;
|
||||
this.locationFactory = new DoubleBufferedLocationFactory();
|
||||
|
||||
MIN_REQUIRED_ACCURACY_KEY = context.getString(R.string.min_required_accuracy_key);
|
||||
|
||||
resetState();
|
||||
}
|
||||
|
||||
@@ -294,11 +288,13 @@ public class TrackDataHub {
|
||||
}
|
||||
|
||||
private void loadSharedPreferences() {
|
||||
selectedTrackId = PreferencesUtils.getSelectedTrackId(context);
|
||||
metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||
reportSpeed = PreferencesUtils.isReportSpeed(context);
|
||||
minRequiredAccuracy = preferences.getInt(MIN_REQUIRED_ACCURACY_KEY,
|
||||
DEFAULT_MIN_REQUIRED_ACCURACY);
|
||||
selectedTrackId = PreferencesUtils.getLong(context, R.string.selected_track_id_key);
|
||||
metricUnits = PreferencesUtils.getBoolean(
|
||||
context, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT);
|
||||
reportSpeed = PreferencesUtils.getBoolean(
|
||||
context, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
|
||||
minRequiredAccuracy = PreferencesUtils.getInt(context, R.string.min_required_accuracy_key,
|
||||
PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT);
|
||||
}
|
||||
|
||||
/** Updates known magnetic declination if needed. */
|
||||
@@ -372,8 +368,9 @@ public class TrackDataHub {
|
||||
if (!isStarted()) {
|
||||
loadSharedPreferences();
|
||||
}
|
||||
long recordingTrackId = PreferencesUtils.getRecordingTrackId(context);
|
||||
return recordingTrackId != -1L && recordingTrackId == selectedTrackId;
|
||||
long recordingTrackId = PreferencesUtils.getLong(context, R.string.recording_track_id_key);
|
||||
return recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT
|
||||
&& recordingTrackId == selectedTrackId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,7 +388,7 @@ public class TrackDataHub {
|
||||
|
||||
// Save the selection to memory and flush.
|
||||
selectedTrackId = trackId;
|
||||
PreferencesUtils.setSelectedTrackId(context, selectedTrackId);
|
||||
PreferencesUtils.setLong(context, R.string.selected_track_id_key, selectedTrackId);
|
||||
|
||||
// Force it to reload data from the beginning.
|
||||
Log.d(TAG, "Loading track");
|
||||
@@ -605,21 +602,23 @@ public class TrackDataHub {
|
||||
|
||||
/**
|
||||
* Called when a preference changes.
|
||||
*
|
||||
*
|
||||
* @param key the key to the preference that changed
|
||||
*/
|
||||
private void notifyPreferenceChanged(String key) {
|
||||
if (MIN_REQUIRED_ACCURACY_KEY.equals(key)) {
|
||||
minRequiredAccuracy = preferences.getInt(MIN_REQUIRED_ACCURACY_KEY,
|
||||
DEFAULT_MIN_REQUIRED_ACCURACY);
|
||||
} else if (PreferencesUtils.getMetricUnitsKey(context).equals(key)) {
|
||||
metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||
if (PreferencesUtils.getKey(context, R.string.min_required_accuracy_key).equals(key)) {
|
||||
minRequiredAccuracy = PreferencesUtils.getInt(context, R.string.min_required_accuracy_key,
|
||||
PreferencesUtils.MIN_REQUIRED_ACCURACY_DEFAULT);
|
||||
} else if (PreferencesUtils.getKey(context, R.string.metric_units_key).equals(key)) {
|
||||
metricUnits = PreferencesUtils.getBoolean(
|
||||
context, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT);
|
||||
notifyUnitsChanged();
|
||||
} else if (PreferencesUtils.getReportSpeedKey(context).equals(key)) {
|
||||
reportSpeed = PreferencesUtils.isReportSpeed(context);
|
||||
} else if (PreferencesUtils.getKey(context, R.string.report_speed_key).equals(key)) {
|
||||
reportSpeed = PreferencesUtils.getBoolean(
|
||||
context, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
|
||||
notifySpeedReportingChanged();
|
||||
} else if (PreferencesUtils.getSelectedTrackIdKey(context).equals(key)) {
|
||||
loadTrack(PreferencesUtils.getSelectedTrackId(context));
|
||||
} else if (PreferencesUtils.getKey(context, R.string.selected_track_id_key).equals(key)) {
|
||||
loadTrack(PreferencesUtils.getLong(context, R.string.selected_track_id_key));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user