forked from upstream-mirrors/OpenTracks
@@ -2,14 +2,17 @@ package de.dennisguse.opentracks.settings;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.preference.EditTextPreference;
|
import androidx.preference.EditTextPreference;
|
||||||
import androidx.preference.Preference;
|
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.settings.bluetooth.BluetoothLeSensorPreference;
|
import de.dennisguse.opentracks.settings.bluetooth.BluetoothLeSensorPreference;
|
||||||
|
import de.dennisguse.opentracks.util.PermissionRequester;
|
||||||
|
|
||||||
public class SensorsSettingsFragment extends PreferenceFragmentCompat {
|
public class SensorsSettingsFragment extends PreferenceFragmentCompat {
|
||||||
|
|
||||||
@@ -30,6 +33,13 @@ public class SensorsSettingsFragment extends PreferenceFragmentCompat {
|
|||||||
@Override
|
@Override
|
||||||
public void onDisplayPreferenceDialog(Preference preference) {
|
public void onDisplayPreferenceDialog(Preference preference) {
|
||||||
if (preference instanceof BluetoothLeSensorPreference) {
|
if (preference instanceof BluetoothLeSensorPreference) {
|
||||||
|
if(!PermissionRequester.BLUETOOTH.hasPermission(preference.getContext())) {
|
||||||
|
// TODO: maybe use requestPermissionsIfNeeded here or disable preferences at all
|
||||||
|
FragmentActivity activity = getActivity();
|
||||||
|
Toast.makeText(activity, getString(R.string.permission_bluetooth_failed), Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DialogFragment dialogFragment = ((BluetoothLeSensorPreference) preference).createInstance();
|
DialogFragment dialogFragment = ((BluetoothLeSensorPreference) preference).createInstance();
|
||||||
dialogFragment.setTargetFragment(this, 0);
|
dialogFragment.setTargetFragment(this, 0);
|
||||||
dialogFragment.show(getParentFragmentManager(), getClass().getSimpleName());
|
dialogFragment.show(getParentFragmentManager(), getClass().getSimpleName());
|
||||||
|
|||||||
Reference in New Issue
Block a user