1
0
Fork 0

Use a ListPreference for tone frequency, which is more typical

This commit is contained in:
Eoin Mcloughlin 2020-05-19 20:27:05 +01:00
parent 77b8463ed9
commit 2e346a9c6f
3 changed files with 28 additions and 10 deletions

View file

@ -360,9 +360,11 @@ data class DitDahGeneratorSettings(var context : Context? = null) {
init { init {
if(context != null) { if(context != null) {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
toneFrequency = sharedPreferences.getInt(context!!.getString(R.string.setting_tone_key), toneFrequency)
wordsPerMinute = sharedPreferences.getInt(context!!.getString(R.string.setting_wpm_key), wordsPerMinute) wordsPerMinute = sharedPreferences.getInt(context!!.getString(R.string.setting_wpm_key), wordsPerMinute)
farnsworthWordsPerMinute = sharedPreferences.getInt(context!!.getString(R.string.setting_effective_wpm_key), farnsworthWordsPerMinute) farnsworthWordsPerMinute = sharedPreferences.getInt(context!!.getString(R.string.setting_effective_wpm_key), farnsworthWordsPerMinute)
// This one is a little strange; the ListPreference stores a string, which we need to parse
toneFrequency = sharedPreferences.getString(context!!.getString(R.string.setting_tone_key), toneFrequency.toString())!!.toInt()
} }
} }
} }

View file

@ -18,7 +18,6 @@
<string name="setting_effective_wpm_label">Effective Words per Minute</string> <string name="setting_effective_wpm_label">Effective Words per Minute</string>
<string name="setting_effective_wpm_summary">Allows extra spacing between characters</string> <string name="setting_effective_wpm_summary">Allows extra spacing between characters</string>
<string name="setting_tone_key">sender_tone</string> <string name="setting_tone_key">sender_tone</string>
<string name="setting_wpm_key">sender_wpm</string> <string name="setting_wpm_key">sender_wpm</string>
<string name="setting_effective_wpm_key">sender_effective_wpm</string> <string name="setting_effective_wpm_key">sender_effective_wpm</string>
@ -34,4 +33,24 @@
<string name="setting_koch_lesson_vary_label">Variable group length</string> <string name="setting_koch_lesson_vary_label">Variable group length</string>
<string name="setting_koch_lesson_vary_off">Always groups of 5</string> <string name="setting_koch_lesson_vary_off">Always groups of 5</string>
<string name="setting_koch_lesson_vary_on">Groups between 2 and 6 characters</string> <string name="setting_koch_lesson_vary_on">Groups between 2 and 6 characters</string>
<string-array name="tone_frequency_strings">
<item>400Hz</item>
<item>450Hz</item>
<item>500Hz</item>
<item>550Hz</item>
<item>600Hz</item>
<item>650Hz</item>
<item>700Hz</item>
</string-array>
<string-array name="tone_frequency_values">
<item>400</item>
<item>450</item>
<item>500</item>
<item>550</item>
<item>600</item>
<item>650</item>
<item>700</item>
</string-array>
</resources> </resources>

View file

@ -10,15 +10,12 @@
android:summaryOn="YEAH" android:summaryOn="YEAH"
android:title="Switch preference" /> android:title="Switch preference" />
<SeekBarPreference <ListPreference
android:defaultValue="600" android:defaultValue="600"
android:max="900" android:entries="@array/tone_frequency_strings"
app:defaultValue="650" android:entryValues="@array/tone_frequency_values"
app:key="@string/setting_tone_key" android:key="@string/setting_tone_key"
app:min="500" android:title="@string/setting_tone_frequency_label" />
app:seekBarIncrement="50"
app:showSeekBarValue="true"
app:title="@string/setting_tone_frequency_label" />
<SeekBarPreference <SeekBarPreference
android:defaultValue="600" android:defaultValue="600"