forked from upstream-mirrors/OpenTracks
@@ -45,7 +45,7 @@ public class BluetoothLeAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
Device device = devices.get(position);
|
Device device = devices.get(position);
|
||||||
TextView textView = currentView.findViewById(android.R.id.text1);
|
TextView textView = currentView.findViewById(android.R.id.text1);
|
||||||
textView.setText(device.getName());
|
textView.setText(device.getNameOrAddress());
|
||||||
|
|
||||||
return currentView;
|
return currentView;
|
||||||
}
|
}
|
||||||
@@ -81,8 +81,8 @@ public class BluetoothLeAdapter extends BaseAdapter {
|
|||||||
this.address = address;
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getNameOrAddress() {
|
||||||
return name;
|
return name != null ? name : getAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
|
|||||||
@@ -232,6 +232,11 @@ public class PreferencesUtils {
|
|||||||
return getString(R.string.settings_sensor_bluetooth_running_speed_and_cadence_key, getBluetoothSensorAddressNone());
|
return getString(R.string.settings_sensor_bluetooth_running_speed_and_cadence_key, getBluetoothSensorAddressNone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getBluetoothFilterEnabled() {
|
||||||
|
final boolean DEFAULT = resources.getBoolean(R.bool.settings_sensor_bluetooth_service_filter_enabled_default);
|
||||||
|
return getBoolean(R.string.settings_sensor_bluetooth_service_filter_enabled_key, DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean shouldShowStatsOnLockscreen() {
|
public static boolean shouldShowStatsOnLockscreen() {
|
||||||
final boolean STATS_SHOW_ON_LOCKSCREEN_DEFAULT = resources.getBoolean(R.bool.stats_show_on_lockscreen_while_recording_default);
|
final boolean STATS_SHOW_ON_LOCKSCREEN_DEFAULT = resources.getBoolean(R.bool.stats_show_on_lockscreen_while_recording_default);
|
||||||
return getBoolean(R.string.stats_show_on_lockscreen_while_recording_key, STATS_SHOW_ON_LOCKSCREEN_DEFAULT);
|
return getBoolean(R.string.stats_show_on_lockscreen_while_recording_key, STATS_SHOW_ON_LOCKSCREEN_DEFAULT);
|
||||||
|
|||||||
+8
-6
@@ -34,8 +34,8 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
import de.dennisguse.opentracks.settings.BluetoothLeAdapter;
|
import de.dennisguse.opentracks.settings.BluetoothLeAdapter;
|
||||||
import de.dennisguse.opentracks.util.BluetoothUtils;
|
|
||||||
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
||||||
|
import de.dennisguse.opentracks.util.BluetoothUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preference to select a discoverable Bluetooth LE device.
|
* Preference to select a discoverable Bluetooth LE device.
|
||||||
@@ -109,17 +109,14 @@ public abstract class BluetoothLeSensorPreference extends DialogPreference {
|
|||||||
private final ScanCallback scanCallback = new ScanCallback() {
|
private final ScanCallback scanCallback = new ScanCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onScanResult(int callbackType, ScanResult result) {
|
public void onScanResult(int callbackType, ScanResult result) {
|
||||||
super.onScanResult(callbackType, result);
|
|
||||||
Log.d(TAG, "Found device " + result.getDevice().getName() + " " + result);
|
Log.d(TAG, "Found device " + result.getDevice().getName() + " " + result);
|
||||||
|
|
||||||
listAdapter.add(result.getDevice());
|
listAdapter.add(result.getDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBatchScanResults(List<ScanResult> results) {
|
public void onBatchScanResults(List<ScanResult> results) {
|
||||||
for (ScanResult result : results) {
|
for (ScanResult result : results) {
|
||||||
Log.d(TAG, "Found device " + result.getDevice().getName() + " " + result);
|
onScanResult(-1, result);
|
||||||
listAdapter.add(result.getDevice());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +210,12 @@ public abstract class BluetoothLeSensorPreference extends DialogPreference {
|
|||||||
selectedEntryIndex = 1;
|
selectedEntryIndex = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ScanFilter> scanFilter = serviceUUIDs.stream().map(it -> new ScanFilter.Builder().setServiceUuid(it).build()).collect(Collectors.toList());
|
List<ScanFilter> scanFilter = null;
|
||||||
|
if (PreferencesUtils.getBluetoothFilterEnabled()) {
|
||||||
|
scanFilter = serviceUUIDs.stream()
|
||||||
|
.map(it -> new ScanFilter.Builder().setServiceUuid(it).build())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
ScanSettings.Builder scanSettingsBuilder = new ScanSettings.Builder();
|
ScanSettings.Builder scanSettingsBuilder = new ScanSettings.Builder();
|
||||||
scanSettingsBuilder.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY);
|
scanSettingsBuilder.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY);
|
||||||
|
|||||||
@@ -39,6 +39,11 @@
|
|||||||
<string name="settings_sensor_bluetooth_cycling_speed_wheel_circumference_key" translatable="false">bluetoothCyclingSpeedWheelCircumference</string>
|
<string name="settings_sensor_bluetooth_cycling_speed_wheel_circumference_key" translatable="false">bluetoothCyclingSpeedWheelCircumference</string>
|
||||||
<string name="settings_sensor_bluetooth_cycling_speed_wheel_circumference_default" translatable="false">2135</string>
|
<string name="settings_sensor_bluetooth_cycling_speed_wheel_circumference_default" translatable="false">2135</string>
|
||||||
|
|
||||||
|
<string name="settings_sensor_bluetooth_service_filter_enabled_key" translatable="false">bluetoothSensorFilterEnabled</string>
|
||||||
|
<bool name="settings_sensor_bluetooth_service_filter_enabled_default" translatable="false">
|
||||||
|
true
|
||||||
|
</bool>
|
||||||
|
|
||||||
<string name="settings_default_export_directory_key" translatable="false">settingsDefaultExportDirectory</string>
|
<string name="settings_default_export_directory_key" translatable="false">settingsDefaultExportDirectory</string>
|
||||||
<string name="post_workout_export_enabled_key" translatable="false">instantExportEnabled</string>
|
<string name="post_workout_export_enabled_key" translatable="false">instantExportEnabled</string>
|
||||||
<bool name="post_workout_export_enabled_default" translatable="false">false</bool>
|
<bool name="post_workout_export_enabled_default" translatable="false">false</bool>
|
||||||
|
|||||||
@@ -433,6 +433,7 @@ limitations under the License.
|
|||||||
<string name="settings_sensor_cycling_cadence">Cadence</string>
|
<string name="settings_sensor_cycling_cadence">Cadence</string>
|
||||||
<string name="settings_sensor_running_speed_and_cadence">Distance, Speed, and Cadence</string>
|
<string name="settings_sensor_running_speed_and_cadence">Distance, Speed, and Cadence</string>
|
||||||
<string name="settings_sensor_wheel_circumference">Wheel Circumference (mm)</string>
|
<string name="settings_sensor_wheel_circumference">Wheel Circumference (mm)</string>
|
||||||
|
<string name="settings_sensor_bluetooth_service_filter_enabled">Only show Bluetooth devices that announce required services</string>
|
||||||
|
|
||||||
<!-- Settings Stats -->
|
<!-- Settings Stats -->
|
||||||
<string name="settings_stats_rate_title">Preferred rate</string>
|
<string name="settings_stats_rate_title">Preferred rate</string>
|
||||||
|
|||||||
@@ -39,4 +39,11 @@
|
|||||||
android:title="@string/settings_sensor_running_speed_and_cadence" />
|
android:title="@string/settings_sensor_running_speed_and_cadence" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory android:title="@string/settings_advanced">
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="@bool/settings_sensor_bluetooth_service_filter_enabled_default"
|
||||||
|
android:key="@string/settings_sensor_bluetooth_service_filter_enabled_key"
|
||||||
|
android:title="@string/settings_sensor_bluetooth_service_filter_enabled" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
Reference in New Issue
Block a user