mirror of
https://github.com/PhilKes/NotallyX.git
synced 2025-06-28 20:29:54 +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) {
|
fun setCanEdit(value: Boolean) {
|
||||||
post {
|
if (!value) {
|
||||||
if (!value) {
|
clearFocus()
|
||||||
clearFocus()
|
|
||||||
}
|
|
||||||
keyListener?.let { keyListenerInstance = it }
|
|
||||||
keyListener = if (value) keyListenerInstance else null // Disables text editing
|
|
||||||
isCursorVisible = true
|
|
||||||
isFocusable = value
|
|
||||||
isFocusableInTouchMode = value
|
|
||||||
setTextIsSelectable(true)
|
|
||||||
}
|
}
|
||||||
|
keyListener?.let { keyListenerInstance = it }
|
||||||
|
keyListener = if (value) keyListenerInstance else null // Disables text editing
|
||||||
|
isCursorVisible = true
|
||||||
|
isFocusable = value
|
||||||
|
isFocusableInTouchMode = value
|
||||||
|
setTextIsSelectable(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
|
|
|
@ -50,11 +50,6 @@ class ListItemVH(
|
||||||
binding.EditText.apply {
|
binding.EditText.apply {
|
||||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, body)
|
setTextSize(TypedValue.COMPLEX_UNIT_SP, body)
|
||||||
|
|
||||||
setOnNextAction {
|
|
||||||
val position = bindingAdapterPosition + 1
|
|
||||||
listManager.add(position)
|
|
||||||
}
|
|
||||||
|
|
||||||
textWatcher =
|
textWatcher =
|
||||||
createListTextWatcherWithHistory(
|
createListTextWatcherWithHistory(
|
||||||
listManager,
|
listManager,
|
||||||
|
@ -157,24 +152,6 @@ class ListItemVH(
|
||||||
paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
||||||
}
|
}
|
||||||
alpha = if (item.checked) 0.5f else 1.0f
|
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"
|
contentDescription = "EditText$position"
|
||||||
if (viewMode == NoteViewMode.EDIT) {
|
if (viewMode == NoteViewMode.EDIT) {
|
||||||
setOnFocusChangeListener { _, hasFocus ->
|
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