Wheel circumference is now a textfield accepting input as mm.

Fixes #278.
This commit is contained in:
Dennis Guse
2020-08-07 17:39:24 +02:00
parent 0b2bd6899f
commit c8bdf8e641
14 changed files with 31 additions and 26 deletions
@@ -2,11 +2,13 @@ package de.dennisguse.opentracks.settings;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.DialogFragment;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
@@ -81,6 +83,7 @@ public class SettingsActivity extends AppCompatActivity implements ChooseActivit
}
setExportTrackFileFormatOptions();
setWheelCircumferenceInputFilter();
}
@Override
@@ -183,5 +186,20 @@ public class SettingsActivity extends AppCompatActivity implements ChooseActivit
listPreference.setEntries(entries);
listPreference.setEntryValues(entryValues);
}
private void setWheelCircumferenceInputFilter() {
EditTextPreference wheelPreference = findPreference(getString(R.string.settings_sensor_bluetooth_cycling_speed_wheel_circumference_key));
wheelPreference.setOnPreferenceChangeListener((preference, newValue) -> {
if (newValue instanceof String) {
try {
int newValueInt = Integer.parseInt((String) newValue);
return newValueInt > 500 && newValueInt < 4000;
} catch (NumberFormatException e) {
Log.w(TAG, "Entered string is no number.");
}
}
return false;
});
}
}
}