Repository navigation
Send message using Enter on physical keyboard - #450
RobertoTired wants to merge 3 commits into
Conversation
Allow sending of message using Enter key on physical keyboard. A parameter toggle has been added to switch between 'Enter to send / Enter + Shift for multiline' and 'Enter for multiline / Ctrl + Enter to send'.
(sad...)
|
Not sure how to fix the Instrumented tests (Android 17 x86_64) issue... I run ./gradlew :app:connectedDebugAndroidTest with a local emulator and I got no issue |
|
It fails because CI emu has 320x640 screen with 160dpi. |
There was a problem hiding this comment.
Please also:
- Squash commits into a single commit
- Remove new localized strings for all languages except English and Russian.
Feature tests coverage is incomplete:
- MessageComposeBarInputTypeTest only tests with the setting off. Nothing covers setting on + Enter sends, setting on + Shift+Enter inserts a newline, or a soft-keyboard Enter not sending.
- AppSettingsRepositoryImplTest.kt makes
SEND_ON_ENTERreturn true, but never assertsresult.sendOnEnterEnabledand doesn't include that read in its verify block - setBooleanPref_writesEveryApplicationBooleanPreferenceKey covers five prefs and skips
SEND_ON_ENTER. - AppSettingsUiStateMapperImplTest only adds
sendOnEnterEnabled = false, which is the default, so the mapping isn't really checked.
| } | ||
| } | ||
|
|
||
| private fun EditText.setupKeyboardSendHandler(onImeSend: State<(() -> Unit)?>) { |
There was a problem hiding this comment.
Enter from a soft keyboard counts as "physical keyboard" and sends the SMS. Reject events where event.flags and KeyEvent.FLAG_SOFT_KEYBOARD != 0, and add a test.
There was a problem hiding this comment.
Also, holding Enter can send more than once. Add event.repeatCount == 0.
| keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER | ||
| if (isPhysicalKeyboard && isEnterKey && event.action == KeyEvent.ACTION_DOWN) { | ||
| val ctx = view.context | ||
| val prefs = ctx.getSharedPreferences( |
There was a problem hiding this comment.
View must not read shared preferences.
| <string name="in_conversation_sound_pref_title">In-conversation message sounds</string> | ||
| <string name="in_conversation_sound_pref_summary">Play a quiet sound for a message that arrives in the conversation you are viewing. Muted and snoozed conversations stay silent.</string> | ||
| <string name="send_on_enter_pref_title">Send on Enter on physical keyboard</string> | ||
| <string name="send_on_enter_pref_summary">Send a message when pressing Enter on a physical keyboard. Use Shift + Enter for a new line. Ctrl + Enter always send the message</string> |
There was a problem hiding this comment.
Should be Ctrl + Enter always sends the message I think
Allow sending of message using Enter key on physical keyboard. A parameter toggle has been added to switch between 'Enter to send / Enter + Shift for multiline' and 'Enter for multiline / Ctrl + Enter to send'.
Thanks