@@ -94,23 +94,21 @@ suspend fun Context.schemaPicker(
94
94
}.create()
95
95
}
96
96
97
- suspend fun Context.soundPicker (
97
+ fun Context.soundPicker (
98
98
@StyleRes themeResId : Int = 0
99
99
): AlertDialog {
100
- return CoroutineChoiceDialog (this , themeResId).apply {
101
- title = getString(R .string.keyboard__key_sound_package_title)
102
- initDispatcher = Dispatchers .IO
103
- onInit {
104
- items = SoundManager .getAllSounds()
105
- .map { it.substringBeforeLast(' .' ) }
106
- .toTypedArray()
107
- val current = SoundManager .getActiveSound()
108
- .substringBeforeLast(' .' )
109
- checkedItem = items.indexOf(current)
100
+ val all = SoundManager .getAllSounds().map { it.substringBeforeLast(' .' ) }
101
+ val current = SoundManager .getActiveSound().substringBeforeLast(' .' )
102
+ var checked = all.indexOf(current)
103
+ return AlertDialog .Builder (this , themeResId)
104
+ .setTitle(R .string.keyboard__key_sound_package_title)
105
+ .setSingleChoiceItems(
106
+ all.toTypedArray(),
107
+ checked
108
+ ) { _, id -> checked = id }
109
+ .setPositiveButton(android.R .string.ok) { _, _ ->
110
+ SoundManager .switchSound(" ${all[checked]} .sound" )
110
111
}
111
- postiveDispatcher = Dispatchers .Default
112
- onOKButton {
113
- SoundManager .switchSound(" ${items[checkedItem]} .sound" )
114
- }
115
- }.create()
112
+ .setNegativeButton(android.R .string.cancel, null )
113
+ .create()
116
114
}
0 commit comments