theolm / WhatsAppNoContact

Start WhatsApp chats without adding numbers to contacts.
MIT License
111 stars 7 forks source link

Erase default country code once not working #42

Closed theolm closed 2 weeks ago

theolm commented 1 month ago

Steps to reproduce

double backspace should remove the default code but it's not working.

Expected behavior

The code should be erased

Actual behavior

It does not work

Crash logs

No response

App version

0.10.0

Device

Galaxy Flip 5

Other details

No response

Acknowledgements

theolm commented 2 weeks ago

@danielleontiev After investigating this issue for some time I came to some conclusions:

  1. There is nothing wrong with the code in the app.
  2. It could be a bug in the Compose not triggering the backpress keyEvent, but it's not likely since I tested with multiple Compose versions and it works with most keyboards.
  3. The issue is directly related to the keyboard that you are using on your device. So far I found the issue is happening only in the FUTO keyboard.

I think this is probably a bug in the keyboard itself. You are using LineageOS, right? I know this ROM has a pretty bad keyboard, do you mind trying a different one?

The ones that I tested and know it's working 100%

I'm closing this issue since there is nothing that I can do on my side.

danielleontiev commented 1 week ago

Hey! Yes, I am using LineageOS. I've tried couple of keyboards that you've suggested and they work as expected. So, it's indeed looks like a bug in the LineageOS's keyboard.

I wonder what is the exact issue with that keyboard and is it possible to implement some workaround for it?

theolm commented 1 week ago

Unfortunately, there is no workaround that I can implement on my side.

Basically, there is a modifier to capture the pressed key

Modifier.onKeyEvent { keyPressed ->
  // if keyPressed == backspace remove country code
}

The issue is that the lineage keyboard never calls this callback... so there is really no way for me to know when the user pressed the backspace.

danielleontiev commented 1 week ago

I've found a lengthy discussion about this issue here: https://issuetracker.google.com/issues/36964165.

It turns out that the AOSP keyboard does not send KEYCODE_DEL, not because it's faulty or buggy, but simply because it chooses not to.

According to the people in the thread, there are multiple reasons why key code events should not be relied upon in application logic. These range from the inability to guarantee the delivery of such events in some cases—making them unreliable in general—to various UX considerations.

I can't comment on whether this approach is fully justified or not, but the reality is that this behavior is deliberate and isn't going to change.

theolm commented 1 week ago

Nice finding. (I searched the issue tracker and didn't find this issue!) Unfortunately, there is nothing that I can do on my side to make this feature work with AOSP keyboards =(

If you have any idea please let me know.

danielleontiev commented 1 week ago

1) The simplest option is to have an icon near the gear icon that deletes everything, including the default code, without affecting the default saved value. 2) The country code now has its own input field, but it could simply be the initial value of the phone number input. In that case, erasing it wouldn't depend on key codes at all.