mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-09-30 16:52:21 +02:00
Settings: removed some default definitions from code into xml.
This commit is contained in:
+5
-5
@@ -135,7 +135,7 @@ public class TrackRecordingServiceTest {
|
||||
createDummyTrack(trackId, System.currentTimeMillis(), true);
|
||||
|
||||
// Clear the number of attempts and set the timeout to 10 min.
|
||||
updateAutoResumePrefs(context, PreferencesUtils.AUTO_RESUME_TRACK_CURRENT_RETRY_DEFAULT, PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT);
|
||||
updateAutoResumePrefs(context, PreferencesUtils.AUTO_RESUME_TRACK_CURRENT_RETRY_DEFAULT, context.getResources().getInteger(R.integer.auto_resume_track_timeout_default));
|
||||
|
||||
// Start the service in "resume" mode (simulates the on-reboot action).
|
||||
Intent startIntent = createStartIntent(context);
|
||||
@@ -154,7 +154,7 @@ public class TrackRecordingServiceTest {
|
||||
@MediumTest
|
||||
@Test
|
||||
public void testResumeAfterReboot_simulateReboot() throws Exception {
|
||||
updateAutoResumePrefs(context, PreferencesUtils.AUTO_RESUME_TRACK_CURRENT_RETRY_DEFAULT, PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT);
|
||||
updateAutoResumePrefs(context, PreferencesUtils.AUTO_RESUME_TRACK_CURRENT_RETRY_DEFAULT, context.getResources().getInteger(R.integer.auto_resume_track_timeout_default));
|
||||
ITrackRecordingService service = ((ITrackRecordingService) mServiceRule.bindService(createStartIntent(context)));
|
||||
Assert.assertFalse(service.isRecording());
|
||||
|
||||
@@ -184,7 +184,7 @@ public class TrackRecordingServiceTest {
|
||||
createDummyTrack(trackId, System.currentTimeMillis(), false);
|
||||
|
||||
// Clear the number of attempts and set the timeout to 10 min.
|
||||
updateAutoResumePrefs(context, PreferencesUtils.AUTO_RESUME_TRACK_CURRENT_RETRY_DEFAULT, PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT);
|
||||
updateAutoResumePrefs(context, PreferencesUtils.AUTO_RESUME_TRACK_CURRENT_RETRY_DEFAULT, context.getResources().getInteger(R.integer.auto_resume_track_timeout_default));
|
||||
|
||||
// Start the service in "resume" mode (simulates the on-reboot action).
|
||||
Intent startIntent = createStartIntent(context);
|
||||
@@ -207,7 +207,7 @@ public class TrackRecordingServiceTest {
|
||||
createDummyTrack(trackId, System.currentTimeMillis() - 1500 * 60 * 1000, true);
|
||||
|
||||
// Clear the number of attempts and set the timeout to 10 min.
|
||||
updateAutoResumePrefs(context, PreferencesUtils.AUTO_RESUME_TRACK_CURRENT_RETRY_DEFAULT, PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT);
|
||||
updateAutoResumePrefs(context, PreferencesUtils.AUTO_RESUME_TRACK_CURRENT_RETRY_DEFAULT, context.getResources().getInteger(R.integer.auto_resume_track_timeout_default));
|
||||
|
||||
// Start the service in "resume" mode (simulates the on-reboot action).
|
||||
Intent startIntent = createStartIntent(context);
|
||||
@@ -230,7 +230,7 @@ public class TrackRecordingServiceTest {
|
||||
createDummyTrack(trackId, System.currentTimeMillis(), true);
|
||||
|
||||
// Set the number of attempts to max.
|
||||
updateAutoResumePrefs(context, TrackRecordingService.MAX_AUTO_RESUME_TRACK_RETRY_ATTEMPTS, PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT);
|
||||
updateAutoResumePrefs(context, TrackRecordingService.MAX_AUTO_RESUME_TRACK_RETRY_ATTEMPTS, context.getResources().getInteger(R.integer.auto_resume_track_timeout_default));
|
||||
|
||||
// Start the service in "resume" mode (simulates the on-reboot action).
|
||||
Intent startIntent = createStartIntent(context);
|
||||
|
||||
+4
-4
@@ -103,7 +103,7 @@ public class TrackRecordingServiceTestLooper {
|
||||
@MediumTest
|
||||
@Test
|
||||
public void testWithProperties_voiceFrequencyDefault() throws TimeoutException {
|
||||
PreferencesUtils.setInt(context, R.string.voice_frequency_key, PreferencesUtils.VOICE_FREQUENCY_DEFAULT);
|
||||
PreferencesUtils.setInt(context, R.string.voice_frequency_key, context.getResources().getInteger(R.integer.voice_frequency_default));
|
||||
fullRecordingSession();
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class TrackRecordingServiceTestLooper {
|
||||
@MediumTest
|
||||
@Test
|
||||
public void testWithProperties_maxRecordingDistanceDefault() throws TimeoutException {
|
||||
PreferencesUtils.setInt(context, R.string.max_recording_distance_key, PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT);
|
||||
PreferencesUtils.setInt(context, R.string.max_recording_distance_key, context.getResources().getInteger(R.integer.max_recording_distance_default));
|
||||
fullRecordingSession();
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public class TrackRecordingServiceTestLooper {
|
||||
@MediumTest
|
||||
@Test
|
||||
public void testWithProperties_splitFrequencyDefault() throws TimeoutException {
|
||||
PreferencesUtils.setInt(context, R.string.split_frequency_key, PreferencesUtils.SPLIT_FREQUENCY_DEFAULT);
|
||||
PreferencesUtils.setInt(context, R.string.split_frequency_key, context.getResources().getInteger(R.integer.split_frequency_default));
|
||||
fullRecordingSession();
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ public class TrackRecordingServiceTestLooper {
|
||||
@MediumTest
|
||||
@Test
|
||||
public void testWithProperties_minRecordingIntervalDefault() throws TimeoutException {
|
||||
PreferencesUtils.setInt(context, R.string.min_recording_interval_key, PreferencesUtils.MIN_RECORDING_INTERVAL_DEFAULT);
|
||||
PreferencesUtils.setInt(context, R.string.min_recording_interval_key, context.getResources().getInteger(R.integer.min_recording_interval_default));
|
||||
fullRecordingSession();
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public class MarkerListActivity extends AbstractActivity implements DeleteMarker
|
||||
recordingTrackId = PreferencesUtils.getRecordingTrackId(MarkerListActivity.this);
|
||||
}
|
||||
if (PreferencesUtils.isKey(MarkerListActivity.this, R.string.recording_track_paused_key, key)) {
|
||||
recordingTrackPaused = PreferencesUtils.getBoolean(MarkerListActivity.this, R.string.recording_track_paused_key, PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
|
||||
recordingTrackPaused = PreferencesUtils.isRecordingTrackPaused(MarkerListActivity.this);
|
||||
}
|
||||
if (key != null) {
|
||||
runOnUiThread(new Runnable() {
|
||||
|
||||
@@ -150,7 +150,7 @@ public class SearchListActivity extends AbstractListActivity implements DeleteMa
|
||||
recordingTrackId = PreferencesUtils.getRecordingTrackId(SearchListActivity.this);
|
||||
}
|
||||
if (PreferencesUtils.isKey(SearchListActivity.this, R.string.recording_track_paused_key, key)) {
|
||||
recordingTrackPaused = PreferencesUtils.getBoolean(SearchListActivity.this, R.string.recording_track_paused_key, PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
|
||||
recordingTrackPaused = PreferencesUtils.isRecordingTrackPaused(SearchListActivity.this);
|
||||
}
|
||||
if (key != null) {
|
||||
runOnUiThread(new Runnable() {
|
||||
|
||||
@@ -131,7 +131,7 @@ public class TrackDetailActivity extends AbstractListActivity implements ChooseA
|
||||
}
|
||||
|
||||
if (PreferencesUtils.isKey(TrackDetailActivity.this, R.string.recording_track_paused_key, key)) {
|
||||
recordingTrackPaused = PreferencesUtils.getBoolean(TrackDetailActivity.this, R.string.recording_track_paused_key, PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
|
||||
recordingTrackPaused = PreferencesUtils.isRecordingTrackPaused(TrackDetailActivity.this);
|
||||
}
|
||||
|
||||
if (PreferencesUtils.isKey(TrackDetailActivity.this, R.string.stats_show_on_lockscreen_while_recording_key, key)) {
|
||||
|
||||
@@ -145,9 +145,7 @@ public class TrackListActivity extends AbstractListActivity implements ConfirmDe
|
||||
}
|
||||
}
|
||||
if (PreferencesUtils.isKey(TrackListActivity.this, R.string.recording_track_paused_key, key)) {
|
||||
recordingTrackPaused = PreferencesUtils.getBoolean(TrackListActivity.this,
|
||||
R.string.recording_track_paused_key,
|
||||
PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
|
||||
recordingTrackPaused = PreferencesUtils.isRecordingTrackPaused(TrackListActivity.this);
|
||||
}
|
||||
if (key != null) {
|
||||
runOnUiThread(new Runnable() {
|
||||
|
||||
@@ -258,7 +258,7 @@ public class TrackDataHub implements DataSourceListener {
|
||||
recordingTrackId = PreferencesUtils.getRecordingTrackId(context);
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.recording_track_paused_key, key)) {
|
||||
recordingTrackPaused = PreferencesUtils.getBoolean(context, R.string.recording_track_paused_key, PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
|
||||
recordingTrackPaused = PreferencesUtils.isRecordingTrackPaused(context);
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.stats_units_key, key)) {
|
||||
metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||
@@ -281,7 +281,7 @@ public class TrackDataHub implements DataSourceListener {
|
||||
}
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.recording_gps_accuracy_key, key)) {
|
||||
recordingGpsAccuracy = PreferencesUtils.getInt(context, R.string.recording_gps_accuracy_key, PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT);
|
||||
recordingGpsAccuracy = PreferencesUtils.getRecordingGPSAccuracy(context);
|
||||
if (key != null) {
|
||||
for (TrackDataListener trackDataListener : trackDataManager.getListeners(TrackDataType.PREFERENCE)) {
|
||||
if (trackDataListener.onRecordingGpsAccuracy(recordingGpsAccuracy)) {
|
||||
@@ -291,7 +291,7 @@ public class TrackDataHub implements DataSourceListener {
|
||||
}
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.recording_distance_interval_key, key)) {
|
||||
recordingDistanceInterval = PreferencesUtils.getInt(context, R.string.recording_distance_interval_key, PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT);
|
||||
recordingDistanceInterval = PreferencesUtils.getRecordingDistanceInterval(context);
|
||||
if (key != null) {
|
||||
for (TrackDataListener trackDataListener : trackDataManager.getListeners(TrackDataType.PREFERENCE)) {
|
||||
if (trackDataListener.onRecordingDistanceIntervalChanged(recordingDistanceInterval)) {
|
||||
|
||||
@@ -263,8 +263,7 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
||||
}
|
||||
reportSpeed = speed;
|
||||
chartView.setReportSpeed(reportSpeed);
|
||||
boolean chartShowSpeed = PreferencesUtils.getBoolean(
|
||||
getActivity(), R.string.chart_show_speed_key, PreferencesUtils.CHART_SHOW_SPEED_DEFAULT);
|
||||
boolean chartShowSpeed = PreferencesUtils.shouldChartShowSpeed(getActivity());
|
||||
setSeriesEnabled(ChartView.SPEED_SERIES, chartShowSpeed && reportSpeed);
|
||||
setSeriesEnabled(ChartView.PACE_SERIES, chartShowSpeed && !reportSpeed);
|
||||
runOnUiThread(new Runnable() {
|
||||
@@ -309,24 +308,24 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
||||
reloadTrackDataHub();
|
||||
needUpdate = true;
|
||||
}
|
||||
if (setSeriesEnabled(ChartView.ELEVATION_SERIES, PreferencesUtils.getBoolean(getActivity(), R.string.chart_show_elevation_key, PreferencesUtils.CHART_SHOW_ELEVATION_DEFAULT))) {
|
||||
if (setSeriesEnabled(ChartView.ELEVATION_SERIES, PreferencesUtils.shouldChartShowElevation(getActivity()))) {
|
||||
needUpdate = true;
|
||||
}
|
||||
|
||||
boolean chartShowSpeed = PreferencesUtils.getBoolean(getActivity(), R.string.chart_show_speed_key, PreferencesUtils.CHART_SHOW_SPEED_DEFAULT);
|
||||
boolean chartShowSpeed = PreferencesUtils.shouldChartShowSpeed(getActivity());
|
||||
if (setSeriesEnabled(ChartView.SPEED_SERIES, chartShowSpeed && reportSpeed)) {
|
||||
needUpdate = true;
|
||||
}
|
||||
if (setSeriesEnabled(ChartView.PACE_SERIES, chartShowSpeed && !reportSpeed)) {
|
||||
needUpdate = true;
|
||||
}
|
||||
if (setSeriesEnabled(ChartView.POWER_SERIES, PreferencesUtils.getBoolean(getActivity(), R.string.chart_show_power_key, PreferencesUtils.CHART_SHOW_POWER_DEFAULT))) {
|
||||
if (setSeriesEnabled(ChartView.POWER_SERIES, PreferencesUtils.shouldChartShowPower(getActivity()))) {
|
||||
needUpdate = true;
|
||||
}
|
||||
if (setSeriesEnabled(ChartView.CADENCE_SERIES, PreferencesUtils.getBoolean(getActivity(), R.string.chart_show_cadence_key, PreferencesUtils.CHART_SHOW_CADENCE_DEFAULT))) {
|
||||
if (setSeriesEnabled(ChartView.CADENCE_SERIES, PreferencesUtils.shouldChartShowCadence(getActivity()))) {
|
||||
needUpdate = true;
|
||||
}
|
||||
if (setSeriesEnabled(ChartView.HEART_RATE_SERIES, PreferencesUtils.getBoolean(getActivity(), R.string.chart_show_heart_rate_key, PreferencesUtils.CHART_SHOW_HEART_RATE_DEFAULT))) {
|
||||
if (setSeriesEnabled(ChartView.HEART_RATE_SERIES, PreferencesUtils.shouldChartShowHeartRate(getActivity()))) {
|
||||
needUpdate = true;
|
||||
}
|
||||
if (needUpdate) {
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.content.Track;
|
||||
import de.dennisguse.opentracks.content.TracksColumns;
|
||||
@@ -100,7 +99,7 @@ public class ExportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
try {
|
||||
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
|
||||
boolean isRecording = PreferencesUtils.isRecording(exportActivity);
|
||||
boolean isPaused = PreferencesUtils.getBoolean(exportActivity, R.string.recording_track_paused_key, PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
|
||||
boolean isPaused = PreferencesUtils.isRecordingTrackPaused(exportActivity);
|
||||
// Get the wake lock if not recording or paused
|
||||
if (!isRecording || isPaused) {
|
||||
wakeLock = SystemUtils.acquireWakeLock(exportActivity, wakeLock);
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
this.context = context;
|
||||
this.importTrackId = importTrackId;
|
||||
this.contentProviderUtils = contentProviderUtils;
|
||||
this.recordingDistanceInterval = PreferencesUtils.getInt(context, R.string.recording_distance_interval_key, PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT);
|
||||
this.recordingDistanceInterval = PreferencesUtils.getRecordingDistanceInterval(context);
|
||||
trackIds = new ArrayList<>();
|
||||
waypoints = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.content.Track;
|
||||
import de.dennisguse.opentracks.io.file.TrackFileFormat;
|
||||
@@ -104,7 +103,7 @@ public class ImportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
|
||||
// Get the wake lock if not recording or paused
|
||||
boolean isRecording = PreferencesUtils.isRecording(importActivity);
|
||||
boolean isPaused = PreferencesUtils.getBoolean(importActivity, R.string.recording_track_paused_key, PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
|
||||
boolean isPaused = PreferencesUtils.isRecordingTrackPaused(importActivity);
|
||||
if (!isRecording || isPaused) {
|
||||
wakeLock = SystemUtils.acquireWakeLock(importActivity, wakeLock);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class TrackRecordingService extends Service {
|
||||
}
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.recording_track_paused_key, key)) {
|
||||
recordingTrackPaused = PreferencesUtils.getBoolean(context, R.string.recording_track_paused_key, PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
|
||||
recordingTrackPaused = PreferencesUtils.isRecordingTrackPaused(context);
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.stats_units_key, key)) {
|
||||
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||
@@ -132,13 +132,13 @@ public class TrackRecordingService extends Service {
|
||||
splitExecutor.setMetricUnits(metricUnits);
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.voice_frequency_key, key)) {
|
||||
voiceExecutor.setTaskFrequency(PreferencesUtils.getInt(context, R.string.voice_frequency_key, PreferencesUtils.VOICE_FREQUENCY_DEFAULT));
|
||||
voiceExecutor.setTaskFrequency(PreferencesUtils.getVoiceFrequency(context));
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.split_frequency_key, key)) {
|
||||
splitExecutor.setTaskFrequency(PreferencesUtils.getInt(context, R.string.split_frequency_key, PreferencesUtils.SPLIT_FREQUENCY_DEFAULT));
|
||||
splitExecutor.setTaskFrequency(PreferencesUtils.getSplitFrequency(context));
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.min_recording_interval_key, key)) {
|
||||
int minRecordingInterval = PreferencesUtils.getInt(context, R.string.min_recording_interval_key, PreferencesUtils.MIN_RECORDING_INTERVAL_DEFAULT);
|
||||
int minRecordingInterval = PreferencesUtils.getMinRecordingInterval(context);
|
||||
switch (minRecordingInterval) {
|
||||
case PreferencesUtils.MIN_RECORDING_INTERVAL_ADAPT_BATTERY_LIFE:
|
||||
// Choose battery life over moving time accuracy.
|
||||
@@ -153,16 +153,16 @@ public class TrackRecordingService extends Service {
|
||||
}
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.recording_distance_interval_key, key)) {
|
||||
recordingDistanceInterval = PreferencesUtils.getInt(context, R.string.recording_distance_interval_key, PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT);
|
||||
recordingDistanceInterval = PreferencesUtils.getRecordingDistanceInterval(context);
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.max_recording_distance_key, key)) {
|
||||
maxRecordingDistance = PreferencesUtils.getInt(context, R.string.max_recording_distance_key, PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT);
|
||||
maxRecordingDistance = PreferencesUtils.getMaxRecordingDistance(context);
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.recording_gps_accuracy_key, key)) {
|
||||
recordingGpsAccuracy = PreferencesUtils.getInt(context, R.string.recording_gps_accuracy_key, PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT);
|
||||
recordingGpsAccuracy = PreferencesUtils.getRecordingGPSAccuracy(context);
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.auto_resume_track_timeout_key, key)) {
|
||||
autoResumeTrackTimeout = PreferencesUtils.getInt(context, R.string.auto_resume_track_timeout_key, PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT);
|
||||
autoResumeTrackTimeout = PreferencesUtils.getAutoResumeTrackTimeout(context);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -471,12 +471,12 @@ public class TrackRecordingService extends Service {
|
||||
}
|
||||
PreferencesUtils.incrementAutoResumeTrackCurrentRetryDefault(this);
|
||||
|
||||
if (autoResumeTrackTimeout == PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_NEVER) {
|
||||
if (autoResumeTrackTimeout == context.getResources().getInteger(R.integer.auto_resume_track_timeout_never)) {
|
||||
Log.d(TAG, "Not resuming. Auto-resume track timeout set to never.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (autoResumeTrackTimeout == PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_ALWAYS) {
|
||||
if (autoResumeTrackTimeout == context.getResources().getInteger(R.integer.auto_resume_track_timeout_always)) {
|
||||
Log.d(TAG, "Resuming. Auto-resume track timeout set to always.");
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
-2
@@ -203,9 +203,9 @@ public class TrackRecordingServiceConnection implements ServiceConnection, Death
|
||||
if (PreferencesUtils.isRecording(context)) {
|
||||
PreferencesUtils.setLong(context, R.string.recording_track_id_key, PreferencesUtils.RECORDING_TRACK_ID_DEFAULT);
|
||||
}
|
||||
boolean recordingTrackPaused = PreferencesUtils.getBoolean(context, R.string.recording_track_paused_key, PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
|
||||
boolean recordingTrackPaused = PreferencesUtils.isRecordingTrackPaused(context);
|
||||
if (!recordingTrackPaused) {
|
||||
PreferencesUtils.setBoolean(context, R.string.recording_track_paused_key, PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
|
||||
PreferencesUtils.defaultRecordingTrackPaused(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -168,15 +168,12 @@ final class PreferenceHelper {
|
||||
static void setAutoResumeTrackTimeoutOptions(Context context, String[] options, String[] values) {
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
int value = Integer.parseInt(values[i]);
|
||||
switch (value) {
|
||||
case PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_NEVER:
|
||||
options[i] = context.getString(R.string.value_never);
|
||||
break;
|
||||
case PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_ALWAYS:
|
||||
options[i] = context.getString(R.string.value_always);
|
||||
break;
|
||||
default:
|
||||
options[i] = context.getString(R.string.value_integer_minute, value);
|
||||
if (value == context.getResources().getInteger(R.integer.auto_resume_track_timeout_never)) {
|
||||
options[i] = context.getString(R.string.value_never);
|
||||
} else if (value == context.getResources().getInteger(R.integer.auto_resume_track_timeout_always)) {
|
||||
options[i] = context.getString(R.string.value_always);
|
||||
} else {
|
||||
options[i] = context.getString(R.string.value_integer_minute, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,43 +36,36 @@ public class PreferencesUtils {
|
||||
* Preferences values.
|
||||
* The defaults need to match the defaults in the xml files.
|
||||
*/
|
||||
// Values for auto_resume_track_timeout_key
|
||||
public static final int AUTO_RESUME_TRACK_TIMEOUT_ALWAYS = -1;
|
||||
public static final int AUTO_RESUME_TRACK_TIMEOUT_DEFAULT = 10;
|
||||
public static final int AUTO_RESUME_TRACK_TIMEOUT_NEVER = 0;
|
||||
@Deprecated
|
||||
public static final boolean RECORDING_TRACK_PAUSED_DEFAULT = true;
|
||||
|
||||
public static final String BLUETOOTH_SENSOR_DEFAULT = "";
|
||||
|
||||
public static final boolean CHART_SHOW_CADENCE_DEFAULT = true;
|
||||
public static final boolean CHART_SHOW_ELEVATION_DEFAULT = true;
|
||||
public static final boolean CHART_SHOW_HEART_RATE_DEFAULT = true;
|
||||
public static final boolean CHART_SHOW_POWER_DEFAULT = true;
|
||||
public static final boolean CHART_SHOW_SPEED_DEFAULT = true;
|
||||
|
||||
// Value for split_frequency_key and voice_frequency_key
|
||||
@Deprecated
|
||||
public static final int FREQUENCY_OFF = 0;
|
||||
|
||||
@Deprecated
|
||||
public static final int MAX_RECORDING_DISTANCE_DEFAULT = 200;
|
||||
|
||||
// Values for min_recording_interval_key
|
||||
@Deprecated
|
||||
public static final int MIN_RECORDING_INTERVAL_ADAPT_ACCURACY = -1;
|
||||
@Deprecated
|
||||
public static final int MIN_RECORDING_INTERVAL_ADAPT_BATTERY_LIFE = -2;
|
||||
@Deprecated
|
||||
public static final int MIN_RECORDING_INTERVAL_DEFAULT = 0;
|
||||
|
||||
@Deprecated
|
||||
public static final int RECORDING_DISTANCE_INTERVAL_DEFAULT = 10;
|
||||
|
||||
// Values for recording_gps_accuracy
|
||||
@Deprecated
|
||||
public static final int RECORDING_GPS_ACCURACY_DEFAULT = 50;
|
||||
@Deprecated
|
||||
public static final int RECORDING_GPS_ACCURACY_EXCELLENT = 10;
|
||||
@Deprecated
|
||||
public static final int RECORDING_GPS_ACCURACY_POOR = 2000;
|
||||
static final boolean STATS_SHOW_COORDINATE_DEFAULT = false;
|
||||
public static final boolean RECORDING_TRACK_PAUSED_DEFAULT = true;
|
||||
|
||||
public static final int SPLIT_FREQUENCY_DEFAULT = 0;
|
||||
static final boolean STATS_SHOW_ELEVATION_DEFAULT = false;
|
||||
|
||||
// Track widget
|
||||
public static final int VOICE_FREQUENCY_DEFAULT = 0;
|
||||
|
||||
private PreferencesUtils() {
|
||||
}
|
||||
@@ -209,7 +202,7 @@ public class PreferencesUtils {
|
||||
* @param context the context
|
||||
* @param keyId the key id
|
||||
*/
|
||||
public static long getLong(Context context, int keyId, long defaultValue) {
|
||||
private static long getLong(Context context, int keyId, long defaultValue) {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences(context);
|
||||
return sharedPreferences.getLong(getKey(context, keyId), defaultValue);
|
||||
}
|
||||
@@ -260,8 +253,8 @@ public class PreferencesUtils {
|
||||
* @param context the context
|
||||
*/
|
||||
public static boolean isMetricUnits(Context context) {
|
||||
String statsUnitDefault = context.getString(R.string.stats_units_default);
|
||||
return statsUnitDefault.equals(getString(context, R.string.stats_units_key, statsUnitDefault));
|
||||
final String STATS_UNIT = context.getString(R.string.stats_units_default);
|
||||
return STATS_UNIT.equals(getString(context, R.string.stats_units_key, STATS_UNIT));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,21 +268,96 @@ public class PreferencesUtils {
|
||||
return STATS_RATE_DEFAULT.equals(getString(context, R.string.stats_rate_key, STATS_RATE_DEFAULT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if chart x axis is by distance, false if by time.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static int getAutoResumeTrackTimeout(Context context) {
|
||||
final int AUTO_RESUME_TRACK_TIMEOUT = context.getResources().getInteger(R.integer.auto_resume_track_timeout_default);
|
||||
return PreferencesUtils.getInt(context, R.string.auto_resume_track_timeout_key, AUTO_RESUME_TRACK_TIMEOUT);
|
||||
}
|
||||
|
||||
public static boolean isRecordingTrackPaused(Context context) {
|
||||
final boolean RECORDING_TRACK_PAUSED = context.getResources().getBoolean(R.bool.recording_track_paused_default);
|
||||
return PreferencesUtils.getBoolean(context, R.string.recording_track_paused_key, RECORDING_TRACK_PAUSED);
|
||||
}
|
||||
|
||||
public static void defaultRecordingTrackPaused(Context context) {
|
||||
final boolean RECORDING_TRACK_PAUSED = context.getResources().getBoolean(R.bool.recording_track_paused_default);
|
||||
PreferencesUtils.setBoolean(context, R.string.recording_track_paused_key, RECORDING_TRACK_PAUSED);
|
||||
}
|
||||
|
||||
public static boolean isChartByDistance(Context context) {
|
||||
final String CHART_X_AXIS_DEFAULT = context.getString(R.string.chart_x_axis_default);
|
||||
return CHART_X_AXIS_DEFAULT.equals(getString(context, R.string.chart_x_axis_key, CHART_X_AXIS_DEFAULT));
|
||||
}
|
||||
|
||||
public static boolean shouldChartShowCadence(Context context) {
|
||||
final boolean CHART_SHOW_CADENCE = context.getResources().getBoolean(R.bool.chart_show_cadence_default);
|
||||
return PreferencesUtils.getBoolean(context, R.string.chart_show_cadence_key, CHART_SHOW_CADENCE);
|
||||
}
|
||||
|
||||
public static boolean shouldChartShowElevation(Context context) {
|
||||
final boolean CHART_SHOW_ELEVATION = context.getResources().getBoolean(R.bool.chart_show_elevation_default);
|
||||
return PreferencesUtils.getBoolean(context, R.string.chart_show_elevation_key, CHART_SHOW_ELEVATION);
|
||||
}
|
||||
|
||||
public static boolean shouldChartShowHeartRate(Context context) {
|
||||
final boolean CHART_SHOW_HEARTRATE = context.getResources().getBoolean(R.bool.chart_show_heart_rate_default);
|
||||
return PreferencesUtils.getBoolean(context, R.string.chart_show_heart_rate_key, CHART_SHOW_HEARTRATE);
|
||||
}
|
||||
|
||||
public static boolean shouldChartShowPower(Context context) {
|
||||
final boolean CHART_SHOW_POWER = context.getResources().getBoolean(R.bool.chart_show_power_default);
|
||||
return PreferencesUtils.getBoolean(context, R.string.chart_show_power_key, CHART_SHOW_POWER);
|
||||
}
|
||||
|
||||
public static boolean shouldChartShowSpeed(Context context) {
|
||||
final boolean CHART_SHOW_SPEED = context.getResources().getBoolean(R.bool.chart_show_speed_default);
|
||||
return PreferencesUtils.getBoolean(context, R.string.chart_show_speed_key, CHART_SHOW_SPEED);
|
||||
}
|
||||
|
||||
public static boolean shouldShowStatsOnLockscreen(Context context) {
|
||||
final boolean STATS_SHOW_ON_LOCKSCREEN_DEFAULT = context.getResources().getBoolean(R.bool.stats_show_on_lockscreen_while_recording_default);
|
||||
return getBoolean(context, R.string.stats_show_on_lockscreen_while_recording_key, STATS_SHOW_ON_LOCKSCREEN_DEFAULT);
|
||||
}
|
||||
|
||||
public static boolean isShowStatsGradeElevation(Context context) {
|
||||
final boolean STATS_SHOW_GRADE_ELEVATION = context.getResources().getBoolean(R.bool.stats_show_grade_elevation_default);
|
||||
return PreferencesUtils.getBoolean(context, R.string.stats_show_grade_elevation_key, STATS_SHOW_GRADE_ELEVATION);
|
||||
}
|
||||
|
||||
public static boolean isStatsShowCoordinate(Context context) {
|
||||
final boolean STATS_SHOW_COORDINATE = context.getResources().getBoolean(R.bool.stats_show_coordinate_default);
|
||||
return PreferencesUtils.getBoolean(context, R.string.stats_show_coordinate_key, STATS_SHOW_COORDINATE);
|
||||
}
|
||||
|
||||
public static int getVoiceFrequency(Context context) {
|
||||
final int VOICE_FREQUENCY_DEFAULT = context.getResources().getInteger(R.integer.voice_frequency_default);
|
||||
return PreferencesUtils.getInt(context, R.string.voice_frequency_key, VOICE_FREQUENCY_DEFAULT);
|
||||
}
|
||||
|
||||
public static int getSplitFrequency(Context context) {
|
||||
final int SPLIT_FREQUENCY_DEFAULT = context.getResources().getInteger(R.integer.split_frequency_default);
|
||||
return PreferencesUtils.getInt(context, R.string.split_frequency_key, SPLIT_FREQUENCY_DEFAULT);
|
||||
}
|
||||
|
||||
public static int getRecordingDistanceInterval(Context context) {
|
||||
final int RECORDING_DISTANCE_INTERVAL = context.getResources().getInteger(R.integer.recording_distance_interval_default);
|
||||
return PreferencesUtils.getInt(context, R.string.recording_distance_interval_key, RECORDING_DISTANCE_INTERVAL);
|
||||
}
|
||||
|
||||
public static int getMaxRecordingDistance(Context context) {
|
||||
final int MAX_RECORDING_DISTANCE = context.getResources().getInteger(R.integer.max_recording_distance_default);
|
||||
return PreferencesUtils.getInt(context, R.string.max_recording_distance_key, MAX_RECORDING_DISTANCE);
|
||||
}
|
||||
|
||||
public static int getMinRecordingInterval(Context context) {
|
||||
final int MIN_RECORDING_INTERVAL = context.getResources().getInteger(R.integer.min_recording_interval_default);
|
||||
return PreferencesUtils.getInt(context, R.string.min_recording_interval_key, MIN_RECORDING_INTERVAL);
|
||||
}
|
||||
|
||||
public static int getRecordingGPSAccuracy(Context context) {
|
||||
final int RECORDING_GPS_ACCURACY = context.getResources().getInteger(R.integer.recording_gps_accuracy_default);
|
||||
return PreferencesUtils.getInt(context, R.string.recording_gps_accuracy_key, RECORDING_GPS_ACCURACY);
|
||||
}
|
||||
|
||||
public static boolean isRecording(Context context) {
|
||||
long recordingTrackId = PreferencesUtils.getRecordingTrackId(context);
|
||||
return recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
|
||||
|
||||
@@ -70,7 +70,7 @@ public class StatsUtils {
|
||||
}
|
||||
|
||||
// Set elevation
|
||||
boolean showGradeElevation = PreferencesUtils.getBoolean(activity, R.string.stats_show_grade_elevation_key, PreferencesUtils.STATS_SHOW_ELEVATION_DEFAULT) && isRecording;
|
||||
boolean showGradeElevation = isRecording && PreferencesUtils.isShowStatsGradeElevation(activity);
|
||||
View elevationContainer = activity.findViewById(R.id.stats_elevation);
|
||||
elevationContainer.setVisibility(showGradeElevation ? View.VISIBLE : View.GONE);
|
||||
|
||||
@@ -85,7 +85,7 @@ public class StatsUtils {
|
||||
}
|
||||
|
||||
// Set coordinate
|
||||
boolean showCoordinate = isRecording && PreferencesUtils.getBoolean(activity, R.string.stats_show_coordinate_key, PreferencesUtils.STATS_SHOW_COORDINATE_DEFAULT);
|
||||
boolean showCoordinate = isRecording && PreferencesUtils.isStatsShowCoordinate(activity);
|
||||
|
||||
View coordinateSeparator = activity.findViewById(R.id.stats_coordinate_separator);
|
||||
coordinateSeparator.setVisibility(showCoordinate ? View.VISIBLE : View.GONE);
|
||||
@@ -241,7 +241,7 @@ public class StatsUtils {
|
||||
|
||||
// Set elevation
|
||||
{
|
||||
boolean showElevation = PreferencesUtils.getBoolean(activity, R.string.stats_show_grade_elevation_key, PreferencesUtils.STATS_SHOW_ELEVATION_DEFAULT);
|
||||
boolean showElevation = PreferencesUtils.isShowStatsGradeElevation(activity);
|
||||
View gradeElevationSeparator = activity.findViewById(R.id.stats_elevation_separator);
|
||||
gradeElevationSeparator.setVisibility(showElevation ? View.VISIBLE : View.GONE);
|
||||
|
||||
|
||||
@@ -18,5 +18,7 @@ limitations under the License.
|
||||
<!--But they should not get backed up or restored.-->
|
||||
<string name="auto_resume_track_current_retry_key" translatable="false">autoResumeTrackCurrentRetry</string>
|
||||
<string name="recording_track_id_key" translatable="false">recordingTrackId</string>
|
||||
|
||||
<string name="recording_track_paused_key" translatable="false">recordingTrackPaused</string>
|
||||
<bool name="recording_track_paused_default" translatable="false">false</bool>
|
||||
</resources>
|
||||
@@ -2,15 +2,25 @@
|
||||
<resources>
|
||||
<!-- Do not translate anything in this file directly. -->
|
||||
<string name="chart_show_cadence_key" translatable="false">chartShowCadence</string>
|
||||
<bool name="chart_show_cadence_default" translatable="false">true</bool>
|
||||
|
||||
<string name="chart_show_elevation_key" translatable="false">chartShowElevation</string>
|
||||
<bool name="chart_show_elevation_default" translatable="false">true</bool>
|
||||
|
||||
<string name="chart_show_heart_rate_key" translatable="false">chartShowHeartRate</string>
|
||||
<bool name="chart_show_heart_rate_default" translatable="false">true</bool>
|
||||
|
||||
<string name="chart_show_power_key" translatable="false">chartShowPower</string>
|
||||
<bool name="chart_show_power_default" translatable="false">true</bool>
|
||||
|
||||
<string name="chart_show_speed_key" translatable="false">chartShowSpeed</string>
|
||||
<bool name="chart_show_speed_default" translatable="false">true</bool>
|
||||
|
||||
<string name="stats_show_coordinate_key" translatable="false">statsShowCoordinate</string>
|
||||
<bool name="stats_show_coordinate_default" translatable="false">false</bool>
|
||||
|
||||
<string name="stats_show_grade_elevation_key" translatable="false">statsShowGradeElevation</string>
|
||||
<bool name="stats_show_grade_elevation_default" translatable="false">false</bool>
|
||||
|
||||
<string name="stats_show_on_lockscreen_while_recording_key" translatable="false">trackdetail_show_on_lockscreen_while_recording</string>
|
||||
<bool name="stats_show_on_lockscreen_while_recording_default" translatable="false">false</bool>
|
||||
@@ -92,12 +102,15 @@
|
||||
</string-array>
|
||||
|
||||
<string name="auto_resume_track_timeout_key" translatable="false">autoResumeTrackTimeout</string>
|
||||
<integer name="auto_resume_track_timeout_default" translatable="false">10</integer>
|
||||
<integer name="auto_resume_track_timeout_always" translatable="false">-1</integer>
|
||||
<integer name="auto_resume_track_timeout_never" translatable="false">0</integer>
|
||||
<string-array name="auto_resume_track_timeout_values">
|
||||
<item>0</item>
|
||||
<item>@integer/auto_resume_track_timeout_never</item>
|
||||
<item>5</item>
|
||||
<item>10</item>
|
||||
<item>@integer/auto_resume_track_timeout_default</item>
|
||||
<item>15</item>
|
||||
<item>-1</item>
|
||||
<item>@integer/auto_resume_track_timeout_always</item>
|
||||
</string-array>
|
||||
|
||||
<string name="chart_x_axis_key" translatable="false">chartXAxis</string>
|
||||
@@ -114,9 +127,14 @@
|
||||
</string-array>
|
||||
|
||||
<string name="split_frequency_key" translatable="false">splitFrequency</string>
|
||||
<integer name="split_frequency_default" translatable="false">@integer/frequency_default
|
||||
</integer>
|
||||
<string name="voice_frequency_key" translatable="false">voiceFrequency</string>
|
||||
<integer name="voice_frequency_default" translatable="false">@integer/frequency_default
|
||||
</integer>
|
||||
<integer name="frequency_default" translatable="false">0</integer>
|
||||
<string-array name="frequency_values">
|
||||
<item>0</item>
|
||||
<item>@integer/frequency_default</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>5</item>
|
||||
@@ -133,31 +151,36 @@
|
||||
</string-array>
|
||||
|
||||
<string name="recording_distance_interval_key" translatable="false">recordingDistanceInterval</string>
|
||||
<integer name="recording_distance_interval_default" translatable="false">10</integer>
|
||||
<string-array name="recording_distance_interval_values">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>5</item>
|
||||
<item>10</item>
|
||||
<item>@integer/recording_distance_interval_default</item>
|
||||
<item>20</item>
|
||||
<item>50</item>
|
||||
<item>100</item>
|
||||
</string-array>
|
||||
|
||||
<string name="max_recording_distance_key" translatable="false">maxRecordingDistance</string>
|
||||
<integer name="max_recording_distance_default" translatable="false">200</integer>
|
||||
<string-array name="max_recording_distance_values">
|
||||
<item>50</item>
|
||||
<item>100</item>
|
||||
<item>200</item>
|
||||
<item>@integer/max_recording_distance_default</item>
|
||||
<item>500</item>
|
||||
<item>1000</item>
|
||||
<item>5000</item>
|
||||
</string-array>
|
||||
|
||||
<string name="min_recording_interval_key" translatable="false">minRecordingInterval</string>
|
||||
<integer name="min_recording_interval_default" translatable="false">0</integer>
|
||||
<integer name="min_recording_interval_adapt_accuracy" translatable="false">-1</integer>
|
||||
<integer name="min_recording_interval_adapt_battery_life" translatable="false">-2</integer>
|
||||
<string-array name="min_recording_interval_values">
|
||||
<item>-2</item>
|
||||
<item>-1</item>
|
||||
<item>0</item>
|
||||
<item>@integer/min_recording_interval_adapt_battery_life</item>
|
||||
<item>@integer/min_recording_interval_adapt_accuracy</item>
|
||||
<item>@integer/min_recording_interval_default</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
@@ -174,16 +197,19 @@
|
||||
</string-array>
|
||||
|
||||
<string name="recording_gps_accuracy_key" translatable="false">recordingGpsAccuracy</string>
|
||||
<integer name="recording_gps_accuracy_default" translatable="false">50</integer>
|
||||
<integer name="recording_gps_accuracy_excellent" translatable="false">10</integer>
|
||||
<integer name="recording_gps_accuracy_poor" translatable="false">2000</integer>
|
||||
<string-array name="recording_gps_accuracy_values">
|
||||
<item>10</item>
|
||||
<item>@integer/recording_gps_accuracy_excellent</item>
|
||||
<item>20</item>
|
||||
<item>30</item>
|
||||
<item>50</item>
|
||||
<item>@integer/recording_gps_accuracy_default</item>
|
||||
<item>100</item>
|
||||
<item>200</item>
|
||||
<item>500</item>
|
||||
<item>1000</item>
|
||||
<item>2000</item>
|
||||
<item>@integer/recording_gps_accuracy_poor</item>
|
||||
</string-array>
|
||||
|
||||
<string name="stats_rate_key" translatable="false">statsRate</string>
|
||||
|
||||
@@ -35,7 +35,7 @@ limitations under the License.
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_show">
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:defaultValue="@bool/stats_show_grade_elevation_default"
|
||||
android:key="@string/stats_show_grade_elevation_key"
|
||||
android:title="@string/settings_stats_grade_elevation" />
|
||||
<CheckBoxPreference
|
||||
@@ -73,13 +73,13 @@ limitations under the License.
|
||||
android:summary="@string/settings_recording_show_on_lockscreen_while_recording_summary"
|
||||
android:title="@string/settings_recording_show_on_lockscreen_while_recording_title" />
|
||||
<ListPreference
|
||||
android:defaultValue="0"
|
||||
android:defaultValue="@integer/voice_frequency_default"
|
||||
android:entryValues="@array/frequency_values"
|
||||
android:key="@string/voice_frequency_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/menu_voice_frequency" />
|
||||
<ListPreference
|
||||
android:defaultValue="0"
|
||||
android:defaultValue="@integer/split_frequency_default"
|
||||
android:entryValues="@array/frequency_values"
|
||||
android:key="@string/split_frequency_key"
|
||||
android:summary="%s"
|
||||
@@ -98,13 +98,13 @@ limitations under the License.
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_recording_min_recording_interval_title" />
|
||||
<ListPreference
|
||||
android:defaultValue="10"
|
||||
android:defaultValue="@integer/recording_distance_interval_default"
|
||||
android:entryValues="@array/recording_distance_interval_values"
|
||||
android:key="@string/recording_distance_interval_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_recording_min_recording_distance_title" />
|
||||
<ListPreference
|
||||
android:defaultValue="200"
|
||||
android:defaultValue="@integer/max_recording_distance_default"
|
||||
android:entryValues="@array/max_recording_distance_values"
|
||||
android:key="@string/max_recording_distance_key"
|
||||
android:summary="%s"
|
||||
|
||||
Reference in New Issue
Block a user