mirror of
https://github.com/PhilKes/NotallyX.git
synced 2025-06-28 12:19:55 +00:00
Merge pull request #500 from PhilKes/fix/next-action-edittext
Fix next action on ListItem EditText
This commit is contained in:
commit
4924ee46ec
2 changed files with 27 additions and 33 deletions
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue