forked from upstream-mirrors/OpenTracks
@@ -9,11 +9,6 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothUtils;
|
|
||||||
import de.dennisguse.opentracks.settings.bluetooth.BluetoothLeCyclingCadenceAndSpeedPreference;
|
|
||||||
import de.dennisguse.opentracks.settings.bluetooth.BluetoothLeCyclingPowerPreference;
|
|
||||||
import de.dennisguse.opentracks.settings.bluetooth.BluetoothLeHeartRatePreference;
|
|
||||||
import de.dennisguse.opentracks.settings.bluetooth.BluetoothLeRunningSpeedAndCadencePreference;
|
|
||||||
import de.dennisguse.opentracks.settings.bluetooth.BluetoothLeSensorPreference;
|
import de.dennisguse.opentracks.settings.bluetooth.BluetoothLeSensorPreference;
|
||||||
|
|
||||||
public class SensorsSettingsFragment extends PreferenceFragmentCompat {
|
public class SensorsSettingsFragment extends PreferenceFragmentCompat {
|
||||||
@@ -34,18 +29,8 @@ public class SensorsSettingsFragment extends PreferenceFragmentCompat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisplayPreferenceDialog(Preference preference) {
|
public void onDisplayPreferenceDialog(Preference preference) {
|
||||||
DialogFragment dialogFragment = null;
|
if (preference instanceof BluetoothLeSensorPreference) {
|
||||||
if (preference instanceof BluetoothLeHeartRatePreference) {
|
DialogFragment dialogFragment = ((BluetoothLeSensorPreference) preference).createInstance();
|
||||||
dialogFragment = BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(preference.getKey(), BluetoothUtils.HEART_RATE_SUPPORTING_DEVICES);
|
|
||||||
} else if (preference instanceof BluetoothLeCyclingCadenceAndSpeedPreference) {
|
|
||||||
dialogFragment = BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(preference.getKey(), BluetoothUtils.CYCLING_SPEED_CADENCE_SERVICE_UUID);
|
|
||||||
} else if (preference instanceof BluetoothLeCyclingPowerPreference) {
|
|
||||||
dialogFragment = BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(preference.getKey(), BluetoothUtils.CYCLING_POWER_UUID);
|
|
||||||
} else if (preference instanceof BluetoothLeRunningSpeedAndCadencePreference) {
|
|
||||||
dialogFragment = BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(preference.getKey(), BluetoothUtils.RUNNING_RUNNING_SPEED_CADENCE_UUID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dialogFragment != null) {
|
|
||||||
dialogFragment.setTargetFragment(this, 0);
|
dialogFragment.setTargetFragment(this, 0);
|
||||||
dialogFragment.show(getParentFragmentManager(), getClass().getSimpleName());
|
dialogFragment.show(getParentFragmentManager(), getClass().getSimpleName());
|
||||||
return;
|
return;
|
||||||
|
|||||||
+9
@@ -3,6 +3,10 @@ package de.dennisguse.opentracks.settings.bluetooth;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceDialogFragmentCompat;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.sensors.BluetoothUtils;
|
||||||
|
|
||||||
public class BluetoothLeCyclingCadenceAndSpeedPreference extends BluetoothLeSensorPreference {
|
public class BluetoothLeCyclingCadenceAndSpeedPreference extends BluetoothLeSensorPreference {
|
||||||
|
|
||||||
public BluetoothLeCyclingCadenceAndSpeedPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
public BluetoothLeCyclingCadenceAndSpeedPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
@@ -20,4 +24,9 @@ public class BluetoothLeCyclingCadenceAndSpeedPreference extends BluetoothLeSens
|
|||||||
public BluetoothLeCyclingCadenceAndSpeedPreference(Context context) {
|
public BluetoothLeCyclingCadenceAndSpeedPreference(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PreferenceDialogFragmentCompat createInstance() {
|
||||||
|
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), BluetoothUtils.CYCLING_SPEED_CADENCE_SERVICE_UUID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -3,6 +3,10 @@ package de.dennisguse.opentracks.settings.bluetooth;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceDialogFragmentCompat;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.sensors.BluetoothUtils;
|
||||||
|
|
||||||
public class BluetoothLeCyclingPowerPreference extends BluetoothLeSensorPreference {
|
public class BluetoothLeCyclingPowerPreference extends BluetoothLeSensorPreference {
|
||||||
|
|
||||||
public BluetoothLeCyclingPowerPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
public BluetoothLeCyclingPowerPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
@@ -20,4 +24,9 @@ public class BluetoothLeCyclingPowerPreference extends BluetoothLeSensorPreferen
|
|||||||
public BluetoothLeCyclingPowerPreference(Context context) {
|
public BluetoothLeCyclingPowerPreference(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PreferenceDialogFragmentCompat createInstance() {
|
||||||
|
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), BluetoothUtils.CYCLING_POWER_UUID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+9
@@ -3,6 +3,10 @@ package de.dennisguse.opentracks.settings.bluetooth;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceDialogFragmentCompat;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.sensors.BluetoothUtils;
|
||||||
|
|
||||||
public class BluetoothLeHeartRatePreference extends BluetoothLeSensorPreference {
|
public class BluetoothLeHeartRatePreference extends BluetoothLeSensorPreference {
|
||||||
|
|
||||||
public BluetoothLeHeartRatePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
public BluetoothLeHeartRatePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
@@ -20,4 +24,9 @@ public class BluetoothLeHeartRatePreference extends BluetoothLeSensorPreference
|
|||||||
public BluetoothLeHeartRatePreference(Context context) {
|
public BluetoothLeHeartRatePreference(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PreferenceDialogFragmentCompat createInstance() {
|
||||||
|
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), BluetoothUtils.HEART_RATE_SUPPORTING_DEVICES);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+9
@@ -3,6 +3,10 @@ package de.dennisguse.opentracks.settings.bluetooth;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceDialogFragmentCompat;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.sensors.BluetoothUtils;
|
||||||
|
|
||||||
public class BluetoothLeRunningSpeedAndCadencePreference extends BluetoothLeSensorPreference {
|
public class BluetoothLeRunningSpeedAndCadencePreference extends BluetoothLeSensorPreference {
|
||||||
|
|
||||||
public BluetoothLeRunningSpeedAndCadencePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
public BluetoothLeRunningSpeedAndCadencePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
@@ -20,4 +24,9 @@ public class BluetoothLeRunningSpeedAndCadencePreference extends BluetoothLeSens
|
|||||||
public BluetoothLeRunningSpeedAndCadencePreference(Context context) {
|
public BluetoothLeRunningSpeedAndCadencePreference(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PreferenceDialogFragmentCompat createInstance() {
|
||||||
|
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), BluetoothUtils.RUNNING_RUNNING_SPEED_CADENCE_UUID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -92,6 +92,8 @@ public abstract class BluetoothLeSensorPreference extends DialogPreference {
|
|||||||
return getValue();
|
return getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract PreferenceDialogFragmentCompat createInstance();
|
||||||
|
|
||||||
public static class BluetoothLeSensorPreferenceDialog extends PreferenceDialogFragmentCompat {
|
public static class BluetoothLeSensorPreferenceDialog extends PreferenceDialogFragmentCompat {
|
||||||
|
|
||||||
private AnimatedVectorDrawableCompat bluetoothIcon;
|
private AnimatedVectorDrawableCompat bluetoothIcon;
|
||||||
|
|||||||
Reference in New Issue
Block a user