Merge pull request #500 from PhilKes/fix/next-action-edittext

Fix next action on ListItem EditText
This commit is contained in:
Phil 2025-03-29 12:20:11 +01:00 committed by GitHub
commit 4924ee46ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 33 deletions

View file

@ -33,17 +33,15 @@ open class EditTextWithWatcher(context: Context, attrs: AttributeSet) :
}
fun setCanEdit(value: Boolean) {
post {
if (!value) {
clearFocus()
}
keyListener?.let { keyListenerInstance = it }
keyListener = if (value) keyListenerInstance else null // Disables text editing
isCursorVisible = true
isFocusable = value
isFocusableInTouchMode = value
setTextIsSelectable(true)
if (!value) {
clearFocus()
}
keyListener?.let { keyListenerInstance = it }
keyListener = if (value) keyListenerInstance else null // Disables text editing
isCursorVisible = true
isFocusable = value
isFocusableInTouchMode = value
setTextIsSelectable(true)
}
@Deprecated(

View file

@ -50,11 +50,6 @@ class ListItemVH(
binding.EditText.apply {
setTextSize(TypedValue.COMPLEX_UNIT_SP, body)
setOnNextAction {
val position = bindingAdapterPosition + 1
listManager.add(position)
}
textWatcher =
createListTextWatcherWithHistory(
listManager,
@ -157,24 +152,6 @@ class ListItemVH(
paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
}
alpha = if (item.checked) 0.5f else 1.0f
setOnKeyListener { _, keyCode, event ->
if (
event.action == KeyEvent.ACTION_DOWN &&
keyCode == KeyEvent.KEYCODE_DEL &&
item.body.isEmpty()
) {
// TODO: when there are multiple checked items above it does not jump to the
// last
// unchecked item but always re-adds a new item
listManager.delete(
absoluteAdapterPosition,
inCheckedList = inCheckedList,
force = false,
)
} else {
false
}
}
contentDescription = "EditText$position"
if (viewMode == NoteViewMode.EDIT) {
setOnFocusChangeListener { _, hasFocus ->
@ -207,6 +184,25 @@ class ListItemVH(
}
}
}
setOnNextAction { listManager.add(bindingAdapterPosition + 1) }
setOnKeyListener { _, keyCode, event ->
if (
event.action == KeyEvent.ACTION_DOWN &&
keyCode == KeyEvent.KEYCODE_DEL &&
item.body.isEmpty()
) {
// TODO: when there are multiple checked items above it does not jump to the
// last
// unchecked item but always re-adds a new item
listManager.delete(
absoluteAdapterPosition,
inCheckedList = inCheckedList,
force = false,
)
} else {
false
}
}
}
}