dessalines / thumb-key

A privacy-conscious Android keyboard made for your thumbs
GNU Affero General Public License v3.0
998 stars 210 forks source link

In some apps return/enter key doesn't create a new line #136

Closed SevastianGit closed 10 months ago

SevastianGit commented 1 year ago

When using Discord (v126.21) for example, pressing the enter key while in a search bar initiates a search, but when editing a message it does nothing (should create a new line), while in a browser it works just fine (creates a new line in text input) and I don't face such issues when using an usual keyboard. Not the biggest problem, but just a minor inconvenience that forces me to switch keyboards whenever I need it.

dessalines commented 1 year ago

You need to go into discord settings for that. Thumb-Key uses whatever the default IME action is. Sometimes its send, sometimes its enter.

https://github.com/dessalines/thumb-key/blob/main/app/src/main/java/com/dessalines/thumbkey/utils/Utils.kt#L227

dessalines commented 11 months ago

Look at the code above, thumb-key should use whatever IME action that input has.

dessalines commented 11 months ago

I could try adding the unspecified action they reference above, but there's no guarantee that would fix it. Discord and slack should just use a proper IME action, its really on them.

AeliusSaionji commented 11 months ago

Ah you did it while I was typing (on phone). Thanks!

AeliusSaionji commented 11 months ago

That wasn't the solution unfortunately. In fact this new version also breaks Octodroid and keybase and deltachat and probably more :)

AeliusSaionji commented 11 months ago

I asked the AnySoftKeyboard team for guidance, and they said to look here https://github.com/AnySoftKeyboard/AnySoftKeyboard/blob/93fdbb39790c065b5be6616f857a2040ca02bb09/ime/app/src/main/java/com/anysoftkeyboard/utils/IMEUtil.java#L118

KraXen72 commented 11 months ago

in update 2.4.1, in discord, hitting enter after typing something right after focusing the input box sends the message (incorrect behaviour, should do new line), and subsequent messages don't react to enter in any way (focusing the input or un-focusing doesen't affect this) (incorrect behaviour). Please re-open. Thanks!

dessalines commented 11 months ago

I copied that exact section from AnySoftKeyboard, so I don't know what else to do there. I also don't want to spend any time researching fixes for discord and slack specific hacks. They should use proper IME actions like every other app.

I'll re-open if someone wants to work on it tho.

KraXen72 commented 11 months ago

i think a good solution could be testing a few foss keyboards like florisboard, to see if they have correct behaviour. then, borrow their code.

dessalines commented 11 months ago

The correct solution is actually getting discord and slack to adhere to proper IME actions, instead of forcing every keyboard designer to build specific hacks for their apps.

KraXen72 commented 11 months ago

yes, but if it works with other keyboards and not this one, users are going to blame the keyboard, even though it's the app's fault. This is the same situation as some special edge case websites having their own rules in Browsers' engines, because "if it doesen't work on chrome and it does on firefox, chrome is at fault, even though our site is bad".

Also, getting every app to fix this and standardise their IME actions would take much longer than fixing it in the keyboard, so I say it's better to bite the bullet and implement app-specific fixes.

I'm not saying you exactly need to fix it, but it would be good to keep this issue open for somebody spiteful/annoyed enough to fix it themselves and submit a PR.

nejni-marji commented 11 months ago

I've been using this workaround, and I have yet to encounter a situation where it causes any issues: https://github.com/nejni-marji/thumb-key/commit/80c7e68ab9bf24fc693ab405f863624310802fb5

I highly doubt that it's a perfect solution, it might break something I don't use.

dessalines commented 10 months ago

I believe this is solved in a recent PR. Might also be good to open up an issue on discord's issue tracker to properly use android IME actions.

DestyNova commented 9 months ago

I checked v2.6.3 and the behaviour is the same, unless the PR in question isn't in the current release yet.

dessalines commented 9 months ago

Which app? You'll have to open up an issue on their issue tracker.

DestyNova commented 9 months ago

Which app? You'll have to open up an issue on their issue tracker.

Discord, but as you mentioned they're unlikely to be interested based on the track record so far. I might try modifying the patch by @nejni-marji to replace the enter key handling with a newline when the keyboard is in shift-pressed state, as a workaround for Discord and other poorly behaved apps.

KraXen72 commented 9 months ago

i think this could be a good option even for the official app. if not satisfactory as a default, add it in as a setting.

nejni-marji commented 9 months ago

this is the biggest reason i run my own build of the app instead of using upstream builds

nejni-marji commented 9 months ago

like i get that it sucks as a dev to have to do jank to support someone else's bad development (eg, discord's), but lacking the ability to type newlines in any program is just not realistic

dessalines commented 9 months ago

Pretty much all chat apps (and text editors) have the correct behavior, (newlines on enter) in chat boxes, because they're correctly using IME actions. Element and signal are both doing this correctly for example.

Discord has the bug, and it needs to be fixed there.

KraXen72 commented 9 months ago

couldn't you log out all the IME info discord provides for their app, like flags, etc. then find something that distinguishes it and send \n there? pretty sure there are, or atleast were, specific checks for wierd ime actions in the thumb-key codebase, so it's just about the correct send, i.e. sending '\n' instead of down and enter.

DestyNova commented 9 months ago

couldn't you log out all the IME info discord provides for their app, like flags, etc. then find something that distinguishes it and send \n there? pretty sure there are, or atleast were, specific checks for wierd ime actions in the thumb-key codebase, so it's just about the correct send, i.e. sending '\n' instead of down and enter.

