Make Clipboard plugin work in Android X

Authored by anjani on Mar 12 2020, 3:56 AM.

Description

Make Clipboard plugin work in Android X

Summary

Fixes #5

BUG: 417419](https://bugs.kde.org/show_bug.cgi?id=417419)

This patch introduces a workaround to access the restricted clipboard in Android X.
Clipboard synchronisation in KDE Connect was one of the killer features before Android X. An action button is added in the persistent foreground notification Send Clipboard which adds the ability to send the clipboard using a small workaround. Clipboard Synchronisation works as usual in lower Android Versions.

This is a very convenient workaround for sending clipboard quickly as it does not requires to open the app. Floating Activity is quite handy for quick actions.

Details of the workaround

ClipboardFloatingActivity

  • This activity is only executed in Android X.
  • This is transparent, accesses the clipboard when in focus.
  • Sends a NetworkPacket containing *text* and *timestamp*.
  • When the packet has been sent, it pops up a toast with a success message.
  • Automatically closes after the showing the Toast.

Reverted changes for Android X.

The action button in the notification for Send Clipboard is not added in the lower versions of Android. It is only added in Android X.

Two way sync is working in Android X with this patch. Sync works normally in lower Android versions.

Test Plan

Before:

Clipboard from PC to Phones were synchronised but Clipboard of phones didn't get synchronised with the PC.

After:

The action button is up in Android X while using other apps.

!Screenshot_20200227-150435_Chrome

After clicking the button, a cute Toast appears with the message *Clipboard sent*

!Screenshot_20200228-233701_Chrome

I think this is one of the best workarounds available to make this awesome plugin work.

Details

Committed
sredmanMar 12 2020, 3:56 AM
Parents
R225:61c1629ff090: GIT_SILENT made messages (after extraction)
Branches
Unknown
Tags
Unknown