forked from upstream-mirrors/OpenTracks
merge heads
This commit is contained in:
@@ -31,6 +31,7 @@ import android.content.DialogInterface;
|
|||||||
import android.content.DialogInterface.OnClickListener;
|
import android.content.DialogInterface.OnClickListener;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
@@ -682,7 +683,9 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
metricspeed = newValue;
|
metricspeed = newValue;
|
||||||
}
|
}
|
||||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
||||||
prefs.edit().putString(getString(id), metricspeed).commit();
|
Editor editor = prefs.edit();
|
||||||
|
editor.putString(getString(id), metricspeed);
|
||||||
|
ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package com.google.android.apps.mytracks.io.backup;
|
package com.google.android.apps.mytracks.io.backup;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.content.ContentTypeIds;
|
import com.google.android.apps.mytracks.content.ContentTypeIds;
|
||||||
|
import com.google.android.apps.mytracks.util.ApiFeatures;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.Editor;
|
import android.content.SharedPreferences.Editor;
|
||||||
@@ -77,15 +78,14 @@ class PreferenceBackupHelper {
|
|||||||
*
|
*
|
||||||
* @param data the byte array to read preferences from
|
* @param data the byte array to read preferences from
|
||||||
* @param preferences the shared preferences to edit
|
* @param preferences the shared preferences to edit
|
||||||
* @return whether the preference change was successful
|
|
||||||
* @throws IOException if there are any errors while reading
|
* @throws IOException if there are any errors while reading
|
||||||
*/
|
*/
|
||||||
public boolean importPreferences(byte[] data, SharedPreferences preferences)
|
public void importPreferences(byte[] data, SharedPreferences preferences)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
ByteArrayInputStream bufStream = new ByteArrayInputStream(data);
|
ByteArrayInputStream bufStream = new ByteArrayInputStream(data);
|
||||||
DataInputStream reader = new DataInputStream(bufStream);
|
DataInputStream reader = new DataInputStream(bufStream);
|
||||||
|
|
||||||
return importPreferences(reader, preferences);
|
importPreferences(reader, preferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,10 +93,9 @@ class PreferenceBackupHelper {
|
|||||||
*
|
*
|
||||||
* @param reader the stream to read from
|
* @param reader the stream to read from
|
||||||
* @param preferences the shared preferences to edit
|
* @param preferences the shared preferences to edit
|
||||||
* @return whether the preference change was successful
|
|
||||||
* @throws IOException if there are any errors while reading
|
* @throws IOException if there are any errors while reading
|
||||||
*/
|
*/
|
||||||
public boolean importPreferences(DataInputStream reader,
|
public void importPreferences(DataInputStream reader,
|
||||||
SharedPreferences preferences) throws IOException {
|
SharedPreferences preferences) throws IOException {
|
||||||
Editor editor = preferences.edit();
|
Editor editor = preferences.edit();
|
||||||
editor.clear();
|
editor.clear();
|
||||||
@@ -107,8 +106,7 @@ class PreferenceBackupHelper {
|
|||||||
byte typeId = reader.readByte();
|
byte typeId = reader.readByte();
|
||||||
readAndSetPreference(name, typeId, reader, editor);
|
readAndSetPreference(name, typeId, reader, editor);
|
||||||
}
|
}
|
||||||
|
ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(editor);
|
||||||
return editor.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,9 +16,11 @@
|
|||||||
package com.google.android.apps.mytracks.services;
|
package com.google.android.apps.mytracks.services;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
|
import com.google.android.apps.mytracks.util.ApiFeatures;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -169,24 +171,21 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAutoResumeTrackCurrentRetry(int retryAttempts) {
|
public void setAutoResumeTrackCurrentRetry(int retryAttempts) {
|
||||||
sharedPreferences
|
Editor editor = sharedPreferences.edit();
|
||||||
.edit()
|
editor.putInt(autoResumeTrackCurrentRetryKey, retryAttempts);
|
||||||
.putInt(autoResumeTrackCurrentRetryKey, retryAttempts)
|
ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(editor);
|
||||||
.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRecordingTrack(long id) {
|
public void setRecordingTrack(long id) {
|
||||||
sharedPreferences
|
Editor editor = sharedPreferences.edit();
|
||||||
.edit()
|
editor.putLong(recordingTrackKey, id);
|
||||||
.putLong(recordingTrackKey, id)
|
ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(editor);
|
||||||
.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedTrack(long id) {
|
public void setSelectedTrack(long id) {
|
||||||
sharedPreferences
|
Editor editor = sharedPreferences.edit();
|
||||||
.edit()
|
editor.putLong(selectedTrackKey, id);
|
||||||
.putLong(selectedTrackKey, id)
|
ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(editor);
|
||||||
.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
|||||||
+5
-5
@@ -17,13 +17,13 @@ package com.google.android.apps.mytracks.services.sensors.ant;
|
|||||||
|
|
||||||
import static com.google.android.apps.mytracks.Constants.TAG;
|
import static com.google.android.apps.mytracks.Constants.TAG;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
|
||||||
import com.google.android.apps.mytracks.content.Sensor;
|
|
||||||
import com.google.android.maps.mytracks.R;
|
|
||||||
|
|
||||||
import com.dsi.ant.AntDefine;
|
import com.dsi.ant.AntDefine;
|
||||||
import com.dsi.ant.AntMesg;
|
import com.dsi.ant.AntMesg;
|
||||||
import com.dsi.ant.exception.AntInterfaceException;
|
import com.dsi.ant.exception.AntInterfaceException;
|
||||||
|
import com.google.android.apps.mytracks.Constants;
|
||||||
|
import com.google.android.apps.mytracks.content.Sensor;
|
||||||
|
import com.google.android.apps.mytracks.util.ApiFeatures;
|
||||||
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@@ -135,7 +135,7 @@ public class AntDirectSensorManager extends AntSensorManager {
|
|||||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
editor.putInt(context.getString(R.string.ant_heart_rate_sensor_id_key), deviceNumberHRM);
|
editor.putInt(context.getString(R.string.ant_heart_rate_sensor_id_key), deviceNumberHRM);
|
||||||
editor.commit();
|
ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleMessageResponse(byte[] rawMessage) {
|
private void handleMessageResponse(byte[] rawMessage) {
|
||||||
|
|||||||
+2
-1
@@ -22,6 +22,7 @@ import com.dsi.ant.AntMesg;
|
|||||||
import com.dsi.ant.exception.AntInterfaceException;
|
import com.dsi.ant.exception.AntInterfaceException;
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
import com.google.android.apps.mytracks.content.Sensor;
|
import com.google.android.apps.mytracks.content.Sensor;
|
||||||
|
import com.google.android.apps.mytracks.util.ApiFeatures;
|
||||||
import com.google.android.apps.mytracks.util.SystemUtils;
|
import com.google.android.apps.mytracks.util.SystemUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
@@ -198,7 +199,7 @@ public class AntSrmBridgeSensorManager extends AntSensorManager {
|
|||||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
editor.putInt(context.getString(R.string.ant_srm_bridge_sensor_id_key), deviceNumber);
|
editor.putInt(context.getString(R.string.ant_srm_bridge_sensor_id_key), deviceNumber);
|
||||||
editor.commit();
|
ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleMessageResponse(byte[] rawMessage) {
|
private void handleMessageResponse(byte[] rawMessage) {
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ public class MyTracksTest extends ActivityInstrumentationTestCase2<MyTracks>{
|
|||||||
editor.putLong(getActivity().getString(R.string.recording_track_key), -1);
|
editor.putLong(getActivity().getString(R.string.recording_track_key), -1);
|
||||||
|
|
||||||
editor.clear();
|
editor.clear();
|
||||||
editor.commit();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ public class TrackDataHubTest extends AndroidTestCase {
|
|||||||
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
||||||
Track track = new Track();
|
Track track = new Track();
|
||||||
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
||||||
.putLong("selectedTrack", TRACK_ID).commit();
|
.putLong("selectedTrack", TRACK_ID).apply();
|
||||||
expect(providerUtils.getTrack(TRACK_ID)).andStubReturn(track);
|
expect(providerUtils.getTrack(TRACK_ID)).andStubReturn(track);
|
||||||
expectStart();
|
expectStart();
|
||||||
dataSources.registerContentObserver(
|
dataSources.registerContentObserver(
|
||||||
@@ -297,7 +297,7 @@ public class TrackDataHubTest extends AndroidTestCase {
|
|||||||
public void testWaypointListen() {
|
public void testWaypointListen() {
|
||||||
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
||||||
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
||||||
.putLong("selectedTrack", TRACK_ID).commit();
|
.putLong("selectedTrack", TRACK_ID).apply();
|
||||||
|
|
||||||
Waypoint wpt1 = new Waypoint(),
|
Waypoint wpt1 = new Waypoint(),
|
||||||
wpt2 = new Waypoint(),
|
wpt2 = new Waypoint(),
|
||||||
@@ -411,7 +411,7 @@ public class TrackDataHubTest extends AndroidTestCase {
|
|||||||
public void testPointsListen() {
|
public void testPointsListen() {
|
||||||
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
||||||
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
||||||
.putLong("selectedTrack", TRACK_ID).commit();
|
.putLong("selectedTrack", TRACK_ID).apply();
|
||||||
|
|
||||||
expectStart();
|
expectStart();
|
||||||
dataSources.registerContentObserver(
|
dataSources.registerContentObserver(
|
||||||
@@ -498,7 +498,7 @@ public class TrackDataHubTest extends AndroidTestCase {
|
|||||||
public void testPointsListen_reRegister() {
|
public void testPointsListen_reRegister() {
|
||||||
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
||||||
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
||||||
.putLong("selectedTrack", TRACK_ID).commit();
|
.putLong("selectedTrack", TRACK_ID).apply();
|
||||||
|
|
||||||
expectStart();
|
expectStart();
|
||||||
dataSources.registerContentObserver(
|
dataSources.registerContentObserver(
|
||||||
@@ -570,7 +570,7 @@ public class TrackDataHubTest extends AndroidTestCase {
|
|||||||
public void testPointsListen_reRegisterTrackChanged() {
|
public void testPointsListen_reRegisterTrackChanged() {
|
||||||
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
||||||
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
||||||
.putLong("selectedTrack", TRACK_ID).commit();
|
.putLong("selectedTrack", TRACK_ID).apply();
|
||||||
|
|
||||||
expectStart();
|
expectStart();
|
||||||
dataSources.registerContentObserver(
|
dataSources.registerContentObserver(
|
||||||
@@ -628,7 +628,7 @@ public class TrackDataHubTest extends AndroidTestCase {
|
|||||||
public void testPointsListen_largeTrackSampling() {
|
public void testPointsListen_largeTrackSampling() {
|
||||||
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
||||||
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
||||||
.putLong("selectedTrack", TRACK_ID).commit();
|
.putLong("selectedTrack", TRACK_ID).apply();
|
||||||
|
|
||||||
expectStart();
|
expectStart();
|
||||||
dataSources.registerContentObserver(
|
dataSources.registerContentObserver(
|
||||||
@@ -661,7 +661,7 @@ public class TrackDataHubTest extends AndroidTestCase {
|
|||||||
public void testPointsListen_resampling() {
|
public void testPointsListen_resampling() {
|
||||||
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
Capture<ContentObserver> observerCapture = new Capture<ContentObserver>();
|
||||||
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
prefs.edit().putLong("recordingTrack", TRACK_ID)
|
||||||
.putLong("selectedTrack", TRACK_ID).commit();
|
.putLong("selectedTrack", TRACK_ID).apply();
|
||||||
|
|
||||||
expectStart();
|
expectStart();
|
||||||
dataSources.registerContentObserver(
|
dataSources.registerContentObserver(
|
||||||
@@ -814,7 +814,7 @@ public class TrackDataHubTest extends AndroidTestCase {
|
|||||||
prefs.edit()
|
prefs.edit()
|
||||||
.putBoolean(metricUnitsKey, true)
|
.putBoolean(metricUnitsKey, true)
|
||||||
.putBoolean(speedKey, true)
|
.putBoolean(speedKey, true)
|
||||||
.commit();
|
.apply();
|
||||||
|
|
||||||
Capture<OnSharedPreferenceChangeListener> listenerCapture =
|
Capture<OnSharedPreferenceChangeListener> listenerCapture =
|
||||||
new Capture<OnSharedPreferenceChangeListener>();
|
new Capture<OnSharedPreferenceChangeListener>();
|
||||||
@@ -840,7 +840,7 @@ public class TrackDataHubTest extends AndroidTestCase {
|
|||||||
|
|
||||||
prefs.edit()
|
prefs.edit()
|
||||||
.putBoolean(speedKey, false)
|
.putBoolean(speedKey, false)
|
||||||
.commit();
|
.apply();
|
||||||
OnSharedPreferenceChangeListener listener = listenerCapture.getValue();
|
OnSharedPreferenceChangeListener listener = listenerCapture.getValue();
|
||||||
listener.onSharedPreferenceChanged(prefs, speedKey);
|
listener.onSharedPreferenceChanged(prefs, speedKey);
|
||||||
|
|
||||||
@@ -854,7 +854,7 @@ public class TrackDataHubTest extends AndroidTestCase {
|
|||||||
|
|
||||||
prefs.edit()
|
prefs.edit()
|
||||||
.putBoolean(metricUnitsKey, false)
|
.putBoolean(metricUnitsKey, false)
|
||||||
.commit();
|
.apply();
|
||||||
listener.onSharedPreferenceChanged(prefs, metricUnitsKey);
|
listener.onSharedPreferenceChanged(prefs, metricUnitsKey);
|
||||||
|
|
||||||
verifyAndReset();
|
verifyAndReset();
|
||||||
|
|||||||
+4
-4
@@ -48,13 +48,13 @@ public class PreferenceBackupHelperTest extends TestCase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean commit() {
|
public boolean commit() {
|
||||||
preferenceValues = newPreferences;
|
apply();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply() {
|
public void apply() {
|
||||||
commit();
|
preferenceValues = newPreferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -185,7 +185,7 @@ public class PreferenceBackupHelperTest extends TestCase {
|
|||||||
editor.putInt("int1", 42);
|
editor.putInt("int1", 42);
|
||||||
editor.putLong("long1", 123456789L);
|
editor.putLong("long1", 123456789L);
|
||||||
editor.putString("str1", "lolcat");
|
editor.putString("str1", "lolcat");
|
||||||
editor.commit();
|
editor.apply();
|
||||||
|
|
||||||
// Export it
|
// Export it
|
||||||
byte[] exported = preferenceBackupHelper.exportPreferences(preferences);
|
byte[] exported = preferenceBackupHelper.exportPreferences(preferences);
|
||||||
@@ -195,7 +195,7 @@ public class PreferenceBackupHelperTest extends TestCase {
|
|||||||
editor.clear();
|
editor.clear();
|
||||||
editor.putString("str2", "Shouldn't be there after restore");
|
editor.putString("str2", "Shouldn't be there after restore");
|
||||||
editor.putBoolean("bool2", true);
|
editor.putBoolean("bool2", true);
|
||||||
editor.commit();
|
editor.apply();
|
||||||
|
|
||||||
// Import it back
|
// Import it back
|
||||||
preferenceBackupHelper.importPreferences(exported, preferences);
|
preferenceBackupHelper.importPreferences(exported, preferences);
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ public class TrackPathPainterFactoryTest extends TrackPathPainterTestCase {
|
|||||||
private <T> void testTrackPathPainterFactorySpecific(Context context, SharedPreferences prefs,
|
private <T> void testTrackPathPainterFactorySpecific(Context context, SharedPreferences prefs,
|
||||||
int track_color_mode, Class <?> c) {
|
int track_color_mode, Class <?> c) {
|
||||||
prefs.edit().putString(context.getString(R.string.track_color_mode_key),
|
prefs.edit().putString(context.getString(R.string.track_color_mode_key),
|
||||||
context.getString(track_color_mode)).commit();
|
context.getString(track_color_mode)).apply();
|
||||||
|
|
||||||
int startLocationIdx = 0;
|
int startLocationIdx = 0;
|
||||||
Boolean alwaysVisible = true;
|
Boolean alwaysVisible = true;
|
||||||
|
|||||||
+5
-5
@@ -154,14 +154,14 @@ public class TrackRecordingServiceTest
|
|||||||
sharedPreferences = context.getSharedPreferences(
|
sharedPreferences = context.getSharedPreferences(
|
||||||
Constants.SETTINGS_NAME, 0);
|
Constants.SETTINGS_NAME, 0);
|
||||||
// Let's use default values.
|
// Let's use default values.
|
||||||
sharedPreferences.edit().clear().commit();
|
sharedPreferences.edit().clear().apply();
|
||||||
|
|
||||||
// Disable auto resume by default.
|
// Disable auto resume by default.
|
||||||
updateAutoResumePrefs(0, -1);
|
updateAutoResumePrefs(0, -1);
|
||||||
// No recording track.
|
// No recording track.
|
||||||
Editor editor = sharedPreferences.edit();
|
Editor editor = sharedPreferences.edit();
|
||||||
editor.putLong(context.getString(R.string.recording_track_key), -1);
|
editor.putLong(context.getString(R.string.recording_track_key), -1);
|
||||||
editor.commit();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@@ -654,7 +654,7 @@ public class TrackRecordingServiceTest
|
|||||||
R.string.auto_resume_track_current_retry_key), attempts);
|
R.string.auto_resume_track_current_retry_key), attempts);
|
||||||
editor.putInt(context.getString(
|
editor.putInt(context.getString(
|
||||||
R.string.auto_resume_track_timeout_key), timeoutMins);
|
R.string.auto_resume_track_timeout_key), timeoutMins);
|
||||||
editor.commit();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Intent createStartIntent() {
|
private Intent createStartIntent() {
|
||||||
@@ -673,7 +673,7 @@ public class TrackRecordingServiceTest
|
|||||||
private void setRecordingTrack(long id) {
|
private void setRecordingTrack(long id) {
|
||||||
Editor editor = sharedPreferences.edit();
|
Editor editor = sharedPreferences.edit();
|
||||||
editor.putLong(context.getString(R.string.recording_track_key), id);
|
editor.putLong(context.getString(R.string.recording_track_key), id);
|
||||||
editor.commit();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: We support multiple values for readability, however this test's
|
// TODO: We support multiple values for readability, however this test's
|
||||||
@@ -697,7 +697,7 @@ public class TrackRecordingServiceTest
|
|||||||
} else if (value == null) {
|
} else if (value == null) {
|
||||||
// Do nothing, as clear above has already removed this property.
|
// Do nothing, as clear above has already removed this property.
|
||||||
}
|
}
|
||||||
editor.commit();
|
editor.apply();
|
||||||
|
|
||||||
fullRecordingSession();
|
fullRecordingSession();
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -20,7 +20,7 @@ public class SensorManagerFactoryTest extends AndroidTestCase {
|
|||||||
sharedPreferences = getContext().getSharedPreferences(
|
sharedPreferences = getContext().getSharedPreferences(
|
||||||
Constants.SETTINGS_NAME, 0);
|
Constants.SETTINGS_NAME, 0);
|
||||||
// Let's use default values.
|
// Let's use default values.
|
||||||
sharedPreferences.edit().clear().commit();
|
sharedPreferences.edit().clear().apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@@ -47,7 +47,7 @@ public class SensorManagerFactoryTest extends AndroidTestCase {
|
|||||||
sharedPreferences.edit()
|
sharedPreferences.edit()
|
||||||
.putString(getContext().getString(R.string.sensor_type_key),
|
.putString(getContext().getString(R.string.sensor_type_key),
|
||||||
getContext().getString(i))
|
getContext().getString(i))
|
||||||
.commit();
|
.apply();
|
||||||
SensorManager sm = SensorManagerFactory.getSensorManager(getContext());
|
SensorManager sm = SensorManagerFactory.getSensorManager(getContext());
|
||||||
assertNotNull(sm);
|
assertNotNull(sm);
|
||||||
assertTrue(c.isInstance(sm));
|
assertTrue(c.isInstance(sm));
|
||||||
|
|||||||
+1
-2
@@ -18,7 +18,6 @@ package com.google.android.apps.mytracks.services.sensors.ant;
|
|||||||
import com.dsi.ant.AntMesg;
|
import com.dsi.ant.AntMesg;
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
import com.google.android.apps.mytracks.content.Sensor;
|
import com.google.android.apps.mytracks.content.Sensor;
|
||||||
import com.google.android.apps.mytracks.services.sensors.ant.AntDirectSensorManager;
|
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@@ -34,7 +33,7 @@ public class AntDirectSensorManagerTest extends AndroidTestCase {
|
|||||||
sharedPreferences = getContext().getSharedPreferences(
|
sharedPreferences = getContext().getSharedPreferences(
|
||||||
Constants.SETTINGS_NAME, 0);
|
Constants.SETTINGS_NAME, 0);
|
||||||
// Let's use default values.
|
// Let's use default values.
|
||||||
sharedPreferences.edit().clear().commit();
|
sharedPreferences.edit().clear().apply();
|
||||||
manager = new AntDirectSensorManager(getContext());
|
manager = new AntDirectSensorManager(getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user