I don't think it's right to fill the app with workarounds for Discord or other misbehaved, proprietary apps, though. IMO just having a shortcut for sending a hard \n is more reasonable -- like I said, I'll try doing that and open a PR later (assuming I can figure it out).

DestyNova commented 9 months ago

Just FYI, response from Discord support:

Thanks for reaching out and providing detailed information about the issue you're experiencing on your Android device using a Thumbkey input method. As you've explained, hitting the enter key doesn't create a new line in your messages, which can be problematic. What you're experiencing seems related to how certain input methods handle the "enter" key action in conjunction with IME options set by the app itself. Discord's behavior here might be causing Thumbkey to interpret "enter" as the send action rather than a line break. Unfortunately, as Discord Support, we don't have the ability to change the way Discord interacts with various input methods. We recommend trying GBoard or another keyboard app to see if it provides a better result. Apologies for any inconvenience this has caused. Your feedback is valuable to us and we'll be sure to forward it to our development team for review.

I wasn't particularly happy with "as Discord support, we don't have the ability to change...", nor expecting users to switch keyboards to use the app. I've asked them to log a bug ticket with the app dev team but won't hold my breath.

To be honest their reply reads like a ChatGPT-generated "yes, I get it but go away" response.

dessalines commented 9 months ago

I don't think it's right to fill the app with workarounds for Discord or other misbehaved, proprietary apps, though. IMO just having a shortcut for sending a hard \n is more reasonable -- like I said, I'll try doing that and open a PR later (assuming I can figure it out).

I'd be okay with that. Adding a default false setting for ignore_ime_action, and just always sending a newline. It will break every other enter action on every other app, but that's the price you gotta pay for using discord / other spyware.

KraXen72 commented 9 months ago

can we get the newline on only shifted enter though?

dessalines commented 9 months ago

I spose, but again, completely unecessary for an app that uses IME actions correctly.

KraXen72 commented 9 months ago

not really easy to convince a lot of people who use discord to switch to something else

DestyNova commented 9 months ago

can we get the newline on only shifted enter though?

Yes that is what I had proposed earlier, so we get sane behaviour for sane apps, and a shft-enter workaround for Discord, Slack etc.

KraXen72 commented 8 months ago

@DestyNova / someone else

IMO just having a shortcut for sending a hard \n is more reasonable any chance this could get implemented? enter is still inconsistent or doesen't work at all for a few apps for me. i believe this would be a good solution. thanks!

DestyNova commented 8 months ago

@KraXen72 I forked the repo but am running into a problem building it (without changing anything yet):

  Lint found 26 errors, 13 warnings. First failure:

  /home/omf/code/foss/thumb-key/app/src/main/res/values/strings.xml:12: Error: "dracula" is not translated in "bg" (Bulgarian) [MissingTranslation]
      <string name="dracula">Dracula</string>
              ~~~~~~~~~~~~~~

...Unless ./gradlew build is not the correct way to build an APK for testing.

dessalines commented 8 months ago

buildDebug

but also it shouldn't be linting those translations. Are you using android studio?

DestyNova commented 8 months ago

buildDebug

but also it shouldn't be linting those translations. Are you using android studio?

Thanks -- I have Android Studio but was just using the command line (i.e. forked and cloned the repo, then ran ./gradlew build).

Update: ./gradlew buildDebug prints this but doesn't produce an APK -- I'm guessing bundle or something is needed for that?

To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.4/userguide/gradle_daemon.html#sec:disabling_the_daemon in the G
radle documentation.                      
Daemon will be stopped at the end of the build 
Calculating task graph as no configuration cache is available for tasks: buildDebug

BUILD SUCCESSFUL in 14s                              
33 actionable tasks: 4 executed, 29 up-to-date
Configuration cache entry stored.        

I'll see about making a Matrix account since back and forth here is probably annoying :)

KraXen72 commented 8 months ago

@DestyNova thanks for working on this! Hopefully this fix can bring consistency into thumb-key's enter :3

dessalines commented 8 months ago

@DestyNova I recommend using android studio to develop, and setting up remote debugging to your device. https://developer.android.com/studio/run/device

DestyNova commented 8 months ago

Okay, I've added a separate "shifted" return key item (only in the "English programmer thumb-key" layout) as a test here: https://github.com/dessalines/thumb-key/pull/629

It replaces the enter icon with "CR" when shifted, indicating that a hard newline will be sent. It fixes the behaviour in Discord for me, but I think it would be better to have it as a swipe action rather than shifted. That might solve the problem with my version -- applying the change fully would require updating every single layout.

KraXen72 commented 8 months ago

i would vote for either:

DestyNova commented 8 months ago

i would vote for either:

* an option that when enabled, always sends \n on enter (personally i'd use this, same as nenji-mari's workaround. i barely ever use enter for something else than a newline)

* an option that when enabled, sends \n on shifted enter (could have diff icon?)

Finding the right icons is hard! I looked through the Material Design icons that seem to come with Jetpack and there wasn't a lot there that seemed like a good candidate. I couldn't even find a definitive list of exactly what icons were available in the collection (some on the MD site seemed to be unavailable in the "Outlined" set).

KraXen72 commented 8 months ago

if you're going with the first option, i'd keep the current icon.
for the second option, you could use keyboard return for the normal enter and subdirectory arrow left or just the string \n
the difference betweent those 2 icons is subtle, but if they get instantly switched, user will notice the difference. i think it's quite intuitive @DestyNova