mirror of
https://github.com/oxen-io/session-android.git
synced 2023-12-14 02:53:01 +01:00
25 lines
702 B
Kotlin
25 lines
702 B
Kotlin
package org.thoughtcrime.securesms.preferences
|
|
|
|
import android.content.Context
|
|
import androidx.appcompat.app.AlertDialog
|
|
import androidx.preference.ListPreference
|
|
import org.thoughtcrime.securesms.showSessionDialog
|
|
|
|
fun listPreferenceDialog(
|
|
context: Context,
|
|
listPreference: ListPreference,
|
|
onChange: () -> Unit
|
|
) : AlertDialog = listPreference.run {
|
|
context.showSessionDialog {
|
|
val index = entryValues.indexOf(value)
|
|
val options = entries.map(CharSequence::toString).toTypedArray()
|
|
|
|
title(dialogTitle)
|
|
text(dialogMessage)
|
|
singleChoiceItems(options, index) {
|
|
listPreference.setValueIndex(it)
|
|
onChange()
|
|
}
|
|
}
|
|
}
|