Barometer: select INTERNAL or NONE (also while recording).

Part of #1424.
This commit is contained in:
Dennis Guse
2023-12-27 18:43:47 +01:00
parent 490141db2a
commit 94540606ef
9 changed files with 86 additions and 28 deletions
@@ -48,6 +48,7 @@ import de.dennisguse.opentracks.data.models.HeartRateZones;
import de.dennisguse.opentracks.data.models.Track;
import de.dennisguse.opentracks.io.file.TrackFileFormat;
import de.dennisguse.opentracks.io.file.TrackFilenameGenerator;
import de.dennisguse.opentracks.sensors.SensorType;
import de.dennisguse.opentracks.ui.customRecordingLayout.CsvLayoutUtils;
import de.dennisguse.opentracks.ui.customRecordingLayout.RecordingLayout;
import de.dennisguse.opentracks.ui.customRecordingLayout.RecordingLayoutIO;
@@ -249,22 +250,21 @@ public class PreferencesUtils {
}
private static String getBluetoothSensorAddressNone() {
return resources.getString(R.string.sensor_type_value_none);
return SensorType.NONE.getPreferenceValue();
}
public static boolean isBluetoothSensorAddressNone(String currentValue) {
return getBluetoothSensorAddressNone().equals(currentValue);
}
private static String getBluetoothSensorAddressInternal() {
return resources.getString(R.string.sensor_type_value_internal);
public static SensorType getSensorType(String address) {
return Arrays.stream(SensorType.values())
.filter(it -> it.getPreferenceValue().equals(address))
.findFirst()
.orElse(SensorType.REMOTE);
}
public static boolean isBluetoothSensorAddressInternal(String currentValue) {
return getBluetoothSensorAddressInternal().equals(currentValue);
}
public static String getBluetoothPressureAddress() {
public static String getBarometerSensorAddress() {
return getString(R.string.settings_sensor_bluetooth_pressure_key, getBluetoothSensorAddressNone());
}
@@ -7,9 +7,7 @@ import android.util.AttributeSet;
import androidx.preference.PreferenceDialogFragmentCompat;
import java.util.List;
import de.dennisguse.opentracks.sensors.BluetoothHandlerBarometricPressure;
import java.util.Collections;
public class BluetoothLePressurePreference extends BluetoothLeSensorPreference {
@@ -36,6 +34,7 @@ public class BluetoothLePressurePreference extends BluetoothLeSensorPreference {
boolean hasInternalSensor = pressureSensor != null;
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog
.newInstance(getKey(), List.of(BluetoothHandlerBarometricPressure.BAROMETRIC_PRESSURE), hasInternalSensor);
// .newInstance(getKey(), List.of(BluetoothHandlerBarometricPressure.BAROMETRIC_PRESSURE), hasInternalSensor); //TODO #1424
.newInstance(getKey(), Collections.emptyList(), hasInternalSensor);
}
}
@@ -28,6 +28,7 @@ import java.util.stream.Collectors;
import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.sensors.BluetoothUtils;
import de.dennisguse.opentracks.sensors.SensorType;
import de.dennisguse.opentracks.sensors.ServiceMeasurementUUID;
import de.dennisguse.opentracks.settings.PreferencesUtils;
import de.dennisguse.opentracks.util.PermissionRequester;
@@ -86,10 +87,10 @@ public abstract class BluetoothLeSensorPreference extends DialogPreference {
@Override
public CharSequence getSummary() {
if (value == null || PreferencesUtils.isBluetoothSensorAddressNone(value)) {
if (value == null || SensorType.NONE.getPreferenceValue().equals(value)) {
return getContext().getString(DEVICE_NONE_RESOURCEID);
}
if (PreferencesUtils.isBluetoothSensorAddressInternal(value)) {
if (SensorType.INTERNAL.getPreferenceValue().equals(value)) {
return getContext().getString(SENSOR_INTERNAL_RESOURCEID);
}