Skip to content

Commit bee6dac

Browse files
PR Batch Testerclaude
andcommitted
refactor(mobile): split Return submit checks to satisfy detekt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 20ad7b5 commit bee6dac

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

‎apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ComposerEditorView.kt‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -676,14 +676,7 @@ internal class SelectionAwareEditText(context: Context) : EditText(context) {
676676
*/
677677
private fun submitChord(keyCode: Int, event: KeyEvent): Boolean? {
678678
val isReturn = keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER
679-
val fromSoftKeyboard =
680-
event.deviceId == KeyCharacterMap.VIRTUAL_KEYBOARD ||
681-
(event.flags and KeyEvent.FLAG_SOFT_KEYBOARD) != 0
682-
// Return during IME composition (CJK on a hardware keyboard) commits the candidate, like
683-
// iOS's marked-text guard, so the draft is never sent half-typed.
684-
val composing = text?.let { BaseInputConnection.getComposingSpanStart(it) != -1 } == true
685-
val canSubmit = submitEnabled && submitListener != null && !readOnly && isEnabled && !composing
686-
if (!isReturn || fromSoftKeyboard || !canSubmit) {
679+
if (!isReturn || isFromSoftKeyboard(event) || !canSubmit()) {
687680
return null
688681
}
689682
return when {
@@ -695,6 +688,17 @@ internal class SelectionAwareEditText(context: Context) : EditText(context) {
695688
}
696689
}
697690

691+
private fun isFromSoftKeyboard(event: KeyEvent): Boolean =
692+
event.deviceId == KeyCharacterMap.VIRTUAL_KEYBOARD ||
693+
(event.flags and KeyEvent.FLAG_SOFT_KEYBOARD) != 0
694+
695+
private fun canSubmit(): Boolean {
696+
// Return during IME composition (CJK on a hardware keyboard) commits the candidate, like
697+
// iOS's marked-text guard, so the draft is never sent half-typed.
698+
val composing = text?.let { BaseInputConnection.getComposingSpanStart(it) != -1 } == true
699+
return submitEnabled && submitListener != null && !readOnly && isEnabled && !composing
700+
}
701+
698702
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
699703
val alternate = submitChord(keyCode, event)
700704
if (alternate != null) {

0 commit comments

Comments
 (0)