florisboard icon indicating copy to clipboard operation
florisboard copied to clipboard

Can't paste when switching back keyboard

Open klaurence opened this issue 3 years ago • 6 comments

Short description

When a user copies text while using another keyboard, the Paste button is unclickable and the user therefore can't paste text. This occurs even when the clipboard has text.

Steps to reproduce

  1. Switch to Florisboard as the primary keyboard.
  2. Go to a text box and copy some text. If the Paste button previously isn't clickable, it should now be.
  3. Clear the clipboard using the Clear primary clip button.
  4. Switch to another keyboard and copy some text.
  5. Switch back to Florisboard. The Paste button should be not clickable.

Environment information

klaurence avatar Aug 26 '22 05:08 klaurence

Are you suggesting that the content copied by another keyboard should be available in Florisboard? If yes:

  1. I don't think this is possible if the other keyboard doesn't want to share that information
  2. However, there is a setting that makes Florisboard read content copied via Android's copy-menu. Screenshot_20220826-152923_FlorisBoard Beta.jpg In the settings, check this option: Screenshot_20220826-152530_FlorisBoard Beta.jpg Screenshot_20220826-152552_FlorisBoard Beta.jpg

EDIT: I may have misunderstood your issue.

Glitchy-Tozier avatar Aug 26 '22 13:08 Glitchy-Tozier

I meant to mention that the text should be copied while using another keyboard but not necessarily via inbuilt functionality of that keyboard (the bug still happens when copying via the system Copy button that appears when selecting).

I'll attempt to record a video that illustrates the issue.

klaurence avatar Aug 26 '22 13:08 klaurence

Just to make sure: Did you try it after activating the setting I showed (the first option inside the clipboard-settings)?

Glitchy-Tozier avatar Aug 26 '22 13:08 Glitchy-Tozier

Yep. Enabling the internal clipboard (and the options Sync from system clipboard and Sync to system clipboard) doesn't solve it.

klaurence avatar Aug 26 '22 14:08 klaurence

The reason is very simple why this does not work: FlorisBoard has only access to the clipboard as long as it is the default IME, else it gets "null" items delivered, which are useless. This is to protect the privacy of the clipboard data and is enforced by the Android system.

As FlorisBoard relies solely on the clipboard primary clip changed listener it thus does not notice a change if you use another keyboard. What I could try is every time the IME window is shown again to manually query the current system primary clip and compare it with the cache. If it matches I assume nothing changed, if it doesn't match I will treat this as a change event. Of course reading from the system clipboard is only done either if you have disabled the internal clipboard or if you have enabled it AND have enabled sync from system.

The corresponding update code can be seen here: https://github.com/florisboard/florisboard/blob/de2b3b9433ba56bc629d53e9538cea5446fea6ff/app/src/main/kotlin/dev/patrickgold/florisboard/ime/clipboard/ClipboardManager.kt#L162-L202

patrickgold avatar Aug 26 '22 14:08 patrickgold

I would be okay with that solution. I also don't think there's a problem with assuming that no clipboard operations occurred if the stored clipboard is the same, since the Paste button would still be clickable (or if the clipboard is empty this entire time, unclickable) regardless.

klaurence avatar Aug 26 '22 14:08 klaurence