Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Removed getValue() method as it was deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
khushaliparmar authored Oct 14, 2023
1 parent 570fa28 commit 5f3af94
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static boolean hasBluetooth(Context context) {

public static BatteryLevel parseBatteryLevel(BluetoothGattCharacteristic characteristic) {
// DOCUMENTATION org.bluetooth.characteristic.battery_level.xml
byte[] raw = characteristic.getValue();
byte[] raw = characteristic.getData();
if (raw.length == 0) {
return null;
}
Expand All @@ -126,7 +126,7 @@ public static BatteryLevel parseBatteryLevel(BluetoothGattCharacteristic charact

public static HeartRate parseHeartRate(BluetoothGattCharacteristic characteristic) {
//DOCUMENTATION https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.heart_rate_measurement.xml
byte[] raw = characteristic.getValue();
byte[] raw = characteristic.getData();
if (raw.length == 0) {
return null;
}
Expand All @@ -143,7 +143,7 @@ public static HeartRate parseHeartRate(BluetoothGattCharacteristic characteristi
}

public static AtmosphericPressure parseEnvironmentalSensing(BluetoothGattCharacteristic characteristic) {
byte[] raw = characteristic.getValue();
byte[] raw = characteristic.getData();

if (raw.length < 4) {
return null;
Expand All @@ -155,7 +155,7 @@ public static AtmosphericPressure parseEnvironmentalSensing(BluetoothGattCharact

public static SensorDataCyclingPower.Data parseCyclingPower(String address, String sensorName, BluetoothGattCharacteristic characteristic) {
// DOCUMENTATION https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.cycling_power_measurement.xml
int valueLength = characteristic.getValue().length;
int valueLength = characteristic.getData().length;
if (valueLength == 0) {
return null;
}
Expand Down Expand Up @@ -197,12 +197,12 @@ public static SensorDataCyclingPower.Data parseCyclingPower(String address, Stri

public static SensorDataCyclingCadenceAndDistanceSpeed parseCyclingCrankAndWheel(String address, String sensorName, @NonNull BluetoothGattCharacteristic characteristic) {
// DOCUMENTATION https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.csc_measurement.xml
int valueLength = characteristic.getValue().length;
int valueLength = characteristic.getData().length;
if (valueLength == 0) {
return null;
}

int flags = characteristic.getValue()[0];
int flags = characteristic.getData()[0];
boolean hasWheel = (flags & 0x01) > 0;
boolean hasCrank = (flags & 0x02) > 0;

Expand Down Expand Up @@ -230,12 +230,12 @@ public static SensorDataCyclingCadenceAndDistanceSpeed parseCyclingCrankAndWheel

public static SensorDataRunning parseRunningSpeedAndCadence(String address, String sensorName, @NonNull BluetoothGattCharacteristic characteristic) {
// DOCUMENTATION https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.rsc_measurement.xml
int valueLength = characteristic.getValue().length;
int valueLength = characteristic.getData().length;
if (valueLength == 0) {
return null;
}

int flags = characteristic.getValue()[0];
int flags = characteristic.getData()[0];
boolean hasStrideLength = (flags & 0x01) > 0;
boolean hasTotalDistance = (flags & 0x02) > 0;
boolean hasStatus = (flags & 0x03) > 0; // walking vs running
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public BluetoothLeSensorPreference(Context context) {
private String value;
private boolean valueSet = false;

public String getValue() {
public String getData() {
return value;
}

public void setValue(String value) {
public void setData(String value) {
final boolean changed = !TextUtils.equals(this.value, value);
if (changed || !valueSet) {
this.value = value;
Expand All @@ -80,16 +80,16 @@ public void setValue(String value) {

@Override
protected void onSetInitialValue(Object defaultValue) {
setValue(getPersistedString((String) defaultValue));
setData(getPersistedString((String) defaultValue));
}

@Override
public CharSequence getSummary() {
if (getValue() == null || PreferencesUtils.isBluetoothSensorAddressNone(getValue())) {
if (getData() == null || PreferencesUtils.isBluetoothSensorAddressNone(getData())) {
return getContext().getString(DEVICE_NONE_RESOURCEID);
}

return getValue();
return getData();
}

public abstract PreferenceDialogFragmentCompat createInstance();
Expand Down Expand Up @@ -192,9 +192,9 @@ private void startBluetoothScan() {
selectedEntryIndex = 0;

BluetoothLeSensorPreference preference = (BluetoothLeSensorPreference) getPreference();
String deviceSelected = preference.getValue();
String deviceSelected = preference.getData();
if (deviceSelected != null && !deviceNone.equals(deviceSelected)) {
listAdapter.add(preference.getValue(), preference.getValue());
listAdapter.add(preference.getData(), preference.getData());
selectedEntryIndex = 1;
}

Expand Down Expand Up @@ -239,7 +239,7 @@ public void onDialogClosed(boolean positiveResult) {
String value = listAdapter.get(selectedEntryIndex).getAddress();
BluetoothLeSensorPreference preference = (BluetoothLeSensorPreference) getPreference();
if (preference.callChangeListener(value)) {
preference.setValue(value);
preference.setData(value);
}
}
}
Expand Down

0 comments on commit 5f3af94

Please sign in to comment.