mirror of
https://github.com/FossifyOrg/Notes.git
synced 2026-03-02 21:47:18 -05:00
Fixed multiline pasting for checklist (#99)
This commit is contained in:
@@ -57,7 +57,7 @@ class NewChecklistItemDialog(val activity: Activity, callback: (titles: ArrayLis
|
||||
}
|
||||
}
|
||||
|
||||
private fun addNewEditText() {
|
||||
private fun addNewEditText(initialText: String? = null) {
|
||||
ItemAddChecklistBinding.inflate(activity.layoutInflater).apply {
|
||||
titleEditText.setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_DONE || actionId == KeyEvent.KEYCODE_ENTER) {
|
||||
@@ -67,6 +67,21 @@ class NewChecklistItemDialog(val activity: Activity, callback: (titles: ArrayLis
|
||||
false
|
||||
}
|
||||
}
|
||||
titleEditText.onTextChangeListener { text ->
|
||||
val lines = text.split("\n").filter { it.trim().isNotEmpty() }
|
||||
if (lines.size > 1) {
|
||||
lines.forEachIndexed { i, line ->
|
||||
if (i == 0) {
|
||||
titleEditText.setText(line)
|
||||
} else {
|
||||
addNewEditText(line)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (initialText != null) {
|
||||
titleEditText.setText(initialText)
|
||||
}
|
||||
titles.add(titleEditText)
|
||||
binding.checklistHolder.addView(this.root)
|
||||
activity.updateTextColors(binding.checklistHolder)
|
||||
|
||||
Reference in New Issue
Block a user