Skip to content

Commit

Permalink
Use a ListPreference for tone frequency, which is more typical
Browse files Browse the repository at this point in the history
  • Loading branch information
Eoin Mcloughlin committed Jun 13, 2020
1 parent 77b8463 commit 2e346a9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
4 changes: 3 additions & 1 deletion app/src/main/java/es/eoinrul/ecwt/DitDahGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,11 @@ data class DitDahGeneratorSettings(var context : Context? = null) {
init {
if(context != null) {
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)
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()
}
}
}
Expand Down
21 changes: 20 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<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_tone_key">sender_tone</string>
<string name="setting_wpm_key">sender_wpm</string>
<string name="setting_effective_wpm_key">sender_effective_wpm</string>
Expand All @@ -34,4 +33,24 @@
<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_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>
13 changes: 5 additions & 8 deletions app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@
android:summaryOn="YEAH"
android:title="Switch preference" />

<SeekBarPreference
<ListPreference
android:defaultValue="600"
android:max="900"
app:defaultValue="650"
app:key="@string/setting_tone_key"
app:min="500"
app:seekBarIncrement="50"
app:showSeekBarValue="true"
app:title="@string/setting_tone_frequency_label" />
android:entries="@array/tone_frequency_strings"
android:entryValues="@array/tone_frequency_values"
android:key="@string/setting_tone_key"
android:title="@string/setting_tone_frequency_label" />

<SeekBarPreference
android:defaultValue="600"
Expand Down

0 comments on commit 2e346a9

Please sign in to comment.