mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-03-03 19:09:07 +01:00
Fix crash related to color keys
Color keys can be a name like 'aliceblue' or 'green'
This commit is contained in:
parent
1a769df439
commit
22836dc71d
@ -20,15 +20,15 @@ class SelectEventColorDialog(val activity: Activity, val eventType: EventType, v
|
||||
private var dialog: AlertDialog? = null
|
||||
private val radioGroup: RadioGroup
|
||||
private var wasInit = false
|
||||
private val colors = activity.calDAVHelper.getAvailableCalDAVCalendarColors(eventType, Colors.TYPE_EVENT)
|
||||
private val colors = activity.calDAVHelper.getAvailableCalDAVCalendarColors(eventType, Colors.TYPE_EVENT).keys
|
||||
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_select_event_color, null) as ViewGroup
|
||||
radioGroup = view.dialog_select_event_type_color_radio
|
||||
|
||||
addRadioButton(colorKey = colors.values.size.inc(), color = eventType.color)
|
||||
colors.forEach { (color, key) ->
|
||||
addRadioButton(key.toInt(), color)
|
||||
addRadioButton(index = colors.size.inc(), color = eventType.color)
|
||||
colors.forEachIndexed { index, color ->
|
||||
addRadioButton(index, color)
|
||||
}
|
||||
|
||||
wasInit = true
|
||||
@ -40,12 +40,12 @@ class SelectEventColorDialog(val activity: Activity, val eventType: EventType, v
|
||||
}
|
||||
}
|
||||
|
||||
private fun addRadioButton(colorKey: Int, color: Int) {
|
||||
private fun addRadioButton(index: Int, color: Int) {
|
||||
val view = activity.layoutInflater.inflate(R.layout.radio_button_with_color, null)
|
||||
(view.dialog_radio_button as RadioButton).apply {
|
||||
text = if (color == eventType.color) activity.getString(R.string.default_color) else String.format("#%06X", 0xFFFFFF and color)
|
||||
isChecked = color == selectedColor
|
||||
id = colorKey
|
||||
id = index
|
||||
}
|
||||
|
||||
view.dialog_radio_color.setFillWithStroke(color, activity.getProperBackgroundColor())
|
||||
|
Loading…
x
Reference in New Issue
Block a user